fix(sync): 同步链路审计修复——水位边界白拉/全量无超时/群活跃窗判定源
全项目数据同步审计发现四漏洞(前项为证据): ① 消息增量边界白拉(证据:昨夜 wa-messages fetched=53,682 而真实新消息 仅 321 条,99.4% 是白拉白写的已入库旧消息)——云客 chatRecords/msg-chats 的 start 参数是 inclusive(返回 ts>=start 含边界),四个消息实体(微信 1:1/WA 1:1/微信群/WA 群)统一在归一化后过滤 ts<=watermark 的边界行, 不计数不写库(省 99% 写放大,计数从此反映真实新增) ② full_sync_all.sh 无超时——极端情况(常态 10-20h)拖进次日相位把 02:00 全量又挤掉(前两天事故同型);加 22h 上限 ③ 周日 full-history 无超时——4 实体全历史可能 24h+,必挤周一;单实体 加 6h 上限 ④ 群消息活跃窗判定源是昨晚 full 的 chat_group.last_chat_time 快照—— 「昨天安静、今天突然活跃」的群会被 24h 窗口漏到明晚;4h 序列在 group-messages 前加 chatroom-stats 全窗(~1min)刷新群活跃判定源 722 测试绿(4h 序列断言 9→10 命令+chatroom-stats 位序)。 Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -589,7 +589,7 @@ async def test_safe_page_run_messages_builds_scrape_command(engine, monkeypatch)
|
||||
|
||||
await sched._safe_page_run("messages")
|
||||
|
||||
assert len(commands) == 9
|
||||
assert len(commands) == 10
|
||||
for args in commands:
|
||||
assert args[1].endswith("scrape_via_page.py")
|
||||
|
||||
@@ -601,13 +601,14 @@ async def test_safe_page_run_messages_builds_scrape_command(engine, monkeypatch)
|
||||
assert entity_of(commands[1]) == "wa-accounts"
|
||||
assert entity_of(commands[2]) == "friends"
|
||||
assert entity_of(commands[3]) == "wa-friends"
|
||||
# 群消息前刷群活跃(chatroom-stats 全窗——群活跃窗判定源,2026-09-10)
|
||||
entities_seq = [entity_of(a) for a in commands]
|
||||
assert entities_seq.index("chatroom-stats") < entities_seq.index("group-messages")
|
||||
# 四类消息:24h 活跃窗(2026-09-10 根治调度堵塞)
|
||||
for args in commands[4:8]:
|
||||
assert entity_of(args) in (
|
||||
"messages", "wa-messages", "group-messages", "wa-group-messages",
|
||||
)
|
||||
assert args[args.index("--max-conversations") + 1] == "99999"
|
||||
assert args[args.index("--active-window-hours") + 1] == "24"
|
||||
for args in commands:
|
||||
if entity_of(args) in ("messages", "wa-messages", "group-messages", "wa-group-messages"):
|
||||
assert args[args.index("--max-conversations") + 1] == "99999"
|
||||
assert args[args.index("--active-window-hours") + 1] == "24"
|
||||
# moments 浅扫在序列末尾:每员工最多 3 页
|
||||
moments_cmd = commands[-1]
|
||||
assert entity_of(moments_cmd) == "moments"
|
||||
|
||||
Reference in New Issue
Block a user