From 8a8eabc8d7a8b47beb68a2eea3e39b14db579efb Mon Sep 17 00:00:00 2001 From: Vegetable <3089665724@qq.com> Date: Wed, 25 Nov 2026 22:58:46 +0800 Subject: [PATCH 01/13] feat(n5): add release gate and resident soak harness --- docs/README.md | 1 + .../2026-11-25-feat-007-n5-release.md | 111 +++ feature_list.json | 10 +- progress.md | 2 + scripts/n5/analyze_journal.py | 108 +++ scripts/n5/attach.ps1 | 58 ++ scripts/n5/n5_resume.py | 189 ++++ scripts/n5/n5_soak.py | 848 ++++++++++++++++++ scripts/n5/preflight.ps1 | 220 +++++ scripts/n5/verify-release.ps1 | 416 +++++++++ session-handoff.md | 2 + 11 files changed, 1960 insertions(+), 5 deletions(-) create mode 100644 docs/acceptance/2026-11-25-feat-007-n5-release.md create mode 100644 scripts/n5/analyze_journal.py create mode 100644 scripts/n5/attach.ps1 create mode 100644 scripts/n5/n5_resume.py create mode 100644 scripts/n5/n5_soak.py create mode 100644 scripts/n5/preflight.ps1 create mode 100644 scripts/n5/verify-release.ps1 diff --git a/docs/README.md b/docs/README.md index a45e8329..06015f78 100644 --- a/docs/README.md +++ b/docs/README.md @@ -66,6 +66,7 @@ - feat-004 后续观测判定:[回调线程与停止观测合同](acceptance/2026-11-15-feat-004-observation.md)。 - feat-005 当前范围:[正式/历史路线判定与剩余证据](acceptance/2026-11-21-feat-005-scope.md);历史原生 MSF/G3 路线为研究资产,不作正式链路完成门。 - feat-006 文本 MVP:[阻塞点判定、传输协议与慢连接证据](acceptance/2026-11-24-feat-006-text-mvp.md);真实外部应用与现场慢连接仍待验收。 +- feat-007 N5 发布门:[启动包、未知版本与持续运行证据](acceptance/2026-11-25-feat-007-n5-release.md);24h 与 QQ 重启矩阵仍待闭合。 - 响应消费者历史起点:[response-consumer-scope](research/response-consumer-scope.md)。 “实现未开始”等旧结论以 N 台账后续接线记录补充;scope 原文保留。 - 详细样本与负结果:从 P/N 执行台账进入对应 `evidence/`,按样本定位, diff --git a/docs/acceptance/2026-11-25-feat-007-n5-release.md b/docs/acceptance/2026-11-25-feat-007-n5-release.md new file mode 100644 index 00000000..09149a17 --- /dev/null +++ b/docs/acceptance/2026-11-25-feat-007-n5-release.md @@ -0,0 +1,111 @@ +# feat-007 N5 持续运行与发布验收(2026-11-25) + +本文对应 issue #16:按 N5 发布门逐项证明常驻运行、恢复矩阵、未知版本拒绝、停止边界、 +启动包和长时间运行。**当前不是 feat-007 完成声明**:离线启动包/未知版本门与 2h 现场观察 +有证据,24h 单账号运行和 QQ 重启矩阵尚未闭合。产品整体仍 NOT READY。 + +固定构建与原始材料只在本机;本文只记录可复核的命令、哈希、轨迹和边界。 + +## 1. 完成条件对照 + +| done_criterion | 已有证据 | 仍未闭合 | +|---|---|---| +| 正常入口无需每消息交互 | feat-006 现场:daemon + 一次 attach 后真实应用经 HTTP/WS 收发;本轮 2h 现场:同一 daemon/attach 下 117 个采样、351/351 次只读查询成功,495 条真实入站事件入账,无每条消息 CLI 交互 | 24h 连续运行 | +| core/QQ 重启、断链/慢客户端矩阵 | 离线 `core_restart_query_lab` 4/4、`recovery_contract` 13/13、`onebot_transport` 10/10;本轮 2h 现场 3/3 次 core 崩溃重启与 bridge 重连(各约 1.5s) | QQ 退出/重启后新代次重绑;真实 TCP 背压 | +| 未知版本零 native 调用,停止边界如实 | 本轮离线门:篡改 manifest 后 `verify-manifest`/`qq-entry` 在 gate 1 拒绝,report 未产生;`inject` 在默认构建被 K4-D0 拒绝;现场控制停止后默认 bridge 保留 | 失败停止的现场负例仍未新增(沿用 feat-005/006 证据) | +| 24h 单账号验收及启动包证据齐全 | 本轮启动包:release zip、`build-info.json`、sidecar SHA-256、包内逐文件哈希、解压后 daemon 两次启动/停止与诚实无 bridge 登录失败 | 24h 单账号运行与最终证据封包 | + +## 2. 启动包与离线门 + +重跑入口: + +```powershell +.\scripts\n5\verify-release.ps1 +``` + +脚本执行:默认 release 构建 → 调用 `.github/scripts/package-release.ps1` → 校验 zip/sidecar +与 `build-info.json` 的 commit/version/target/mode/文件哈希 → 解压后启动 packaged daemon +两次(同一 journal/token,不同 HTTP 端口)→ 探测 `get_version_info`/`get_login_info` → +控制停止 → 构造篡改 manifest → `verify-manifest`、`qq-entry`、`inject` 拒绝路径。 + +本轮结果(`target-harness/n5-offline-gate/offline-gate.json`,overall `pass`): + +| 项目 | 结果 | +|---|---| +| 构建 | `caligo.exe` SHA-256 `820781DB…57CE5`,`caligo_bridge.dll` SHA-256 `1EBF6E35…44FC` | +| 启动包 | `caligo-0.3.0-windows-x64.zip`,sidecar SHA-256 与包哈希一致;`build-info.json` 的 commit/version/target/mode/research/entrypoint 均匹配,4 个包内文件哈希逐项匹配 | +| 包内启动 | `get_version_info` retcode 0;无 bridge 时 `get_login_info` retcode 1502(诚实失败,不伪造登录);两次启动后 journal SHA-256 不变(空账本) | +| 未知版本 | 篡改 `QQ.exe` 哈希:`verify-manifest` exit 2;`qq-entry` exit 2 且 `[gate 1] REJECT`、report 未产生;`inject` exit 3(K4-D0 默认构建禁用)、report 未产生 | +| 停止 | packaged daemon 两次均由 `daemon-control ... stop` 正常退出,journal 保留 | + +`inject` 在默认 release 里先被 K4-D0 现场门拒绝,所以它的 exit 3 不是 manifest 门本身; +manifest 门的零 native 调用由 `verify-manifest` 与 `qq-entry` 的 gate 1 证明。三者都没有 +创建 report,也没有加载 bridge。 + +## 3. N5 恢复/传输矩阵 + +| 场景 | 证据层级 | 现有结果 | +|---|---|---| +| core 进程崩溃 + 同 journal/pipe/token 重启 | lab + field | `core_restart_query_lab` 4/4(在途发送不重派、迟到结果只交付一次、两次查询跨 core 不重放);`recovery_contract` 13/13;本轮 2h 现场 3/3 次 kill/restart 后 bridge 重连、登录查询恢复,恢复 1.56/1.53/1.55s | +| bridge 管道断开 | field | 同一次 core kill 使 bridge 进入重连回退;恢复后 `get_login_info` 成功,未重新 attach | +| QQ 退出/重启 | 未执行 | 需要新鲜 QQ 代次、重新 preflight/attach;旧请求不重放 | +| 慢客户端/写端阻塞 | lab + field(feat-006) | `onebot_transport` 的 stalled-writer、POST 失败仍 fanout、WS 重连;feat-006 现场慢 POST + 非读取 WS。真实 Windows loopback 背压仍不可复现,不宣称真实 TCP 慢客户端通过 | +| 未知版本 | lab(本轮) | 见 §2 | +| 停止边界 | lab + field | `stop_observation_lab` 全部分支;feat-005/006 的 `0x25`/`0xe0` 记录保留。本轮控制停止 daemon,默认 bridge 无 owner-stop,映射保留、QQ 响应 | + +## 4. 2h 现场观察(issue #16 第 2 项) + +现场包在 ignored `local-evidence/feat007-n5-20261125-unbound/`。目标为最后启动的新 QQ 主根 +(PID 见包内 `state.private.json`,登录登记账号 B),通过只读 preflight:固定 manifest/模块 +哈希、PE/backend 审计、唯一 Environment、无已映射 bridge、端口唯一。 + +流程:一次 `cli qq-entry` attach → 60s 周期 `get_version_info`/`get_status`/`get_login_info` +→ 在 30/60/90 分钟各注入一次 core 崩溃(kill),同 journal/pipe/token 重启并等待 bridge +重连 → 结束控制停止。**零消息发送**;该账号期间收到 495 条真实入站事件,正文/身份只留在 +本机 ignored 目录,仓库只保留计数与哈希。 + +结果(2026-11-25T12:04:55Z–14:04:57Z,包内 `soak-summary.public.json`,overall `pass`): + +| 项目 | 结果 | +|---|---| +| 常驻/探测 | 117 个采样;`version`/`status`/`login` 共 351/351 成功,0 failure;延迟 median 25.48ms、p95 446.86ms、max 463.96ms | +| 入站持续性 | journal 从 0 增至 511,157 bytes;495 个 Event,`event_seq` 1–495 无缺口,495 个唯一 native ID、0 重复,generation 始终 1 | +| core 重启 | 3/3 次 kill 后同 journal/pipe/token 恢复;恢复耗时 1.56 / 1.53 / 1.55s;journal 完整帧前缀每次保留;bridge 未重新 attach | +| 进程指标 | daemon working set 7.7→14.6 MiB(max 14.6 MiB),handles 102→102(max 103);QQ working set 792.6→735.5 MiB(max 802.2 MiB),handles 1736→1695 | +| 停止边界 | `daemon-control ... stop` exit 0,daemon 退出;默认 bridge 映射保留(`bridge_final=true`),QQ 仍响应;未尝试 research owner-stop,未热卸载 | + +该样本证明的是“同一 daemon/一次 attach 下 2h 常驻查询与 3 次 core 崩溃恢复”;不证明 24h、 +QQ 退出/重启后的新代次重绑,也不证明真实 TCP 背压。 + +## 5. 剩余门与边界 + +- **24h**:本轮 2h 观察只覆盖短时恢复;`CoreStopped` 后默认 bridge 的 daemon worker 已退出, + 同一 QQ 代次不能重新 attach。2026-11-25T14:56:45Z 已在新的新鲜 QQ 主根上启动 24h soak + (零发送、60s 只读探测、+2h/+8h/+16h 各一次 core 崩溃重启),预计 2026-11-26T14:56:45Z 结束; + 到点由本机定时任务读取 `soak-summary.json` 与 journal 分析,通过后才更新最终结论并关闭 + issue #16。本节在 24h 结果出来前不把该门标为通过。 +- **QQ 重启**:需要操作者退出并重启 QQ,随后对新 PID/创建时间重新 preflight/attach; + 旧代次的请求、映射和回调不得混入新实例。 +- **启动包**:本轮为 default 构建;research 构建、真实 QQ 字段与发布 tag 流程是独立验收。 +- **停止**:默认 bridge 不提供 research owner-stop;任何未知停止结果不重试、不热卸载, + bridge 保留到 QQ 正常退出。 +- **慢客户端**:确定性 transport 合同与 feat-006 现场慢 POST 已有证据;真实 TCP 背压仍未证。 + +## 6. 复现命令 + +```powershell +# 离线启动包 + 未知版本门 +.\scripts\n5\verify-release.ps1 + +# 现场包准备(示例值,必须使用当次新鲜 QQ 的 PID/创建时间/登记账号) +.\scripts\n5\preflight.ps1 -Pack local-evidence/feat007-n5-20261125-unbound ` + -TargetPid -ExpectedCreated -Account ` + -DurationHours 2 -RestartAtMinutes 30,60,90 + +# 操作者核对后把授权文件 authorized 改为 true,再启动 +python -B scripts/n5/n5_soak.py ` + --state local-evidence/feat007-n5-20261125-unbound/state.private.json ` + --hours 2 --sample-seconds 60 --restart-at-min 30 60 90 +``` + +原始证据只在本机 ignored `local-evidence/`;仓库只提交脚本、合同和脱敏结果。 diff --git a/feature_list.json b/feature_list.json index 7b007fe3..ed746a34 100644 --- a/feature_list.json +++ b/feature_list.json @@ -1,8 +1,8 @@ { "$schema": "https://raw.githubusercontent.com/walkinglabs/learn-harness-engineering/main/skills/harness-creator/templates/feature-list.schema.json", - "updated": "2026-11-24", + "updated": "2026-11-25", "baseline_commit": "0f5b483", - "active_feature": null, + "active_feature": "feat-007", "status_basis": "产品 status 反映完成门,implemented/wired/lab/field 分开描述。历史执行台账是证据,状态更新不能替代现场验收。", "features": [ { @@ -109,9 +109,9 @@ "description": "按 N5 发布门逐项证明恢复、版本拒绝与长时间运行。", "plan_steps": ["N5"], "dependencies": ["feat-006"], - "status": "not-started", - "evidence": "已有恢复组件与局部研究观察;完整 N5 矩阵、2h/24h 运行和发布验收尚无闭合证据。", - "evidence_paths": ["docs/plans/2026-10-09-gitnexus-plan-caligo-snowluma-capability-parity.md"], + "status": "in-progress", + "evidence": "2026-11-25 离线启动包/未知版本门通过(scripts/n5/verify-release.ps1):default release 构建与 CI 同源打包,zip sidecar、build-info commit/version/target/mode 和包内逐文件 SHA-256 均匹配;解压后 packaged daemon 两次启动均回答 get_version_info、无 bridge 时 get_login_info 诚实返回 1502、控制停止后 journal 保留;篡改 QQ.exe 哈希后 verify-manifest 与 qq-entry 均在 gate 1 拒绝且不产生 report,默认构建的 inject 先被 K4-D0 拒绝。现场 2h 观察通过(零发送、60s 只读探测、30/60/90 分钟 core 崩溃重启):新 QQ 主根一次 attach,117 个采样、351/351 次查询成功、495 条真实入站事件无重复/缺口(event_seq 1–495),3/3 次 core 崩溃重启各约 1.5s 恢复且 journal 完整帧前缀保留,控制停止后默认 bridge 保留、QQ 响应。CoreStopped 后同一代次不能重新 attach,因此 2026-11-25T14:56:45Z 在新的新鲜 QQ 主根上启动 24h soak(+2h/+8h/+16h 各一次 core 崩溃重启,预计 2026-11-26T14:56:45Z 结束);24h 结果出来前不提升状态。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。", + "evidence_paths": ["docs/acceptance/2026-11-25-feat-007-n5-release.md", "scripts/n5/verify-release.ps1", "scripts/n5/preflight.ps1", "scripts/n5/attach.ps1", "scripts/n5/n5_soak.py", "docs/plans/2026-10-09-gitnexus-plan-caligo-snowluma-capability-parity.md"], "done_criteria": ["正常入口无需每消息交互", "core/QQ 重启、断链/慢客户端矩阵通过", "未知版本零 native 调用,停止边界如实", "24h 单账号验收及启动包证据齐全"] }, { diff --git a/progress.md b/progress.md index e9c5daa9..aed9b916 100644 --- a/progress.md +++ b/progress.md @@ -2,6 +2,8 @@ ## Current State +2026-11-25 feat-007 N5 启动包/未知版本门与 2h 现场观察(issue #16):新增 `scripts/n5/verify-release.ps1`,按 CI 同源脚本构建并打包 default release,校验 zip sidecar、`build-info.json` 的 commit/version/target/mode/entrypoint 与包内逐文件 SHA-256;解压后的 packaged daemon 两次启动均回答 `get_version_info`(retcode 0),无 bridge 时 `get_login_info` 诚实返回 1502,控制停止后 journal 保留;篡改 `QQ.exe` 哈希后 `verify-manifest` 与 `qq-entry` 均在 gate 1 拒绝且不产生 report,默认构建 `inject` 先被 K4-D0 拒绝。固定构建 `caligo.exe` SHA-256 `820781DB…57CE5`、`caligo_bridge.dll` `1EBF6E35…44FC`。现场 2h(本轮零发送):新 QQ 主根 `26620`(创建 `2026-11-25T12:03:11.4979693Z`,登记账号 B)通过固定 manifest/模块、PE/backend 审计与唯一 Environment 后一次 attach;117 个采样、`version`/`status`/`login` 351/351 成功、0 探测失败;30/60/90 分钟 3/3 次 kill core 并以同 journal/pipe/token 重启,恢复 1.56/1.53/1.55s、journal 完整帧前缀保留、bridge 未重新 attach;期间 495 条真实入站事件,`event_seq` 1–495 无缺口、495 个唯一 native ID、0 重复,generation 始终 1;daemon working set 7.7→14.6 MiB、handles 102→102,控制停止 daemon 后默认 bridge 保留、QQ 响应。2h 样本不证明 24h、QQ 重启后新代次重绑或真实 TCP 背压;`CoreStopped` 后同一代次不能重新 attach,24h 需新新鲜 QQ。随后在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并于 `14:56:45Z` 启动 24h soak(零发送、60s 只读探测、+2h/+8h/+16h 各一次 core 崩溃重启,预计 `2026-11-26T14:56:45Z` 结束);到点由本机定时任务读取 summary/journal 并决定是否关闭 issue #16。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/` 与 `feat007-n5-24h-20261125-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) + 2026-11-24 feat-006 现场 attempt 2(通过,单构建,issue #15):新 QQ `31584`(创建 `2026-11-24T13:40:42.5671257Z`,登记账号 B)通过 preflight,一次 attach,`get_login_info` 返回同一账号。对端 A 发送私聊 36 与群 41,NoneBot 反向 WS 收到并各回复一次(37/42),应用与 Caligo `get_msg` 均成功;账本保存 36/37/41/42,发送方 A/B 正确;同一 36/41 同时有签名通过的 HTTP POST 与正向 WS 证据。慢阶段 90 在 8 秒慢 POST、5 秒超时下仍到达应用(慢 POST 积压后约 38 秒),daemon 记录 23 次 POST 失败、66 次送达、0 丢弃,非读取 WS 客户端不影响应用连接;该阶段自动回复请求 `onebot-85939363ae79fe15-4` 以 `DeliveryUnknown` 结束(账本另存自发消息 106),未重发;操作者确认 A 已收到该慢回复(106)。控制管道正常停止 daemon;默认生产 bridge 无 research owner-stop(`0xe0`),bridge 保留、QQ 仍响应、未热卸载。原始 runner 的 `app_get_msg` 检查存在 source/outbound ID 比较缺陷,导致 `summary.json` 两项 false negative;`verify-evidence.py` 在不改原 summary、不重发的前提下离线重算,9 项 criteria 全 true、overall pass。feat-006 保持 in-progress(依赖 feat-005 未 done),产品 NOT READY;慢 POST 积压延迟 WS 与慢阶段回复 unknown 列入后续风险。原始材料只在 ignored `local-evidence/feat006-field-20261124-unbound/`。 2026-11-24 feat-006 现场 attempt 1(失败,零发送):新 QQ `34608` preflight PASS,`cli qq-entry` 实际接入成功(bridge 映射、`listener_armed`、daemon 客户端启动),但 `attach.ps1` 用 attach 前缓存的进程模块快照复查映射而误报失败;runner 按失败路径正常停止 core。正常 Stop 使 bridge 的 daemon worker 收到 `CoreStopped` 后退出,同 pipe 重启 core 60 秒无 Hello,实例消耗。默认生产 bridge 不提供 research owner-stop(退出码 `0xe0`),按边界保留映射、未热卸载,QQ 仍响应;全程零发送、零入站、零账本业务记录。已修:attach 后刷新进程快照;attach 非零但 bridge 已映射时记录 `attach_script_warning` 并继续;owner-stop 在默认 bridge 上归类为 `unavailable_default_bridge`,不作为重试理由。细节在 ignored `local-evidence/feat006-field-20261124-unbound/attempt-1.private.md`;下一轮使用重新登录的新实例,不复用 `34608`。 diff --git a/scripts/n5/analyze_journal.py b/scripts/n5/analyze_journal.py new file mode 100644 index 00000000..c548a4a8 --- /dev/null +++ b/scripts/n5/analyze_journal.py @@ -0,0 +1,108 @@ +#!/usr/bin/env python3 +"""Content-free journal accounting for the N5 soak. + +The journal is a framed binary log: `CLGJ` + version + payload length + CRC32 + +UTF-8 JSON. This tool reports only counts and sequence gaps; it never prints +message text, sender UINs, group codes or native message IDs. +""" + +from __future__ import annotations + +import argparse +import collections +import json +import struct +import zlib +from pathlib import Path + +MAGIC = b"CLGJ" + + +def parse(path: Path): + data = path.read_bytes() + offset = 0 + records = [] + failures = [] + version = None + while offset < len(data): + if offset + 16 > len(data): + failures.append({"offset": offset, "error": "truncated header"}) + break + if data[offset : offset + 4] != MAGIC: + failures.append({"offset": offset, "error": "bad magic"}) + break + version, length, expected_crc = struct.unpack(" len(data): + failures.append({"offset": offset, "error": "truncated payload"}) + break + body = data[body_start:body_end] + actual_crc = zlib.crc32(body) & 0xFFFFFFFF + if actual_crc != expected_crc: + failures.append({"offset": offset, "error": "crc mismatch"}) + break + try: + records.append(json.loads(body)) + except json.JSONDecodeError as error: + failures.append({"offset": offset, "error": f"json: {error}"}) + break + offset = body_end + return { + "bytes": len(data), + "records": records, + "consumed_bytes": offset, + "failures": failures, + "version": version if records else None, + } + + +def summarize(path: Path): + parsed = parse(path) + records = parsed["records"] + kinds = collections.Counter(record.get("t") for record in records) + events = [record.get("d", {}) for record in records if record.get("t") == "Event"] + event_seqs = [event.get("event_seq") for event in events if isinstance(event.get("event_seq"), int)] + native_ids = [event.get("native_id") for event in events if event.get("native_id")] + counts = collections.Counter(native_ids) + duplicates = {key: value for key, value in counts.items() if value > 1} + gaps = [] + if event_seqs: + low, high = min(event_seqs), max(event_seqs) + present = set(event_seqs) + gaps = [value for value in range(low, high + 1) if value not in present][:50] + return { + "journal": str(path), + "bytes": parsed["bytes"], + "consumed_bytes": parsed["consumed_bytes"], + "frame_version": parsed["version"], + "records": len(records), + "kinds": dict(kinds), + "events": len(events), + "event_seq_min": min(event_seqs) if event_seqs else None, + "event_seq_max": max(event_seqs) if event_seqs else None, + "event_seq_gaps": gaps, + "unique_native_ids": len(counts), + "duplicate_native_ids": sum(value - 1 for value in duplicates.values()), + "duplicate_id_samples": len(duplicates), + "session_generations": sorted({event.get("session_generation") for event in events}), + "directions": dict(collections.Counter(event.get("direction") for event in events)), + "failures": parsed["failures"], + } + + +def main() -> int: + parser = argparse.ArgumentParser(description="N5 journal accounting without message content") + parser.add_argument("journal") + parser.add_argument("--out") + args = parser.parse_args() + result = summarize(Path(args.journal)) + text = json.dumps(result, ensure_ascii=False, indent=2) + if args.out: + Path(args.out).write_text(text + "\n", encoding="utf-8") + print(text) + return 1 if result["failures"] or result["event_seq_gaps"] or result["duplicate_native_ids"] else 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/scripts/n5/attach.ps1 b/scripts/n5/attach.ps1 new file mode 100644 index 00000000..82b6a269 --- /dev/null +++ b/scripts/n5/attach.ps1 @@ -0,0 +1,58 @@ +param( + [string]$Pack = $PSScriptRoot +) + +# One admitted N5 attach. Requires the preflight state and the daemon startup +# record written by n5_soak.py. It refuses a reused generation, a changed +# module, an already mapped bridge, or a second reservation. + +$ErrorActionPreference = 'Stop' +Set-StrictMode -Version Latest + +function Load-Json([string]$Path) { + [IO.File]::ReadAllText($Path, [Text.Encoding]::UTF8) | ConvertFrom-Json +} + +$state = Load-Json (Join-Path $Pack 'state.private.json') +$daemon = Load-Json (Join-Path $Pack 'daemon.private.json') +$exe = $state.build.caligo_exe +$bridge = $state.build.bridge + +if (-not (Test-Path -LiteralPath $exe) -or -not (Test-Path -LiteralPath $bridge)) { throw 'Pinned release binaries are missing' } +if ((Get-FileHash -LiteralPath $exe -Algorithm SHA256).Hash -ne $state.build.caligo_sha256) { throw 'Operator EXE pin mismatch' } +if ((Get-FileHash -LiteralPath $bridge -Algorithm SHA256).Hash -ne $state.build.bridge_sha256) { throw 'Bridge pin mismatch' } +if ((Get-FileHash -LiteralPath $state.manifest -Algorithm SHA256).Hash -ne $state.manifest_sha256) { throw 'Manifest pin mismatch' } + +$p = Get-Process -Id $state.pid -ErrorAction Stop +if ($p.StartTime.ToUniversalTime().ToString('o') -ne $state.created -or -not $p.Responding) { + throw 'Target generation or health changed since preflight' +} +if (@($p.Modules | Where-Object ModuleName -like '*caligo*bridge*').Count -gt 0) { throw 'Bridge already mapped' } +foreach ($module in @($state.modules)) { + $loaded = @($p.Modules | Where-Object ModuleName -eq $module.name) + if ($loaded.Count -ne 1 -or + [IO.Path]::GetFullPath($loaded[0].FileName) -ne [IO.Path]::GetFullPath([string]$module.path) -or + (Get-FileHash -LiteralPath $loaded[0].FileName -Algorithm SHA256).Hash -ne $module.sha256) { + throw "Loaded module changed: $($module.name)" + } +} + +$reservation = Join-Path $Pack 'attach-reserved' +if (Test-Path -LiteralPath $reservation) { throw 'Attach was already reserved for this pack; do not reattach' } +$handle = [IO.File]::Open($reservation, [IO.FileMode]::CreateNew, [IO.FileAccess]::Write, [IO.FileShare]::None) +$handle.Dispose() + +$report = Join-Path $Pack 'entry.private.jsonl' +& $exe cli qq-entry --pid $state.pid --created-filetime $state.filetime ` + --bridge $bridge --manifest $state.manifest --report $report --wait-s 20 ` + --confirm-designated-test-instance --daemon-pipe $daemon.bridge_pipe ` + --daemon-auth-file $state.token_file --daemon-generation 1 --daemon-account ([string]$state.account) *> (Join-Path $Pack 'attach.private.log') +if ($LASTEXITCODE -ne 0) { throw 'Attach failed; no retry' } + +$p.Refresh() +$mapped = @($p.Modules | Where-Object ModuleName -like '*caligo*bridge*') +if ($mapped.Count -ne 1) { throw 'Bridge mapping not observed after attach' } +if ([IO.Path]::GetFullPath($mapped[0].FileName) -ne [IO.Path]::GetFullPath($bridge)) { + throw 'A different bridge was mapped' +} +Write-Output 'PASS one admitted attach; bridge mapped' diff --git a/scripts/n5/n5_resume.py b/scripts/n5/n5_resume.py new file mode 100644 index 00000000..68cbedc3 --- /dev/null +++ b/scripts/n5/n5_resume.py @@ -0,0 +1,189 @@ +#!/usr/bin/env python3 +"""Continue monitoring an already-running N5 field daemon. + +This mode does not start, attach, restart or replace anything. It is used when +the short observation has passed and the operator decides to continue the same +resident session toward the long-duration gate. The original monitor is stopped +without sending a control Stop; this process takes over the same daemon, bridge +and journal, then performs the final control stop. +""" + +from __future__ import annotations + +import argparse +import datetime as dt +import json +import subprocess +import sys +import time +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent)) + +from analyze_journal import summarize as summarize_journal # noqa: E402 +from n5_soak import ( # noqa: E402 + bridge_mapped, + process_identity, + process_metrics, + probe, + read_json, + sanitize_probe, + utcnow, + write_json, +) + + +def main() -> int: + parser = argparse.ArgumentParser(description="Resume an N5 resident soak without reattaching") + parser.add_argument("--state", required=True) + parser.add_argument("--daemon", required=True) + parser.add_argument("--hours", type=float, required=True) + parser.add_argument("--sample-seconds", type=float, default=60) + parser.add_argument("--out") + args = parser.parse_args() + + state = read_json(Path(args.state).resolve()) + daemon = read_json(Path(args.daemon).resolve()) + pack = Path(args.state).resolve().parent + out = Path(args.out).resolve() if args.out else pack + out.mkdir(parents=True, exist_ok=True) + + exe = Path(state["build"]["caligo_exe"]) + bridge = Path(state["build"]["bridge"]) + token = Path(state["token_file"]).read_text(encoding="ascii").strip() + if len(token) != 64: + raise SystemExit("token file is invalid") + pid = int(daemon["pid"]) + qq_pid = int(state["pid"]) + identity = process_identity(qq_pid) + if not identity or identity["created"] != state["created"] or not identity["responding"]: + raise SystemExit("QQ generation/health changed; refusing to resume") + if not bridge_mapped(qq_pid, bridge): + raise SystemExit("bridge is not mapped; refusing to resume") + daemon_metrics = process_metrics(pid) + if not daemon_metrics.get("available") or not daemon_metrics.get("alive"): + raise SystemExit("daemon is not running; refusing to resume") + check = probe(int(state["ports"]["http"]), token, "get_version_info") + if not check.get("ok"): + raise SystemExit(f"daemon HTTP is not answering; refusing to resume: {check}") + + started_utc = None + events_log = pack / "soak-events.jsonl" + if events_log.exists(): + for line in events_log.read_text(encoding="utf-8").splitlines(): + try: + record = json.loads(line) + except json.JSONDecodeError: + continue + if record.get("kind") == "soak_start": + started_utc = record.get("t_utc") + break + if not started_utc: + started_utc = daemon.get("started_utc") or utcnow() + started = dt.datetime.fromisoformat(started_utc.replace("Z", "+00:00")) + uptime_before = max(0.0, (dt.datetime.now(dt.timezone.utc) - started).total_seconds()) + target_hours = args.hours + target_seconds = target_hours * 3600 + start = time.time() + events_path = out / "resume-events.jsonl" + failures = [] + samples = [] + + print(json.dumps({"kind": "resume_start", "uptime_before_s": round(uptime_before, 2), "target_hours": target_hours}), flush=True) + with events_path.open("a", encoding="utf-8") as events: + next_sample = time.time() + index = 0 + while time.time() - start < target_seconds: + now = time.time() + if now >= next_sample: + version = probe(int(state["ports"]["http"]), token, "get_version_info") + status = probe(int(state["ports"]["http"]), token, "get_status") + login = probe(int(state["ports"]["http"]), token, "get_login_info") + record = { + "t_utc": utcnow(), + "elapsed_s": round(time.time() - start, 2), + "daemon": process_metrics(pid), + "qq": process_metrics(qq_pid), + "journal_size": Path(state["journal"]).stat().st_size if Path(state["journal"]).exists() else None, + "probes": {"version": version, "status": status, "login": login}, + } + if index % 10 == 0: + record["bridge_mapped"] = bridge_mapped(qq_pid, bridge) + events.write(json.dumps({"kind": "sample", **record}, ensure_ascii=False) + "\n") + events.flush() + samples.append(record) + for name, value in (("version", version), ("status", status), ("login", login)): + if not value.get("ok"): + failures.append({"t_utc": record["t_utc"], "kind": name, "result": sanitize_probe(value)}) + index += 1 + next_sample += max(1.0, args.sample_seconds) + if index % 30 == 0: + print(json.dumps({"kind": "progress", "samples": index, "elapsed_s": record["elapsed_s"]}), flush=True) + remaining = next_sample - time.time() + if remaining > 0: + time.sleep(min(remaining, 5.0)) + + print(json.dumps({"kind": "resume_window_complete", "samples": len(samples)}), flush=True) + stop_record = {} + control = subprocess.run( + [ + str(exe), + "cli", + "daemon-control", + "--pipe", + daemon["control_pipe"], + "--auth", + token, + "stop", + ], + capture_output=True, + text=True, + timeout=30, + ) + stop_record.update({"control_exit": control.returncode, "stdout": control.stdout.strip(), "stderr": control.stderr.strip()}) + deadline = time.time() + 20 + while time.time() < deadline: + if not process_metrics(pid).get("alive"): + break + time.sleep(0.2) + stop_record["exited"] = not process_metrics(pid).get("alive") + bridge_final = bridge_mapped(qq_pid, bridge) + qq_final = process_identity(qq_pid) + stop_record["bridge_retained"] = bridge_final + stop_record["qq_responding"] = bool(qq_final and qq_final["responding"]) + + journal = summarize_journal(Path(state["journal"])) + duration = time.time() - start + total_uptime = uptime_before + duration + criteria = { + "probes_answered": len(failures) == 0 and len(samples) > 0, + "journal_intact": not journal["failures"] and not journal["event_seq_gaps"], + "journal_no_duplicates": journal["duplicate_native_ids"] == 0, + "bridge_retained_after_stop": bridge_final is True, + "qq_responsive_after_stop": stop_record["qq_responding"] is True, + "daemon_stopped_by_control": stop_record.get("control_exit") == 0 and stop_record.get("exited") is True, + "continuous_uptime_24h": total_uptime >= 24 * 3600, + } + summary = { + "schema": "caligo/n5-resume-summary/1", + "started_utc": started_utc, + "resume_started_utc": utcnow(), + "duration_seconds": round(duration, 2), + "uptime_before_seconds": round(uptime_before, 2), + "total_continuous_seconds": round(total_uptime, 2), + "total_continuous_hours": round(total_uptime / 3600, 3), + "samples": len(samples), + "probe_failures": len(failures), + "probe_failure_samples": failures[:20], + "journal": journal, + "stop": stop_record, + "criteria": criteria, + "overall": "pass" if all(criteria.values()) else "fail", + } + write_json(out / "resume-summary.json", summary) + print(json.dumps({"kind": "resume_finished", "overall": summary["overall"], "criteria": criteria}), flush=True) + return 0 if summary["overall"] == "pass" else 1 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/scripts/n5/n5_soak.py b/scripts/n5/n5_soak.py new file mode 100644 index 00000000..86918677 --- /dev/null +++ b/scripts/n5/n5_soak.py @@ -0,0 +1,848 @@ +#!/usr/bin/env python3 +"""N5 resident soak and recovery harness. + +Field mode drives one already-admitted QQ generation through a single bridge +attach, repeated OneBot health queries, and controlled core crash/restart +injections. Rehearsal mode exercises the same daemon start/restart/stop path +without QQ or a bridge. The harness never sends a message and never hot-unloads +a mapped bridge. + +Raw state, tokens, logs, journal and samples stay in the ignored pack +directory. Only a summary is meant to be copied into acceptance evidence. +""" + +from __future__ import annotations + +import argparse +import ctypes +import datetime as dt +import hashlib +import json +import os +import statistics +import struct +import subprocess +import sys +import time +import urllib.error +import urllib.request +import uuid +from pathlib import Path + +CREATE_NO_WINDOW = 0x08000000 +PROCESS_QUERY_LIMITED_INFORMATION = 0x1000 +STILL_ACTIVE = 259 + +kernel32 = ctypes.WinDLL("kernel32", use_last_error=True) +psapi = ctypes.WinDLL("psapi", use_last_error=True) + + +class FILETIME(ctypes.Structure): + _fields_ = [("low", ctypes.c_uint32), ("high", ctypes.c_uint32)] + + +kernel32.OpenProcess.argtypes = [ctypes.c_uint32, ctypes.c_int, ctypes.c_uint32] +kernel32.OpenProcess.restype = ctypes.c_void_p +kernel32.CloseHandle.argtypes = [ctypes.c_void_p] +kernel32.CloseHandle.restype = ctypes.c_int +kernel32.GetProcessHandleCount.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_uint32)] +kernel32.GetProcessHandleCount.restype = ctypes.c_int +kernel32.GetExitCodeProcess.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_uint32)] +kernel32.GetExitCodeProcess.restype = ctypes.c_int +kernel32.GetProcessTimes.argtypes = [ + ctypes.c_void_p, + ctypes.POINTER(FILETIME), + ctypes.POINTER(FILETIME), + ctypes.POINTER(FILETIME), + ctypes.POINTER(FILETIME), +] +kernel32.GetProcessTimes.restype = ctypes.c_int + + +class PROCESS_MEMORY_COUNTERS_EX(ctypes.Structure): + _fields_ = [ + ("cb", ctypes.c_uint32), + ("PageFaultCount", ctypes.c_uint32), + ("PeakWorkingSetSize", ctypes.c_size_t), + ("WorkingSetSize", ctypes.c_size_t), + ("QuotaPeakPagedPoolUsage", ctypes.c_size_t), + ("QuotaPagedPoolUsage", ctypes.c_size_t), + ("QuotaPeakNonPagedPoolUsage", ctypes.c_size_t), + ("QuotaNonPagedPoolUsage", ctypes.c_size_t), + ("PagefileUsage", ctypes.c_size_t), + ("PeakPagefileUsage", ctypes.c_size_t), + ("PrivateUsage", ctypes.c_size_t), + ] + + +psapi.GetProcessMemoryInfo.argtypes = [ + ctypes.c_void_p, + ctypes.POINTER(PROCESS_MEMORY_COUNTERS_EX), + ctypes.c_uint32, +] +psapi.GetProcessMemoryInfo.restype = ctypes.c_int + + +def utcnow() -> str: + return dt.datetime.now(dt.timezone.utc).isoformat() + + +def read_json(path: Path): + return json.loads(path.read_text(encoding="utf-8")) + + +def write_json(path: Path, value) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(json.dumps(value, ensure_ascii=False, indent=2), encoding="utf-8") + + +def sha256_file(path: Path) -> str: + digest = hashlib.sha256() + with path.open("rb") as handle: + for chunk in iter(lambda: handle.read(1024 * 1024), b""): + digest.update(chunk) + return digest.hexdigest() + + +def sha256_prefix(path: Path, length: int) -> str: + with path.open("rb") as handle: + return hashlib.sha256(handle.read(length)).hexdigest() + + +def complete_frame_prefix(path: Path): + """Return (complete_bytes, sha256(complete_bytes)) for the journal prefix. + + A core kill can catch the writer in the middle of a frame. Recovery may then + truncate that partial tail; comparing only complete frames avoids treating a + safe truncation as a changed prefix. + """ + data = path.read_bytes() + offset = 0 + while offset + 16 <= len(data): + if data[offset : offset + 4] != b"CLGJ": + break + version, length, _crc = struct.unpack(" len(data) or length > 16 * 1024 * 1024: + break + offset += 16 + length + return offset, hashlib.sha256(data[:offset]).hexdigest() + + +def new_hex(byte_count: int) -> str: + return os.urandom(byte_count).hex() + + +def free_port() -> int: + import socket + + with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: + sock.bind(("127.0.0.1", 0)) + return sock.getsockname()[1] + + +def process_metrics(pid: int): + handle = kernel32.OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, 0, pid) + if not handle: + return {"available": False, "error": ctypes.get_last_error()} + try: + counters = PROCESS_MEMORY_COUNTERS_EX() + counters.cb = ctypes.sizeof(counters) + memory_ok = bool(psapi.GetProcessMemoryInfo(handle, ctypes.byref(counters), counters.cb)) + handles = ctypes.c_uint32(0) + handles_ok = bool(kernel32.GetProcessHandleCount(handle, ctypes.byref(handles))) + creation, exit_time, kernel, user = FILETIME(), FILETIME(), FILETIME(), FILETIME() + times_ok = bool( + kernel32.GetProcessTimes( + handle, + ctypes.byref(creation), + ctypes.byref(exit_time), + ctypes.byref(kernel), + ctypes.byref(user), + ) + ) + cpu_100ns = ( + ((kernel.high << 32) | kernel.low) + ((user.high << 32) | user.low) + if times_ok + else 0 + ) + exit_code = ctypes.c_uint32(0) + alive = bool(kernel32.GetExitCodeProcess(handle, ctypes.byref(exit_code))) and exit_code.value == STILL_ACTIVE + return { + "available": True, + "alive": alive, + "working_set_bytes": counters.WorkingSetSize if memory_ok else None, + "peak_working_set_bytes": counters.PeakWorkingSetSize if memory_ok else None, + "private_bytes": counters.PrivateUsage if memory_ok else None, + "pagefile_bytes": counters.PagefileUsage if memory_ok else None, + "handles": handles.value if handles_ok else None, + "cpu_seconds": round(cpu_100ns / 10_000_000, 3) if times_ok else None, + } + finally: + kernel32.CloseHandle(handle) + + +def powershell(script: str, timeout: float = 20.0) -> subprocess.CompletedProcess: + return subprocess.run( + [ + "C:\\windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", + "-NoProfile", + "-NonInteractive", + "-ExecutionPolicy", + "Bypass", + "-Command", + script, + ], + capture_output=True, + text=True, + timeout=timeout, + ) + + +def process_identity(pid: int): + result = powershell( + f"$p=Get-Process -Id {pid}; if(-not $p){{exit 3}}; " + "Write-Output ($p.StartTime.ToUniversalTime().ToString('o') + '|' + $p.Responding + '|' + $p.MainWindowHandle)" + ) + if result.returncode != 0: + return None + parts = result.stdout.strip().split("|") + if len(parts) != 3: + return None + return {"created": parts[0], "responding": parts[1] == "True", "window": int(parts[2])} + + +def bridge_mapped(pid: int, bridge: Path) -> bool: + expected = str(bridge).replace("'", "''") + result = powershell( + f"$p=Get-Process -Id {pid}; if(-not $p){{exit 3}}; " + f"@($p.Modules | Where-Object {{ $_.FileName -eq '{expected}' }}).Count" + ) + return result.returncode == 0 and result.stdout.strip().isdigit() and int(result.stdout.strip()) == 1 + + +def onebot_action(port: int, token: str, action: str, params=None, timeout: float = 10.0): + body = json.dumps( + {"action": action, "params": params or {}, "echo": f"{action}-{uuid.uuid4().hex[:8]}"} + ).encode("utf-8") + request = urllib.request.Request( + f"http://127.0.0.1:{port}/", + data=body, + headers={"Authorization": f"Bearer {token}", "Content-Type": "application/json"}, + method="POST", + ) + with urllib.request.urlopen(request, timeout=timeout) as response: + raw = response.read() + return json.loads(raw) + + +def probe(port: int, token: str, action: str, params=None): + started = time.perf_counter() + try: + reply = onebot_action(port, token, action, params) + latency = round((time.perf_counter() - started) * 1000, 2) + return { + "ok": reply.get("retcode") == 0, + "retcode": reply.get("retcode"), + "status": reply.get("status"), + "latency_ms": latency, + "data": reply.get("data"), + } + except Exception as error: # noqa: BLE001 - field evidence records the failure text + return { + "ok": False, + "retcode": None, + "error": f"{type(error).__name__}: {error}", + "latency_ms": round((time.perf_counter() - started) * 1000, 2), + } + + +def sanitize_probe(value): + if not isinstance(value, dict): + return value + keep = ("ok", "retcode", "status", "error", "latency_ms") + return {key: value[key] for key in keep if key in value} + + +def wait_ready(log_path: Path, proc: subprocess.Popen, timeout: float = 20.0): + deadline = time.time() + timeout + while time.time() < deadline: + if log_path.exists(): + text = log_path.read_text(encoding="utf-8", errors="replace").splitlines() + if text: + try: + value = json.loads(text[0]) + if value.get("onebot_http"): + return value + except json.JSONDecodeError: + pass + if proc.poll() is not None: + break + time.sleep(0.1) + return None + + +class Soak: + def __init__(self, state: dict, pack: Path, args): + self.state = state + self.pack = pack + self.args = args + self.out = Path(args.out) if args.out else pack + self.out.mkdir(parents=True, exist_ok=True) + self.events_path = self.out / "soak-events.jsonl" + self.events = self.events_path.open("a", encoding="utf-8") + self.daemon_proc: subprocess.Popen | None = None + self.ready: dict | None = None + self.started = time.time() + self.start_utc = utcnow() + self.samples: list[dict] = [] + self.restarts: list[dict] = [] + self.probe_failures: list[dict] = [] + self.stop_record: dict = {} + self.fatal: str | None = None + self.bridge_initial: bool | None = None + self.bridge_final: bool | None = None + self.journal_initial: dict | None = None + self.journal_final: dict | None = None + + def log_event(self, kind: str, **fields): + record = {"t_utc": utcnow(), "kind": kind, "elapsed_s": round(time.time() - self.started, 2)} + record.update(fields) + self.events.write(json.dumps(record, ensure_ascii=False) + "\n") + self.events.flush() + print(json.dumps(record, ensure_ascii=False), flush=True) + + def daemon_args(self, account: str): + return [ + str(self.state["build"]["caligo_exe"]), + "daemon", + "--pipe-prefix", + self.state["pipe"], + "--journal", + self.state["journal"], + "--baseline", + "qq-9.9.33-52230", + "--account", + account, + "--core-build", + "caligo-n5-soak", + "--token-file", + self.state["token_file"], + "--onebot-http-bind", + f"127.0.0.1:{self.state['ports']['http']}", + "--onebot-ws-bind", + f"127.0.0.1:{self.state['ports']['ws']}", + ] + + def start_daemon(self, index: int, expect_pid: int | None): + args = self.daemon_args(str(self.state["account"])) + if expect_pid: + args += ["--expect-pid", str(expect_pid)] + log_path = self.out / f"daemon-{index}.stdout.private.log" + err_path = self.out / f"daemon-{index}.stderr.private.log" + log_path.unlink(missing_ok=True) + err_path.unlink(missing_ok=True) + with log_path.open("wb") as out, err_path.open("wb") as err: + proc = subprocess.Popen( + args, + cwd=str(Path(args[0]).parent), + stdout=out, + stderr=err, + creationflags=CREATE_NO_WINDOW, + ) + ready = wait_ready(log_path, proc, timeout=30.0) + if not ready: + if proc.poll() is None: + proc.kill() + error = err_path.read_text(encoding="utf-8", errors="replace") if err_path.exists() else "" + raise RuntimeError(f"daemon start failed (exit={proc.poll()}): {error[-2000:]}") + self.daemon_proc = proc + self.ready = ready + write_json( + self.pack / "daemon.private.json", + { + "pid": proc.pid, + "started_utc": utcnow(), + "bridge_pipe": ready.get("bridge_pipe"), + "control_pipe": ready.get("control_pipe"), + "onebot_http": ready.get("onebot_http"), + "onebot_ws": ready.get("onebot_ws"), + }, + ) + self.log_event("daemon_started", pid=proc.pid, http=ready.get("onebot_http"), ws=ready.get("onebot_ws")) + return proc, ready + + def wait_login(self, timeout: float = 120.0): + deadline = time.time() + timeout + last = None + while time.time() < deadline: + last = probe(self.state["ports"]["http"], self.token, "get_login_info") + if last.get("ok") and str((last.get("data") or {}).get("user_id")) == str(self.state["account"]): + return last + time.sleep(1.0) + return last + + def stop_daemon(self, force: bool = False): + if not self.daemon_proc: + return + if self.daemon_proc.poll() is None: + result = subprocess.run( + [ + str(self.state["build"]["caligo_exe"]), + "cli", + "daemon-control", + "--pipe", + self.ready["control_pipe"], + "--auth", + self.ready["auth_token"], + "stop", + ], + capture_output=True, + text=True, + timeout=30, + ) + self.stop_record = { + "control_exit": result.returncode, + "stdout": result.stdout.strip(), + "stderr": result.stderr.strip(), + "method": "control-stop", + } + if result.returncode != 0 and force: + self.daemon_proc.kill() + self.stop_record["method"] = "control-stop-failed-force-kill" + try: + self.daemon_proc.wait(timeout=20) + except subprocess.TimeoutExpired: + if force: + self.daemon_proc.kill() + self.daemon_proc.wait(timeout=10) + else: + raise + self.stop_record["exited"] = self.daemon_proc.poll() is not None + self.stop_record["exit_code"] = self.daemon_proc.poll() + + def journal_state(self, with_hash: bool): + path = Path(self.state["journal"]) + if not path.exists(): + return {"exists": False} + value = {"exists": True, "size": path.stat().st_size, "mtime_utc": dt.datetime.fromtimestamp(path.stat().st_mtime, dt.timezone.utc).isoformat()} + if with_hash: + value["sha256"] = sha256_file(path) + complete_bytes, complete_hash = complete_frame_prefix(path) + value["complete_bytes"] = complete_bytes + value["complete_sha256"] = complete_hash + return value + + def sample(self, index: int, with_hash: bool): + version = probe(self.state["ports"]["http"], self.token, "get_version_info") + status = probe(self.state["ports"]["http"], self.token, "get_status") + login = probe(self.state["ports"]["http"], self.token, "get_login_info") + record = { + "t_utc": utcnow(), + "elapsed_s": round(time.time() - self.started, 2), + "daemon": process_metrics(self.daemon_proc.pid) if self.daemon_proc else {"available": False}, + "qq": process_metrics(int(self.state["pid"])) if self.state.get("pid") else {"available": False}, + "journal": self.journal_state(with_hash), + "probes": {"version": version, "status": status, "login": login}, + } + if self.bridge_initial is not None and index % 10 == 0: + record["bridge_mapped"] = bridge_mapped(int(self.state["pid"]), Path(self.state["build"]["bridge"])) + if not record["bridge_mapped"]: + self.probe_failures.append({"t_utc": record["t_utc"], "kind": "bridge-unmapped"}) + self.samples.append(record) + self.events.write(json.dumps({"kind": "sample", **record}, ensure_ascii=False) + "\n") + self.events.flush() + rehearsal = self.state.get("mode") == "rehearsal" + for name, value in (("version", version), ("status", status), ("login", login)): + if not value.get("ok") and not (rehearsal and name in ("status", "login")): + self.probe_failures.append( + {"t_utc": record["t_utc"], "kind": name, "result": sanitize_probe(value)} + ) + return record + + def wait_recovered(self, timeout: float = 180.0): + deadline = time.time() + timeout + last = None + rehearsal = self.state.get("mode") == "rehearsal" + while time.time() < deadline: + last = probe( + self.state["ports"]["http"], + self.token, + "get_version_info" if rehearsal else "get_login_info", + ) + if last.get("ok"): + return last, round(timeout - (deadline - time.time()), 2) + time.sleep(1.0) + return last, None + + def restart_core(self, index: int): + before = self.journal_state(True) + self.log_event("core_kill", index=index, journal=before) + self.daemon_proc.kill() + self.daemon_proc.wait(timeout=20) + killed_at = time.time() + proc, _ = self.start_daemon(index, int(self.state["pid"]) if self.state.get("pid") else None) + recovered, recovered_after = self.wait_recovered() + after = self.journal_state(True) + prefix_ok = None + if before.get("exists") and after.get("exists"): + size = int(before.get("complete_bytes", 0)) + if size > 0: + prefix_ok = sha256_prefix(Path(self.state["journal"]), size) == before.get("complete_sha256") + record = { + "index": index, + "t_utc": utcnow(), + "journal_before": before, + "journal_after": after, + "journal_prefix_preserved": prefix_ok, + "recovered": bool(recovered and recovered.get("ok")), + "recovery_seconds": round(time.time() - killed_at, 2), + "probe": sanitize_probe(recovered), + } + self.restarts.append(record) + self.log_event("core_restarted", **record) + if not record["recovered"]: + raise RuntimeError(f"core restart {index} did not recover within timeout: {recovered}") + return record + + def summarize_process(self, name: str): + values = [s[name] for s in self.samples if s.get(name, {}).get("available")] + if not values: + return {"available": False, "samples": 0} + working = [v["working_set_bytes"] for v in values if v.get("working_set_bytes") is not None] + handles = [v["handles"] for v in values if v.get("handles") is not None] + private = [v["private_bytes"] for v in values if v.get("private_bytes") is not None] + return { + "available": True, + "samples": len(values), + "working_set_first": working[0] if working else None, + "working_set_last": working[-1] if working else None, + "working_set_max": max(working) if working else None, + "private_first": private[0] if private else None, + "private_last": private[-1] if private else None, + "handles_first": handles[0] if handles else None, + "handles_last": handles[-1] if handles else None, + "handles_max": max(handles) if handles else None, + } + + def hourly_summary(self, hour_index: int): + recent = [s for s in self.samples if hour_index * 3600 <= s["elapsed_s"] < (hour_index + 1) * 3600] + if not recent: + return + value = { + "hour": hour_index, + "t_utc": utcnow(), + "samples": len(recent), + "daemon_working_set_max": max( + (s["daemon"].get("working_set_bytes") or 0) for s in recent if s["daemon"].get("available") + ), + "daemon_handles_max": max( + (s["daemon"].get("handles") or 0) for s in recent if s["daemon"].get("available") + ), + "qq_working_set_max": max( + (s["qq"].get("working_set_bytes") or 0) for s in recent if s["qq"].get("available") + ), + "probe_failures": sum( + 1 + for s in recent + for p in s["probes"].values() + if not p.get("ok") + ), + "journal_size": recent[-1]["journal"].get("size"), + } + (self.out / "hourly").mkdir(exist_ok=True) + write_json(self.out / "hourly" / f"hour-{hour_index:02d}.json", value) + print(json.dumps({"kind": "hourly", **value}, ensure_ascii=False), flush=True) + + def final_summary(self, duration_target: float): + duration = time.time() - self.started + probes = [p for s in self.samples for p in s["probes"].values()] + latencies = [p["latency_ms"] for p in probes if "latency_ms" in p] + probe_ok = sum(1 for p in probes if p.get("ok")) + restart_ok = bool(self.restarts) and all(r["recovered"] and r.get("journal_prefix_preserved") is not False for r in self.restarts) + journal_prefix = all(r.get("journal_prefix_preserved") is not False for r in self.restarts) + bridge_retained = self.bridge_final is True + qq_ok = False + if self.state.get("pid"): + identity = process_identity(int(self.state["pid"])) + qq_ok = bool(identity and identity["responding"]) + daemon_summary = self.summarize_process("daemon") + qq_summary = self.summarize_process("qq") + bounded = True + if daemon_summary.get("working_set_first") and daemon_summary.get("working_set_max"): + bounded = bounded and daemon_summary["working_set_max"] < 1024 * 1024 * 1024 + bounded = bounded and (daemon_summary["working_set_last"] or 0) < daemon_summary["working_set_first"] * 3 + 256 * 1024 * 1024 + if daemon_summary.get("handles_first") and daemon_summary.get("handles_last"): + bounded = bounded and daemon_summary["handles_last"] < daemon_summary["handles_first"] + 512 + rehearsal = self.state.get("mode") == "rehearsal" + criteria = { + "resident_duration": duration >= duration_target - 180, + "probes_answered": probe_ok > 0 and len(self.probe_failures) == 0, + "core_restarts_recovered": restart_ok, + "journal_prefix_preserved": journal_prefix, + "bridge_retained_after_stop": True if rehearsal else bridge_retained, + "qq_responsive_after_stop": True if rehearsal else qq_ok, + "process_growth_bounded": bounded, + } + overall = "pass" if all(criteria.values()) else "fail" + if duration_target - duration > 180: + overall = "incomplete" + summary = { + "schema": "caligo/n5-soak-summary/1", + "mode": self.state.get("mode", "field"), + "started_utc": self.start_utc, + "finished_utc": utcnow(), + "duration_seconds": round(duration, 2), + "duration_target_seconds": round(duration_target, 2), + "target_hours": self.state.get("duration_hours"), + "sample_seconds": self.state.get("sample_seconds"), + "samples": len(self.samples), + "probe_count": len(probes), + "probe_ok": probe_ok, + "probe_failures": len(self.probe_failures), + "probe_failure_samples": self.probe_failures[:20], + "latency_ms": { + "median": round(statistics.median(latencies), 2) if latencies else None, + "p95": round(sorted(latencies)[int(len(latencies) * 0.95) - 1], 2) if latencies else None, + "max": max(latencies) if latencies else None, + }, + "daemon": daemon_summary, + "qq": qq_summary, + "restarts": self.restarts, + "journal_initial": self.journal_initial, + "journal_final": self.journal_final, + "stop": self.stop_record, + "bridge_initial": self.bridge_initial, + "bridge_final": self.bridge_final, + "criteria": criteria, + "overall": overall, + "fatal": self.fatal, + } + write_json(self.out / "soak-summary.json", summary) + lines = [ + "# N5 soak summary", + "", + f"- mode: `{summary['mode']}`", + f"- started: {summary['started_utc']}", + f"- finished: {summary['finished_utc']}", + f"- duration: {summary['duration_seconds']:.0f}s (target {summary['duration_target_seconds']:.0f}s)", + f"- samples: {summary['samples']}, probes: {summary['probe_ok']}/{summary['probe_count']} ok", + f"- daemon working set first/last/max: {daemon_summary.get('working_set_first')}/{daemon_summary.get('working_set_last')}/{daemon_summary.get('working_set_max')}", + f"- daemon handles first/last/max: {daemon_summary.get('handles_first')}/{daemon_summary.get('handles_last')}/{daemon_summary.get('handles_max')}", + f"- core restarts: {len(self.restarts)}", + f"- bridge initial/final: {self.bridge_initial}/{self.bridge_final}", + f"- criteria: {json.dumps(criteria, ensure_ascii=False)}", + f"- overall: **{overall}**", + ] + if self.fatal: + lines.append(f"- fatal: {self.fatal}") + (self.out / "soak-summary.md").write_text("\n".join(lines) + "\n", encoding="utf-8") + return summary + + +def load_state(path: Path) -> dict: + state = read_json(path) + required = ["schema", "build", "pipe", "journal", "token_file", "ports", "account", "duration_hours", "sample_seconds"] + for field in required: + if field not in state: + raise SystemExit(f"state is missing {field}") + build = state["build"] + for key in ("caligo_exe", "caligo_sha256", "bridge", "bridge_sha256"): + if key not in build: + raise SystemExit(f"state.build is missing {key}") + if not Path(build["caligo_exe"]).exists() or not Path(build["bridge"]).exists(): + raise SystemExit("pinned release binaries are missing") + if sha256_file(Path(build["caligo_exe"])).lower() != str(build["caligo_sha256"]).lower(): + raise SystemExit("pinned release EXE hash mismatch") + if sha256_file(Path(build["bridge"])).lower() != str(build["bridge_sha256"]).lower(): + raise SystemExit("pinned bridge hash mismatch") + token_path = Path(state["token_file"]) + if not token_path.exists(): + raise SystemExit("token file is missing") + token = token_path.read_text(encoding="ascii").strip() + if len(token) != 64 or any(c not in "0123456789abcdef" for c in token): + raise SystemExit("token file is not 64 lowercase hex characters") + return state + + +def rehearse_state(repo: Path, work: Path, hours: float, sample_seconds: int) -> dict: + exe = repo / "target-harness/x86_64-pc-windows-msvc/release/caligo.exe" + bridge = repo / "target-harness/x86_64-pc-windows-msvc/release/caligo_bridge.dll" + if not exe.exists(): + exe = repo / "target-harness/release/caligo.exe" + bridge = repo / "target-harness/release/caligo_bridge.dll" + if not exe.exists() or not bridge.exists(): + raise SystemExit("release binaries are missing; run verify-release.ps1 first") + work.mkdir(parents=True, exist_ok=True) + token_file = work / "rehearsal.token" + token_file.write_text(new_hex(32), encoding="ascii") + return { + "schema": "caligo/n5-soak-state/1", + "mode": "rehearsal", + "build": { + "caligo_exe": str(exe), + "caligo_sha256": sha256_file(exe), + "bridge": str(bridge), + "bridge_sha256": sha256_file(bridge), + }, + "pipe": "caligo-n5-rehearsal-" + new_hex(4), + "journal": str(work / "journal.jsonl"), + "token_file": str(token_file), + "ports": {"http": free_port(), "ws": free_port()}, + "account": 1694717255, + "pid": 0, + "duration_hours": hours, + "sample_seconds": sample_seconds, + "restart_at_minutes": [0.25], + } + + +def main() -> int: + parser = argparse.ArgumentParser(description="N5 resident soak and recovery harness") + parser.add_argument("--state", help="field state JSON from preflight.ps1") + parser.add_argument("--pack", help="field pack directory (defaults to state parent)") + parser.add_argument("--out", help="output directory (defaults to pack)") + parser.add_argument("--rehearse", action="store_true", help="run without QQ or bridge") + parser.add_argument("--hours", type=float, help="override duration hours") + parser.add_argument("--sample-seconds", type=int, help="override sample interval") + parser.add_argument("--restart-at-min", type=float, nargs="*", help="override restart minutes") + parser.add_argument("--repo", default=str(Path(__file__).resolve().parents[2])) + args = parser.parse_args() + + repo = Path(args.repo).resolve() + if args.rehearse: + work = Path(args.out) if args.out else repo / "target-harness/n5-soak-rehearsal" + state = rehearse_state(repo, work, args.hours or 0.02, args.sample_seconds or 5) + if args.restart_at_min is not None: + state["restart_at_minutes"] = list(args.restart_at_min) + pack = work + else: + if not args.state: + parser.error("--state is required unless --rehearse is used") + state_path = Path(args.state).resolve() + state = load_state(state_path) + pack = Path(args.pack).resolve() if args.pack else state_path.parent + if args.hours is not None: + state["duration_hours"] = args.hours + if args.sample_seconds is not None: + state["sample_seconds"] = args.sample_seconds + if args.restart_at_min is not None: + state["restart_at_minutes"] = list(args.restart_at_min) + authorization = pack / "authorization.private.json" + if not authorization.exists(): + raise SystemExit(f"authorization is missing: {authorization}") + authorization_data = read_json(authorization) + if authorization_data.get("authorized") is not True: + raise SystemExit("authorization.private.json is not authorized") + if int(authorization_data.get("pid", 0)) != int(state.get("pid", 0)): + raise SystemExit("authorization PID does not match state") + if authorization_data.get("created_utc") != state.get("created"): + raise SystemExit("authorization creation time does not match state") + identity = process_identity(int(state["pid"])) + if not identity or identity["created"] != state["created"] or not identity["responding"]: + raise SystemExit("QQ target generation/health changed since preflight") + if bridge_mapped(int(state["pid"]), Path(state["build"]["bridge"])): + raise SystemExit("bridge is already mapped; use a fresh QQ generation") + if Path(state["journal"]).exists() and Path(state["journal"]).stat().st_size > 0: + raise SystemExit("journal already contains data; use a fresh pack") + + out = Path(args.out).resolve() if args.out else pack + soak = Soak(state, pack, args) + soak.token = Path(state["token_file"]).read_text(encoding="ascii").strip() + summary = None + try: + soak.log_event("soak_start", mode=state.get("mode"), hours=state["duration_hours"], account=state.get("account")) + soak.start_daemon(0, int(state["pid"]) if state.get("pid") else None) + if not args.rehearse: + result = subprocess.run( + [ + "C:\\windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", + "-NoProfile", + "-ExecutionPolicy", + "Bypass", + "-File", + str(repo / "scripts/n5/attach.ps1"), + "-Pack", + str(pack), + ], + capture_output=True, + text=True, + timeout=120, + ) + (pack / "attach.private.log").write_text( + result.stdout + "\n" + result.stderr, encoding="utf-8" + ) + if result.returncode != 0: + raise RuntimeError(f"attach failed (exit {result.returncode}): {result.stderr[-2000:]}") + soak.bridge_initial = bridge_mapped(int(state["pid"]), Path(state["build"]["bridge"])) + if not soak.bridge_initial: + raise RuntimeError("bridge is not mapped after attach") + login = soak.wait_login() + if not login or not login.get("ok"): + raise RuntimeError(f"login was not confirmed after attach: {login}") + soak.log_event("bridge_attached", bridge_mapped=soak.bridge_initial, login_ok=True) + soak.journal_initial = soak.journal_state(True) + + target_seconds = float(state["duration_hours"]) * 3600 + restart_at = sorted(float(value) * 60 for value in state.get("restart_at_minutes", [])) + restart_index = 0 + sample_seconds = max(1.0, float(state["sample_seconds"])) + next_sample = time.time() + next_hour = 1 + index = 0 + while time.time() - soak.started < target_seconds: + now = time.time() + if now >= next_sample: + soak.sample(index, with_hash=(index % 10 == 0)) + index += 1 + next_sample += sample_seconds + if now - soak.started >= next_hour * 3600: + soak.hourly_summary(next_hour - 1) + next_hour += 1 + if restart_index < len(restart_at) and time.time() - soak.started >= restart_at[restart_index]: + restart_index += 1 + soak.restart_core(restart_index) + next_sample = time.time() + sample_seconds + remaining = min(next_sample - time.time(), target_seconds - (time.time() - soak.started)) + if remaining > 0: + time.sleep(min(remaining, 1.0)) + soak.log_event("soak_window_complete", samples=len(soak.samples)) + except Exception as error: # noqa: BLE001 - evidence records the fatal boundary + soak.fatal = f"{type(error).__name__}: {error}" + soak.log_event("soak_fatal", error=soak.fatal) + finally: + try: + stop_error = None + if soak.daemon_proc and soak.daemon_proc.poll() is None: + try: + soak.stop_daemon(force=True) + except Exception as error: # noqa: BLE001 - preserve the stop failure in evidence + stop_error = f"{type(error).__name__}: {error}" + soak.stop_record["stop_error"] = stop_error + if soak.daemon_proc and soak.daemon_proc.poll() is None: + soak.daemon_proc.kill() + if state.get("pid"): + soak.bridge_final = bridge_mapped(int(state["pid"]), Path(state["build"]["bridge"])) + identity = process_identity(int(state["pid"])) + soak.log_event( + "stop_boundary", + daemon_exited=soak.daemon_proc.poll() if soak.daemon_proc else None, + bridge_retained=soak.bridge_final, + qq_responding=bool(identity and identity["responding"]), + owner_stop="not_attempted_default_bridge", + stop_error=stop_error, + ) + soak.journal_final = soak.journal_state(True) + summary = soak.final_summary(target_seconds if "target_seconds" in locals() else 0) + soak.log_event("soak_finished", overall=summary["overall"], criteria=summary["criteria"]) + except Exception as error: # noqa: BLE001 - the harness must still close its evidence file + soak.fatal = soak.fatal or f"finalization: {type(error).__name__}: {error}" + print(json.dumps({"kind": "finalization_error", "error": soak.fatal}), flush=True) + finally: + soak.events.close() + if soak.fatal: + return 2 + return 0 if summary and summary.get("overall") == "pass" else 1 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/scripts/n5/preflight.ps1 b/scripts/n5/preflight.ps1 new file mode 100644 index 00000000..c78ce4b2 --- /dev/null +++ b/scripts/n5/preflight.ps1 @@ -0,0 +1,220 @@ +[CmdletBinding()] +param( + [string]$Repo = '', + [string]$Pack = '', + [UInt32]$TargetPid = 0, + [string]$ExpectedCreated = '', + [UInt64]$Account = 0, + [double]$DurationHours = 24, + [int]$SampleSeconds = 60, + [int[]]$RestartAtMinutes = @(120, 480, 960), + [switch]$Rehearse +) + +# N5 field admission and pack preparation. +# +# Field mode requires a fresh, designated QQ main root. It performs the same +# read-only gates used by the feat-006 pack: exact release pins, manifest and +# loaded-module hashes, PE/backend audit, unique Environment scan, no mapped +# Caligo bridge, and unique loopback ports. It writes private state only under +# the ignored pack directory. Rehearse mode writes a synthetic pack state for +# the offline soak rehearsal and never inspects QQ. + +$ErrorActionPreference = 'Stop' +Set-StrictMode -Version Latest + +if (-not $Repo) { $Repo = (Resolve-Path (Join-Path $PSScriptRoot '../..')).Path } +$Repo = (Resolve-Path -LiteralPath $Repo).Path +if (-not $Pack) { $Pack = Join-Path $Repo 'local-evidence/feat007-n5-20261125-unbound' } +New-Item -ItemType Directory -Force -Path $Pack | Out-Null +$Pack = (Resolve-Path -LiteralPath $Pack).Path + +$exe = Join-Path $Repo 'target-harness/x86_64-pc-windows-msvc/release/caligo.exe' +$bridge = Join-Path $Repo 'target-harness/x86_64-pc-windows-msvc/release/caligo_bridge.dll' +$manifest = Join-Path $Repo 'local-evidence/n4-r2-r3-closure-20261107/manifest-qq-9.9.36-53644-pilot.json' +$audit = Join-Path $Repo 'local-evidence/n4-r2-callback-20261108/audit-g3-target-modules.ps1' +$prior = Join-Path $Repo 'local-evidence/snowcat-dual-login-fresh-20261114/state.private.json' + +function Save-Json([string]$Path, $Value) { + [IO.File]::WriteAllText($Path, ($Value | ConvertTo-Json -Depth 12), [Text.UTF8Encoding]::new($false)) +} +function New-Hex([int]$Bytes) { + $builder = New-Object Text.StringBuilder + for ($i = 0; $i -lt $Bytes; $i++) { [void]$builder.Append(('{0:x2}' -f (Get-Random -Maximum 256))) } + return $builder.ToString() +} +function Assert-FreePort([int]$Port) { + $listener = [Net.Sockets.TcpListener]::new([Net.IPAddress]::Loopback, $Port) + try { $listener.Start() } catch { throw "Port $Port is already in use" } finally { $listener.Stop() } +} +function Get-FreePort { + $listener = [Net.Sockets.TcpListener]::new([Net.IPAddress]::Loopback, 0) + $listener.Start() + try { return ([Net.IPEndPoint]$listener.LocalEndpoint).Port } finally { $listener.Stop() } +} + +if (-not (Test-Path -LiteralPath $exe) -or -not (Test-Path -LiteralPath $bridge)) { + throw 'Release binaries missing; run scripts/n5/verify-release.ps1 first' +} +if (-not (Test-Path -LiteralPath $manifest)) { throw 'Field manifest missing' } + +$state = [ordered]@{ + schema = 'caligo/n5-soak-state/1' + mode = if ($Rehearse) { 'rehearsal' } else { 'field' } + source_head = (& git -C $Repo rev-parse --short HEAD).Trim() + prepared_utc = [DateTime]::UtcNow.ToString('o') + build = [ordered]@{ + caligo_exe = $exe + caligo_sha256 = (Get-FileHash -LiteralPath $exe -Algorithm SHA256).Hash + bridge = $bridge + bridge_sha256 = (Get-FileHash -LiteralPath $bridge -Algorithm SHA256).Hash + } + manifest = $manifest + manifest_sha256 = (Get-FileHash -LiteralPath $manifest -Algorithm SHA256).Hash + account = $Account + pid = $TargetPid + created = $ExpectedCreated + filetime = 0 + env = '0x0' + modules = @() + pipe = 'caligo-n5-' + (New-Hex 6) + journal = Join-Path $Pack 'field/journal.jsonl' + token_file = Join-Path $Pack 'onebot.token' + ports = [ordered]@{ http = 0; ws = 0 } + duration_hours = $DurationHours + sample_seconds = $SampleSeconds + restart_at_minutes = @($RestartAtMinutes) +} + +if ($Rehearse) { + $state.pid = 0 + $state.created = '' + $state.account = 1694717255 + $state.ports.http = 0 + $state.ports.ws = 0 + $state.journal = Join-Path $Pack 'rehearsal/journal.jsonl' + New-Item -ItemType Directory -Force -Path (Split-Path $state.journal) | Out-Null +} else { + if (-not $TargetPid -or -not $ExpectedCreated) { throw '-TargetPid and -ExpectedCreated are required in field mode' } + $p = Get-Process -Id $TargetPid -ErrorAction Stop + if ($p.StartTime.ToUniversalTime().ToString('o') -ne $ExpectedCreated) { throw 'Target creation time mismatch' } + if (-not $p.Responding) { throw 'Target is not responding' } + $mods = @($p.Modules | ForEach-Object { + [pscustomobject]@{ name = $_.ModuleName; path = $_.FileName; size = $_.ModuleMemorySize } + }) + if (@($mods | Where-Object name -like '*caligo*bridge*').Count -gt 0) { throw 'Bridge already mapped; use a fresh QQ generation' } + if (@($mods | Where-Object name -eq 'wrapper.node').Count -ne 1 -or @($mods | Where-Object name -eq 'major.node').Count -ne 1) { + throw 'Target is not the QQ main root (major.node/wrapper.node not both loaded)' + } + if ($p.MainWindowHandle -eq 0) { Write-Warning 'Target has no visible main window; continuing because module/hash/admission checks pass' } + + & $exe cli verify-manifest $manifest *> (Join-Path $Pack 'manifest.private.log') + if ($LASTEXITCODE -ne 0) { throw 'Manifest rejected' } + $pm = [IO.File]::ReadAllText($manifest, [Text.Encoding]::UTF8) | ConvertFrom-Json + $verified = @() + foreach ($name in @('QQNT.dll', 'major.node', 'wrapper.node')) { + $loaded = @($mods | Where-Object name -eq $name) + $pin = @($pm.modules | Where-Object { [IO.Path]::GetFileName([string]$_.path) -eq $name }) + if ($loaded.Count -ne 1 -or $pin.Count -ne 1) { throw "Loaded module count mismatch $name" } + $hash = (Get-FileHash -LiteralPath $loaded[0].path -Algorithm SHA256).Hash + if ($hash -ne $pin[0].sha256) { throw "Loaded module mismatch $name" } + $verified += [pscustomobject]@{ name = $name; path = $loaded[0].path; sha256 = $pin[0].sha256 } + } + + $auditPath = Join-Path $Pack 'audit.private.json' + $auditor = Start-Process 'C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe' -WindowStyle Hidden -PassThru -Wait ` + -ArgumentList @('-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', $audit, + '-ProcessId', $TargetPid, '-ManifestPath', $manifest, '-ReportPath', $auditPath) ` + -RedirectStandardOutput (Join-Path $Pack 'audit.stdout.private.log') ` + -RedirectStandardError (Join-Path $Pack 'audit.stderr.private.log') + if ($auditor.ExitCode -ne 0) { throw "Backend audit exited $($auditor.ExitCode)" } + $auditResult = [IO.File]::ReadAllText($auditPath, [Text.Encoding]::UTF8) | ConvertFrom-Json + if ($auditResult.decision -ne 'PASS_KNOWN_BACKEND_AND_TEMP_MODULE_GATE') { + throw "Backend audit rejected: $($auditResult.decision)" + } + + $scanPath = Join-Path $Pack 'envscan.private.json' + & $exe cli envscan --pid $TargetPid --vtable 0xA804990 --context 0 --out $scanPath *> (Join-Path $Pack 'envscan.private.log') + if ($LASTEXITCODE -ne 0) { throw 'Read-only Environment scan failed' } + $scan = [IO.File]::ReadAllText($scanPath, [Text.Encoding]::UTF8) | ConvertFrom-Json + if ($scan.pid -ne $TargetPid -or @($scan.hits).Count -ne 1 -or $scan.regions_read_failed -ne 0) { + throw 'Environment scan was not unique and clean' + } + + $targets = ([IO.File]::ReadAllText($prior, [Text.Encoding]::UTF8) | ConvertFrom-Json).targets + if (-not $Account) { $Account = [UInt64]($targets | Where-Object alias -eq 'B').account } + $registered = @($targets | Where-Object { [UInt64]$_.account -eq $Account }) + if ($registered.Count -ne 1) { throw 'Account is not one of the registered test targets' } + + $state.pid = $TargetPid + $state.created = $ExpectedCreated + $state.filetime = $p.StartTime.ToFileTimeUtc() + $state.account = $Account + $state.env = ('0x{0:x}' -f [UInt64]$scan.hits[0].candidate_env) + $state.modules = $verified + $state.ports.http = Get-FreePort + $state.ports.ws = Get-FreePort + Assert-FreePort $state.ports.http + Assert-FreePort $state.ports.ws + Write-Output ('PASS designated main root pid={0}; exact manifest/modules; PE/backend audit; unique read-only Environment' -f $TargetPid) +} + +New-Item -ItemType Directory -Force -Path (Split-Path $state.journal) | Out-Null +if (-not $Rehearse) { + New-Hex 32 | Set-Content -LiteralPath $state.token_file -NoNewline -Encoding Ascii +} +Save-Json (Join-Path $Pack 'state.private.json') $state + +$authorization = [ordered]@{ + authorized = $false + pid = $state.pid + created_utc = $state.created + scope = 'One admitted attach; zero message sends; resident OneBot queries for the soak duration; up to the listed core crash/restart injections; bridge retained at the end (no hot unload).' + allow_core_restart = $true + sends = 0 + note = 'Operator sets authorized=true only after reviewing this pack and the designated QQ main root. No message is sent by the harness.' +} +Save-Json (Join-Path $Pack 'authorization.template.json') $authorization + +$preparation = [ordered]@{ + schema = 'caligo/n5-preparation/1' + scope = 'issue #16 criterion 2/4: one fresh QQ generation, one admitted attach, 24h single-account resident probes, controlled core crash/restart injections, bounded bridge/daemon process metrics, honest stop boundary without hot unload.' + mode = $state.mode + source_head = $state.source_head + build = $state.build + manifest_sha256 = $state.manifest_sha256 + ports = $state.ports + duration_hours = $state.duration_hours + sample_seconds = $state.sample_seconds + restart_at_minutes = $state.restart_at_minutes + expected = [ordered]@{ + resident = 'one daemon and one admitted bridge; OneBot get_version_info/get_status/get_login_info continue to answer without per-message CLI interaction' + restart = 'each injected core crash is followed by the same journal/pipe/token, bridge reconnects, and login/query becomes available again' + journal = 'journal prefix is preserved; no request is replayed or duplicated; no message is sent' + stop = 'control Stop ends the daemon; the default bridge has no owner-stop and stays mapped; QQ remains responsive' + } + refusals = @( + 'preflight state missing or bound to another PID/created time/build hash', + 'module, manifest, PE/backend or unique Environment check failed -> stop without attach', + 'authorization.private.json missing/mismatched/not authorized -> runner refuses before starting services', + 'any unresolved restart is never retried blindly; the bridge is not hot-unloaded', + 'never reattach to the consumed QQ generation' + ) +} +Save-Json (Join-Path $Pack 'preparation-unbound.json') $preparation + +$files = @(Get-ChildItem -LiteralPath $Pack -File | Where-Object { $_.Name -notlike '*.private.*' -and $_.Name -notin @('onebot.token') } | Sort-Object Name) +$manifestEntries = @(foreach ($file in $files) { + [ordered]@{ name = $file.Name; sha256 = (Get-FileHash -LiteralPath $file.FullName -Algorithm SHA256).Hash.ToLowerInvariant() } +}) +$seal = [ordered]@{ + schema = 'caligo/n5-pack/1' + prepared_utc = [DateTime]::UtcNow.ToString('o') + source_head = $state.source_head + files = $manifestEntries +} +Save-Json (Join-Path $Pack 'pack-manifest.json') $seal +$aggregate = [System.BitConverter]::ToString(([Security.Cryptography.SHA256]::Create().ComputeHash( + [Text.Encoding]::UTF8.GetBytes(($manifestEntries | ConvertTo-Json -Depth 6 -Compress))))).Replace('-', '').ToLowerInvariant() +Write-Output ('pack={0} aggregate={1}' -f $Pack, $aggregate) +Write-Output ('ports http={0} ws={1}; journal={2}' -f $state.ports.http, $state.ports.ws, $state.journal) diff --git a/scripts/n5/verify-release.ps1 b/scripts/n5/verify-release.ps1 new file mode 100644 index 00000000..38667b33 --- /dev/null +++ b/scripts/n5/verify-release.ps1 @@ -0,0 +1,416 @@ +[CmdletBinding()] +param( + [string]$Repo = '', + [string]$TargetDir = 'target-harness', + [string]$OutDir = '', + [string]$Manifest = '', + [switch]$SkipBuild, + [switch]$AllowDirty +) + +# N5 startup-package and unknown-version gate. +# +# This script is offline: it builds the default release entry, packages it with +# the same script CI uses, verifies the package hashes/build-info, starts the +# packaged daemon twice on the same journal/token and checks honest OneBot +# responses, then proves a tampered module manifest is rejected before any +# bridge load or report write. It does not touch a running QQ process. + +$ErrorActionPreference = 'Stop' +Set-StrictMode -Version Latest +if (Test-Path variable:PSNativeCommandUseErrorActionPreference) { + $PSNativeCommandUseErrorActionPreference = $false +} + +if (-not $Repo) { $Repo = (Resolve-Path (Join-Path $PSScriptRoot '../..')).Path } +$Repo = (Resolve-Path -LiteralPath $Repo).Path +$target = 'x86_64-pc-windows-msvc' +$version = $null +$commit = $null +$started = [DateTime]::UtcNow +if (-not $OutDir) { $OutDir = Join-Path $Repo "$TargetDir/n5-offline-gate" } +New-Item -ItemType Directory -Force -Path $OutDir | Out-Null +$OutDir = (Resolve-Path -LiteralPath $OutDir).Path + +$steps = New-Object System.Collections.ArrayList +$summary = [ordered]@{ + schema = 'caligo/n5-offline-gate/1' + started_utc = $started.ToString('o') + repo = $Repo + target = $target + overall = 'running' + steps = $steps + failure = $null +} +$exitCode = 0 + +function Add-Step { + param([string]$Name, [string]$Status, $Detail) + [void]$steps.Add([ordered]@{ + name = $Name + status = $Status + detail = $Detail + at_utc = [DateTime]::UtcNow.ToString('o') + }) + Write-Host ("[{0}] {1}" -f $Status.ToUpperInvariant(), $Name) +} + +function Save-Summary { + $summary.finished_utc = [DateTime]::UtcNow.ToString('o') + $path = Join-Path $OutDir 'offline-gate.json' + [IO.File]::WriteAllText($path, ($summary | ConvertTo-Json -Depth 12), [Text.UTF8Encoding]::new($false)) + Write-Host "summary=$path" +} + +function Get-FreePort { + $listener = [Net.Sockets.TcpListener]::new([Net.IPAddress]::Loopback, 0) + $listener.Start() + try { return ([Net.IPEndPoint]$listener.LocalEndpoint).Port } finally { $listener.Stop() } +} + +function New-Hex { + param([int]$Bytes) + $builder = New-Object Text.StringBuilder + for ($i = 0; $i -lt $Bytes; $i++) { [void]$builder.Append(('{0:x2}' -f (Get-Random -Maximum 256))) } + return $builder.ToString() +} + +function Read-FirstJsonLine { + param([string]$Path, [int]$TimeoutMs = 15000) + $deadline = [DateTime]::UtcNow.AddMilliseconds($TimeoutMs) + while ([DateTime]::UtcNow -lt $deadline) { + if (Test-Path -LiteralPath $Path) { + $lines = @(Get-Content -LiteralPath $Path -Encoding UTF8 -TotalCount 1 -ErrorAction SilentlyContinue) + if ($lines.Count -gt 0 -and $lines[0]) { + try { return ($lines[0] | ConvertFrom-Json) } catch { } + } + } + Start-Sleep -Milliseconds 100 + } + return $null +} + +function Invoke-ExeLogged { + param([string]$Exe, [string[]]$Arguments, [string]$Stdout, [string]$Stderr) + $proc = Start-Process -FilePath $Exe -ArgumentList $Arguments -NoNewWindow -PassThru -Wait ` + -RedirectStandardOutput $Stdout -RedirectStandardError $Stderr + return $proc.ExitCode +} + +function Invoke-OneBot { + param([int]$Port, [string]$Token, [string]$Action, $Params = @{}) + $body = [ordered]@{ action = $Action; params = $Params; echo = $Action } | ConvertTo-Json -Depth 8 -Compress + $headers = @{ Authorization = "Bearer $Token" } + return Invoke-RestMethod -Uri ("http://127.0.0.1:{0}/" -f $Port) -Method Post -Body $body ` + -ContentType 'application/json' -Headers $headers -TimeoutSec 10 +} + +function Start-GateDaemon { + param( + [string]$Exe, + [string]$ExtractDir, + [string]$PipePrefix, + [string]$Journal, + [string]$TokenFile, + [int]$HttpPort, + [int]$WsPort, + [string]$Account, + [string]$Stdout, + [string]$Stderr + ) + Remove-Item -LiteralPath $Stdout, $Stderr -Force -ErrorAction SilentlyContinue + $arguments = @( + 'daemon', + '--pipe-prefix', $PipePrefix, + '--journal', $Journal, + '--baseline', 'local-pilot-2026-11-07-qq-9.9.36-53644', + '--account', $Account, + '--core-build', 'caligo-n5-offline-gate', + '--token-file', $TokenFile, + '--onebot-http-bind', ('127.0.0.1:{0}' -f $HttpPort), + '--onebot-ws-bind', ('127.0.0.1:{0}' -f $WsPort) + ) + $proc = Start-Process -FilePath $Exe -ArgumentList $arguments -WorkingDirectory $ExtractDir ` + -PassThru -WindowStyle Hidden -RedirectStandardOutput $Stdout -RedirectStandardError $Stderr + $ready = Read-FirstJsonLine -Path $Stdout -TimeoutMs 20000 + if (-not $ready) { + if (-not $proc.HasExited) { Stop-Process -Id $proc.Id -Force -ErrorAction SilentlyContinue } + $errorText = if (Test-Path $Stderr) { [IO.File]::ReadAllText($Stderr) } else { '' } + throw "daemon did not print its ready line: $errorText" + } + if (-not $ready.onebot_http -or -not $ready.onebot_ws) { throw 'daemon ready line is missing OneBot listeners' } + return [pscustomobject]@{ process = $proc; ready = $ready } +} + +function Stop-GateDaemon { + param([string]$Exe, $Ready, $Process) + $code = Invoke-ExeLogged -Exe $Exe -Arguments @( + 'cli', 'daemon-control', '--pipe', $Ready.control_pipe, '--auth', $Ready.auth_token, 'stop' + ) -Stdout (Join-Path $OutDir 'control-stop.stdout.private.log') -Stderr (Join-Path $OutDir 'control-stop.stderr.private.log') + $exited = $false + for ($i = 0; $i -lt 200; $i++) { + if ($Process.HasExited) { $exited = $true; break } + Start-Sleep -Milliseconds 50 + } + if (-not $exited) { + Stop-Process -Id $Process.Id -Force -ErrorAction SilentlyContinue + throw 'daemon did not exit after control Stop' + } + if ($code -ne 0) { throw "daemon-control stop exited $code" } + return $code +} + +try { + Push-Location -LiteralPath $Repo + try { + $version = [regex]::Match([IO.File]::ReadAllText((Join-Path $Repo 'Cargo.toml')), '(?ms)^\[workspace\.package\]\s*\r?\nversion\s*=\s*"([^"]+)"').Groups[1].Value + $commit = (& git rev-parse HEAD).Trim() + $dirtyLines = @(& git status --porcelain | Where-Object { $_ -notmatch '^\?\?' }) + $sourceDirty = $dirtyLines.Count -gt 0 + if ($sourceDirty -and -not $AllowDirty) { + throw "tracked working tree is dirty ($($dirtyLines.Count) entries); commit or pass -AllowDirty for a rehearsal" + } + $summary.version = $version + $summary.commit = $commit + $summary.source_dirty = $sourceDirty + $summary.rustc = (& rustc --version).Trim() + Add-Step 'source-identity' 'pass' ([ordered]@{ version = $version; commit = $commit; source_dirty = $sourceDirty }) + } finally { Pop-Location } + + if (-not $Manifest) { + $localPilot = Join-Path $Repo 'local-evidence/n4-r2-r3-closure-20261107/manifest-qq-9.9.36-53644-pilot.json' + $Manifest = if (Test-Path -LiteralPath $localPilot) { $localPilot } else { Join-Path $Repo 'docs/contracts/version-adapter-manifest.json' } + } + $Manifest = (Resolve-Path -LiteralPath $Manifest).Path + $summary.manifest = [ordered]@{ + path = $Manifest + sha256 = (Get-FileHash -LiteralPath $Manifest -Algorithm SHA256).Hash + } + Add-Step 'manifest-source' 'pass' $summary.manifest + + $binaryRoot = Join-Path $Repo (Join-Path $TargetDir (Join-Path $target 'release')) + if (-not $SkipBuild) { + Add-Step 'release-build' 'running' $null + $previousTarget = $env:CARGO_BUILD_TARGET + $env:CARGO_BUILD_TARGET = $target + $buildOut = Join-Path $OutDir 'release-build.stdout.private.log' + $buildErr = Join-Path $OutDir 'release-build.stderr.private.log' + try { + $build = Start-Process -FilePath 'cargo' -ArgumentList @( + 'build', '--release', '--locked', '--offline', '--target-dir', $TargetDir, + '-p', 'caligo-cli', '--bin', 'caligo', '-p', 'caligo-bridge', '--lib' + ) -NoNewWindow -PassThru -Wait -RedirectStandardOutput $buildOut -RedirectStandardError $buildErr + if ($build.ExitCode -ne 0) { + $tail = if (Test-Path $buildErr) { Get-Content $buildErr -Tail 20 | Out-String } else { '' } + throw "cargo build exited $($build.ExitCode): $tail" + } + } finally { + if ($null -eq $previousTarget) { Remove-Item Env:CARGO_BUILD_TARGET -ErrorAction SilentlyContinue } + else { $env:CARGO_BUILD_TARGET = $previousTarget } + } + ($steps[$steps.Count - 1]).status = 'pass' + Write-Host '[PASS] release-build' + } + $exe = Join-Path $binaryRoot 'caligo.exe' + $bridge = Join-Path $binaryRoot 'caligo_bridge.dll' + if (-not (Test-Path -LiteralPath $exe) -or -not (Test-Path -LiteralPath $bridge)) { + throw "release binaries missing under $binaryRoot" + } + $summary.build = [ordered]@{ + caligo_exe = $exe + caligo_sha256 = (Get-FileHash -LiteralPath $exe -Algorithm SHA256).Hash + bridge = $bridge + bridge_sha256 = (Get-FileHash -LiteralPath $bridge -Algorithm SHA256).Hash + } + Add-Step 'release-binaries' 'pass' $summary.build + + Add-Step 'package-release' 'running' $null + $packageOut = Join-Path $OutDir 'package-release.stdout.private.log' + $packageErr = Join-Path $OutDir 'package-release.stderr.private.log' + $package = Start-Process -FilePath 'C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe' -ArgumentList @( + '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', + (Join-Path $Repo '.github/scripts/package-release.ps1') + ) -NoNewWindow -PassThru -Wait -RedirectStandardOutput $packageOut -RedirectStandardError $packageErr + if ($package.ExitCode -ne 0) { + $tail = if (Test-Path $packageErr) { Get-Content $packageErr -Tail 20 | Out-String } else { '' } + throw "package-release.ps1 exited $($package.ExitCode): $tail" + } + ($steps[$steps.Count - 1]).status = 'pass' + Write-Host '[PASS] package-release' + + $archive = Join-Path $Repo (Join-Path $TargetDir ('dist/caligo-{0}-windows-x64.zip' -f $version)) + $sidecar = "$archive.sha256" + if (-not (Test-Path -LiteralPath $archive) -or -not (Test-Path -LiteralPath $sidecar)) { + throw "release archive or sidecar missing: $archive" + } + $archiveHash = (Get-FileHash -LiteralPath $archive -Algorithm SHA256).Hash.ToLowerInvariant() + $sidecarHash = ([IO.File]::ReadAllText($sidecar)).Split(' ')[0].Trim().ToLowerInvariant() + if ($archiveHash -ne $sidecarHash) { throw 'archive SHA-256 does not match its sidecar' } + $summary.package = [ordered]@{ + archive = $archive + sha256 = $archiveHash + sidecar = $sidecar + size_bytes = (Get-Item -LiteralPath $archive).Length + } + Add-Step 'package-checksum' 'pass' $summary.package + + $extract = Join-Path $OutDir 'package' + if (Test-Path -LiteralPath $extract) { Remove-Item -LiteralPath $extract -Recurse -Force } + Expand-Archive -LiteralPath $archive -DestinationPath $extract -Force + $infoPath = Join-Path $extract 'build-info.json' + if (-not (Test-Path -LiteralPath $infoPath)) { throw 'build-info.json missing from the package' } + $info = [IO.File]::ReadAllText($infoPath) | ConvertFrom-Json + if ($info.version -ne $version) { throw "build-info version $($info.version) != $version" } + if ($info.commit -ne $commit) { throw "build-info commit $($info.commit) != $commit" } + if ($info.target -ne $target) { throw "build-info target $($info.target) != $target" } + if ($info.mode -ne 'default' -or $info.research -ne $false) { throw 'build-info is not a default/non-research build' } + if ($info.entrypoint -ne 'caligo.exe') { throw "build-info entrypoint $($info.entrypoint) != caligo.exe" } + $expectedNames = @('LICENSE', 'README.md', 'build-info.json', 'caligo.exe', 'caligo_bridge.dll') + $actualNames = @(Get-ChildItem -LiteralPath $extract -File | ForEach-Object Name | Sort-Object) + $diff = @(Compare-Object -ReferenceObject $expectedNames -DifferenceObject $actualNames) + if ($diff.Count -ne 0) { throw "package file allowlist mismatch: $($diff | ForEach-Object { $_.InputObject })" } + foreach ($entry in @($info.files)) { + $path = Join-Path $extract $entry.name + if (-not (Test-Path -LiteralPath $path)) { throw "build-info lists missing file $($entry.name)" } + $hash = (Get-FileHash -LiteralPath $path -Algorithm SHA256).Hash.ToLowerInvariant() + if ($hash -ne $entry.sha256) { throw "package file hash mismatch for $($entry.name)" } + } + $summary.package.extracted = $extract + $summary.package.build_info = $info + Add-Step 'package-integrity' 'pass' ([ordered]@{ files = $expectedNames; build_info_files = @($info.files).Count }) + + Add-Step 'package-startup' 'running' $null + $smokeRoot = Join-Path $OutDir 'smoke' + New-Item -ItemType Directory -Force -Path $smokeRoot | Out-Null + $journal = Join-Path $smokeRoot 'journal.jsonl' + Remove-Item -LiteralPath $journal -Force -ErrorAction SilentlyContinue + $tokenFile = Join-Path $smokeRoot 'auth.token' + $token = New-Hex 32 + [IO.File]::WriteAllText($tokenFile, $token, [Text.Encoding]::ASCII) + $pipePrefix = 'caligo-n5-gate-' + (New-Hex 6) + $httpPort = Get-FreePort + $wsPort = Get-FreePort + $daemon = Start-GateDaemon -Exe (Join-Path $extract 'caligo.exe') -ExtractDir $extract ` + -PipePrefix $pipePrefix -Journal $journal -TokenFile $tokenFile ` + -HttpPort $httpPort -WsPort $wsPort -Account '1694717255' ` + -Stdout (Join-Path $smokeRoot 'daemon-1.stdout.private.log') ` + -Stderr (Join-Path $smokeRoot 'daemon-1.stderr.private.log') + $versionProbe = Invoke-OneBot -Port $httpPort -Token $token -Action 'get_version_info' + if ($versionProbe.retcode -ne 0 -or -not $versionProbe.data) { throw 'packaged daemon did not answer get_version_info' } + $loginProbe = Invoke-OneBot -Port $httpPort -Token $token -Action 'get_login_info' + if ($loginProbe.retcode -eq 0) { throw 'packaged daemon invented a login without a bridge' } + Stop-GateDaemon -Exe (Join-Path $extract 'caligo.exe') -Ready $daemon.ready -Process $daemon.process | Out-Null + $journalBefore = if (Test-Path -LiteralPath $journal) { (Get-FileHash -LiteralPath $journal -Algorithm SHA256).Hash } else { '' } + $journalSizeBefore = if (Test-Path -LiteralPath $journal) { (Get-Item -LiteralPath $journal).Length } else { 0 } + + $httpPort2 = Get-FreePort + $wsPort2 = Get-FreePort + $daemon2 = Start-GateDaemon -Exe (Join-Path $extract 'caligo.exe') -ExtractDir $extract ` + -PipePrefix $pipePrefix -Journal $journal -TokenFile $tokenFile ` + -HttpPort $httpPort2 -WsPort $wsPort2 -Account '1694717255' ` + -Stdout (Join-Path $smokeRoot 'daemon-2.stdout.private.log') ` + -Stderr (Join-Path $smokeRoot 'daemon-2.stderr.private.log') + $versionProbe2 = Invoke-OneBot -Port $httpPort2 -Token $token -Action 'get_version_info' + if ($versionProbe2.retcode -ne 0 -or -not $versionProbe2.data) { throw 'restarted packaged daemon did not answer get_version_info' } + Stop-GateDaemon -Exe (Join-Path $extract 'caligo.exe') -Ready $daemon2.ready -Process $daemon2.process | Out-Null + $journalAfter = if (Test-Path -LiteralPath $journal) { (Get-FileHash -LiteralPath $journal -Algorithm SHA256).Hash } else { '' } + $journalSizeAfter = if (Test-Path -LiteralPath $journal) { (Get-Item -LiteralPath $journal).Length } else { 0 } + if ($journalSizeAfter -lt $journalSizeBefore) { throw 'journal shrank across packaged restart' } + if ($journalSizeBefore -gt 0) { + $beforeBytes = [IO.File]::ReadAllBytes($journal) + $afterBytes = [IO.File]::ReadAllBytes($journal) + for ($i = 0; $i -lt $beforeBytes.Length; $i++) { + if ($beforeBytes[$i] -ne $afterBytes[$i]) { throw 'journal prefix changed across packaged restart' } + } + } + ($steps[$steps.Count - 1]).status = 'pass' + $summary.startup = [ordered]@{ + package_exe = (Join-Path $extract 'caligo.exe') + first_http = $httpPort + second_http = $httpPort2 + version_retcode = $versionProbe.retcode + login_without_bridge_retcode = $loginProbe.retcode + journal_before = $journalBefore + journal_after = $journalAfter + journal_size_before = $journalSizeBefore + journal_size_after = $journalSizeAfter + } + Write-Host ('[PASS] package-startup (version={0}, login_without_bridge={1})' -f $versionProbe.retcode, $loginProbe.retcode) + + Add-Step 'unknown-version-rejection' 'running' $null + $manifestJson = [IO.File]::ReadAllText($Manifest, [Text.Encoding]::UTF8) | ConvertFrom-Json + $module = @($manifestJson.modules | Where-Object hash_checked)[0] + if (-not $module) { throw 'manifest has no hash-checked module to tamper' } + $originalHash = [string]$module.sha256 + $tamperedHash = if ($originalHash.Substring(0, 1) -eq 'A') { 'B' + $originalHash.Substring(1) } else { 'A' + $originalHash.Substring(1) } + $module.sha256 = $tamperedHash + $tamperedManifest = Join-Path $OutDir 'manifest-tampered.private.json' + [IO.File]::WriteAllText($tamperedManifest, ($manifestJson | ConvertTo-Json -Depth 12), [Text.UTF8Encoding]::new($false)) + + $packageExe = Join-Path $extract 'caligo.exe' + $verifyOut = Join-Path $OutDir 'verify-tampered.stdout.private.log' + $verifyErr = Join-Path $OutDir 'verify-tampered.stderr.private.log' + $verifyCode = Invoke-ExeLogged -Exe $packageExe -Arguments @('cli', 'verify-manifest', $tamperedManifest) -Stdout $verifyOut -Stderr $verifyErr + if ($verifyCode -ne 2) { throw "verify-manifest on a tampered manifest exited $verifyCode (expected 2)" } + if (-not (Select-String -LiteralPath $verifyOut -Pattern 'RESULT: REJECT' -Quiet)) { throw 'tampered manifest did not print RESULT: REJECT' } + + $report = Join-Path $OutDir 'entry-tampered.private.jsonl' + Remove-Item -LiteralPath $report -Force -ErrorAction SilentlyContinue + $daemonAuth = Join-Path $OutDir 'gate-auth.private.token' + [IO.File]::WriteAllText($daemonAuth, (New-Hex 32), [Text.Encoding]::ASCII) + $entryBridge = Join-Path $extract 'caligo_bridge.dll' + $entryOut = Join-Path $OutDir 'entry-tampered.stdout.private.log' + $entryErr = Join-Path $OutDir 'entry-tampered.stderr.private.log' + $entryCode = Invoke-ExeLogged -Exe $packageExe -Arguments @( + 'cli', 'qq-entry', '--pid', '999999', '--created-filetime', '1', + '--bridge', $entryBridge, '--manifest', $tamperedManifest, '--report', $report, '--wait-s', '1', + '--confirm-designated-test-instance', '--daemon-pipe', 'caligo-n5-gate-offline', + '--daemon-auth-file', $daemonAuth, '--daemon-generation', '1', '--daemon-account', '1694717255' + ) -Stdout $entryOut -Stderr $entryErr + if ($entryCode -ne 2) { throw "qq-entry on a tampered manifest exited $entryCode (expected 2)" } + if (-not (Select-String -LiteralPath $entryErr -Pattern '\[gate 1\] REJECT' -Quiet)) { throw 'qq-entry did not reject at gate 1' } + if (Test-Path -LiteralPath $report) { throw 'qq-entry wrote a report despite rejecting the manifest' } + + $injectReport = Join-Path $OutDir 'inject-tampered.private.json' + Remove-Item -LiteralPath $injectReport -Force -ErrorAction SilentlyContinue + $injectOut = Join-Path $OutDir 'inject-tampered.stdout.private.log' + $injectErr = Join-Path $OutDir 'inject-tampered.stderr.private.log' + $injectCode = Invoke-ExeLogged -Exe $packageExe -Arguments @( + 'cli', 'inject', '--pid', '999999', '--bridge', $entryBridge, + '--manifest', $tamperedManifest, '--report', $injectReport, '--confirm-designated-test-instance' + ) -Stdout $injectOut -Stderr $injectErr + # The default release disables the legacy inject/exec route before argument + # or manifest processing (K4-D0). Exit 3 with no report is the expected + # zero-native-call result; the manifest gate itself is proven by qq-entry. + if ($injectCode -ne 3) { throw "inject on the default release exited $injectCode (expected 3: legacy route disabled)" } + if (-not (Select-String -LiteralPath $injectErr -Pattern 'K4-D0' -Quiet)) { + throw 'inject did not report the default-build legacy-route refusal' + } + if (Test-Path -LiteralPath $injectReport) { throw 'inject wrote a report despite the default-build refusal' } + ($steps[$steps.Count - 1]).status = 'pass' + $summary.unknown_version = [ordered]@{ + manifest = $tamperedManifest + tampered_module = $module.path + original_sha256 = $originalHash + tampered_sha256 = $tamperedHash + verify_manifest_exit = $verifyCode + qq_entry_exit = $entryCode + qq_entry_report_absent = -not (Test-Path -LiteralPath $report) + inject_exit = $injectCode + inject_report_absent = -not (Test-Path -LiteralPath $injectReport) + } + Write-Host '[PASS] unknown-version-rejection (zero bridge load/report write)' + + $summary.overall = 'pass' + Add-Step 'overall' 'pass' $null +} catch { + $summary.overall = 'fail' + $summary.failure = $_.Exception.Message + Add-Step 'overall' 'fail' $summary.failure + Write-Error -Message $_.Exception.Message -ErrorAction Continue + $exitCode = 1 +} finally { + Save-Summary +} + +exit $exitCode diff --git a/session-handoff.md b/session-handoff.md index 66a3e2f1..bcc7ef40 100644 --- a/session-handoff.md +++ b/session-handoff.md @@ -1,5 +1,7 @@ # Session handoff +2026-11-25 feat-007 N5 离线启动包/未知版本门 + 2h 现场观察通过(issue #16):`scripts/n5/verify-release.ps1` 的 default release 打包、sidecar/build-info/包内哈希、两次 packaged daemon 启动与诚实无 bridge 登录失败、篡改 manifest 的 gate 1 拒绝均 pass;固定 `caligo.exe` `820781DB…57CE5`、bridge `1EBF6E35…44FC`。现场新 QQ `26620`(创建 `2026-11-25T12:03:11.4979693Z`,账号 B)一次 attach,零发送;117 samples、351/351 查询成功、3/3 次 core 崩溃重启约 1.5s 恢复、495 条入站事件无重复/缺口、控制停止后 bridge 保留。2h 样本不证明 24h/QQ 重启新代次/真实 TCP 背压;`CoreStopped` 后同代次不能重新 attach。已在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight,并于 `14:56:45Z` 启动 24h soak(+2h/+8h/+16h 各一次 core 崩溃重启,预计 `2026-11-26T14:56:45Z` 结束);已创建 `2026-11-26T23:10+08:00` 的定时核验任务 `schedule-c05cd080-9504-495f-9e9c-9d20bdf851d4`,通过才关闭 issue #16。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/` 与 `feat007-n5-24h-20261125-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) + 2026-11-24 feat-006 现场 attempt 2 通过(issue #15):新 QQ `31584` 一次 attach,NoneBot2 经反向 WS 收到私聊 36 / 群 41,各回复一次(37/42);应用与 Caligo `get_msg` 均成功,账本与发送方一致;同一消息有签名 HTTP POST 与正向 WS 证据。慢阶段 90 在慢 POST/超时下仍到达应用(积压后约 38 秒),daemon 记录 23 failed / 66 delivered / 0 dropped;该阶段自动回复请求 `onebot-85939363ae79fe15-4` 为 `DeliveryUnknown`(账本另存自发消息 106),未重发。控制停止 daemon;默认 bridge 无 research owner-stop(0xe0),bridge 保留、QQ 响应。runner 的 `app_get_msg` 误报已由 `verify-evidence.py` 离线更正,9/9 criteria true。操作者已确认 A 收到 37、42、106;issue #15 按证据关闭;feat-006 保持 in-progress(依赖 feat-005 未 done),慢 POST 积压延迟 WS 投递列为后续风险。证据见 [acceptance §6.2](docs/acceptance/2026-11-24-feat-006-text-mvp.md#62-现场-attempt-2通过单构建)。 2026-11-24 PR #20(`codex/feat-006-text-mvp` → `main`):issue #15 阻塞点判定、传输协议/慢连接回归与可观测日志、现场包与 attempt 记录已提交推送;分支含 `3d2ef1b`/`cfc9168`/`109140e`/`6983f77`/`a7b62d6` 及现场记录提交。GitNexus 刷新索引后 detect 8 files / 34 symbols / 14 flows / high、`impact serve_ws_socket` CRITICAL 已核对(改动为日志/测试路径)。全仓 default 506 / research 566,0 failed。 From d6da162e533787ef83a1949b7e4bb1f21bb2e39c Mon Sep 17 00:00:00 2001 From: Vegetable <3089665724@qq.com> Date: Wed, 25 Nov 2026 22:59:11 +0800 Subject: [PATCH 02/13] docs(feat-007): bind N5 offline gate to clean commit --- docs/acceptance/2026-11-25-feat-007-n5-release.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/acceptance/2026-11-25-feat-007-n5-release.md b/docs/acceptance/2026-11-25-feat-007-n5-release.md index 09149a17..e423ee58 100644 --- a/docs/acceptance/2026-11-25-feat-007-n5-release.md +++ b/docs/acceptance/2026-11-25-feat-007-n5-release.md @@ -28,12 +28,12 @@ 两次(同一 journal/token,不同 HTTP 端口)→ 探测 `get_version_info`/`get_login_info` → 控制停止 → 构造篡改 manifest → `verify-manifest`、`qq-entry`、`inject` 拒绝路径。 -本轮结果(`target-harness/n5-offline-gate/offline-gate.json`,overall `pass`): +本轮结果(`target-harness/n5-offline-gate/offline-gate.json`,overall `pass`,`source_dirty=false`): | 项目 | 结果 | |---|---| -| 构建 | `caligo.exe` SHA-256 `820781DB…57CE5`,`caligo_bridge.dll` SHA-256 `1EBF6E35…44FC` | -| 启动包 | `caligo-0.3.0-windows-x64.zip`,sidecar SHA-256 与包哈希一致;`build-info.json` 的 commit/version/target/mode/research/entrypoint 均匹配,4 个包内文件哈希逐项匹配 | +| 构建 | commit `8a8eabc`;`caligo.exe` SHA-256 `820781DB…57CE5`,`caligo_bridge.dll` SHA-256 `1EBF6E35…44FC` | +| 启动包 | `caligo-0.3.0-windows-x64.zip`,sidecar SHA-256 `10fc66EE…BB6B` 与包哈希一致;`build-info.json` 的 commit/version/target/mode/research/entrypoint 均匹配,4 个包内文件哈希逐项匹配 | | 包内启动 | `get_version_info` retcode 0;无 bridge 时 `get_login_info` retcode 1502(诚实失败,不伪造登录);两次启动后 journal SHA-256 不变(空账本) | | 未知版本 | 篡改 `QQ.exe` 哈希:`verify-manifest` exit 2;`qq-entry` exit 2 且 `[gate 1] REJECT`、report 未产生;`inject` exit 3(K4-D0 默认构建禁用)、report 未产生 | | 停止 | packaged daemon 两次均由 `daemon-control ... stop` 正常退出,journal 保留 | From 6f20b3f4cf6c4b7d9231b7d06a6beb6ba5768784 Mon Sep 17 00:00:00 2001 From: Vegetable <3089665724@qq.com> Date: Thu, 26 Nov 2026 07:02:33 +0800 Subject: [PATCH 03/13] fix(n5): separate login availability from resident recovery --- .../2026-11-25-feat-007-n5-release.md | 29 +++++-- feature_list.json | 2 +- progress.md | 2 +- scripts/n5/n5_resume.py | 9 ++- scripts/n5/n5_soak.py | 78 +++++++++++++++---- session-handoff.md | 2 +- 6 files changed, 97 insertions(+), 25 deletions(-) diff --git a/docs/acceptance/2026-11-25-feat-007-n5-release.md b/docs/acceptance/2026-11-25-feat-007-n5-release.md index e423ee58..335bd7c2 100644 --- a/docs/acceptance/2026-11-25-feat-007-n5-release.md +++ b/docs/acceptance/2026-11-25-feat-007-n5-release.md @@ -13,7 +13,7 @@ | 正常入口无需每消息交互 | feat-006 现场:daemon + 一次 attach 后真实应用经 HTTP/WS 收发;本轮 2h 现场:同一 daemon/attach 下 117 个采样、351/351 次只读查询成功,495 条真实入站事件入账,无每条消息 CLI 交互 | 24h 连续运行 | | core/QQ 重启、断链/慢客户端矩阵 | 离线 `core_restart_query_lab` 4/4、`recovery_contract` 13/13、`onebot_transport` 10/10;本轮 2h 现场 3/3 次 core 崩溃重启与 bridge 重连(各约 1.5s) | QQ 退出/重启后新代次重绑;真实 TCP 背压 | | 未知版本零 native 调用,停止边界如实 | 本轮离线门:篡改 manifest 后 `verify-manifest`/`qq-entry` 在 gate 1 拒绝,report 未产生;`inject` 在默认构建被 K4-D0 拒绝;现场控制停止后默认 bridge 保留 | 失败停止的现场负例仍未新增(沿用 feat-005/006 证据) | -| 24h 单账号验收及启动包证据齐全 | 本轮启动包:release zip、`build-info.json`、sidecar SHA-256、包内逐文件哈希、解压后 daemon 两次启动/停止与诚实无 bridge 登录失败 | 24h 单账号运行与最终证据封包 | +| 24h 单账号验收及启动包证据齐全 | 本轮启动包:release zip、`build-info.json`、sidecar SHA-256、包内逐文件哈希、解压后 daemon 两次启动/停止与诚实无 bridge 登录失败 | 24h 单账号运行:attempt 1 在 8h 处 incomplete(§4.1),判据已修正,需新 QQ 代次重跑 | ## 2. 启动包与离线门 @@ -77,13 +77,30 @@ manifest 门的零 native 调用由 `verify-manifest` 与 `qq-entry` 的 gate 1 该样本证明的是“同一 daemon/一次 attach 下 2h 常驻查询与 3 次 core 崩溃恢复”;不证明 24h、 QQ 退出/重启后的新代次重绑,也不证明真实 TCP 背压。 +### 4.1 24h attempt 1(2026-11-25T14:56:45Z–23:00:15Z,incomplete) + +在另一个新 QQ 主根上启动 24h soak(零发送、60s 探测、+2h/+8h/+16h 重启): + +| 项目 | 结果 | +|---|---| +| 运行 | 479 个采样、约 8h 后 harness 主动终止;version/status 探测 958/958 成功(`retcode=0`),但 `get_login_info` 从 `15:19:49Z` 起持续返回 1502,共 456 次 | +| 入站链 | journal 从 0 增至 4,409,381 bytes;第一次重启后 journal 继续增长,说明 bridge/core 仍在接收事件 | +| 重启 | 第 1 次(`16:56:46Z`)1.5s 恢复且登录查询短暂成功;第 2 次(`22:56:46Z`)daemon 启动、journal 继续增长,但 `get_login_info` 在 188s 内超时,harness 将其判为 fatal 并停止 | +| 停止 | control Stop exit 0,daemon 退出(进程码 1),默认 bridge 保留、QQ 响应;未重试、未重新 attach | +| 结论 | **24h 门未通过**。不能把“登录查询 1502”单独解释为常驻链失败:version/status 与 journal 增长显示事件链仍工作;但 24h 样本没有闭合 | + +harness 的两个判据被证明不合适:`get_login_info` 在 QQ 锁屏/会话不可用时诚实返回 1502, +不应计入 version/status 探测失败;core 重启恢复也不应以登录查询为唯一信号。`n5_soak.py` +已改为:version/status 作为恢复与 `probes_answered` 信号,登录查询单独计数并保留 1502; +attach 时仍要求一次登录成功。该修复通过离线 rehearsal(18s,含一次 core 重启)。 + ## 5. 剩余门与边界 -- **24h**:本轮 2h 观察只覆盖短时恢复;`CoreStopped` 后默认 bridge 的 daemon worker 已退出, - 同一 QQ 代次不能重新 attach。2026-11-25T14:56:45Z 已在新的新鲜 QQ 主根上启动 24h soak - (零发送、60s 只读探测、+2h/+8h/+16h 各一次 core 崩溃重启),预计 2026-11-26T14:56:45Z 结束; - 到点由本机定时任务读取 `soak-summary.json` 与 journal 分析,通过后才更新最终结论并关闭 - issue #16。本节在 24h 结果出来前不把该门标为通过。 +- **24h**:2h 观察只覆盖短时恢复;`CoreStopped` 后默认 bridge 的 daemon worker 已退出, + 同一 QQ 代次不能重新 attach。24h attempt 1 在 8h 处 incomplete(§4.1):version/status + 与 journal 链持续,但 `get_login_info` 因 QQ 锁屏/会话不可用长期返回 1502,harness 误把它 + 当作探测失败/重启恢复信号。判据已修正,需要在新的新鲜 QQ 代次上重跑完整 24h;重跑通过前 + 不把该门标为通过,也不关闭 issue #16。 - **QQ 重启**:需要操作者退出并重启 QQ,随后对新 PID/创建时间重新 preflight/attach; 旧代次的请求、映射和回调不得混入新实例。 - **启动包**:本轮为 default 构建;research 构建、真实 QQ 字段与发布 tag 流程是独立验收。 diff --git a/feature_list.json b/feature_list.json index ed746a34..36f3fa6e 100644 --- a/feature_list.json +++ b/feature_list.json @@ -110,7 +110,7 @@ "plan_steps": ["N5"], "dependencies": ["feat-006"], "status": "in-progress", - "evidence": "2026-11-25 离线启动包/未知版本门通过(scripts/n5/verify-release.ps1):default release 构建与 CI 同源打包,zip sidecar、build-info commit/version/target/mode 和包内逐文件 SHA-256 均匹配;解压后 packaged daemon 两次启动均回答 get_version_info、无 bridge 时 get_login_info 诚实返回 1502、控制停止后 journal 保留;篡改 QQ.exe 哈希后 verify-manifest 与 qq-entry 均在 gate 1 拒绝且不产生 report,默认构建的 inject 先被 K4-D0 拒绝。现场 2h 观察通过(零发送、60s 只读探测、30/60/90 分钟 core 崩溃重启):新 QQ 主根一次 attach,117 个采样、351/351 次查询成功、495 条真实入站事件无重复/缺口(event_seq 1–495),3/3 次 core 崩溃重启各约 1.5s 恢复且 journal 完整帧前缀保留,控制停止后默认 bridge 保留、QQ 响应。CoreStopped 后同一代次不能重新 attach,因此 2026-11-25T14:56:45Z 在新的新鲜 QQ 主根上启动 24h soak(+2h/+8h/+16h 各一次 core 崩溃重启,预计 2026-11-26T14:56:45Z 结束);24h 结果出来前不提升状态。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。", + "evidence": "2026-11-25 离线启动包/未知版本门通过(scripts/n5/verify-release.ps1):default release 构建与 CI 同源打包,zip sidecar、build-info commit/version/target/mode 和包内逐文件 SHA-256 均匹配;解压后 packaged daemon 两次启动均回答 get_version_info、无 bridge 时 get_login_info 诚实返回 1502、控制停止后 journal 保留;篡改 QQ.exe 哈希后 verify-manifest 与 qq-entry 均在 gate 1 拒绝且不产生 report,默认构建的 inject 先被 K4-D0 拒绝。现场 2h 观察通过(零发送、60s 只读探测、30/60/90 分钟 core 崩溃重启):新 QQ 主根一次 attach,117 个采样、351/351 次查询成功、495 条真实入站事件无重复/缺口(event_seq 1–495),3/3 次 core 崩溃重启各约 1.5s 恢复且 journal 完整帧前缀保留,控制停止后默认 bridge 保留、QQ 响应。CoreStopped 后同一代次不能重新 attach,因此在新主根上启动 24h soak;attempt 1 在约 8h 处 incomplete:version/status 探测 958/958 成功、journal 持续增长,但 get_login_info 从 15:19Z 起长期返回 1502(456 次),第 2 次 core 重启后 harness 因登录查询超时判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实结果,不是常驻链失败;harness 已改为 version/status 作为探测与重启恢复信号、登录查询单独计数(离线 rehearsal 通过),24h 仍需新 QQ 代次重跑。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。", "evidence_paths": ["docs/acceptance/2026-11-25-feat-007-n5-release.md", "scripts/n5/verify-release.ps1", "scripts/n5/preflight.ps1", "scripts/n5/attach.ps1", "scripts/n5/n5_soak.py", "docs/plans/2026-10-09-gitnexus-plan-caligo-snowluma-capability-parity.md"], "done_criteria": ["正常入口无需每消息交互", "core/QQ 重启、断链/慢客户端矩阵通过", "未知版本零 native 调用,停止边界如实", "24h 单账号验收及启动包证据齐全"] }, diff --git a/progress.md b/progress.md index aed9b916..38240e92 100644 --- a/progress.md +++ b/progress.md @@ -2,7 +2,7 @@ ## Current State -2026-11-25 feat-007 N5 启动包/未知版本门与 2h 现场观察(issue #16):新增 `scripts/n5/verify-release.ps1`,按 CI 同源脚本构建并打包 default release,校验 zip sidecar、`build-info.json` 的 commit/version/target/mode/entrypoint 与包内逐文件 SHA-256;解压后的 packaged daemon 两次启动均回答 `get_version_info`(retcode 0),无 bridge 时 `get_login_info` 诚实返回 1502,控制停止后 journal 保留;篡改 `QQ.exe` 哈希后 `verify-manifest` 与 `qq-entry` 均在 gate 1 拒绝且不产生 report,默认构建 `inject` 先被 K4-D0 拒绝。固定构建 `caligo.exe` SHA-256 `820781DB…57CE5`、`caligo_bridge.dll` `1EBF6E35…44FC`。现场 2h(本轮零发送):新 QQ 主根 `26620`(创建 `2026-11-25T12:03:11.4979693Z`,登记账号 B)通过固定 manifest/模块、PE/backend 审计与唯一 Environment 后一次 attach;117 个采样、`version`/`status`/`login` 351/351 成功、0 探测失败;30/60/90 分钟 3/3 次 kill core 并以同 journal/pipe/token 重启,恢复 1.56/1.53/1.55s、journal 完整帧前缀保留、bridge 未重新 attach;期间 495 条真实入站事件,`event_seq` 1–495 无缺口、495 个唯一 native ID、0 重复,generation 始终 1;daemon working set 7.7→14.6 MiB、handles 102→102,控制停止 daemon 后默认 bridge 保留、QQ 响应。2h 样本不证明 24h、QQ 重启后新代次重绑或真实 TCP 背压;`CoreStopped` 后同一代次不能重新 attach,24h 需新新鲜 QQ。随后在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并于 `14:56:45Z` 启动 24h soak(零发送、60s 只读探测、+2h/+8h/+16h 各一次 core 崩溃重启,预计 `2026-11-26T14:56:45Z` 结束);到点由本机定时任务读取 summary/journal 并决定是否关闭 issue #16。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/` 与 `feat007-n5-24h-20261125-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) +2026-11-25 feat-007 N5 启动包/未知版本门与 2h 现场观察(issue #16):新增 `scripts/n5/verify-release.ps1`,按 CI 同源脚本构建并打包 default release,校验 zip sidecar、`build-info.json` 的 commit/version/target/mode/entrypoint 与包内逐文件 SHA-256;解压后的 packaged daemon 两次启动均回答 `get_version_info`(retcode 0),无 bridge 时 `get_login_info` 诚实返回 1502,控制停止后 journal 保留;篡改 `QQ.exe` 哈希后 `verify-manifest` 与 `qq-entry` 均在 gate 1 拒绝且不产生 report,默认构建 `inject` 先被 K4-D0 拒绝。固定构建 `caligo.exe` SHA-256 `820781DB…57CE5`、`caligo_bridge.dll` `1EBF6E35…44FC`。现场 2h(本轮零发送):新 QQ 主根 `26620`(创建 `2026-11-25T12:03:11.4979693Z`,登记账号 B)通过固定 manifest/模块、PE/backend 审计与唯一 Environment 后一次 attach;117 个采样、`version`/`status`/`login` 351/351 成功、0 探测失败;30/60/90 分钟 3/3 次 kill core 并以同 journal/pipe/token 重启,恢复 1.56/1.53/1.55s、journal 完整帧前缀保留、bridge 未重新 attach;期间 495 条真实入站事件,`event_seq` 1–495 无缺口、495 个唯一 native ID、0 重复,generation 始终 1;daemon working set 7.7→14.6 MiB、handles 102→102,控制停止 daemon 后默认 bridge 保留、QQ 响应。2h 样本不证明 24h、QQ 重启后新代次重绑或真实 TCP 背压;`CoreStopped` 后同一代次不能重新 attach,24h 需新新鲜 QQ。随后在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并于 `14:56:45Z` 启动 24h soak。attempt 1 在约 8h 处 incomplete 停止(`2026-11-25T23:00:15Z`):479 samples、version/status 958/958 成功、journal 持续增长到 4,409,381 bytes,但 `get_login_info` 从 `15:19:49Z` 起长期返回 1502(456 次);第 2 次 core 重启(`22:56:46Z`)后 daemon 启动、journal 继续增长,但登录查询 188s 超时,harness 判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实返回,不应作为常驻链失败或重启恢复唯一信号;`n5_soak.py` 已改为 version/status 作为探测与恢复信号、登录查询单独计数并保留 1502,离线 rehearsal(18s、含一次 core 重启)通过。24h 门未通过,需新新鲜 QQ 代次用修正判据重跑;原定 `2026-11-26T23:10` 的到点任务已取消。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/` 与 `feat007-n5-24h-20261125-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) 2026-11-24 feat-006 现场 attempt 2(通过,单构建,issue #15):新 QQ `31584`(创建 `2026-11-24T13:40:42.5671257Z`,登记账号 B)通过 preflight,一次 attach,`get_login_info` 返回同一账号。对端 A 发送私聊 36 与群 41,NoneBot 反向 WS 收到并各回复一次(37/42),应用与 Caligo `get_msg` 均成功;账本保存 36/37/41/42,发送方 A/B 正确;同一 36/41 同时有签名通过的 HTTP POST 与正向 WS 证据。慢阶段 90 在 8 秒慢 POST、5 秒超时下仍到达应用(慢 POST 积压后约 38 秒),daemon 记录 23 次 POST 失败、66 次送达、0 丢弃,非读取 WS 客户端不影响应用连接;该阶段自动回复请求 `onebot-85939363ae79fe15-4` 以 `DeliveryUnknown` 结束(账本另存自发消息 106),未重发;操作者确认 A 已收到该慢回复(106)。控制管道正常停止 daemon;默认生产 bridge 无 research owner-stop(`0xe0`),bridge 保留、QQ 仍响应、未热卸载。原始 runner 的 `app_get_msg` 检查存在 source/outbound ID 比较缺陷,导致 `summary.json` 两项 false negative;`verify-evidence.py` 在不改原 summary、不重发的前提下离线重算,9 项 criteria 全 true、overall pass。feat-006 保持 in-progress(依赖 feat-005 未 done),产品 NOT READY;慢 POST 积压延迟 WS 与慢阶段回复 unknown 列入后续风险。原始材料只在 ignored `local-evidence/feat006-field-20261124-unbound/`。 diff --git a/scripts/n5/n5_resume.py b/scripts/n5/n5_resume.py index 68cbedc3..5ff9fab5 100644 --- a/scripts/n5/n5_resume.py +++ b/scripts/n5/n5_resume.py @@ -88,6 +88,7 @@ def main() -> int: events_path = out / "resume-events.jsonl" failures = [] samples = [] + login_unavailable = 0 print(json.dumps({"kind": "resume_start", "uptime_before_s": round(uptime_before, 2), "target_hours": target_hours}), flush=True) with events_path.open("a", encoding="utf-8") as events: @@ -112,7 +113,12 @@ def main() -> int: events.write(json.dumps({"kind": "sample", **record}, ensure_ascii=False) + "\n") events.flush() samples.append(record) - for name, value in (("version", version), ("status", status), ("login", login)): + login_locked = login.get("retcode") == 1502 and login.get("status") == "failed" + if login_locked: + login_unavailable += 1 + elif not login.get("ok"): + failures.append({"t_utc": record["t_utc"], "kind": "login", "result": sanitize_probe(login)}) + for name, value in (("version", version), ("status", status)): if not value.get("ok"): failures.append({"t_utc": record["t_utc"], "kind": name, "result": sanitize_probe(value)}) index += 1 @@ -175,6 +181,7 @@ def main() -> int: "samples": len(samples), "probe_failures": len(failures), "probe_failure_samples": failures[:20], + "login_unavailable": login_unavailable, "journal": journal, "stop": stop_record, "criteria": criteria, diff --git a/scripts/n5/n5_soak.py b/scripts/n5/n5_soak.py index 86918677..1f65b79f 100644 --- a/scripts/n5/n5_soak.py +++ b/scripts/n5/n5_soak.py @@ -297,6 +297,8 @@ def __init__(self, state: dict, pack: Path, args): self.samples: list[dict] = [] self.restarts: list[dict] = [] self.probe_failures: list[dict] = [] + self.login_unavailable: int = 0 + self.attach_login_ok: bool = False self.stop_record: dict = {} self.fatal: str | None = None self.bridge_initial: bool | None = None @@ -448,28 +450,50 @@ def sample(self, index: int, with_hash: bool): record["bridge_mapped"] = bridge_mapped(int(self.state["pid"]), Path(self.state["build"]["bridge"])) if not record["bridge_mapped"]: self.probe_failures.append({"t_utc": record["t_utc"], "kind": "bridge-unmapped"}) + # QQ may lock the client while the resident bridge/core keeps receiving + # events. In that state get_login_info honestly returns 1502 (not ready) + # while get_version_info/get_status stay healthy. That is not a resident + # failure; it is recorded separately and cannot be used as the restart + # recovery signal. + login_unavailable = login.get("retcode") == 1502 and login.get("status") == "failed" + record["login_unavailable"] = login_unavailable self.samples.append(record) self.events.write(json.dumps({"kind": "sample", **record}, ensure_ascii=False) + "\n") self.events.flush() rehearsal = self.state.get("mode") == "rehearsal" - for name, value in (("version", version), ("status", status), ("login", login)): - if not value.get("ok") and not (rehearsal and name in ("status", "login")): + if login_unavailable: + self.login_unavailable += 1 + elif not login.get("ok") and not rehearsal: + self.probe_failures.append( + {"t_utc": record["t_utc"], "kind": "login", "result": sanitize_probe(login)} + ) + for name, value in (("version", version), ("status", status)): + if not value.get("ok") and not (rehearsal and name == "status"): self.probe_failures.append( {"t_utc": record["t_utc"], "kind": name, "result": sanitize_probe(value)} ) return record def wait_recovered(self, timeout: float = 180.0): + """Wait for the core to answer version/status after a core restart. + + get_login_info is deliberately not the recovery signal: a locked QQ can + return 1502 while the resident bridge and core still receive events. + Login availability is recorded separately. + """ deadline = time.time() + timeout last = None rehearsal = self.state.get("mode") == "rehearsal" while time.time() < deadline: - last = probe( - self.state["ports"]["http"], - self.token, - "get_version_info" if rehearsal else "get_login_info", + version = probe(self.state["ports"]["http"], self.token, "get_version_info") + status = ( + {"ok": True, "retcode": 0, "status": "ok"} + if rehearsal + else probe(self.state["ports"]["http"], self.token, "get_status") ) - if last.get("ok"): + last = {"version": version, "status": status} + if version.get("ok") and status.get("ok"): + last["login"] = probe(self.state["ports"]["http"], self.token, "get_login_info") return last, round(timeout - (deadline - time.time()), 2) time.sleep(1.0) return last, None @@ -488,20 +512,34 @@ def restart_core(self, index: int): size = int(before.get("complete_bytes", 0)) if size > 0: prefix_ok = sha256_prefix(Path(self.state["journal"]), size) == before.get("complete_sha256") + recovered_ok = bool( + recovered + and recovered.get("version", {}).get("ok") + and recovered.get("status", {}).get("ok") + ) + journal_not_shrunk = bool( + before.get("exists") + and after.get("exists") + and after.get("size", 0) >= before.get("size", 0) + ) record = { "index": index, "t_utc": utcnow(), "journal_before": before, "journal_after": after, "journal_prefix_preserved": prefix_ok, - "recovered": bool(recovered and recovered.get("ok")), + "journal_not_shrunk": journal_not_shrunk, + "recovered": recovered_ok, "recovery_seconds": round(time.time() - killed_at, 2), - "probe": sanitize_probe(recovered), + "probe": sanitize_probe(recovered.get("version") if recovered else None), + "status": sanitize_probe(recovered.get("status") if recovered else None), + "login": sanitize_probe(recovered.get("login") if recovered else None), + "login_available": bool(recovered and recovered.get("login", {}).get("ok")), } self.restarts.append(record) self.log_event("core_restarted", **record) if not record["recovered"]: - raise RuntimeError(f"core restart {index} did not recover within timeout: {recovered}") + raise RuntimeError(f"core restart {index} did not recover version/status: {recovered}") return record def summarize_process(self, name: str): @@ -544,9 +582,10 @@ def hourly_summary(self, hour_index: int): "probe_failures": sum( 1 for s in recent - for p in s["probes"].values() - if not p.get("ok") + for name, p in s["probes"].items() + if name in ("version", "status") and not p.get("ok") ), + "login_unavailable": sum(1 for s in recent if s.get("login_unavailable")), "journal_size": recent[-1]["journal"].get("size"), } (self.out / "hourly").mkdir(exist_ok=True) @@ -557,7 +596,9 @@ def final_summary(self, duration_target: float): duration = time.time() - self.started probes = [p for s in self.samples for p in s["probes"].values()] latencies = [p["latency_ms"] for p in probes if "latency_ms" in p] - probe_ok = sum(1 for p in probes if p.get("ok")) + probe_ok = sum(1 for s in self.samples for name, p in s["probes"].items() if name in ("version", "status") and p.get("ok")) + login_probes = [s["probes"]["login"] for s in self.samples] + login_ok = sum(1 for p in login_probes if p.get("ok")) restart_ok = bool(self.restarts) and all(r["recovered"] and r.get("journal_prefix_preserved") is not False for r in self.restarts) journal_prefix = all(r.get("journal_prefix_preserved") is not False for r in self.restarts) bridge_retained = self.bridge_final is True @@ -579,6 +620,7 @@ def final_summary(self, duration_target: float): "probes_answered": probe_ok > 0 and len(self.probe_failures) == 0, "core_restarts_recovered": restart_ok, "journal_prefix_preserved": journal_prefix, + "identity_confirmed_at_attach": True if rehearsal else self.attach_login_ok, "bridge_retained_after_stop": True if rehearsal else bridge_retained, "qq_responsive_after_stop": True if rehearsal else qq_ok, "process_growth_bounded": bounded, @@ -596,10 +638,14 @@ def final_summary(self, duration_target: float): "target_hours": self.state.get("duration_hours"), "sample_seconds": self.state.get("sample_seconds"), "samples": len(self.samples), - "probe_count": len(probes), + "probe_count": 2 * len(self.samples), "probe_ok": probe_ok, "probe_failures": len(self.probe_failures), "probe_failure_samples": self.probe_failures[:20], + "login_probe_count": len(login_probes), + "login_probe_ok": login_ok, + "login_unavailable": self.login_unavailable, + "attach_login_ok": self.attach_login_ok, "latency_ms": { "median": round(statistics.median(latencies), 2) if latencies else None, "p95": round(sorted(latencies)[int(len(latencies) * 0.95) - 1], 2) if latencies else None, @@ -625,7 +671,8 @@ def final_summary(self, duration_target: float): f"- started: {summary['started_utc']}", f"- finished: {summary['finished_utc']}", f"- duration: {summary['duration_seconds']:.0f}s (target {summary['duration_target_seconds']:.0f}s)", - f"- samples: {summary['samples']}, probes: {summary['probe_ok']}/{summary['probe_count']} ok", + f"- samples: {summary['samples']}, version/status probes: {summary['probe_ok']}/{summary['probe_count']} ok", + f"- login probes: {summary['login_probe_ok']}/{summary['login_probe_count']} ok; unavailable(1502): {summary['login_unavailable']}", f"- daemon working set first/last/max: {daemon_summary.get('working_set_first')}/{daemon_summary.get('working_set_last')}/{daemon_summary.get('working_set_max')}", f"- daemon handles first/last/max: {daemon_summary.get('handles_first')}/{daemon_summary.get('handles_last')}/{daemon_summary.get('handles_max')}", f"- core restarts: {len(self.restarts)}", @@ -779,6 +826,7 @@ def main() -> int: login = soak.wait_login() if not login or not login.get("ok"): raise RuntimeError(f"login was not confirmed after attach: {login}") + soak.attach_login_ok = True soak.log_event("bridge_attached", bridge_mapped=soak.bridge_initial, login_ok=True) soak.journal_initial = soak.journal_state(True) diff --git a/session-handoff.md b/session-handoff.md index bcc7ef40..f82dc1fd 100644 --- a/session-handoff.md +++ b/session-handoff.md @@ -1,6 +1,6 @@ # Session handoff -2026-11-25 feat-007 N5 离线启动包/未知版本门 + 2h 现场观察通过(issue #16):`scripts/n5/verify-release.ps1` 的 default release 打包、sidecar/build-info/包内哈希、两次 packaged daemon 启动与诚实无 bridge 登录失败、篡改 manifest 的 gate 1 拒绝均 pass;固定 `caligo.exe` `820781DB…57CE5`、bridge `1EBF6E35…44FC`。现场新 QQ `26620`(创建 `2026-11-25T12:03:11.4979693Z`,账号 B)一次 attach,零发送;117 samples、351/351 查询成功、3/3 次 core 崩溃重启约 1.5s 恢复、495 条入站事件无重复/缺口、控制停止后 bridge 保留。2h 样本不证明 24h/QQ 重启新代次/真实 TCP 背压;`CoreStopped` 后同代次不能重新 attach。已在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight,并于 `14:56:45Z` 启动 24h soak(+2h/+8h/+16h 各一次 core 崩溃重启,预计 `2026-11-26T14:56:45Z` 结束);已创建 `2026-11-26T23:10+08:00` 的定时核验任务 `schedule-c05cd080-9504-495f-9e9c-9d20bdf851d4`,通过才关闭 issue #16。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/` 与 `feat007-n5-24h-20261125-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) +2026-11-25 feat-007 N5 离线启动包/未知版本门 + 2h 现场观察通过(issue #16):`scripts/n5/verify-release.ps1` 的 default release 打包、sidecar/build-info/包内哈希、两次 packaged daemon 启动与诚实无 bridge 登录失败、篡改 manifest 的 gate 1 拒绝均 pass;固定 `caligo.exe` `820781DB…57CE5`、bridge `1EBF6E35…44FC`。现场新 QQ `26620`(创建 `2026-11-25T12:03:11.4979693Z`,账号 B)一次 attach,零发送;117 samples、351/351 查询成功、3/3 次 core 崩溃重启约 1.5s 恢复、495 条入站事件无重复/缺口、控制停止后 bridge 保留。2h 样本不证明 24h/QQ 重启新代次/真实 TCP 背压;`CoreStopped` 后同代次不能重新 attach。已在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并启动 24h soak;attempt 1 在约 8h 处 incomplete(`2026-11-25T23:00:15Z`):version/status 958/958 成功、journal 持续增长,但 `get_login_info` 从 `15:19:49Z` 起长期返回 1502(456 次),第 2 次 core 重启后登录查询 188s 超时触发 fatal。已确认 1502 是 QQ 锁屏/会话不可用时的诚实返回;`n5_soak.py` 已改为 version/status 作为探测与恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h 未通过,需新新鲜 QQ 代次重跑;原定时核验任务已取消。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/` 与 `feat007-n5-24h-20261125-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) 2026-11-24 feat-006 现场 attempt 2 通过(issue #15):新 QQ `31584` 一次 attach,NoneBot2 经反向 WS 收到私聊 36 / 群 41,各回复一次(37/42);应用与 Caligo `get_msg` 均成功,账本与发送方一致;同一消息有签名 HTTP POST 与正向 WS 证据。慢阶段 90 在慢 POST/超时下仍到达应用(积压后约 38 秒),daemon 记录 23 failed / 66 delivered / 0 dropped;该阶段自动回复请求 `onebot-85939363ae79fe15-4` 为 `DeliveryUnknown`(账本另存自发消息 106),未重发。控制停止 daemon;默认 bridge 无 research owner-stop(0xe0),bridge 保留、QQ 响应。runner 的 `app_get_msg` 误报已由 `verify-evidence.py` 离线更正,9/9 criteria true。操作者已确认 A 收到 37、42、106;issue #15 按证据关闭;feat-006 保持 in-progress(依赖 feat-005 未 done),慢 POST 积压延迟 WS 投递列为后续风险。证据见 [acceptance §6.2](docs/acceptance/2026-11-24-feat-006-text-mvp.md#62-现场-attempt-2通过单构建)。 From bad14db03926b624898a198765c9c16ae0a0a8b3 Mon Sep 17 00:00:00 2001 From: Vegetable <3089665724@qq.com> Date: Thu, 26 Nov 2026 07:34:19 +0800 Subject: [PATCH 04/13] docs(feat-007): record corrected 24h attempt and remaining gate --- docs/acceptance/2026-11-25-feat-007-n5-release.md | 8 +++++--- feature_list.json | 2 +- progress.md | 2 +- session-handoff.md | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/acceptance/2026-11-25-feat-007-n5-release.md b/docs/acceptance/2026-11-25-feat-007-n5-release.md index 335bd7c2..fa0e1b80 100644 --- a/docs/acceptance/2026-11-25-feat-007-n5-release.md +++ b/docs/acceptance/2026-11-25-feat-007-n5-release.md @@ -13,7 +13,7 @@ | 正常入口无需每消息交互 | feat-006 现场:daemon + 一次 attach 后真实应用经 HTTP/WS 收发;本轮 2h 现场:同一 daemon/attach 下 117 个采样、351/351 次只读查询成功,495 条真实入站事件入账,无每条消息 CLI 交互 | 24h 连续运行 | | core/QQ 重启、断链/慢客户端矩阵 | 离线 `core_restart_query_lab` 4/4、`recovery_contract` 13/13、`onebot_transport` 10/10;本轮 2h 现场 3/3 次 core 崩溃重启与 bridge 重连(各约 1.5s) | QQ 退出/重启后新代次重绑;真实 TCP 背压 | | 未知版本零 native 调用,停止边界如实 | 本轮离线门:篡改 manifest 后 `verify-manifest`/`qq-entry` 在 gate 1 拒绝,report 未产生;`inject` 在默认构建被 K4-D0 拒绝;现场控制停止后默认 bridge 保留 | 失败停止的现场负例仍未新增(沿用 feat-005/006 证据) | -| 24h 单账号验收及启动包证据齐全 | 本轮启动包:release zip、`build-info.json`、sidecar SHA-256、包内逐文件哈希、解压后 daemon 两次启动/停止与诚实无 bridge 登录失败 | 24h 单账号运行:attempt 1 在 8h 处 incomplete(§4.1),判据已修正,需新 QQ 代次重跑 | +| 24h 单账号验收及启动包证据齐全 | 本轮启动包:release zip、`build-info.json`、sidecar SHA-256、包内逐文件哈希、解压后 daemon 两次启动/停止与诚实无 bridge 登录失败 | 24h 单账号运行:attempt 1 在 8h 处 incomplete(§4.1),判据已修正;attempt 2 于 `2026-11-25T23:33:25Z` 启动,结果待到点核验 | ## 2. 启动包与离线门 @@ -99,8 +99,10 @@ attach 时仍要求一次登录成功。该修复通过离线 rehearsal(18s, - **24h**:2h 观察只覆盖短时恢复;`CoreStopped` 后默认 bridge 的 daemon worker 已退出, 同一 QQ 代次不能重新 attach。24h attempt 1 在 8h 处 incomplete(§4.1):version/status 与 journal 链持续,但 `get_login_info` 因 QQ 锁屏/会话不可用长期返回 1502,harness 误把它 - 当作探测失败/重启恢复信号。判据已修正,需要在新的新鲜 QQ 代次上重跑完整 24h;重跑通过前 - 不把该门标为通过,也不关闭 issue #16。 + 当作探测失败/重启恢复信号。判据已修正;attempt 2 于 `2026-11-25T23:33:25Z` 在新的新鲜 + QQ 主根上启动(零发送、version/status 驱动探测与恢复、登录查询单独计数、+2h/+8h/+16h + 各一次 core 重启),预计 `2026-11-26T23:33:25Z` 结束;本机定时任务在 `2026-11-27T07:50+08:00` + 读取 summary/journal 并更新证据。结果出来前不把该门标为通过,也不关闭 issue #16。 - **QQ 重启**:需要操作者退出并重启 QQ,随后对新 PID/创建时间重新 preflight/attach; 旧代次的请求、映射和回调不得混入新实例。 - **启动包**:本轮为 default 构建;research 构建、真实 QQ 字段与发布 tag 流程是独立验收。 diff --git a/feature_list.json b/feature_list.json index 36f3fa6e..ca481937 100644 --- a/feature_list.json +++ b/feature_list.json @@ -110,7 +110,7 @@ "plan_steps": ["N5"], "dependencies": ["feat-006"], "status": "in-progress", - "evidence": "2026-11-25 离线启动包/未知版本门通过(scripts/n5/verify-release.ps1):default release 构建与 CI 同源打包,zip sidecar、build-info commit/version/target/mode 和包内逐文件 SHA-256 均匹配;解压后 packaged daemon 两次启动均回答 get_version_info、无 bridge 时 get_login_info 诚实返回 1502、控制停止后 journal 保留;篡改 QQ.exe 哈希后 verify-manifest 与 qq-entry 均在 gate 1 拒绝且不产生 report,默认构建的 inject 先被 K4-D0 拒绝。现场 2h 观察通过(零发送、60s 只读探测、30/60/90 分钟 core 崩溃重启):新 QQ 主根一次 attach,117 个采样、351/351 次查询成功、495 条真实入站事件无重复/缺口(event_seq 1–495),3/3 次 core 崩溃重启各约 1.5s 恢复且 journal 完整帧前缀保留,控制停止后默认 bridge 保留、QQ 响应。CoreStopped 后同一代次不能重新 attach,因此在新主根上启动 24h soak;attempt 1 在约 8h 处 incomplete:version/status 探测 958/958 成功、journal 持续增长,但 get_login_info 从 15:19Z 起长期返回 1502(456 次),第 2 次 core 重启后 harness 因登录查询超时判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实结果,不是常驻链失败;harness 已改为 version/status 作为探测与重启恢复信号、登录查询单独计数(离线 rehearsal 通过),24h 仍需新 QQ 代次重跑。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。", + "evidence": "2026-11-25 离线启动包/未知版本门通过(scripts/n5/verify-release.ps1):default release 构建与 CI 同源打包,zip sidecar、build-info commit/version/target/mode 和包内逐文件 SHA-256 均匹配;解压后 packaged daemon 两次启动均回答 get_version_info、无 bridge 时 get_login_info 诚实返回 1502、控制停止后 journal 保留;篡改 QQ.exe 哈希后 verify-manifest 与 qq-entry 均在 gate 1 拒绝且不产生 report,默认构建的 inject 先被 K4-D0 拒绝。现场 2h 观察通过(零发送、60s 只读探测、30/60/90 分钟 core 崩溃重启):新 QQ 主根一次 attach,117 个采样、351/351 次查询成功、495 条真实入站事件无重复/缺口(event_seq 1–495),3/3 次 core 崩溃重启各约 1.5s 恢复且 journal 完整帧前缀保留,控制停止后默认 bridge 保留、QQ 响应。CoreStopped 后同一代次不能重新 attach,因此在新主根上启动 24h soak;attempt 1 在约 8h 处 incomplete:version/status 探测 958/958 成功、journal 持续增长,但 get_login_info 从 15:19Z 起长期返回 1502(456 次),第 2 次 core 重启后 harness 因登录查询超时判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实结果,不是常驻链失败;harness 已改为 version/status 作为探测与重启恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 2 已于 2026-11-25T23:33:25Z 在新主根上启动,预计 2026-11-26T23:33:25Z 结束,到点由定时任务核验;结果出来前不提升状态。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。", "evidence_paths": ["docs/acceptance/2026-11-25-feat-007-n5-release.md", "scripts/n5/verify-release.ps1", "scripts/n5/preflight.ps1", "scripts/n5/attach.ps1", "scripts/n5/n5_soak.py", "docs/plans/2026-10-09-gitnexus-plan-caligo-snowluma-capability-parity.md"], "done_criteria": ["正常入口无需每消息交互", "core/QQ 重启、断链/慢客户端矩阵通过", "未知版本零 native 调用,停止边界如实", "24h 单账号验收及启动包证据齐全"] }, diff --git a/progress.md b/progress.md index 38240e92..ef67222a 100644 --- a/progress.md +++ b/progress.md @@ -2,7 +2,7 @@ ## Current State -2026-11-25 feat-007 N5 启动包/未知版本门与 2h 现场观察(issue #16):新增 `scripts/n5/verify-release.ps1`,按 CI 同源脚本构建并打包 default release,校验 zip sidecar、`build-info.json` 的 commit/version/target/mode/entrypoint 与包内逐文件 SHA-256;解压后的 packaged daemon 两次启动均回答 `get_version_info`(retcode 0),无 bridge 时 `get_login_info` 诚实返回 1502,控制停止后 journal 保留;篡改 `QQ.exe` 哈希后 `verify-manifest` 与 `qq-entry` 均在 gate 1 拒绝且不产生 report,默认构建 `inject` 先被 K4-D0 拒绝。固定构建 `caligo.exe` SHA-256 `820781DB…57CE5`、`caligo_bridge.dll` `1EBF6E35…44FC`。现场 2h(本轮零发送):新 QQ 主根 `26620`(创建 `2026-11-25T12:03:11.4979693Z`,登记账号 B)通过固定 manifest/模块、PE/backend 审计与唯一 Environment 后一次 attach;117 个采样、`version`/`status`/`login` 351/351 成功、0 探测失败;30/60/90 分钟 3/3 次 kill core 并以同 journal/pipe/token 重启,恢复 1.56/1.53/1.55s、journal 完整帧前缀保留、bridge 未重新 attach;期间 495 条真实入站事件,`event_seq` 1–495 无缺口、495 个唯一 native ID、0 重复,generation 始终 1;daemon working set 7.7→14.6 MiB、handles 102→102,控制停止 daemon 后默认 bridge 保留、QQ 响应。2h 样本不证明 24h、QQ 重启后新代次重绑或真实 TCP 背压;`CoreStopped` 后同一代次不能重新 attach,24h 需新新鲜 QQ。随后在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并于 `14:56:45Z` 启动 24h soak。attempt 1 在约 8h 处 incomplete 停止(`2026-11-25T23:00:15Z`):479 samples、version/status 958/958 成功、journal 持续增长到 4,409,381 bytes,但 `get_login_info` 从 `15:19:49Z` 起长期返回 1502(456 次);第 2 次 core 重启(`22:56:46Z`)后 daemon 启动、journal 继续增长,但登录查询 188s 超时,harness 判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实返回,不应作为常驻链失败或重启恢复唯一信号;`n5_soak.py` 已改为 version/status 作为探测与恢复信号、登录查询单独计数并保留 1502,离线 rehearsal(18s、含一次 core 重启)通过。24h 门未通过,需新新鲜 QQ 代次用修正判据重跑;原定 `2026-11-26T23:10` 的到点任务已取消。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/` 与 `feat007-n5-24h-20261125-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) +2026-11-25 feat-007 N5 启动包/未知版本门与 2h 现场观察(issue #16):新增 `scripts/n5/verify-release.ps1`,按 CI 同源脚本构建并打包 default release,校验 zip sidecar、`build-info.json` 的 commit/version/target/mode/entrypoint 与包内逐文件 SHA-256;解压后的 packaged daemon 两次启动均回答 `get_version_info`(retcode 0),无 bridge 时 `get_login_info` 诚实返回 1502,控制停止后 journal 保留;篡改 `QQ.exe` 哈希后 `verify-manifest` 与 `qq-entry` 均在 gate 1 拒绝且不产生 report,默认构建 `inject` 先被 K4-D0 拒绝。固定构建 `caligo.exe` SHA-256 `820781DB…57CE5`、`caligo_bridge.dll` `1EBF6E35…44FC`。现场 2h(本轮零发送):新 QQ 主根 `26620`(创建 `2026-11-25T12:03:11.4979693Z`,登记账号 B)通过固定 manifest/模块、PE/backend 审计与唯一 Environment 后一次 attach;117 个采样、`version`/`status`/`login` 351/351 成功、0 探测失败;30/60/90 分钟 3/3 次 kill core 并以同 journal/pipe/token 重启,恢复 1.56/1.53/1.55s、journal 完整帧前缀保留、bridge 未重新 attach;期间 495 条真实入站事件,`event_seq` 1–495 无缺口、495 个唯一 native ID、0 重复,generation 始终 1;daemon working set 7.7→14.6 MiB、handles 102→102,控制停止 daemon 后默认 bridge 保留、QQ 响应。2h 样本不证明 24h、QQ 重启后新代次重绑或真实 TCP 背压;`CoreStopped` 后同一代次不能重新 attach,24h 需新新鲜 QQ。随后在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并于 `14:56:45Z` 启动 24h soak。attempt 1 在约 8h 处 incomplete 停止(`2026-11-25T23:00:15Z`):479 samples、version/status 958/958 成功、journal 持续增长到 4,409,381 bytes,但 `get_login_info` 从 `15:19:49Z` 起长期返回 1502(456 次);第 2 次 core 重启(`22:56:46Z`)后 daemon 启动、journal 继续增长,但登录查询 188s 超时,harness 判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实返回,不应作为常驻链失败或重启恢复唯一信号;`n5_soak.py` 已改为 version/status 作为探测与恢复信号、登录查询单独计数并保留 1502,离线 rehearsal(18s、含一次 core 重启)通过。24h 门未通过;原定 `2026-11-26T23:10` 的到点任务已取消。修正判据后,attempt 2 于 `2026-11-25T23:33:25Z` 在新主根 `43444`(创建 `2026-11-25T23:31:19.6213631Z`,账号 B)上启动(零发送,version/status 驱动恢复与探测,登录 1502 单独计数,+2h/+8h/+16h 各一次 core 重启,预计 `2026-11-26T23:33:25Z` 结束);新定时核验任务 `schedule-5aeec657-a229-43d2-8969-f6e7186fffa2` 在 `2026-11-27T07:50+08:00` 执行。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/`、`feat007-n5-24h-20261125-unbound/` 与 `feat007-n5-24h-20261126-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) 2026-11-24 feat-006 现场 attempt 2(通过,单构建,issue #15):新 QQ `31584`(创建 `2026-11-24T13:40:42.5671257Z`,登记账号 B)通过 preflight,一次 attach,`get_login_info` 返回同一账号。对端 A 发送私聊 36 与群 41,NoneBot 反向 WS 收到并各回复一次(37/42),应用与 Caligo `get_msg` 均成功;账本保存 36/37/41/42,发送方 A/B 正确;同一 36/41 同时有签名通过的 HTTP POST 与正向 WS 证据。慢阶段 90 在 8 秒慢 POST、5 秒超时下仍到达应用(慢 POST 积压后约 38 秒),daemon 记录 23 次 POST 失败、66 次送达、0 丢弃,非读取 WS 客户端不影响应用连接;该阶段自动回复请求 `onebot-85939363ae79fe15-4` 以 `DeliveryUnknown` 结束(账本另存自发消息 106),未重发;操作者确认 A 已收到该慢回复(106)。控制管道正常停止 daemon;默认生产 bridge 无 research owner-stop(`0xe0`),bridge 保留、QQ 仍响应、未热卸载。原始 runner 的 `app_get_msg` 检查存在 source/outbound ID 比较缺陷,导致 `summary.json` 两项 false negative;`verify-evidence.py` 在不改原 summary、不重发的前提下离线重算,9 项 criteria 全 true、overall pass。feat-006 保持 in-progress(依赖 feat-005 未 done),产品 NOT READY;慢 POST 积压延迟 WS 与慢阶段回复 unknown 列入后续风险。原始材料只在 ignored `local-evidence/feat006-field-20261124-unbound/`。 diff --git a/session-handoff.md b/session-handoff.md index f82dc1fd..c36f0e12 100644 --- a/session-handoff.md +++ b/session-handoff.md @@ -1,6 +1,6 @@ # Session handoff -2026-11-25 feat-007 N5 离线启动包/未知版本门 + 2h 现场观察通过(issue #16):`scripts/n5/verify-release.ps1` 的 default release 打包、sidecar/build-info/包内哈希、两次 packaged daemon 启动与诚实无 bridge 登录失败、篡改 manifest 的 gate 1 拒绝均 pass;固定 `caligo.exe` `820781DB…57CE5`、bridge `1EBF6E35…44FC`。现场新 QQ `26620`(创建 `2026-11-25T12:03:11.4979693Z`,账号 B)一次 attach,零发送;117 samples、351/351 查询成功、3/3 次 core 崩溃重启约 1.5s 恢复、495 条入站事件无重复/缺口、控制停止后 bridge 保留。2h 样本不证明 24h/QQ 重启新代次/真实 TCP 背压;`CoreStopped` 后同代次不能重新 attach。已在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并启动 24h soak;attempt 1 在约 8h 处 incomplete(`2026-11-25T23:00:15Z`):version/status 958/958 成功、journal 持续增长,但 `get_login_info` 从 `15:19:49Z` 起长期返回 1502(456 次),第 2 次 core 重启后登录查询 188s 超时触发 fatal。已确认 1502 是 QQ 锁屏/会话不可用时的诚实返回;`n5_soak.py` 已改为 version/status 作为探测与恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h 未通过,需新新鲜 QQ 代次重跑;原定时核验任务已取消。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/` 与 `feat007-n5-24h-20261125-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) +2026-11-25 feat-007 N5 离线启动包/未知版本门 + 2h 现场观察通过(issue #16):`scripts/n5/verify-release.ps1` 的 default release 打包、sidecar/build-info/包内哈希、两次 packaged daemon 启动与诚实无 bridge 登录失败、篡改 manifest 的 gate 1 拒绝均 pass;固定 `caligo.exe` `820781DB…57CE5`、bridge `1EBF6E35…44FC`。现场新 QQ `26620`(创建 `2026-11-25T12:03:11.4979693Z`,账号 B)一次 attach,零发送;117 samples、351/351 查询成功、3/3 次 core 崩溃重启约 1.5s 恢复、495 条入站事件无重复/缺口、控制停止后 bridge 保留。2h 样本不证明 24h/QQ 重启新代次/真实 TCP 背压;`CoreStopped` 后同代次不能重新 attach。已在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并启动 24h soak;attempt 1 在约 8h 处 incomplete(`2026-11-25T23:00:15Z`):version/status 958/958 成功、journal 持续增长,但 `get_login_info` 从 `15:19:49Z` 起长期返回 1502(456 次),第 2 次 core 重启后登录查询 188s 超时触发 fatal。已确认 1502 是 QQ 锁屏/会话不可用时的诚实返回;`n5_soak.py` 已改为 version/status 作为探测与恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 1 未通过,原定时核验任务已取消。修正判据后 attempt 2 于 `2026-11-25T23:33:25Z` 在新主根 `43444`(创建 `2026-11-25T23:31:19.6213631Z`,账号 B)启动,预计 `2026-11-26T23:33:25Z` 结束;新定时核验任务 `schedule-5aeec657-a229-43d2-8969-f6e7186fffa2` 在 `2026-11-27T07:50+08:00` 执行,不自动关闭 issue #16。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/`、`feat007-n5-24h-20261125-unbound/` 与 `feat007-n5-24h-20261126-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) 2026-11-24 feat-006 现场 attempt 2 通过(issue #15):新 QQ `31584` 一次 attach,NoneBot2 经反向 WS 收到私聊 36 / 群 41,各回复一次(37/42);应用与 Caligo `get_msg` 均成功,账本与发送方一致;同一消息有签名 HTTP POST 与正向 WS 证据。慢阶段 90 在慢 POST/超时下仍到达应用(积压后约 38 秒),daemon 记录 23 failed / 66 delivered / 0 dropped;该阶段自动回复请求 `onebot-85939363ae79fe15-4` 为 `DeliveryUnknown`(账本另存自发消息 106),未重发。控制停止 daemon;默认 bridge 无 research owner-stop(0xe0),bridge 保留、QQ 响应。runner 的 `app_get_msg` 误报已由 `verify-evidence.py` 离线更正,9/9 criteria true。操作者已确认 A 收到 37、42、106;issue #15 按证据关闭;feat-006 保持 in-progress(依赖 feat-005 未 done),慢 POST 积压延迟 WS 投递列为后续风险。证据见 [acceptance §6.2](docs/acceptance/2026-11-24-feat-006-text-mvp.md#62-现场-attempt-2通过单构建)。 From 56b45dcab0733c4e09f5f83b889711943f01a49d Mon Sep 17 00:00:00 2001 From: Vegetable <3089665724@qq.com> Date: Fri, 27 Nov 2026 07:36:00 +0800 Subject: [PATCH 05/13] docs(feat-007): record 24h resident pass and open caveats --- .../2026-11-25-feat-007-n5-release.md | 29 ++++++++++++++----- feature_list.json | 2 +- progress.md | 2 +- scripts/n5/n5_soak.py | 28 +++++++++++------- session-handoff.md | 2 +- 5 files changed, 42 insertions(+), 21 deletions(-) diff --git a/docs/acceptance/2026-11-25-feat-007-n5-release.md b/docs/acceptance/2026-11-25-feat-007-n5-release.md index fa0e1b80..25fa3f75 100644 --- a/docs/acceptance/2026-11-25-feat-007-n5-release.md +++ b/docs/acceptance/2026-11-25-feat-007-n5-release.md @@ -13,7 +13,7 @@ | 正常入口无需每消息交互 | feat-006 现场:daemon + 一次 attach 后真实应用经 HTTP/WS 收发;本轮 2h 现场:同一 daemon/attach 下 117 个采样、351/351 次只读查询成功,495 条真实入站事件入账,无每条消息 CLI 交互 | 24h 连续运行 | | core/QQ 重启、断链/慢客户端矩阵 | 离线 `core_restart_query_lab` 4/4、`recovery_contract` 13/13、`onebot_transport` 10/10;本轮 2h 现场 3/3 次 core 崩溃重启与 bridge 重连(各约 1.5s) | QQ 退出/重启后新代次重绑;真实 TCP 背压 | | 未知版本零 native 调用,停止边界如实 | 本轮离线门:篡改 manifest 后 `verify-manifest`/`qq-entry` 在 gate 1 拒绝,report 未产生;`inject` 在默认构建被 K4-D0 拒绝;现场控制停止后默认 bridge 保留 | 失败停止的现场负例仍未新增(沿用 feat-005/006 证据) | -| 24h 单账号验收及启动包证据齐全 | 本轮启动包:release zip、`build-info.json`、sidecar SHA-256、包内逐文件哈希、解压后 daemon 两次启动/停止与诚实无 bridge 登录失败 | 24h 单账号运行:attempt 1 在 8h 处 incomplete(§4.1),判据已修正;attempt 2 于 `2026-11-25T23:33:25Z` 启动,结果待到点核验 | +| 24h 单账号验收及启动包证据齐全 | 本轮启动包:release zip、`build-info.json`、sidecar SHA-256、包内逐文件哈希、解压后 daemon 两次启动/停止与诚实无 bridge 登录失败;attempt 2 常驻链跑满 24h(version/status 2876/2876、3/3 重启、bridge/QQ 正常,§4.2) | 应用级 24h 未闭合:无 OneBot 事件消费者导致 13,234 条队列 Gap;`get_login_info` 锁屏/重启后 958 次超时;QQ 重启新代次矩阵未取证 | ## 2. 启动包与离线门 @@ -94,15 +94,28 @@ harness 的两个判据被证明不合适:`get_login_info` 在 QQ 锁屏/会 已改为:version/status 作为恢复与 `probes_answered` 信号,登录查询单独计数并保留 1502; attach 时仍要求一次登录成功。该修复通过离线 rehearsal(18s,含一次 core 重启)。 +### 4.2 24h attempt 2(2026-11-25T23:33:25Z–2026-11-26T23:33:46Z,resident pass with caveats) + +修正判据后在新的新鲜 QQ 主根上重跑,完整跑满 24h: + +| 项目 | 结果 | +|---|---| +| 运行 | 86,420s(目标 86,400s),1438 个采样;附加入站事件见下 | +| version/status | 2876/2876 成功,0 failure;3 次 core 崩溃重启均恢复(0.18s / 0.18s / 0.19s),journal 完整帧前缀每次保留 | +| 身份/停止 | attach 时登录成功;控制停止 daemon 后默认 bridge 保留、QQ 响应;daemon working set 7.7→~10 MiB、handles ~105 稳定,QQ ~730 MiB/handles ~1700 稳定 | +| 入站事件 | journal 3,020,642 bytes;896 个 Event,`event_seq` 1–896 无缺口、896 个唯一 native ID、0 重复、generation 1;但含 **13,234 条 Gap**(`event queue overflow (items/bytes limit)`) | +| 登录查询 | 1438 次中 215 次成功、265 次 1502、958 次 10s 超时;QQ 锁屏/会话不可用后 default `get_login_info` 走 native query,重启后长期超时 | +| 结论 | **常驻链 24h 通过**(version/status、3/3 重启、bridge、QQ、内存/句柄),但**不是应用级 24h 通过**:本轮没有 OneBot WS/SSE/POST 消费者,事件队列满后 Gap 是预期的有界拒绝;`get_login_info` 默认动作在锁屏/重启后不返回缓存身份,属于待修的产品可靠性缺陷。综合见包内 `soak-recomputed.json`(`resident-pass-with-open-caveats`) | + ## 5. 剩余门与边界 -- **24h**:2h 观察只覆盖短时恢复;`CoreStopped` 后默认 bridge 的 daemon worker 已退出, - 同一 QQ 代次不能重新 attach。24h attempt 1 在 8h 处 incomplete(§4.1):version/status - 与 journal 链持续,但 `get_login_info` 因 QQ 锁屏/会话不可用长期返回 1502,harness 误把它 - 当作探测失败/重启恢复信号。判据已修正;attempt 2 于 `2026-11-25T23:33:25Z` 在新的新鲜 - QQ 主根上启动(零发送、version/status 驱动探测与恢复、登录查询单独计数、+2h/+8h/+16h - 各一次 core 重启),预计 `2026-11-26T23:33:25Z` 结束;本机定时任务在 `2026-11-27T07:50+08:00` - 读取 summary/journal 并更新证据。结果出来前不把该门标为通过,也不关闭 issue #16。 +- **24h**:attempt 1 在 8h 处 incomplete(§4.1);修正判据后的 attempt 2 完整跑满 24h + (§4.2),常驻链(version/status、3/3 core 重启、bridge、QQ、内存/句柄)通过。但 + **应用级 24h 未闭合**:本轮没有 OneBot 事件消费者,事件队列满后的 13,234 条 Gap 是有界 + 拒绝、不能当作交付 24h 证据;`get_login_info` 在锁屏/重启后 958 次 10s 超时,默认动作 + 应优先返回持久身份或给出有界失败。上述两项需要实现/构建修正后另行现场复验,并需要至少 + 一个真正的 WS/SSE 消费者参与 24h 运行。重跑通过前不把 N5 24h 门标为完全通过,也不关闭 + issue #16。 - **QQ 重启**:需要操作者退出并重启 QQ,随后对新 PID/创建时间重新 preflight/attach; 旧代次的请求、映射和回调不得混入新实例。 - **启动包**:本轮为 default 构建;research 构建、真实 QQ 字段与发布 tag 流程是独立验收。 diff --git a/feature_list.json b/feature_list.json index ca481937..f2f50917 100644 --- a/feature_list.json +++ b/feature_list.json @@ -110,7 +110,7 @@ "plan_steps": ["N5"], "dependencies": ["feat-006"], "status": "in-progress", - "evidence": "2026-11-25 离线启动包/未知版本门通过(scripts/n5/verify-release.ps1):default release 构建与 CI 同源打包,zip sidecar、build-info commit/version/target/mode 和包内逐文件 SHA-256 均匹配;解压后 packaged daemon 两次启动均回答 get_version_info、无 bridge 时 get_login_info 诚实返回 1502、控制停止后 journal 保留;篡改 QQ.exe 哈希后 verify-manifest 与 qq-entry 均在 gate 1 拒绝且不产生 report,默认构建的 inject 先被 K4-D0 拒绝。现场 2h 观察通过(零发送、60s 只读探测、30/60/90 分钟 core 崩溃重启):新 QQ 主根一次 attach,117 个采样、351/351 次查询成功、495 条真实入站事件无重复/缺口(event_seq 1–495),3/3 次 core 崩溃重启各约 1.5s 恢复且 journal 完整帧前缀保留,控制停止后默认 bridge 保留、QQ 响应。CoreStopped 后同一代次不能重新 attach,因此在新主根上启动 24h soak;attempt 1 在约 8h 处 incomplete:version/status 探测 958/958 成功、journal 持续增长,但 get_login_info 从 15:19Z 起长期返回 1502(456 次),第 2 次 core 重启后 harness 因登录查询超时判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实结果,不是常驻链失败;harness 已改为 version/status 作为探测与重启恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 2 已于 2026-11-25T23:33:25Z 在新主根上启动,预计 2026-11-26T23:33:25Z 结束,到点由定时任务核验;结果出来前不提升状态。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。", + "evidence": "2026-11-25 离线启动包/未知版本门通过(scripts/n5/verify-release.ps1):default release 构建与 CI 同源打包,zip sidecar、build-info commit/version/target/mode 和包内逐文件 SHA-256 均匹配;解压后 packaged daemon 两次启动均回答 get_version_info、无 bridge 时 get_login_info 诚实返回 1502、控制停止后 journal 保留;篡改 QQ.exe 哈希后 verify-manifest 与 qq-entry 均在 gate 1 拒绝且不产生 report,默认构建的 inject 先被 K4-D0 拒绝。现场 2h 观察通过(零发送、60s 只读探测、30/60/90 分钟 core 崩溃重启):新 QQ 主根一次 attach,117 个采样、351/351 次查询成功、495 条真实入站事件无重复/缺口(event_seq 1–495),3/3 次 core 崩溃重启各约 1.5s 恢复且 journal 完整帧前缀保留,控制停止后默认 bridge 保留、QQ 响应。CoreStopped 后同一代次不能重新 attach,因此在新主根上启动 24h soak;attempt 1 在约 8h 处 incomplete:version/status 探测 958/958 成功、journal 持续增长,但 get_login_info 从 15:19Z 起长期返回 1502(456 次),第 2 次 core 重启后 harness 因登录查询超时判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实结果,不是常驻链失败;harness 已改为 version/status 作为探测与重启恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 2 已完整跑满 86,420s:version/status 2876/2876 成功、3/3 次 core 重启恢复(约 0.2s)、bridge 保留、QQ 响应、内存/句柄稳定,但 journal 含 13,234 条 Gap(本轮无 OneBot 事件消费者,队列满后的有界拒绝),且 get_login_info 1438 次中仅 215 次成功(265 次 1502、958 次 10s 超时,锁屏/重启后默认动作走 native query)。常驻链 24h 通过,应用级 24h 与登录动作可靠性仍未闭合;需 WS/SSE 消费者参与重跑并修正默认登录查询。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。", "evidence_paths": ["docs/acceptance/2026-11-25-feat-007-n5-release.md", "scripts/n5/verify-release.ps1", "scripts/n5/preflight.ps1", "scripts/n5/attach.ps1", "scripts/n5/n5_soak.py", "docs/plans/2026-10-09-gitnexus-plan-caligo-snowluma-capability-parity.md"], "done_criteria": ["正常入口无需每消息交互", "core/QQ 重启、断链/慢客户端矩阵通过", "未知版本零 native 调用,停止边界如实", "24h 单账号验收及启动包证据齐全"] }, diff --git a/progress.md b/progress.md index ef67222a..4f1f17a8 100644 --- a/progress.md +++ b/progress.md @@ -2,7 +2,7 @@ ## Current State -2026-11-25 feat-007 N5 启动包/未知版本门与 2h 现场观察(issue #16):新增 `scripts/n5/verify-release.ps1`,按 CI 同源脚本构建并打包 default release,校验 zip sidecar、`build-info.json` 的 commit/version/target/mode/entrypoint 与包内逐文件 SHA-256;解压后的 packaged daemon 两次启动均回答 `get_version_info`(retcode 0),无 bridge 时 `get_login_info` 诚实返回 1502,控制停止后 journal 保留;篡改 `QQ.exe` 哈希后 `verify-manifest` 与 `qq-entry` 均在 gate 1 拒绝且不产生 report,默认构建 `inject` 先被 K4-D0 拒绝。固定构建 `caligo.exe` SHA-256 `820781DB…57CE5`、`caligo_bridge.dll` `1EBF6E35…44FC`。现场 2h(本轮零发送):新 QQ 主根 `26620`(创建 `2026-11-25T12:03:11.4979693Z`,登记账号 B)通过固定 manifest/模块、PE/backend 审计与唯一 Environment 后一次 attach;117 个采样、`version`/`status`/`login` 351/351 成功、0 探测失败;30/60/90 分钟 3/3 次 kill core 并以同 journal/pipe/token 重启,恢复 1.56/1.53/1.55s、journal 完整帧前缀保留、bridge 未重新 attach;期间 495 条真实入站事件,`event_seq` 1–495 无缺口、495 个唯一 native ID、0 重复,generation 始终 1;daemon working set 7.7→14.6 MiB、handles 102→102,控制停止 daemon 后默认 bridge 保留、QQ 响应。2h 样本不证明 24h、QQ 重启后新代次重绑或真实 TCP 背压;`CoreStopped` 后同一代次不能重新 attach,24h 需新新鲜 QQ。随后在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并于 `14:56:45Z` 启动 24h soak。attempt 1 在约 8h 处 incomplete 停止(`2026-11-25T23:00:15Z`):479 samples、version/status 958/958 成功、journal 持续增长到 4,409,381 bytes,但 `get_login_info` 从 `15:19:49Z` 起长期返回 1502(456 次);第 2 次 core 重启(`22:56:46Z`)后 daemon 启动、journal 继续增长,但登录查询 188s 超时,harness 判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实返回,不应作为常驻链失败或重启恢复唯一信号;`n5_soak.py` 已改为 version/status 作为探测与恢复信号、登录查询单独计数并保留 1502,离线 rehearsal(18s、含一次 core 重启)通过。24h 门未通过;原定 `2026-11-26T23:10` 的到点任务已取消。修正判据后,attempt 2 于 `2026-11-25T23:33:25Z` 在新主根 `43444`(创建 `2026-11-25T23:31:19.6213631Z`,账号 B)上启动(零发送,version/status 驱动恢复与探测,登录 1502 单独计数,+2h/+8h/+16h 各一次 core 重启,预计 `2026-11-26T23:33:25Z` 结束);新定时核验任务 `schedule-5aeec657-a229-43d2-8969-f6e7186fffa2` 在 `2026-11-27T07:50+08:00` 执行。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/`、`feat007-n5-24h-20261125-unbound/` 与 `feat007-n5-24h-20261126-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) +2026-11-25 feat-007 N5 启动包/未知版本门与 2h 现场观察(issue #16):新增 `scripts/n5/verify-release.ps1`,按 CI 同源脚本构建并打包 default release,校验 zip sidecar、`build-info.json` 的 commit/version/target/mode/entrypoint 与包内逐文件 SHA-256;解压后的 packaged daemon 两次启动均回答 `get_version_info`(retcode 0),无 bridge 时 `get_login_info` 诚实返回 1502,控制停止后 journal 保留;篡改 `QQ.exe` 哈希后 `verify-manifest` 与 `qq-entry` 均在 gate 1 拒绝且不产生 report,默认构建 `inject` 先被 K4-D0 拒绝。固定构建 `caligo.exe` SHA-256 `820781DB…57CE5`、`caligo_bridge.dll` `1EBF6E35…44FC`。现场 2h(本轮零发送):新 QQ 主根 `26620`(创建 `2026-11-25T12:03:11.4979693Z`,登记账号 B)通过固定 manifest/模块、PE/backend 审计与唯一 Environment 后一次 attach;117 个采样、`version`/`status`/`login` 351/351 成功、0 探测失败;30/60/90 分钟 3/3 次 kill core 并以同 journal/pipe/token 重启,恢复 1.56/1.53/1.55s、journal 完整帧前缀保留、bridge 未重新 attach;期间 495 条真实入站事件,`event_seq` 1–495 无缺口、495 个唯一 native ID、0 重复,generation 始终 1;daemon working set 7.7→14.6 MiB、handles 102→102,控制停止 daemon 后默认 bridge 保留、QQ 响应。2h 样本不证明 24h、QQ 重启后新代次重绑或真实 TCP 背压;`CoreStopped` 后同一代次不能重新 attach,24h 需新新鲜 QQ。随后在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并于 `14:56:45Z` 启动 24h soak。attempt 1 在约 8h 处 incomplete 停止(`2026-11-25T23:00:15Z`):479 samples、version/status 958/958 成功、journal 持续增长到 4,409,381 bytes,但 `get_login_info` 从 `15:19:49Z` 起长期返回 1502(456 次);第 2 次 core 重启(`22:56:46Z`)后 daemon 启动、journal 继续增长,但登录查询 188s 超时,harness 判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实返回,不应作为常驻链失败或重启恢复唯一信号;`n5_soak.py` 已改为 version/status 作为探测与恢复信号、登录查询单独计数并保留 1502,离线 rehearsal(18s、含一次 core 重启)通过。24h 门未通过;原定 `2026-11-26T23:10` 的到点任务已取消。修正判据后,attempt 2 于 `2026-11-25T23:33:25Z` 在新主根 `43444`(创建 `2026-11-25T23:31:19.6213631Z`,账号 B)上重跑并完整跑满 86,420s:1438 个采样,version/status 2876/2876 成功,3/3 次 core 崩溃重启恢复(0.18/0.18/0.19s)、journal 完整帧前缀保留,attach 登录成功,控制停止后 bridge 保留、QQ 响应,daemon working set 7.7→~10 MiB、handles ~105 稳定。但 journal 3,020,642 bytes 含 896 个 Event(`event_seq` 1–896 无缺口、0 重复)和 **13,234 条 Gap**(本轮无 OneBot WS/SSE/POST 消费者,事件队列满后的有界拒绝),因此不是应用级 24h;`get_login_info` 1438 次中 215 次成功、265 次 1502、958 次 10s 超时(锁屏/重启后 default 动作走 native query),是待修产品可靠性缺陷。常驻链 24h 通过、应用级 24h 与登录动作可靠性仍未闭合;需 WS/SSE 消费者参与并修正默认登录查询后另行现场复验。原定时任务已取消。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/`、`feat007-n5-24h-20261125-unbound/` 与 `feat007-n5-24h-20261126-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) 2026-11-24 feat-006 现场 attempt 2(通过,单构建,issue #15):新 QQ `31584`(创建 `2026-11-24T13:40:42.5671257Z`,登记账号 B)通过 preflight,一次 attach,`get_login_info` 返回同一账号。对端 A 发送私聊 36 与群 41,NoneBot 反向 WS 收到并各回复一次(37/42),应用与 Caligo `get_msg` 均成功;账本保存 36/37/41/42,发送方 A/B 正确;同一 36/41 同时有签名通过的 HTTP POST 与正向 WS 证据。慢阶段 90 在 8 秒慢 POST、5 秒超时下仍到达应用(慢 POST 积压后约 38 秒),daemon 记录 23 次 POST 失败、66 次送达、0 丢弃,非读取 WS 客户端不影响应用连接;该阶段自动回复请求 `onebot-85939363ae79fe15-4` 以 `DeliveryUnknown` 结束(账本另存自发消息 106),未重发;操作者确认 A 已收到该慢回复(106)。控制管道正常停止 daemon;默认生产 bridge 无 research owner-stop(`0xe0`),bridge 保留、QQ 仍响应、未热卸载。原始 runner 的 `app_get_msg` 检查存在 source/outbound ID 比较缺陷,导致 `summary.json` 两项 false negative;`verify-evidence.py` 在不改原 summary、不重发的前提下离线重算,9 项 criteria 全 true、overall pass。feat-006 保持 in-progress(依赖 feat-005 未 done),产品 NOT READY;慢 POST 积压延迟 WS 与慢阶段回复 unknown 列入后续风险。原始材料只在 ignored `local-evidence/feat006-field-20261124-unbound/`。 diff --git a/scripts/n5/n5_soak.py b/scripts/n5/n5_soak.py index 1f65b79f..b8401c90 100644 --- a/scripts/n5/n5_soak.py +++ b/scripts/n5/n5_soak.py @@ -297,7 +297,9 @@ def __init__(self, state: dict, pack: Path, args): self.samples: list[dict] = [] self.restarts: list[dict] = [] self.probe_failures: list[dict] = [] - self.login_unavailable: int = 0 + self.login_1502: int = 0 + self.login_timeout: int = 0 + self.login_error: int = 0 self.attach_login_ok: bool = False self.stop_record: dict = {} self.fatal: str | None = None @@ -461,12 +463,13 @@ def sample(self, index: int, with_hash: bool): self.events.write(json.dumps({"kind": "sample", **record}, ensure_ascii=False) + "\n") self.events.flush() rehearsal = self.state.get("mode") == "rehearsal" - if login_unavailable: - self.login_unavailable += 1 - elif not login.get("ok") and not rehearsal: - self.probe_failures.append( - {"t_utc": record["t_utc"], "kind": "login", "result": sanitize_probe(login)} - ) + if not login.get("ok"): + if login.get("retcode") == 1502: + self.login_1502 += 1 + elif login.get("retcode") is None: + self.login_timeout += 1 + else: + self.login_error += 1 for name, value in (("version", version), ("status", status)): if not value.get("ok") and not (rehearsal and name == "status"): self.probe_failures.append( @@ -585,7 +588,9 @@ def hourly_summary(self, hour_index: int): for name, p in s["probes"].items() if name in ("version", "status") and not p.get("ok") ), - "login_unavailable": sum(1 for s in recent if s.get("login_unavailable")), + "login_unavailable": sum( + 1 for s in recent for name, p in s["probes"].items() if name == "login" and not p.get("ok") + ), "journal_size": recent[-1]["journal"].get("size"), } (self.out / "hourly").mkdir(exist_ok=True) @@ -644,7 +649,10 @@ def final_summary(self, duration_target: float): "probe_failure_samples": self.probe_failures[:20], "login_probe_count": len(login_probes), "login_probe_ok": login_ok, - "login_unavailable": self.login_unavailable, + "login_1502": self.login_1502, + "login_timeout": self.login_timeout, + "login_error": self.login_error, + "login_unavailable": self.login_1502 + self.login_timeout + self.login_error, "attach_login_ok": self.attach_login_ok, "latency_ms": { "median": round(statistics.median(latencies), 2) if latencies else None, @@ -672,7 +680,7 @@ def final_summary(self, duration_target: float): f"- finished: {summary['finished_utc']}", f"- duration: {summary['duration_seconds']:.0f}s (target {summary['duration_target_seconds']:.0f}s)", f"- samples: {summary['samples']}, version/status probes: {summary['probe_ok']}/{summary['probe_count']} ok", - f"- login probes: {summary['login_probe_ok']}/{summary['login_probe_count']} ok; unavailable(1502): {summary['login_unavailable']}", + f"- login probes: {summary['login_probe_ok']}/{summary['login_probe_count']} ok; 1502={summary['login_1502']}, timeout={summary['login_timeout']}, other={summary['login_error']}", f"- daemon working set first/last/max: {daemon_summary.get('working_set_first')}/{daemon_summary.get('working_set_last')}/{daemon_summary.get('working_set_max')}", f"- daemon handles first/last/max: {daemon_summary.get('handles_first')}/{daemon_summary.get('handles_last')}/{daemon_summary.get('handles_max')}", f"- core restarts: {len(self.restarts)}", diff --git a/session-handoff.md b/session-handoff.md index c36f0e12..8fc96773 100644 --- a/session-handoff.md +++ b/session-handoff.md @@ -1,6 +1,6 @@ # Session handoff -2026-11-25 feat-007 N5 离线启动包/未知版本门 + 2h 现场观察通过(issue #16):`scripts/n5/verify-release.ps1` 的 default release 打包、sidecar/build-info/包内哈希、两次 packaged daemon 启动与诚实无 bridge 登录失败、篡改 manifest 的 gate 1 拒绝均 pass;固定 `caligo.exe` `820781DB…57CE5`、bridge `1EBF6E35…44FC`。现场新 QQ `26620`(创建 `2026-11-25T12:03:11.4979693Z`,账号 B)一次 attach,零发送;117 samples、351/351 查询成功、3/3 次 core 崩溃重启约 1.5s 恢复、495 条入站事件无重复/缺口、控制停止后 bridge 保留。2h 样本不证明 24h/QQ 重启新代次/真实 TCP 背压;`CoreStopped` 后同代次不能重新 attach。已在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并启动 24h soak;attempt 1 在约 8h 处 incomplete(`2026-11-25T23:00:15Z`):version/status 958/958 成功、journal 持续增长,但 `get_login_info` 从 `15:19:49Z` 起长期返回 1502(456 次),第 2 次 core 重启后登录查询 188s 超时触发 fatal。已确认 1502 是 QQ 锁屏/会话不可用时的诚实返回;`n5_soak.py` 已改为 version/status 作为探测与恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 1 未通过,原定时核验任务已取消。修正判据后 attempt 2 于 `2026-11-25T23:33:25Z` 在新主根 `43444`(创建 `2026-11-25T23:31:19.6213631Z`,账号 B)启动,预计 `2026-11-26T23:33:25Z` 结束;新定时核验任务 `schedule-5aeec657-a229-43d2-8969-f6e7186fffa2` 在 `2026-11-27T07:50+08:00` 执行,不自动关闭 issue #16。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/`、`feat007-n5-24h-20261125-unbound/` 与 `feat007-n5-24h-20261126-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) +2026-11-25 feat-007 N5 离线启动包/未知版本门 + 2h 现场观察通过(issue #16):`scripts/n5/verify-release.ps1` 的 default release 打包、sidecar/build-info/包内哈希、两次 packaged daemon 启动与诚实无 bridge 登录失败、篡改 manifest 的 gate 1 拒绝均 pass;固定 `caligo.exe` `820781DB…57CE5`、bridge `1EBF6E35…44FC`。现场新 QQ `26620`(创建 `2026-11-25T12:03:11.4979693Z`,账号 B)一次 attach,零发送;117 samples、351/351 查询成功、3/3 次 core 崩溃重启约 1.5s 恢复、495 条入站事件无重复/缺口、控制停止后 bridge 保留。2h 样本不证明 24h/QQ 重启新代次/真实 TCP 背压;`CoreStopped` 后同代次不能重新 attach。已在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并启动 24h soak;attempt 1 在约 8h 处 incomplete(`2026-11-25T23:00:15Z`):version/status 958/958 成功、journal 持续增长,但 `get_login_info` 从 `15:19:49Z` 起长期返回 1502(456 次),第 2 次 core 重启后登录查询 188s 超时触发 fatal。已确认 1502 是 QQ 锁屏/会话不可用时的诚实返回;`n5_soak.py` 已改为 version/status 作为探测与恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 1 未通过,原定时核验任务已取消。修正判据后 attempt 2 于 `2026-11-25T23:33:25Z` 在新主根 `43444`(创建 `2026-11-25T23:31:19.6213631Z`,账号 B)重跑,完整跑满 86,420s:version/status 2876/2876 成功、3/3 次 core 重启恢复(约 0.2s)、bridge 保留、QQ 响应、内存/句柄稳定;但 journal 含 13,234 条 Gap(本轮无 OneBot 事件消费者,队列满后的有界拒绝),`get_login_info` 1438 次中 215 次成功、265 次 1502、958 次 10s 超时。常驻链 24h 通过,应用级 24h 与登录动作可靠性仍未闭合;需 WS/SSE 消费者参与并修正 default 登录查询(应优先返回持久身份或有界失败)后另行现场复验。原定时任务已取消,issue #16 不关闭。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/`、`feat007-n5-24h-20261125-unbound/` 与 `feat007-n5-24h-20261126-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) 2026-11-24 feat-006 现场 attempt 2 通过(issue #15):新 QQ `31584` 一次 attach,NoneBot2 经反向 WS 收到私聊 36 / 群 41,各回复一次(37/42);应用与 Caligo `get_msg` 均成功,账本与发送方一致;同一消息有签名 HTTP POST 与正向 WS 证据。慢阶段 90 在慢 POST/超时下仍到达应用(积压后约 38 秒),daemon 记录 23 failed / 66 delivered / 0 dropped;该阶段自动回复请求 `onebot-85939363ae79fe15-4` 为 `DeliveryUnknown`(账本另存自发消息 106),未重发。控制停止 daemon;默认 bridge 无 research owner-stop(0xe0),bridge 保留、QQ 响应。runner 的 `app_get_msg` 误报已由 `verify-evidence.py` 离线更正,9/9 criteria true。操作者已确认 A 收到 37、42、106;issue #15 按证据关闭;feat-006 保持 in-progress(依赖 feat-005 未 done),慢 POST 积压延迟 WS 投递列为后续风险。证据见 [acceptance §6.2](docs/acceptance/2026-11-24-feat-006-text-mvp.md#62-现场-attempt-2通过单构建)。 From 17f5ec6827fe8651d0a9610b3de2aaf7d4b36467 Mon Sep 17 00:00:00 2001 From: Vegetable <3089665724@qq.com> Date: Fri, 27 Nov 2026 08:57:58 +0800 Subject: [PATCH 06/13] fix(core): cache confirmed login identity across restarts --- crates/caligo-core/src/daemon.rs | 166 ++++++++++++++++++- crates/caligo-core/src/onebot_server.rs | 59 ++++++- crates/caligo-core/tests/onebot_query_lab.rs | 13 +- scripts/n5/n5_soak.py | 80 +++++++++ scripts/n5/preflight.ps1 | 3 + scripts/n5/ws_drain.ps1 | 98 +++++++++++ 6 files changed, 413 insertions(+), 6 deletions(-) create mode 100644 scripts/n5/ws_drain.ps1 diff --git a/crates/caligo-core/src/daemon.rs b/crates/caligo-core/src/daemon.rs index aa0035d7..829a184d 100644 --- a/crates/caligo-core/src/daemon.rs +++ b/crates/caligo-core/src/daemon.rs @@ -8,9 +8,10 @@ //! 前在途项显式 unknown)。core 非正常退出由断连恢复(测试在 recovery_contract)。 use std::collections::VecDeque; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; use std::sync::{Arc, Mutex}; +use std::time::{SystemTime, UNIX_EPOCH}; use serde::{Deserialize, Serialize}; @@ -28,7 +29,7 @@ use crate::runtime::{host_identity, AccountActor, NativeResult, RuntimeConfig}; use crate::transport::{ connect_client, generate_token, token_hex, PipeConnection, PipeServer, TransportError, }; -use caligo_model::capability::{positive_decimal, HostQuery, QueryOutcome, QueryScope}; +use caligo_model::capability::{positive_decimal, HostQuery, LoginInfo, QueryOutcome, QueryScope}; use caligo_model::{ Direction, EventSource, MsgEvent, NativeMessageId, SendTextRequest, SessionIdentity, }; @@ -141,6 +142,42 @@ pub struct DaemonConfig { pub test_fault_break_bridge_after_result: bool, } +/// Durable default-login cache. +/// +/// `get_login_info` without `no_cache` must not depend on a live native query: +/// a locked QQ can leave that query unanswered while the bridge and event chain +/// stay healthy. The last successful LoginInfo/SelfProfile answer is persisted +/// in the account directory and returned by default after a core restart. +#[derive(Debug, Clone, Serialize, Deserialize)] +struct LoginCacheFile { + v: u32, + account: String, + user_id: String, + nickname: String, + updated_unix_ms: u64, +} + +fn unix_ms_now() -> u64 { + SystemTime::now() + .duration_since(UNIX_EPOCH) + .map(|d| d.as_millis().min(u128::from(u64::MAX)) as u64) + .unwrap_or(0) +} + +fn valid_login_cache(account: &str, cache: &LoginCacheFile) -> bool { + cache.v == 1 + && cache.account == account + && cache.user_id.parse::().is_ok_and(|id| id > 0) + && !cache.nickname.trim().is_empty() + && cache.nickname.len() <= 4096 +} + +fn load_login_cache(account: &str, path: &Path) -> Option { + let bytes = std::fs::read(path).ok()?; + let cache: LoginCacheFile = serde_json::from_slice(&bytes).ok()?; + valid_login_cache(account, &cache).then_some(cache) +} + /// 常驻 core(LAB 形态;计划 §7-D5)。 pub struct Daemon { pub(crate) voice_media: Option, @@ -164,6 +201,8 @@ pub struct Daemon { pub(crate) bridge_wake: Arc, api_request_seq: AtomicU64, query_broker: CapabilityBroker, + login_cache: Mutex>, + login_cache_path: PathBuf, } /// Every return path (including wire errors) releases ephemeral query waiters. @@ -200,6 +239,8 @@ impl Daemon { } _ => None, }; + let login_cache_path = config.journal_path.with_file_name("login.private.json"); + let login_cache = load_login_cache(&config.account, &login_cache_path); let (actor, _report) = match message_store { Some(store) => AccountActor::open_with_message_store( config.journal_path.clone(), @@ -230,10 +271,54 @@ impl Daemon { bridge_wake: Arc::new(AtomicBool::new(false)), api_request_seq: AtomicU64::new(1), query_broker: CapabilityBroker::default(), + login_cache: Mutex::new(login_cache), + login_cache_path, config, })) } + /// Last confirmed account identity, persisted across core restarts. + pub fn cached_login_info(&self) -> Option { + let guard = self.login_cache.lock().ok()?; + let cache = guard.as_ref()?; + Some(LoginInfo { + user_id: cache.user_id.clone(), + nickname: cache.nickname.clone(), + online: true, + }) + } + + /// Cache a successful LoginInfo/SelfProfile answer for default + /// `get_login_info`. Persistence is best-effort; a failed write keeps the + /// in-memory value and is never reported as a successful native query. + pub fn remember_login_info(&self, user_id: &str, nickname: &str) { + let Ok(id) = user_id.parse::() else { + return; + }; + if id == 0 { + return; + } + if nickname.trim().is_empty() || nickname.len() > 4096 { + return; + } + let cache = LoginCacheFile { + v: 1, + account: self.config.account.clone(), + user_id: user_id.to_string(), + nickname: nickname.to_string(), + updated_unix_ms: unix_ms_now(), + }; + if !valid_login_cache(&self.config.account, &cache) { + return; + } + if let Ok(mut guard) = self.login_cache.lock() { + *guard = Some(cache.clone()); + } + if let Ok(bytes) = serde_json::to_vec(&cache) { + let _ = std::fs::write(&self.login_cache_path, bytes); + } + } + /// (bridge, control) 管道名。前缀可以是短名(自动补 `\.\pipe\`) /// 或完整路径 —— 规避跨 shell 传参的反斜杠转换问题。 pub fn pipe_names(&self) -> (String, String) { @@ -1486,6 +1571,11 @@ impl StoreReader for Daemon { } fn login_info(&self) -> Option<(u64, String)> { + if let Some(info) = self.cached_login_info() { + if let Ok(user_id) = info.user_id.parse::() { + return Some((user_id, info.nickname)); + } + } self.actor.lock().ok()?.login_info() } @@ -1668,3 +1758,75 @@ impl BridgeClient { self.stream.recv_json(&self.conn, &AtomicBool::new(false)) } } + +#[cfg(test)] +mod login_cache_tests { + use super::*; + + fn temp_dir(tag: &str) -> PathBuf { + let dir = std::env::temp_dir().join(format!( + "caligo-{tag}-{}-{}", + std::process::id(), + unix_ms_now() + )); + std::fs::create_dir_all(&dir).expect("temp dir"); + dir + } + + fn config(dir: &Path) -> DaemonConfig { + DaemonConfig { + pipe_prefix: format!("caligo-login-test-{}", unix_ms_now()), + journal_path: dir.join("journal.jsonl"), + module_baseline: "test".into(), + account: "1694717255".into(), + core_build: "test".into(), + expect_client_pid: 0, + runtime: RuntimeConfig::default(), + test_fault_break_bridge_after_hello: false, + test_fault_break_bridge_after_result: false, + } + } + + #[test] + fn login_cache_is_default_and_survives_restart() { + let dir = temp_dir("login-cache"); + let daemon = Daemon::start(config(&dir)).expect("first daemon"); + assert!(daemon.cached_login_info().is_none()); + daemon.remember_login_info("1694717255", "nick"); + let cached = daemon.cached_login_info().expect("cached"); + assert_eq!(cached.user_id, "1694717255"); + assert_eq!(cached.nickname, "nick"); + drop(daemon); + + let daemon = Daemon::start(config(&dir)).expect("second daemon"); + let cached = daemon.cached_login_info().expect("reloaded cache"); + assert_eq!(cached.user_id, "1694717255"); + assert_eq!(cached.nickname, "nick"); + assert_eq!( + StoreReader::login_info(daemon.as_ref()), + Some((1694717255, "nick".to_string())) + ); + drop(daemon); + std::fs::remove_dir_all(&dir).ok(); + } + + #[test] + fn login_cache_rejects_invalid_identity_and_account_drift() { + let dir = temp_dir("login-cache-invalid"); + let daemon = Daemon::start(config(&dir)).expect("daemon"); + daemon.remember_login_info("0", "nick"); + assert!(daemon.cached_login_info().is_none()); + daemon.remember_login_info("1694717255", ""); + assert!(daemon.cached_login_info().is_none()); + + let mut other = config(&dir); + other.account = "10001".into(); + daemon.remember_login_info("1694717255", "nick"); + assert!(dir.join("login.private.json").exists()); + drop(daemon); + let drifted = Daemon::start(other).expect("drifted daemon"); + assert!(drifted.cached_login_info().is_none()); + drop(drifted); + std::fs::remove_dir_all(&dir).ok(); + } +} diff --git a/crates/caligo-core/src/onebot_server.rs b/crates/caligo-core/src/onebot_server.rs index ad62ab4d..2bae2414 100644 --- a/crates/caligo-core/src/onebot_server.rs +++ b/crates/caligo-core/src/onebot_server.rs @@ -8,7 +8,7 @@ use crate::daemon::Daemon; use crate::media_tool::{MediaTool, StopToken}; use crate::onebot::{handle_action_with_queries, QueryBackend}; use crate::onebot_http::{serve_parallel, DEFAULT_MAX_BODY}; -use caligo_model::capability::{HostQuery, QueryOutcome}; +use caligo_model::capability::{HostQuery, QueryData, QueryOutcome}; use caligo_model::onebot_traits::{SendDisposition, SendPayload, SendSink, SendTarget}; use caligo_model::{ActionState, SessionKey, SessionKind}; use std::net::TcpListener; @@ -61,7 +61,25 @@ impl DaemonQueryBackend { impl QueryBackend for DaemonQueryBackend { fn query_host(&self, query: HostQuery, timeout: Duration) -> QueryOutcome { - self.daemon.query_host(query, timeout) + // Default get_login_info must be available after a core restart even + // when a locked QQ leaves the native LoginInfo query unanswered. The + // durable cache is only a cache: no_cache/SelfProfile still queries. + if matches!(query, HostQuery::LoginInfo) { + if let Some(info) = self.daemon.cached_login_info() { + return QueryOutcome::Success(QueryData::LoginInfo(info)); + } + } + let outcome = self.daemon.query_host(query, timeout); + match &outcome { + QueryOutcome::Success(QueryData::LoginInfo(info)) => { + self.daemon.remember_login_info(&info.user_id, &info.nickname); + } + QueryOutcome::Success(QueryData::SelfProfile(info)) => { + self.daemon.remember_login_info(&info.user_id, &info.nickname); + } + _ => {} + } + outcome } fn voice_media(&self) -> Option<(&MediaTool, StopToken)> { @@ -221,6 +239,43 @@ pub fn bind_loopback(address: &str) -> std::io::Result { mod tests { use super::*; + #[test] + fn cached_login_short_circuits_the_native_query() { + let dir = std::env::temp_dir().join(format!( + "caligo-login-backend-{}-{}", + std::process::id(), + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .map(|d| d.as_nanos()) + .unwrap_or(0) + )); + std::fs::create_dir_all(&dir).expect("temp dir"); + let config = crate::daemon::DaemonConfig { + pipe_prefix: format!("caligo-login-backend-{}", std::process::id()), + journal_path: dir.join("journal.jsonl"), + module_baseline: "test".into(), + account: "1694717255".into(), + core_build: "test".into(), + expect_client_pid: 0, + runtime: crate::runtime::RuntimeConfig::default(), + test_fault_break_bridge_after_hello: false, + test_fault_break_bridge_after_result: false, + }; + let daemon = Daemon::start(config).expect("daemon"); + daemon.remember_login_info("1694717255", "nick"); + let backend = DaemonQueryBackend::new(daemon.clone()); + match backend.query_host(HostQuery::LoginInfo, Duration::from_millis(1)) { + QueryOutcome::Success(QueryData::LoginInfo(info)) => { + assert_eq!(info.user_id, "1694717255"); + assert_eq!(info.nickname, "nick"); + } + other => panic!("cached login was not served: {other:?}"), + } + drop(backend); + drop(daemon); + std::fs::remove_dir_all(&dir).ok(); + } + #[test] fn listener_accepts_ephemeral_loopback_and_rejects_external_bind() { let listener = bind_loopback("127.0.0.1:0").unwrap(); diff --git a/crates/caligo-core/tests/onebot_query_lab.rs b/crates/caligo-core/tests/onebot_query_lab.rs index f916b886..b15ae10b 100644 --- a/crates/caligo-core/tests/onebot_query_lab.rs +++ b/crates/caligo-core/tests/onebot_query_lab.rs @@ -695,8 +695,8 @@ mod normal_pipe { ), ( "get_login_info", - json!({}), - HostQuery::LoginInfo, + json!({"no_cache":true}), + HostQuery::SelfProfile, QueryOutcome::PermissionDenied, Value::Null, RET_PERMISSION_DENIED, @@ -738,6 +738,15 @@ mod normal_pipe { assert_eq!(response.echo, json!({"action":action})); assert_eq!(lab.daemon.pending_query_count(), 0); } + // A default get_login_info after one confirmed SelfProfile answer is + // served from the durable login cache without another host query. + let cached = handler("get_login_info", &json!({}), Value::Null); + assert_eq!(cached.retcode, 0); + assert_eq!( + cached.data, + json!({"user_id":10001,"nickname":"Fresh pipe self"}) + ); + assert_eq!(lab.daemon.pending_query_count(), 0); let journal = std::fs::read_to_string(lab.dir.join("journal.log")).unwrap_or_default(); assert!( !journal.contains("query-"), diff --git a/scripts/n5/n5_soak.py b/scripts/n5/n5_soak.py index b8401c90..6d804ccd 100644 --- a/scripts/n5/n5_soak.py +++ b/scripts/n5/n5_soak.py @@ -29,6 +29,8 @@ import uuid from pathlib import Path +from analyze_journal import summarize as summarize_journal + CREATE_NO_WINDOW = 0x08000000 PROCESS_QUERY_LIMITED_INFORMATION = 0x1000 STILL_ACTIVE = 259 @@ -307,6 +309,10 @@ def __init__(self, state: dict, pack: Path, args): self.bridge_final: bool | None = None self.journal_initial: dict | None = None self.journal_final: dict | None = None + self.ws_drain_proc: subprocess.Popen | None = None + self.ws_drain_summary_path: Path | None = None + self.ws_drain_stop_path: Path | None = None + self.ws_drain_summary: dict | None = None def log_event(self, kind: str, **fields): record = {"t_utc": utcnow(), "kind": kind, "elapsed_s": round(time.time() - self.started, 2)} @@ -375,6 +381,59 @@ def start_daemon(self, index: int, expect_pid: int | None): self.log_event("daemon_started", pid=proc.pid, http=ready.get("onebot_http"), ws=ready.get("onebot_ws")) return proc, ready + def start_ws_drain(self): + repo = Path(__file__).resolve().parents[2] + script = repo / "scripts/n5/ws_drain.ps1" + self.ws_drain_summary_path = self.out / "ws-drain-summary.private.json" + self.ws_drain_stop_path = self.out / "ws-drain.stop" + events = self.out / "ws-events.private.jsonl" + stdout = self.out / "ws-drain.stdout.private.log" + stderr = self.out / "ws-drain.stderr.private.log" + for path in (self.ws_drain_summary_path, self.ws_drain_stop_path, events, stdout, stderr): + path.unlink(missing_ok=True) + args = [ + "C:\\windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", + "-NoProfile", + "-ExecutionPolicy", + "Bypass", + "-File", + str(script), + "-Port", + str(self.state["ports"]["ws"]), + "-Token", + self.token, + "-Out", + str(events), + "-Summary", + str(self.ws_drain_summary_path), + "-StopFile", + str(self.ws_drain_stop_path), + "-MaxHours", + str(float(self.state["duration_hours"]) + 2), + ] + with stdout.open("wb") as out, stderr.open("wb") as err: + self.ws_drain_proc = subprocess.Popen( + args, stdout=out, stderr=err, creationflags=CREATE_NO_WINDOW + ) + self.log_event("ws_drain_started", script=str(script), port=self.state["ports"]["ws"]) + + def stop_ws_drain(self): + if not self.ws_drain_proc: + return + if self.ws_drain_stop_path: + self.ws_drain_stop_path.write_text("stop\n", encoding="ascii") + try: + self.ws_drain_proc.wait(timeout=15) + except subprocess.TimeoutExpired: + self.ws_drain_proc.kill() + self.ws_drain_proc.wait(timeout=10) + if self.ws_drain_summary_path and self.ws_drain_summary_path.exists(): + try: + self.ws_drain_summary = json.loads(self.ws_drain_summary_path.read_text(encoding="utf-8")) + except json.JSONDecodeError: + self.ws_drain_summary = {"error": "invalid ws-drain summary"} + self.log_event("ws_drain_stopped", summary=self.ws_drain_summary) + def wait_login(self, timeout: float = 120.0): deadline = time.time() + timeout last = None @@ -620,6 +679,12 @@ def final_summary(self, duration_target: float): if daemon_summary.get("handles_first") and daemon_summary.get("handles_last"): bounded = bounded and daemon_summary["handles_last"] < daemon_summary["handles_first"] + 512 rehearsal = self.state.get("mode") == "rehearsal" + journal_summary = {} + try: + journal_summary = summarize_journal(Path(self.state["journal"])) + except Exception as error: # noqa: BLE001 - record analyzer failure in evidence + journal_summary = {"error": f"{type(error).__name__}: {error}"} + event_consumer = self.ws_drain_summary or {} criteria = { "resident_duration": duration >= duration_target - 180, "probes_answered": probe_ok > 0 and len(self.probe_failures) == 0, @@ -630,6 +695,11 @@ def final_summary(self, duration_target: float): "qq_responsive_after_stop": True if rehearsal else qq_ok, "process_growth_bounded": bounded, } + if self.state.get("require_event_consumer"): + criteria["event_consumer_active"] = bool( + event_consumer.get("connects", 0) > 0 and event_consumer.get("messages", 0) > 0 + ) + criteria["no_event_queue_gaps"] = journal_summary.get("kinds", {}).get("Gap", 0) == 0 overall = "pass" if all(criteria.values()) else "fail" if duration_target - duration > 180: overall = "incomplete" @@ -664,6 +734,8 @@ def final_summary(self, duration_target: float): "restarts": self.restarts, "journal_initial": self.journal_initial, "journal_final": self.journal_final, + "journal_summary": journal_summary, + "event_consumer": event_consumer, "stop": self.stop_record, "bridge_initial": self.bridge_initial, "bridge_final": self.bridge_final, @@ -685,6 +757,8 @@ def final_summary(self, duration_target: float): f"- daemon handles first/last/max: {daemon_summary.get('handles_first')}/{daemon_summary.get('handles_last')}/{daemon_summary.get('handles_max')}", f"- core restarts: {len(self.restarts)}", f"- bridge initial/final: {self.bridge_initial}/{self.bridge_final}", + f"- event consumer: {json.dumps(event_consumer, ensure_ascii=False)}", + f"- journal kinds: {json.dumps(journal_summary.get('kinds', {}), ensure_ascii=False)}", f"- criteria: {json.dumps(criteria, ensure_ascii=False)}", f"- overall: **{overall}**", ] @@ -836,6 +910,8 @@ def main() -> int: raise RuntimeError(f"login was not confirmed after attach: {login}") soak.attach_login_ok = True soak.log_event("bridge_attached", bridge_mapped=soak.bridge_initial, login_ok=True) + if state.get("require_event_consumer"): + soak.start_ws_drain() soak.journal_initial = soak.journal_state(True) target_seconds = float(state["duration_hours"]) * 3600 @@ -868,6 +944,10 @@ def main() -> int: finally: try: stop_error = None + try: + soak.stop_ws_drain() + except Exception as error: # noqa: BLE001 - record, never mask the soak result + soak.log_event("ws_drain_stop_failed", error=f"{type(error).__name__}: {error}") if soak.daemon_proc and soak.daemon_proc.poll() is None: try: soak.stop_daemon(force=True) diff --git a/scripts/n5/preflight.ps1 b/scripts/n5/preflight.ps1 index c78ce4b2..54e947bd 100644 --- a/scripts/n5/preflight.ps1 +++ b/scripts/n5/preflight.ps1 @@ -8,6 +8,7 @@ param( [double]$DurationHours = 24, [int]$SampleSeconds = 60, [int[]]$RestartAtMinutes = @(120, 480, 960), + [switch]$RequireEventConsumer, [switch]$Rehearse ) @@ -84,6 +85,7 @@ $state = [ordered]@{ duration_hours = $DurationHours sample_seconds = $SampleSeconds restart_at_minutes = @($RestartAtMinutes) + require_event_consumer = [bool]$RequireEventConsumer } if ($Rehearse) { @@ -187,6 +189,7 @@ $preparation = [ordered]@{ duration_hours = $state.duration_hours sample_seconds = $state.sample_seconds restart_at_minutes = $state.restart_at_minutes + require_event_consumer = $state.require_event_consumer expected = [ordered]@{ resident = 'one daemon and one admitted bridge; OneBot get_version_info/get_status/get_login_info continue to answer without per-message CLI interaction' restart = 'each injected core crash is followed by the same journal/pipe/token, bridge reconnects, and login/query becomes available again' diff --git a/scripts/n5/ws_drain.ps1 b/scripts/n5/ws_drain.ps1 new file mode 100644 index 00000000..a2ae62e9 --- /dev/null +++ b/scripts/n5/ws_drain.ps1 @@ -0,0 +1,98 @@ +param( + [Parameter(Mandatory = $true)][int]$Port, + [Parameter(Mandatory = $true)][string]$Token, + [Parameter(Mandatory = $true)][string]$Out, + [Parameter(Mandatory = $true)][string]$Summary, + [string]$StopFile = '', + [double]$MaxHours = 26 +) + +# Bounded OneBot forward-WS event consumer for the N5 soak. +# +# It connects to /event, counts messages/bytes, reconnects on close, and writes +# only metadata (no message bodies). It is a test consumer, not a production +# client: it does not issue actions, does not replay unknown requests, and does +# not claim event delivery for a disconnected window. + +$ErrorActionPreference = 'Stop' +Set-StrictMode -Version Latest +$started = [DateTime]::UtcNow +$deadline = $started.AddHours($MaxHours) +$connects = 0 +$messages = 0 +$bytes = 0 +$disconnects = 0 +$errors = 0 +$stopReason = 'deadline' +$writer = New-Object IO.StreamWriter($Out, $true, [Text.UTF8Encoding]::new($false)) +$writer.AutoFlush = $true +$errorLog = "$Summary.err.log" + +function Save-Summary { + $value = [ordered]@{ + schema = 'caligo/n5-ws-drain/1' + port = $Port + started_utc = $started.ToString('o') + finished_utc = [DateTime]::UtcNow.ToString('o') + connects = $connects + messages = $messages + bytes = $bytes + disconnects = $disconnects + errors = $errors + stop_reason = $stopReason + } + [IO.File]::WriteAllText($Summary, ($value | ConvertTo-Json), [Text.UTF8Encoding]::new($false)) +} + +try { + while ([DateTime]::UtcNow -lt $deadline) { + if ($StopFile -and (Test-Path -LiteralPath $StopFile)) { $stopReason = 'stop-file'; break } + $ws = [Net.WebSockets.ClientWebSocket]::new() + try { + $ws.Options.SetRequestHeader('Authorization', "Bearer $Token") + $ws.Options.KeepAliveInterval = [TimeSpan]::FromSeconds(20) + $uri = [Uri]("ws://127.0.0.1:$Port/event") + $cts = [Threading.CancellationTokenSource]::new(10000) + [void]$ws.ConnectAsync($uri, $cts.Token).GetAwaiter().GetResult() + $connects++ + $buffer = New-Object byte[] 65536 + $segment = [ArraySegment[byte]]::new($buffer) + while ($true) { + if ($StopFile -and (Test-Path -LiteralPath $StopFile)) { $stopReason = 'stop-file'; break } + $cts = [Threading.CancellationTokenSource]::new(5000) + try { + $result = $ws.ReceiveAsync($segment, $cts.Token).GetAwaiter().GetResult() + } catch [System.OperationCanceledException] { + if ($ws.State -ne [Net.WebSockets.WebSocketState]::Open) { break } + continue + } catch { + $errors++ + Add-Content -LiteralPath $errorLog -Value ("receive: " + $_.Exception.Message) + break + } + if ($result.MessageType -eq [Net.WebSockets.WebSocketMessageType]::Close) { break } + if ($result.Count -gt 0) { + $bytes += $result.Count + } + if ($result.EndOfMessage) { + $messages++ + $writer.WriteLine((@{ t_utc = [DateTime]::UtcNow.ToString('o'); bytes = $result.Count } | ConvertTo-Json -Compress)) + } + } + } catch { + $errors++ + Add-Content -LiteralPath $errorLog -Value ("connect: " + $_.Exception.Message) + } finally { + if ($ws) { + try { $ws.Dispose() } catch { } + } + } + $disconnects++ + Start-Sleep -Milliseconds 500 + } +} finally { + Save-Summary + $writer.Dispose() +} + +Write-Output ('ws-drain messages={0} bytes={1} connects={2} disconnects={3} errors={4} stop={5}' -f $messages, $bytes, $connects, $disconnects, $errors, $stopReason) From 8170a6a0e4b91ad8c1d853ae7aedb28e4b5ccbe1 Mon Sep 17 00:00:00 2001 From: Vegetable <3089665724@qq.com> Date: Fri, 27 Nov 2026 09:40:15 +0800 Subject: [PATCH 07/13] docs(feat-007): record final 24h build and checks --- .../2026-11-25-feat-007-n5-release.md | 25 ++++++++++++------- feature_list.json | 2 +- progress.md | 2 ++ session-handoff.md | 2 ++ 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/docs/acceptance/2026-11-25-feat-007-n5-release.md b/docs/acceptance/2026-11-25-feat-007-n5-release.md index 25fa3f75..c5e29325 100644 --- a/docs/acceptance/2026-11-25-feat-007-n5-release.md +++ b/docs/acceptance/2026-11-25-feat-007-n5-release.md @@ -32,8 +32,8 @@ | 项目 | 结果 | |---|---| -| 构建 | commit `8a8eabc`;`caligo.exe` SHA-256 `820781DB…57CE5`,`caligo_bridge.dll` SHA-256 `1EBF6E35…44FC` | -| 启动包 | `caligo-0.3.0-windows-x64.zip`,sidecar SHA-256 `10fc66EE…BB6B` 与包哈希一致;`build-info.json` 的 commit/version/target/mode/research/entrypoint 均匹配,4 个包内文件哈希逐项匹配 | +| 构建 | commit `17f5ec6`;`caligo.exe` SHA-256 `4C9B057D…02BB`,`caligo_bridge.dll` SHA-256 `659CE4D1…CE14` | +| 启动包 | `caligo-0.3.0-windows-x64.zip`,sidecar SHA-256 `13FE366F…0D0D` 与包哈希一致;`build-info.json` 的 commit/version/target/mode/research/entrypoint 均匹配,4 个包内文件哈希逐项匹配 | | 包内启动 | `get_version_info` retcode 0;无 bridge 时 `get_login_info` retcode 1502(诚实失败,不伪造登录);两次启动后 journal SHA-256 不变(空账本) | | 未知版本 | 篡改 `QQ.exe` 哈希:`verify-manifest` exit 2;`qq-entry` exit 2 且 `[gate 1] REJECT`、report 未产生;`inject` exit 3(K4-D0 默认构建禁用)、report 未产生 | | 停止 | packaged daemon 两次均由 `daemon-control ... stop` 正常退出,journal 保留 | @@ -107,15 +107,22 @@ attach 时仍要求一次登录成功。该修复通过离线 rehearsal(18s, | 登录查询 | 1438 次中 215 次成功、265 次 1502、958 次 10s 超时;QQ 锁屏/会话不可用后 default `get_login_info` 走 native query,重启后长期超时 | | 结论 | **常驻链 24h 通过**(version/status、3/3 重启、bridge、QQ、内存/句柄),但**不是应用级 24h 通过**:本轮没有 OneBot WS/SSE/POST 消费者,事件队列满后 Gap 是预期的有界拒绝;`get_login_info` 默认动作在锁屏/重启后不返回缓存身份,属于待修的产品可靠性缺陷。综合见包内 `soak-recomputed.json`(`resident-pass-with-open-caveats`) | +### 4.3 24h attempt 3(final build,running) + +针对 §4.2 的两个缺口做了实现修正: + +- **登录缓存**:`get_login_info`(无 `no_cache`)在成功 native/SelfProfile 查询后,把确认身份持久化到账号目录的 `login.private.json`;core 重启后默认动作先返回该持久身份,`no_cache=true` 仍走 native 查询。新增持久化/账号漂移/backend 缓存短路测试。 +- **事件消费者**:新增 `scripts/n5/ws_drain.ps1`,连接 forward WS `/event`,只记录消息数/字节数/重连数(不写正文);soak 在 attach 后启动它,`require_event_consumer` 模式下要求 `event_consumer_active` 且 journal `Gap=0`。 + +最终构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)的启动包/未知版本门见 §2。最终 24h 于 `2026-11-27T01:38:44Z` 在新 QQ 主根上启动,预计 `2026-11-28T01:38:44Z` 结束;到点由本机定时任务核验并更新本节。 + ## 5. 剩余门与边界 -- **24h**:attempt 1 在 8h 处 incomplete(§4.1);修正判据后的 attempt 2 完整跑满 24h - (§4.2),常驻链(version/status、3/3 core 重启、bridge、QQ、内存/句柄)通过。但 - **应用级 24h 未闭合**:本轮没有 OneBot 事件消费者,事件队列满后的 13,234 条 Gap 是有界 - 拒绝、不能当作交付 24h 证据;`get_login_info` 在锁屏/重启后 958 次 10s 超时,默认动作 - 应优先返回持久身份或给出有界失败。上述两项需要实现/构建修正后另行现场复验,并需要至少 - 一个真正的 WS/SSE 消费者参与 24h 运行。重跑通过前不把 N5 24h 门标为完全通过,也不关闭 - issue #16。 +- **24h**:attempt 1 在 8h 处 incomplete(§4.1);attempt 2 完整跑满 24h 但应用级未闭合 + (§4.2:无事件消费者导致 13,234 条 Gap,`get_login_info` 958 次超时)。修正后的 + `17f5ec6` 已新增持久登录缓存与 forward-WS 事件消费者,attempt 3 于 + `2026-11-27T01:38:44Z` 启动(§4.3),结果待到点核验。重跑通过前不把 N5 24h 门标为完全 + 通过,也不关闭 issue #16。 - **QQ 重启**:需要操作者退出并重启 QQ,随后对新 PID/创建时间重新 preflight/attach; 旧代次的请求、映射和回调不得混入新实例。 - **启动包**:本轮为 default 构建;research 构建、真实 QQ 字段与发布 tag 流程是独立验收。 diff --git a/feature_list.json b/feature_list.json index f2f50917..12f80674 100644 --- a/feature_list.json +++ b/feature_list.json @@ -110,7 +110,7 @@ "plan_steps": ["N5"], "dependencies": ["feat-006"], "status": "in-progress", - "evidence": "2026-11-25 离线启动包/未知版本门通过(scripts/n5/verify-release.ps1):default release 构建与 CI 同源打包,zip sidecar、build-info commit/version/target/mode 和包内逐文件 SHA-256 均匹配;解压后 packaged daemon 两次启动均回答 get_version_info、无 bridge 时 get_login_info 诚实返回 1502、控制停止后 journal 保留;篡改 QQ.exe 哈希后 verify-manifest 与 qq-entry 均在 gate 1 拒绝且不产生 report,默认构建的 inject 先被 K4-D0 拒绝。现场 2h 观察通过(零发送、60s 只读探测、30/60/90 分钟 core 崩溃重启):新 QQ 主根一次 attach,117 个采样、351/351 次查询成功、495 条真实入站事件无重复/缺口(event_seq 1–495),3/3 次 core 崩溃重启各约 1.5s 恢复且 journal 完整帧前缀保留,控制停止后默认 bridge 保留、QQ 响应。CoreStopped 后同一代次不能重新 attach,因此在新主根上启动 24h soak;attempt 1 在约 8h 处 incomplete:version/status 探测 958/958 成功、journal 持续增长,但 get_login_info 从 15:19Z 起长期返回 1502(456 次),第 2 次 core 重启后 harness 因登录查询超时判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实结果,不是常驻链失败;harness 已改为 version/status 作为探测与重启恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 2 已完整跑满 86,420s:version/status 2876/2876 成功、3/3 次 core 重启恢复(约 0.2s)、bridge 保留、QQ 响应、内存/句柄稳定,但 journal 含 13,234 条 Gap(本轮无 OneBot 事件消费者,队列满后的有界拒绝),且 get_login_info 1438 次中仅 215 次成功(265 次 1502、958 次 10s 超时,锁屏/重启后默认动作走 native query)。常驻链 24h 通过,应用级 24h 与登录动作可靠性仍未闭合;需 WS/SSE 消费者参与重跑并修正默认登录查询。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。", + "evidence": "2026-11-25 离线启动包/未知版本门通过(scripts/n5/verify-release.ps1):default release 构建与 CI 同源打包,zip sidecar、build-info commit/version/target/mode 和包内逐文件 SHA-256 均匹配;解压后 packaged daemon 两次启动均回答 get_version_info、无 bridge 时 get_login_info 诚实返回 1502、控制停止后 journal 保留;篡改 QQ.exe 哈希后 verify-manifest 与 qq-entry 均在 gate 1 拒绝且不产生 report,默认构建的 inject 先被 K4-D0 拒绝。现场 2h 观察通过(零发送、60s 只读探测、30/60/90 分钟 core 崩溃重启):新 QQ 主根一次 attach,117 个采样、351/351 次查询成功、495 条真实入站事件无重复/缺口(event_seq 1–495),3/3 次 core 崩溃重启各约 1.5s 恢复且 journal 完整帧前缀保留,控制停止后默认 bridge 保留、QQ 响应。CoreStopped 后同一代次不能重新 attach,因此在新主根上启动 24h soak;attempt 1 在约 8h 处 incomplete:version/status 探测 958/958 成功、journal 持续增长,但 get_login_info 从 15:19Z 起长期返回 1502(456 次),第 2 次 core 重启后 harness 因登录查询超时判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实结果,不是常驻链失败;harness 已改为 version/status 作为探测与重启恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 2 已完整跑满 86,420s:version/status 2876/2876 成功、3/3 次 core 重启恢复(约 0.2s)、bridge 保留、QQ 响应、内存/句柄稳定,但 journal 含 13,234 条 Gap(本轮无 OneBot 事件消费者,队列满后的有界拒绝),且 get_login_info 1438 次中仅 215 次成功(265 次 1502、958 次 10s 超时,锁屏/重启后默认动作走 native query)。常驻链 24h 通过,应用级 24h 与登录动作可靠性仍未闭合。随后实现持久登录缓存(默认 get_login_info 返回确认身份,no_cache 仍走 native;core 重启后从 login.private.json 恢复)与 forward-WS 事件消费者(ws_drain.ps1,记录计数不写正文;soak 要求 event_consumer_active 且 journal Gap=0);新构建 17f5ec6(EXE 4C9B057D…02BB、bridge 659CE4D1…CE14)的启动包/未知版本门 PASS,最终 24h 于 2026-11-27T01:38:44Z 启动,预计 2026-11-28T01:38:44Z 结束。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。", "evidence_paths": ["docs/acceptance/2026-11-25-feat-007-n5-release.md", "scripts/n5/verify-release.ps1", "scripts/n5/preflight.ps1", "scripts/n5/attach.ps1", "scripts/n5/n5_soak.py", "docs/plans/2026-10-09-gitnexus-plan-caligo-snowluma-capability-parity.md"], "done_criteria": ["正常入口无需每消息交互", "core/QQ 重启、断链/慢客户端矩阵通过", "未知版本零 native 调用,停止边界如实", "24h 单账号验收及启动包证据齐全"] }, diff --git a/progress.md b/progress.md index 4f1f17a8..f073f3ef 100644 --- a/progress.md +++ b/progress.md @@ -2,6 +2,8 @@ ## Current State +2026-11-27 feat-007 N5 最终 24h 重跑准备(issue #16):24h attempt 2 的缺口已做实现修正——新增持久登录缓存(`get_login_info` 无 `no_cache` 时成功查询后写账号目录 `login.private.json`;core 重启后默认动作先返回持久身份,`no_cache=true` 仍走 native 查询;新增持久化/账号漂移/backend 短路测试)与 forward-WS 事件消费者(`scripts/n5/ws_drain.ps1`,只记消息数/字节数/重连数,不写正文;soak 在 attach 后启动,`require_event_consumer` 模式下要求 `event_consumer_active` 且 journal `Gap=0`)。新构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)的启动包/未知版本门 PASS;`init.ps1 -Mode all` default 509 / research 569、0 failed。最终 24h 于 `2026-11-27T01:38:44Z` 在新 QQ 主根 `33284`(创建 `2026-11-27T01:37:42.0474720Z`,账号 B)启动,带 WS 消费者与登录缓存,+2h/+8h/+16h 各一次 core 重启,预计 `2026-11-28T01:38:44Z` 结束;定时任务 `schedule-7402411b-345a-4f7d-a475-b1671167ceed` 在 `2026-11-28T09:55+08:00` 核验。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-final-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) + 2026-11-25 feat-007 N5 启动包/未知版本门与 2h 现场观察(issue #16):新增 `scripts/n5/verify-release.ps1`,按 CI 同源脚本构建并打包 default release,校验 zip sidecar、`build-info.json` 的 commit/version/target/mode/entrypoint 与包内逐文件 SHA-256;解压后的 packaged daemon 两次启动均回答 `get_version_info`(retcode 0),无 bridge 时 `get_login_info` 诚实返回 1502,控制停止后 journal 保留;篡改 `QQ.exe` 哈希后 `verify-manifest` 与 `qq-entry` 均在 gate 1 拒绝且不产生 report,默认构建 `inject` 先被 K4-D0 拒绝。固定构建 `caligo.exe` SHA-256 `820781DB…57CE5`、`caligo_bridge.dll` `1EBF6E35…44FC`。现场 2h(本轮零发送):新 QQ 主根 `26620`(创建 `2026-11-25T12:03:11.4979693Z`,登记账号 B)通过固定 manifest/模块、PE/backend 审计与唯一 Environment 后一次 attach;117 个采样、`version`/`status`/`login` 351/351 成功、0 探测失败;30/60/90 分钟 3/3 次 kill core 并以同 journal/pipe/token 重启,恢复 1.56/1.53/1.55s、journal 完整帧前缀保留、bridge 未重新 attach;期间 495 条真实入站事件,`event_seq` 1–495 无缺口、495 个唯一 native ID、0 重复,generation 始终 1;daemon working set 7.7→14.6 MiB、handles 102→102,控制停止 daemon 后默认 bridge 保留、QQ 响应。2h 样本不证明 24h、QQ 重启后新代次重绑或真实 TCP 背压;`CoreStopped` 后同一代次不能重新 attach,24h 需新新鲜 QQ。随后在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并于 `14:56:45Z` 启动 24h soak。attempt 1 在约 8h 处 incomplete 停止(`2026-11-25T23:00:15Z`):479 samples、version/status 958/958 成功、journal 持续增长到 4,409,381 bytes,但 `get_login_info` 从 `15:19:49Z` 起长期返回 1502(456 次);第 2 次 core 重启(`22:56:46Z`)后 daemon 启动、journal 继续增长,但登录查询 188s 超时,harness 判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实返回,不应作为常驻链失败或重启恢复唯一信号;`n5_soak.py` 已改为 version/status 作为探测与恢复信号、登录查询单独计数并保留 1502,离线 rehearsal(18s、含一次 core 重启)通过。24h 门未通过;原定 `2026-11-26T23:10` 的到点任务已取消。修正判据后,attempt 2 于 `2026-11-25T23:33:25Z` 在新主根 `43444`(创建 `2026-11-25T23:31:19.6213631Z`,账号 B)上重跑并完整跑满 86,420s:1438 个采样,version/status 2876/2876 成功,3/3 次 core 崩溃重启恢复(0.18/0.18/0.19s)、journal 完整帧前缀保留,attach 登录成功,控制停止后 bridge 保留、QQ 响应,daemon working set 7.7→~10 MiB、handles ~105 稳定。但 journal 3,020,642 bytes 含 896 个 Event(`event_seq` 1–896 无缺口、0 重复)和 **13,234 条 Gap**(本轮无 OneBot WS/SSE/POST 消费者,事件队列满后的有界拒绝),因此不是应用级 24h;`get_login_info` 1438 次中 215 次成功、265 次 1502、958 次 10s 超时(锁屏/重启后 default 动作走 native query),是待修产品可靠性缺陷。常驻链 24h 通过、应用级 24h 与登录动作可靠性仍未闭合;需 WS/SSE 消费者参与并修正默认登录查询后另行现场复验。原定时任务已取消。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/`、`feat007-n5-24h-20261125-unbound/` 与 `feat007-n5-24h-20261126-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) 2026-11-24 feat-006 现场 attempt 2(通过,单构建,issue #15):新 QQ `31584`(创建 `2026-11-24T13:40:42.5671257Z`,登记账号 B)通过 preflight,一次 attach,`get_login_info` 返回同一账号。对端 A 发送私聊 36 与群 41,NoneBot 反向 WS 收到并各回复一次(37/42),应用与 Caligo `get_msg` 均成功;账本保存 36/37/41/42,发送方 A/B 正确;同一 36/41 同时有签名通过的 HTTP POST 与正向 WS 证据。慢阶段 90 在 8 秒慢 POST、5 秒超时下仍到达应用(慢 POST 积压后约 38 秒),daemon 记录 23 次 POST 失败、66 次送达、0 丢弃,非读取 WS 客户端不影响应用连接;该阶段自动回复请求 `onebot-85939363ae79fe15-4` 以 `DeliveryUnknown` 结束(账本另存自发消息 106),未重发;操作者确认 A 已收到该慢回复(106)。控制管道正常停止 daemon;默认生产 bridge 无 research owner-stop(`0xe0`),bridge 保留、QQ 仍响应、未热卸载。原始 runner 的 `app_get_msg` 检查存在 source/outbound ID 比较缺陷,导致 `summary.json` 两项 false negative;`verify-evidence.py` 在不改原 summary、不重发的前提下离线重算,9 项 criteria 全 true、overall pass。feat-006 保持 in-progress(依赖 feat-005 未 done),产品 NOT READY;慢 POST 积压延迟 WS 与慢阶段回复 unknown 列入后续风险。原始材料只在 ignored `local-evidence/feat006-field-20261124-unbound/`。 diff --git a/session-handoff.md b/session-handoff.md index 8fc96773..df7def48 100644 --- a/session-handoff.md +++ b/session-handoff.md @@ -1,5 +1,7 @@ # Session handoff +2026-11-27 feat-007 N5 最终 24h(issue #16):修正 attempt 2 的登录查询与无消费者缺口。新构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)增加持久登录缓存(`login.private.json`;默认 `get_login_info` 走缓存,`no_cache` 走 native)与 forward-WS 事件消费者(`scripts/n5/ws_drain.ps1`,只记录计数)。离线启动包/未知版本门 PASS;`init.ps1 -Mode all` default 509 / research 569、0 failed。最终 24h 于 `2026-11-27T01:38:44Z` 在新主根 `33284`(创建 `2026-11-27T01:37:42.0474720Z`,账号 B)启动,带 WS 消费者与登录缓存,+2h/+8h/+16h 各一次 core 重启,预计 `2026-11-28T01:38:44Z` 结束;定时任务 `schedule-7402411b-345a-4f7d-a475-b1671167ceed` 在 `2026-11-28T09:55+08:00` 核验,不自动关闭 issue #16。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-final-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) + 2026-11-25 feat-007 N5 离线启动包/未知版本门 + 2h 现场观察通过(issue #16):`scripts/n5/verify-release.ps1` 的 default release 打包、sidecar/build-info/包内哈希、两次 packaged daemon 启动与诚实无 bridge 登录失败、篡改 manifest 的 gate 1 拒绝均 pass;固定 `caligo.exe` `820781DB…57CE5`、bridge `1EBF6E35…44FC`。现场新 QQ `26620`(创建 `2026-11-25T12:03:11.4979693Z`,账号 B)一次 attach,零发送;117 samples、351/351 查询成功、3/3 次 core 崩溃重启约 1.5s 恢复、495 条入站事件无重复/缺口、控制停止后 bridge 保留。2h 样本不证明 24h/QQ 重启新代次/真实 TCP 背压;`CoreStopped` 后同代次不能重新 attach。已在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并启动 24h soak;attempt 1 在约 8h 处 incomplete(`2026-11-25T23:00:15Z`):version/status 958/958 成功、journal 持续增长,但 `get_login_info` 从 `15:19:49Z` 起长期返回 1502(456 次),第 2 次 core 重启后登录查询 188s 超时触发 fatal。已确认 1502 是 QQ 锁屏/会话不可用时的诚实返回;`n5_soak.py` 已改为 version/status 作为探测与恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 1 未通过,原定时核验任务已取消。修正判据后 attempt 2 于 `2026-11-25T23:33:25Z` 在新主根 `43444`(创建 `2026-11-25T23:31:19.6213631Z`,账号 B)重跑,完整跑满 86,420s:version/status 2876/2876 成功、3/3 次 core 重启恢复(约 0.2s)、bridge 保留、QQ 响应、内存/句柄稳定;但 journal 含 13,234 条 Gap(本轮无 OneBot 事件消费者,队列满后的有界拒绝),`get_login_info` 1438 次中 215 次成功、265 次 1502、958 次 10s 超时。常驻链 24h 通过,应用级 24h 与登录动作可靠性仍未闭合;需 WS/SSE 消费者参与并修正 default 登录查询(应优先返回持久身份或有界失败)后另行现场复验。原定时任务已取消,issue #16 不关闭。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/`、`feat007-n5-24h-20261125-unbound/` 与 `feat007-n5-24h-20261126-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) 2026-11-24 feat-006 现场 attempt 2 通过(issue #15):新 QQ `31584` 一次 attach,NoneBot2 经反向 WS 收到私聊 36 / 群 41,各回复一次(37/42);应用与 Caligo `get_msg` 均成功,账本与发送方一致;同一消息有签名 HTTP POST 与正向 WS 证据。慢阶段 90 在慢 POST/超时下仍到达应用(积压后约 38 秒),daemon 记录 23 failed / 66 delivered / 0 dropped;该阶段自动回复请求 `onebot-85939363ae79fe15-4` 为 `DeliveryUnknown`(账本另存自发消息 106),未重发。控制停止 daemon;默认 bridge 无 research owner-stop(0xe0),bridge 保留、QQ 响应。runner 的 `app_get_msg` 误报已由 `verify-evidence.py` 离线更正,9/9 criteria true。操作者已确认 A 收到 37、42、106;issue #15 按证据关闭;feat-006 保持 in-progress(依赖 feat-005 未 done),慢 POST 积压延迟 WS 投递列为后续风险。证据见 [acceptance §6.2](docs/acceptance/2026-11-24-feat-006-text-mvp.md#62-现场-attempt-2通过单构建)。 From e9db64a7392e06e47f4a4d7c337f9198a8ee6b53 Mon Sep 17 00:00:00 2001 From: Vegetable <3089665724@qq.com> Date: Fri, 27 Nov 2026 17:48:25 +0800 Subject: [PATCH 08/13] fix(core): keep projected events flowing when control drain queue is full --- crates/caligo-core/src/runtime.rs | 37 ++++++++++++++----- crates/caligo-core/tests/runtime_contract.rs | 31 ++++++++++++++++ .../tests/wrapper_message_chain.rs | 7 +++- .../2026-11-25-feat-007-n5-release.md | 15 +++++--- feature_list.json | 2 +- progress.md | 2 +- scripts/n5/n5_soak.py | 2 +- scripts/n5/ws_drain.ps1 | 5 ++- session-handoff.md | 2 +- 9 files changed, 83 insertions(+), 20 deletions(-) diff --git a/crates/caligo-core/src/runtime.rs b/crates/caligo-core/src/runtime.rs index e85df617..acfd1961 100644 --- a/crates/caligo-core/src/runtime.rs +++ b/crates/caligo-core/src/runtime.rs @@ -146,6 +146,7 @@ pub struct RuntimeCounters { pub events_persisted: u64, pub events_duplicate_suppressed: u64, pub events_old_generation_audited: u64, + pub events_deliverable_queue_dropped: u64, pub gaps_recorded: u64, pub receipts_duplicate_ignored: u64, pub receipts_corrected: u64, @@ -1055,17 +1056,29 @@ impl AccountActor { // 交付队列限额(items/bytes 任一到达 → Gap + 拒绝;bridge 依契约保留 // replay 窗口,不是静默丢弃)。 + // + // 生产 OneBot 事件在 `Daemon::publish_onebot_message` 直接 fanout; + // `events_out` 只是 control `DrainEvents` 的诊断队列。wrapper/projection + // 事件即使诊断队列已满也必须继续持久化并发布,否则长时间运行会把 + // 正常的 OneBot 交付误判为 core 容量耗尽。此时只记录计数,不写 Gap, + // 也不进入 Degraded。 let ev_bytes = ev.queue_bytes(); + let mut enqueue_deliverable = true; if self.events_out.len() + 1 > self.config.event_queue_max_items || self.events_out_bytes.saturating_add(ev_bytes) > self.config.event_queue_max_bytes { - self.record_gap( - self.event_seq_next, - None, - "event queue overflow (items/bytes limit)", - )?; - self.degrade("event queue overflow"); - return Err(RejectReason::CapacityExhausted { queue: "events" }); + if ev.onebot_projection.is_some() || ev.wrapper_message.is_some() { + self.counters.events_deliverable_queue_dropped += 1; + enqueue_deliverable = false; + } else { + self.record_gap( + self.event_seq_next, + None, + "event queue overflow (items/bytes limit)", + )?; + self.degrade("event queue overflow"); + return Err(RejectReason::CapacityExhausted { queue: "events" }); + } } let seq = self.alloc_seq(); @@ -1091,8 +1104,10 @@ impl AccountActor { self.persist_message_projection(&ev)?; self.pending_message_store.remove(&dedup_key); } - self.events_out.push_back(ev); - self.events_out_bytes += ev_bytes; + if enqueue_deliverable { + self.events_out.push_back(ev); + self.events_out_bytes += ev_bytes; + } self.counters.events_persisted += 1; Ok(EventReceipt::Published { event_seq: seq }) } @@ -1115,6 +1130,10 @@ impl AccountActor { if self.events_out.len() + 1 > self.config.event_queue_max_items || self.events_out_bytes.saturating_add(ev_bytes) > self.config.event_queue_max_bytes { + if ev.onebot_projection.is_some() || ev.wrapper_message.is_some() { + self.counters.events_deliverable_queue_dropped += 1; + return Ok(()); + } self.record_gap( ev.event_seq, None, diff --git a/crates/caligo-core/tests/runtime_contract.rs b/crates/caligo-core/tests/runtime_contract.rs index e9020481..dcb5d769 100644 --- a/crates/caligo-core/tests/runtime_contract.rs +++ b/crates/caligo-core/tests/runtime_contract.rs @@ -441,6 +441,37 @@ fn event_queue_overflow_records_gap_and_degrades() { ); } +#[test] +fn projected_event_is_published_even_when_control_drain_queue_is_full() { + let path = tmp_journal("efull-projected"); + let _ = std::fs::remove_file(&path); + let cfg = RuntimeConfig { + event_queue_max_items: 1, + ..RuntimeConfig::default() + }; + let (mut a, _) = AccountActor::open(&path, cfg).unwrap(); + a.attach_session(session(1)).unwrap(); + a.mark_connection_ready(conn(1)).unwrap(); + let t = private_target("123"); + let plain = event(1, &t, "E1", "a", EventSource::Recv); + a.on_event(plain).unwrap(); + let mut projected = event(1, &t, "E2", "b", EventSource::Recv); + projected.onebot_projection = Some(caligo_model::OneBotMessageProjection { + peer_id: 123, + sender_user_id: 1, + real_id: 2, + time: 1, + sender_nickname: None, + sub_type: Some("friend".into()), + font: None, + }); + let receipt = a.on_event(projected).unwrap(); + assert!(matches!(receipt, EventReceipt::Published { event_seq: 2 })); + assert_eq!(a.phase(), Phase::Active); + assert_eq!(a.counters.events_deliverable_queue_dropped, 1); + assert_eq!(a.gaps().len(), 0); +} + // ---- 停止协议:排队项取消;在途项 close 时显式 unknown;不回 Active ---- #[test] diff --git a/crates/caligo-core/tests/wrapper_message_chain.rs b/crates/caligo-core/tests/wrapper_message_chain.rs index 174c74c6..e313858f 100644 --- a/crates/caligo-core/tests/wrapper_message_chain.rs +++ b/crates/caligo-core/tests/wrapper_message_chain.rs @@ -596,10 +596,15 @@ fn d8_owned_records_reach_journal_and_only_current_incoming_messages_fan_out() { Err(caligo_model::RejectReason::SessionStale) ); assert!(event.queue_bytes() > events[0].text.len() + 1024); + // The bounded queue is the control DrainEvents diagnostic queue, not the + // production OneBot fanout. A wrapper record that does not fit must still + // be journaled/published; only the diagnostic copy is dropped and counted. assert!(matches!( budget_actor.on_event(event), - Err(caligo_model::RejectReason::CapacityExhausted { .. }) + Ok(caligo_core::runtime::EventReceipt::Published { .. }) )); + assert_eq!(budget_actor.counters.events_deliverable_queue_dropped, 1); + assert_eq!(budget_actor.gaps().len(), 0); let (_, report) = AccountActor::open(&journal, RuntimeConfig::default()).unwrap(); assert_eq!(report.recovered_events, 6); let store = caligo_core::message_store::MessageStore::open( diff --git a/docs/acceptance/2026-11-25-feat-007-n5-release.md b/docs/acceptance/2026-11-25-feat-007-n5-release.md index c5e29325..25be0952 100644 --- a/docs/acceptance/2026-11-25-feat-007-n5-release.md +++ b/docs/acceptance/2026-11-25-feat-007-n5-release.md @@ -114,15 +114,20 @@ attach 时仍要求一次登录成功。该修复通过离线 rehearsal(18s, - **登录缓存**:`get_login_info`(无 `no_cache`)在成功 native/SelfProfile 查询后,把确认身份持久化到账号目录的 `login.private.json`;core 重启后默认动作先返回该持久身份,`no_cache=true` 仍走 native 查询。新增持久化/账号漂移/backend 缓存短路测试。 - **事件消费者**:新增 `scripts/n5/ws_drain.ps1`,连接 forward WS `/event`,只记录消息数/字节数/重连数(不写正文);soak 在 attach 后启动它,`require_event_consumer` 模式下要求 `event_consumer_active` 且 journal `Gap=0`。 -最终构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)的启动包/未知版本门见 §2。最终 24h 于 `2026-11-27T01:38:44Z` 在新 QQ 主根上启动,预计 `2026-11-28T01:38:44Z` 结束;到点由本机定时任务核验并更新本节。 +最终构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)的启动包/未知版本门见 §2。该构建的 24h 于 `2026-11-27T01:38:44Z` 启动,但在 8h 处发现 **16,686 bytes WS 消费者只收到 309 条、journal 564 Event + 2,848 Gap**: + +- WS 消费者把 `ReceiveAsync` 的 5s 取消当成超时/断开,实际取消了 socket,形成 5,157 次重连(约每 5.6s 一次),不能持续排空事件。 +- 更根本的是 `AccountActor::events_out` 只是 control `DrainEvents` 的诊断队列;生产 OneBot fanout 已直接发布。队列满时旧实现仍 `degrade` 并拒绝 wrapper/projection 事件,导致正常事件不再发布。 +- 停止时 control Stop 返回 `stopped`,但 daemon 在队列压力下未退出(高 CPU),最终 force-kill;bridge 保留、QQ 响应。 + +修正:wrapper/projection 事件在诊断队列满时只增加 `events_deliverable_queue_dropped` 计数,继续 journal/OneBot 发布,不再 Gap/degrade;WS 消费者接收取消改为 30s,soak 停止等待改为 45s。新增 runtime 回归。该构建需要最终 24h 复验,未通过前不把本节视为通过。 ## 5. 剩余门与边界 - **24h**:attempt 1 在 8h 处 incomplete(§4.1);attempt 2 完整跑满 24h 但应用级未闭合 - (§4.2:无事件消费者导致 13,234 条 Gap,`get_login_info` 958 次超时)。修正后的 - `17f5ec6` 已新增持久登录缓存与 forward-WS 事件消费者,attempt 3 于 - `2026-11-27T01:38:44Z` 启动(§4.3),结果待到点核验。重跑通过前不把 N5 24h 门标为完全 - 通过,也不关闭 issue #16。 + (§4.2);attempt 3 在 8h 处发现事件诊断队列拒绝与 WS 消费者重连缺陷(§4.3),已停止并 + 修正。需要新构建 + 新新鲜 QQ 做最终 24h;重跑通过前不把 N5 24h 门标为完全通过,也不关闭 + issue #16。 - **QQ 重启**:需要操作者退出并重启 QQ,随后对新 PID/创建时间重新 preflight/attach; 旧代次的请求、映射和回调不得混入新实例。 - **启动包**:本轮为 default 构建;research 构建、真实 QQ 字段与发布 tag 流程是独立验收。 diff --git a/feature_list.json b/feature_list.json index 12f80674..bc96761f 100644 --- a/feature_list.json +++ b/feature_list.json @@ -110,7 +110,7 @@ "plan_steps": ["N5"], "dependencies": ["feat-006"], "status": "in-progress", - "evidence": "2026-11-25 离线启动包/未知版本门通过(scripts/n5/verify-release.ps1):default release 构建与 CI 同源打包,zip sidecar、build-info commit/version/target/mode 和包内逐文件 SHA-256 均匹配;解压后 packaged daemon 两次启动均回答 get_version_info、无 bridge 时 get_login_info 诚实返回 1502、控制停止后 journal 保留;篡改 QQ.exe 哈希后 verify-manifest 与 qq-entry 均在 gate 1 拒绝且不产生 report,默认构建的 inject 先被 K4-D0 拒绝。现场 2h 观察通过(零发送、60s 只读探测、30/60/90 分钟 core 崩溃重启):新 QQ 主根一次 attach,117 个采样、351/351 次查询成功、495 条真实入站事件无重复/缺口(event_seq 1–495),3/3 次 core 崩溃重启各约 1.5s 恢复且 journal 完整帧前缀保留,控制停止后默认 bridge 保留、QQ 响应。CoreStopped 后同一代次不能重新 attach,因此在新主根上启动 24h soak;attempt 1 在约 8h 处 incomplete:version/status 探测 958/958 成功、journal 持续增长,但 get_login_info 从 15:19Z 起长期返回 1502(456 次),第 2 次 core 重启后 harness 因登录查询超时判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实结果,不是常驻链失败;harness 已改为 version/status 作为探测与重启恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 2 已完整跑满 86,420s:version/status 2876/2876 成功、3/3 次 core 重启恢复(约 0.2s)、bridge 保留、QQ 响应、内存/句柄稳定,但 journal 含 13,234 条 Gap(本轮无 OneBot 事件消费者,队列满后的有界拒绝),且 get_login_info 1438 次中仅 215 次成功(265 次 1502、958 次 10s 超时,锁屏/重启后默认动作走 native query)。常驻链 24h 通过,应用级 24h 与登录动作可靠性仍未闭合。随后实现持久登录缓存(默认 get_login_info 返回确认身份,no_cache 仍走 native;core 重启后从 login.private.json 恢复)与 forward-WS 事件消费者(ws_drain.ps1,记录计数不写正文;soak 要求 event_consumer_active 且 journal Gap=0);新构建 17f5ec6(EXE 4C9B057D…02BB、bridge 659CE4D1…CE14)的启动包/未知版本门 PASS,最终 24h 于 2026-11-27T01:38:44Z 启动,预计 2026-11-28T01:38:44Z 结束。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。", + "evidence": "2026-11-25 离线启动包/未知版本门通过(scripts/n5/verify-release.ps1):default release 构建与 CI 同源打包,zip sidecar、build-info commit/version/target/mode 和包内逐文件 SHA-256 均匹配;解压后 packaged daemon 两次启动均回答 get_version_info、无 bridge 时 get_login_info 诚实返回 1502、控制停止后 journal 保留;篡改 QQ.exe 哈希后 verify-manifest 与 qq-entry 均在 gate 1 拒绝且不产生 report,默认构建的 inject 先被 K4-D0 拒绝。现场 2h 观察通过(零发送、60s 只读探测、30/60/90 分钟 core 崩溃重启):新 QQ 主根一次 attach,117 个采样、351/351 次查询成功、495 条真实入站事件无重复/缺口(event_seq 1–495),3/3 次 core 崩溃重启各约 1.5s 恢复且 journal 完整帧前缀保留,控制停止后默认 bridge 保留、QQ 响应。CoreStopped 后同一代次不能重新 attach,因此在新主根上启动 24h soak;attempt 1 在约 8h 处 incomplete:version/status 探测 958/958 成功、journal 持续增长,但 get_login_info 从 15:19Z 起长期返回 1502(456 次),第 2 次 core 重启后 harness 因登录查询超时判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实结果,不是常驻链失败;harness 已改为 version/status 作为探测与重启恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 2 已完整跑满 86,420s:version/status 2876/2876 成功、3/3 次 core 重启恢复(约 0.2s)、bridge 保留、QQ 响应、内存/句柄稳定,但 journal 含 13,234 条 Gap(本轮无 OneBot 事件消费者,队列满后的有界拒绝),且 get_login_info 1438 次中仅 215 次成功(265 次 1502、958 次 10s 超时,锁屏/重启后默认动作走 native query)。常驻链 24h 通过,应用级 24h 与登录动作可靠性仍未闭合。随后实现持久登录缓存(默认 get_login_info 返回确认身份,no_cache 仍走 native;core 重启后从 login.private.json 恢复)与 forward-WS 事件消费者(ws_drain.ps1,记录计数不写正文;soak 要求 event_consumer_active 且 journal Gap=0);新构建 17f5ec6(EXE 4C9B057D…02BB、bridge 659CE4D1…CE14)的启动包/未知版本门 PASS,但其 24h 在 8h 处发现事件诊断队列拒绝与 WS 消费者 5s 取消重连缺陷(WS 309 条/5,157 次重连,journal 564 Event + 2,848 Gap,停止时 daemon 未退出需 force-kill)。已修正:wrapper/projection 事件在 control DrainEvents 队列满时只计数并继续 journal/OneBot 发布,不再 Gap/degrade;WS 接收取消改为 30s,soak 停止等待 45s;新增 runtime 回归。最终 24h 仍需新构建 + 新新鲜 QQ 重跑。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。", "evidence_paths": ["docs/acceptance/2026-11-25-feat-007-n5-release.md", "scripts/n5/verify-release.ps1", "scripts/n5/preflight.ps1", "scripts/n5/attach.ps1", "scripts/n5/n5_soak.py", "docs/plans/2026-10-09-gitnexus-plan-caligo-snowluma-capability-parity.md"], "done_criteria": ["正常入口无需每消息交互", "core/QQ 重启、断链/慢客户端矩阵通过", "未知版本零 native 调用,停止边界如实", "24h 单账号验收及启动包证据齐全"] }, diff --git a/progress.md b/progress.md index f073f3ef..f3334a9a 100644 --- a/progress.md +++ b/progress.md @@ -2,7 +2,7 @@ ## Current State -2026-11-27 feat-007 N5 最终 24h 重跑准备(issue #16):24h attempt 2 的缺口已做实现修正——新增持久登录缓存(`get_login_info` 无 `no_cache` 时成功查询后写账号目录 `login.private.json`;core 重启后默认动作先返回持久身份,`no_cache=true` 仍走 native 查询;新增持久化/账号漂移/backend 短路测试)与 forward-WS 事件消费者(`scripts/n5/ws_drain.ps1`,只记消息数/字节数/重连数,不写正文;soak 在 attach 后启动,`require_event_consumer` 模式下要求 `event_consumer_active` 且 journal `Gap=0`)。新构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)的启动包/未知版本门 PASS;`init.ps1 -Mode all` default 509 / research 569、0 failed。最终 24h 于 `2026-11-27T01:38:44Z` 在新 QQ 主根 `33284`(创建 `2026-11-27T01:37:42.0474720Z`,账号 B)启动,带 WS 消费者与登录缓存,+2h/+8h/+16h 各一次 core 重启,预计 `2026-11-28T01:38:44Z` 结束;定时任务 `schedule-7402411b-345a-4f7d-a475-b1671167ceed` 在 `2026-11-28T09:55+08:00` 核验。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-final-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) +2026-11-27 feat-007 N5 最终 24h 重跑准备(issue #16):24h attempt 2 的缺口已做实现修正——新增持久登录缓存(`get_login_info` 无 `no_cache` 时成功查询后写账号目录 `login.private.json`;core 重启后默认动作先返回持久身份,`no_cache=true` 仍走 native 查询;新增持久化/账号漂移/backend 短路测试)与 forward-WS 事件消费者(`scripts/n5/ws_drain.ps1`,只记消息数/字节数/重连数,不写正文;soak 在 attach 后启动,`require_event_consumer` 模式下要求 `event_consumer_active` 且 journal `Gap=0`)。新构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)的启动包/未知版本门 PASS;`init.ps1 -Mode all` default 509 / research 569、0 failed。最终 24h 于 `2026-11-27T01:38:44Z` 在新主根 `33284`(创建 `2026-11-27T01:37:42.0474720Z`,账号 B)启动,但在 8h 处发现两个缺陷:WS 消费者把 5s `ReceiveAsync` 取消当成断开,5,157 次重连只收到 309 条;`AccountActor::events_out` 只是 control `DrainEvents` 诊断队列,满时仍 degrade/拒绝 wrapper/projection 事件,导致 journal 564 Event + 2,848 Gap;control Stop 返回后 daemon 未退出,force-kill,bridge 保留。已修正:诊断队列满时 wrapper/projection 事件只增加 `events_deliverable_queue_dropped` 并继续 journal/OneBot 发布(不 Gap、不 degrade),WS 接收取消改为 30s、停止等待 45s;新增 runtime 回归。最终 24h 需新构建 + 新新鲜 QQ 重跑;定时任务已取消。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-final-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) 2026-11-25 feat-007 N5 启动包/未知版本门与 2h 现场观察(issue #16):新增 `scripts/n5/verify-release.ps1`,按 CI 同源脚本构建并打包 default release,校验 zip sidecar、`build-info.json` 的 commit/version/target/mode/entrypoint 与包内逐文件 SHA-256;解压后的 packaged daemon 两次启动均回答 `get_version_info`(retcode 0),无 bridge 时 `get_login_info` 诚实返回 1502,控制停止后 journal 保留;篡改 `QQ.exe` 哈希后 `verify-manifest` 与 `qq-entry` 均在 gate 1 拒绝且不产生 report,默认构建 `inject` 先被 K4-D0 拒绝。固定构建 `caligo.exe` SHA-256 `820781DB…57CE5`、`caligo_bridge.dll` `1EBF6E35…44FC`。现场 2h(本轮零发送):新 QQ 主根 `26620`(创建 `2026-11-25T12:03:11.4979693Z`,登记账号 B)通过固定 manifest/模块、PE/backend 审计与唯一 Environment 后一次 attach;117 个采样、`version`/`status`/`login` 351/351 成功、0 探测失败;30/60/90 分钟 3/3 次 kill core 并以同 journal/pipe/token 重启,恢复 1.56/1.53/1.55s、journal 完整帧前缀保留、bridge 未重新 attach;期间 495 条真实入站事件,`event_seq` 1–495 无缺口、495 个唯一 native ID、0 重复,generation 始终 1;daemon working set 7.7→14.6 MiB、handles 102→102,控制停止 daemon 后默认 bridge 保留、QQ 响应。2h 样本不证明 24h、QQ 重启后新代次重绑或真实 TCP 背压;`CoreStopped` 后同一代次不能重新 attach,24h 需新新鲜 QQ。随后在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并于 `14:56:45Z` 启动 24h soak。attempt 1 在约 8h 处 incomplete 停止(`2026-11-25T23:00:15Z`):479 samples、version/status 958/958 成功、journal 持续增长到 4,409,381 bytes,但 `get_login_info` 从 `15:19:49Z` 起长期返回 1502(456 次);第 2 次 core 重启(`22:56:46Z`)后 daemon 启动、journal 继续增长,但登录查询 188s 超时,harness 判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实返回,不应作为常驻链失败或重启恢复唯一信号;`n5_soak.py` 已改为 version/status 作为探测与恢复信号、登录查询单独计数并保留 1502,离线 rehearsal(18s、含一次 core 重启)通过。24h 门未通过;原定 `2026-11-26T23:10` 的到点任务已取消。修正判据后,attempt 2 于 `2026-11-25T23:33:25Z` 在新主根 `43444`(创建 `2026-11-25T23:31:19.6213631Z`,账号 B)上重跑并完整跑满 86,420s:1438 个采样,version/status 2876/2876 成功,3/3 次 core 崩溃重启恢复(0.18/0.18/0.19s)、journal 完整帧前缀保留,attach 登录成功,控制停止后 bridge 保留、QQ 响应,daemon working set 7.7→~10 MiB、handles ~105 稳定。但 journal 3,020,642 bytes 含 896 个 Event(`event_seq` 1–896 无缺口、0 重复)和 **13,234 条 Gap**(本轮无 OneBot WS/SSE/POST 消费者,事件队列满后的有界拒绝),因此不是应用级 24h;`get_login_info` 1438 次中 215 次成功、265 次 1502、958 次 10s 超时(锁屏/重启后 default 动作走 native query),是待修产品可靠性缺陷。常驻链 24h 通过、应用级 24h 与登录动作可靠性仍未闭合;需 WS/SSE 消费者参与并修正默认登录查询后另行现场复验。原定时任务已取消。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/`、`feat007-n5-24h-20261125-unbound/` 与 `feat007-n5-24h-20261126-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) diff --git a/scripts/n5/n5_soak.py b/scripts/n5/n5_soak.py index 6d804ccd..dbfaa1d9 100644 --- a/scripts/n5/n5_soak.py +++ b/scripts/n5/n5_soak.py @@ -423,7 +423,7 @@ def stop_ws_drain(self): if self.ws_drain_stop_path: self.ws_drain_stop_path.write_text("stop\n", encoding="ascii") try: - self.ws_drain_proc.wait(timeout=15) + self.ws_drain_proc.wait(timeout=45) except subprocess.TimeoutExpired: self.ws_drain_proc.kill() self.ws_drain_proc.wait(timeout=10) diff --git a/scripts/n5/ws_drain.ps1 b/scripts/n5/ws_drain.ps1 index a2ae62e9..dc91c153 100644 --- a/scripts/n5/ws_drain.ps1 +++ b/scripts/n5/ws_drain.ps1 @@ -59,7 +59,10 @@ try { $segment = [ArraySegment[byte]]::new($buffer) while ($true) { if ($StopFile -and (Test-Path -LiteralPath $StopFile)) { $stopReason = 'stop-file'; break } - $cts = [Threading.CancellationTokenSource]::new(5000) + # A short cancellation aborts ClientWebSocket and forces endless + # reconnects. 30s only bounds idle waits; continuous events return + # immediately, and the stop file is checked after each result. + $cts = [Threading.CancellationTokenSource]::new(30000) try { $result = $ws.ReceiveAsync($segment, $cts.Token).GetAwaiter().GetResult() } catch [System.OperationCanceledException] { diff --git a/session-handoff.md b/session-handoff.md index df7def48..f5c3b49f 100644 --- a/session-handoff.md +++ b/session-handoff.md @@ -1,6 +1,6 @@ # Session handoff -2026-11-27 feat-007 N5 最终 24h(issue #16):修正 attempt 2 的登录查询与无消费者缺口。新构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)增加持久登录缓存(`login.private.json`;默认 `get_login_info` 走缓存,`no_cache` 走 native)与 forward-WS 事件消费者(`scripts/n5/ws_drain.ps1`,只记录计数)。离线启动包/未知版本门 PASS;`init.ps1 -Mode all` default 509 / research 569、0 failed。最终 24h 于 `2026-11-27T01:38:44Z` 在新主根 `33284`(创建 `2026-11-27T01:37:42.0474720Z`,账号 B)启动,带 WS 消费者与登录缓存,+2h/+8h/+16h 各一次 core 重启,预计 `2026-11-28T01:38:44Z` 结束;定时任务 `schedule-7402411b-345a-4f7d-a475-b1671167ceed` 在 `2026-11-28T09:55+08:00` 核验,不自动关闭 issue #16。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-final-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) +2026-11-27 feat-007 N5 最终 24h(issue #16):修正 attempt 2 的登录查询与无消费者缺口。新构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)增加持久登录缓存(`login.private.json`;默认 `get_login_info` 走缓存,`no_cache` 走 native)与 forward-WS 事件消费者(`scripts/n5/ws_drain.ps1`,只记录计数)。离线启动包/未知版本门 PASS;`init.ps1 -Mode all` default 509 / research 569、0 failed。最终 24h 于 `2026-11-27T01:38:44Z` 在新主根 `33284`(创建 `2026-11-27T01:37:42.0474720Z`,账号 B)启动,8h 处发现 WS 消费者 5s 取消重连(5,157 次、309 条)与 control `DrainEvents` 诊断队列满时拒绝 wrapper/projection 事件(2,848 Gap);control Stop 后 daemon 未退出,force-kill,bridge 保留。已修正队列语义与 WS 30s 取消/45s 停止等待,并新增 runtime 回归;最终 24h 需新构建 + 新新鲜 QQ 重跑,原定时任务已取消。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-final-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) 2026-11-25 feat-007 N5 离线启动包/未知版本门 + 2h 现场观察通过(issue #16):`scripts/n5/verify-release.ps1` 的 default release 打包、sidecar/build-info/包内哈希、两次 packaged daemon 启动与诚实无 bridge 登录失败、篡改 manifest 的 gate 1 拒绝均 pass;固定 `caligo.exe` `820781DB…57CE5`、bridge `1EBF6E35…44FC`。现场新 QQ `26620`(创建 `2026-11-25T12:03:11.4979693Z`,账号 B)一次 attach,零发送;117 samples、351/351 查询成功、3/3 次 core 崩溃重启约 1.5s 恢复、495 条入站事件无重复/缺口、控制停止后 bridge 保留。2h 样本不证明 24h/QQ 重启新代次/真实 TCP 背压;`CoreStopped` 后同代次不能重新 attach。已在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并启动 24h soak;attempt 1 在约 8h 处 incomplete(`2026-11-25T23:00:15Z`):version/status 958/958 成功、journal 持续增长,但 `get_login_info` 从 `15:19:49Z` 起长期返回 1502(456 次),第 2 次 core 重启后登录查询 188s 超时触发 fatal。已确认 1502 是 QQ 锁屏/会话不可用时的诚实返回;`n5_soak.py` 已改为 version/status 作为探测与恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 1 未通过,原定时核验任务已取消。修正判据后 attempt 2 于 `2026-11-25T23:33:25Z` 在新主根 `43444`(创建 `2026-11-25T23:31:19.6213631Z`,账号 B)重跑,完整跑满 86,420s:version/status 2876/2876 成功、3/3 次 core 重启恢复(约 0.2s)、bridge 保留、QQ 响应、内存/句柄稳定;但 journal 含 13,234 条 Gap(本轮无 OneBot 事件消费者,队列满后的有界拒绝),`get_login_info` 1438 次中 215 次成功、265 次 1502、958 次 10s 超时。常驻链 24h 通过,应用级 24h 与登录动作可靠性仍未闭合;需 WS/SSE 消费者参与并修正 default 登录查询(应优先返回持久身份或有界失败)后另行现场复验。原定时任务已取消,issue #16 不关闭。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/`、`feat007-n5-24h-20261125-unbound/` 与 `feat007-n5-24h-20261126-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) From 8539afd5aa8a13d8ab09085a38453aae8ab26ee5 Mon Sep 17 00:00:00 2001 From: Vegetable <3089665724@qq.com> Date: Fri, 27 Nov 2026 17:49:14 +0800 Subject: [PATCH 09/13] docs(feat-007): record event queue fix build --- docs/acceptance/2026-11-25-feat-007-n5-release.md | 6 +++--- feature_list.json | 2 +- progress.md | 2 +- session-handoff.md | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/acceptance/2026-11-25-feat-007-n5-release.md b/docs/acceptance/2026-11-25-feat-007-n5-release.md index 25be0952..b092663c 100644 --- a/docs/acceptance/2026-11-25-feat-007-n5-release.md +++ b/docs/acceptance/2026-11-25-feat-007-n5-release.md @@ -32,8 +32,8 @@ | 项目 | 结果 | |---|---| -| 构建 | commit `17f5ec6`;`caligo.exe` SHA-256 `4C9B057D…02BB`,`caligo_bridge.dll` SHA-256 `659CE4D1…CE14` | -| 启动包 | `caligo-0.3.0-windows-x64.zip`,sidecar SHA-256 `13FE366F…0D0D` 与包哈希一致;`build-info.json` 的 commit/version/target/mode/research/entrypoint 均匹配,4 个包内文件哈希逐项匹配 | +| 构建 | commit `e9db64a`;`caligo.exe` SHA-256 `58D9CAE9…2C99`,`caligo_bridge.dll` SHA-256 `659CE4D1…CE14` | +| 启动包 | `caligo-0.3.0-windows-x64.zip`,sidecar SHA-256 `23FD37A8…106F` 与包哈希一致;`build-info.json` 的 commit/version/target/mode/research/entrypoint 均匹配,4 个包内文件哈希逐项匹配 | | 包内启动 | `get_version_info` retcode 0;无 bridge 时 `get_login_info` retcode 1502(诚实失败,不伪造登录);两次启动后 journal SHA-256 不变(空账本) | | 未知版本 | 篡改 `QQ.exe` 哈希:`verify-manifest` exit 2;`qq-entry` exit 2 且 `[gate 1] REJECT`、report 未产生;`inject` exit 3(K4-D0 默认构建禁用)、report 未产生 | | 停止 | packaged daemon 两次均由 `daemon-control ... stop` 正常退出,journal 保留 | @@ -120,7 +120,7 @@ attach 时仍要求一次登录成功。该修复通过离线 rehearsal(18s, - 更根本的是 `AccountActor::events_out` 只是 control `DrainEvents` 的诊断队列;生产 OneBot fanout 已直接发布。队列满时旧实现仍 `degrade` 并拒绝 wrapper/projection 事件,导致正常事件不再发布。 - 停止时 control Stop 返回 `stopped`,但 daemon 在队列压力下未退出(高 CPU),最终 force-kill;bridge 保留、QQ 响应。 -修正:wrapper/projection 事件在诊断队列满时只增加 `events_deliverable_queue_dropped` 计数,继续 journal/OneBot 发布,不再 Gap/degrade;WS 消费者接收取消改为 30s,soak 停止等待改为 45s。新增 runtime 回归。该构建需要最终 24h 复验,未通过前不把本节视为通过。 +修正:wrapper/projection 事件在诊断队列满时只增加 `events_deliverable_queue_dropped` 计数,继续 journal/OneBot 发布,不再 Gap/degrade;WS 消费者接收取消改为 30s,soak 停止等待改为 45s。新增 runtime 回归,`init.ps1 -Mode all` default **510** / research **570**、0 failed。新构建 `e9db64a`(`caligo.exe` `58D9CAE9…2C99`、bridge `659CE4D1…CE14`)的启动包/未知版本门 PASS;该构建需要最终 24h 复验,未通过前不把本节视为通过。 ## 5. 剩余门与边界 diff --git a/feature_list.json b/feature_list.json index bc96761f..6ff09dad 100644 --- a/feature_list.json +++ b/feature_list.json @@ -110,7 +110,7 @@ "plan_steps": ["N5"], "dependencies": ["feat-006"], "status": "in-progress", - "evidence": "2026-11-25 离线启动包/未知版本门通过(scripts/n5/verify-release.ps1):default release 构建与 CI 同源打包,zip sidecar、build-info commit/version/target/mode 和包内逐文件 SHA-256 均匹配;解压后 packaged daemon 两次启动均回答 get_version_info、无 bridge 时 get_login_info 诚实返回 1502、控制停止后 journal 保留;篡改 QQ.exe 哈希后 verify-manifest 与 qq-entry 均在 gate 1 拒绝且不产生 report,默认构建的 inject 先被 K4-D0 拒绝。现场 2h 观察通过(零发送、60s 只读探测、30/60/90 分钟 core 崩溃重启):新 QQ 主根一次 attach,117 个采样、351/351 次查询成功、495 条真实入站事件无重复/缺口(event_seq 1–495),3/3 次 core 崩溃重启各约 1.5s 恢复且 journal 完整帧前缀保留,控制停止后默认 bridge 保留、QQ 响应。CoreStopped 后同一代次不能重新 attach,因此在新主根上启动 24h soak;attempt 1 在约 8h 处 incomplete:version/status 探测 958/958 成功、journal 持续增长,但 get_login_info 从 15:19Z 起长期返回 1502(456 次),第 2 次 core 重启后 harness 因登录查询超时判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实结果,不是常驻链失败;harness 已改为 version/status 作为探测与重启恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 2 已完整跑满 86,420s:version/status 2876/2876 成功、3/3 次 core 重启恢复(约 0.2s)、bridge 保留、QQ 响应、内存/句柄稳定,但 journal 含 13,234 条 Gap(本轮无 OneBot 事件消费者,队列满后的有界拒绝),且 get_login_info 1438 次中仅 215 次成功(265 次 1502、958 次 10s 超时,锁屏/重启后默认动作走 native query)。常驻链 24h 通过,应用级 24h 与登录动作可靠性仍未闭合。随后实现持久登录缓存(默认 get_login_info 返回确认身份,no_cache 仍走 native;core 重启后从 login.private.json 恢复)与 forward-WS 事件消费者(ws_drain.ps1,记录计数不写正文;soak 要求 event_consumer_active 且 journal Gap=0);新构建 17f5ec6(EXE 4C9B057D…02BB、bridge 659CE4D1…CE14)的启动包/未知版本门 PASS,但其 24h 在 8h 处发现事件诊断队列拒绝与 WS 消费者 5s 取消重连缺陷(WS 309 条/5,157 次重连,journal 564 Event + 2,848 Gap,停止时 daemon 未退出需 force-kill)。已修正:wrapper/projection 事件在 control DrainEvents 队列满时只计数并继续 journal/OneBot 发布,不再 Gap/degrade;WS 接收取消改为 30s,soak 停止等待 45s;新增 runtime 回归。最终 24h 仍需新构建 + 新新鲜 QQ 重跑。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。", + "evidence": "2026-11-25 离线启动包/未知版本门通过(scripts/n5/verify-release.ps1):default release 构建与 CI 同源打包,zip sidecar、build-info commit/version/target/mode 和包内逐文件 SHA-256 均匹配;解压后 packaged daemon 两次启动均回答 get_version_info、无 bridge 时 get_login_info 诚实返回 1502、控制停止后 journal 保留;篡改 QQ.exe 哈希后 verify-manifest 与 qq-entry 均在 gate 1 拒绝且不产生 report,默认构建的 inject 先被 K4-D0 拒绝。现场 2h 观察通过(零发送、60s 只读探测、30/60/90 分钟 core 崩溃重启):新 QQ 主根一次 attach,117 个采样、351/351 次查询成功、495 条真实入站事件无重复/缺口(event_seq 1–495),3/3 次 core 崩溃重启各约 1.5s 恢复且 journal 完整帧前缀保留,控制停止后默认 bridge 保留、QQ 响应。CoreStopped 后同一代次不能重新 attach,因此在新主根上启动 24h soak;attempt 1 在约 8h 处 incomplete:version/status 探测 958/958 成功、journal 持续增长,但 get_login_info 从 15:19Z 起长期返回 1502(456 次),第 2 次 core 重启后 harness 因登录查询超时判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实结果,不是常驻链失败;harness 已改为 version/status 作为探测与重启恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 2 已完整跑满 86,420s:version/status 2876/2876 成功、3/3 次 core 重启恢复(约 0.2s)、bridge 保留、QQ 响应、内存/句柄稳定,但 journal 含 13,234 条 Gap(本轮无 OneBot 事件消费者,队列满后的有界拒绝),且 get_login_info 1438 次中仅 215 次成功(265 次 1502、958 次 10s 超时,锁屏/重启后默认动作走 native query)。常驻链 24h 通过,应用级 24h 与登录动作可靠性仍未闭合。随后实现持久登录缓存(默认 get_login_info 返回确认身份,no_cache 仍走 native;core 重启后从 login.private.json 恢复)与 forward-WS 事件消费者(ws_drain.ps1,记录计数不写正文;soak 要求 event_consumer_active 且 journal Gap=0);新构建 17f5ec6(EXE 4C9B057D…02BB、bridge 659CE4D1…CE14)的启动包/未知版本门 PASS,但其 24h 在 8h 处发现事件诊断队列拒绝与 WS 消费者 5s 取消重连缺陷(WS 309 条/5,157 次重连,journal 564 Event + 2,848 Gap,停止时 daemon 未退出需 force-kill)。已修正:wrapper/projection 事件在 control DrainEvents 队列满时只计数并继续 journal/OneBot 发布,不再 Gap/degrade;WS 接收取消改为 30s,soak 停止等待 45s;新增 runtime/wrapper 回归,init.ps1 -Mode all default 510 / research 570、0 failed。新构建 e9db64a(EXE 58D9CAE9…2C99、bridge 659CE4D1…CE14)启动包/未知版本门 PASS;最终 24h 仍需新新鲜 QQ 重跑。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。", "evidence_paths": ["docs/acceptance/2026-11-25-feat-007-n5-release.md", "scripts/n5/verify-release.ps1", "scripts/n5/preflight.ps1", "scripts/n5/attach.ps1", "scripts/n5/n5_soak.py", "docs/plans/2026-10-09-gitnexus-plan-caligo-snowluma-capability-parity.md"], "done_criteria": ["正常入口无需每消息交互", "core/QQ 重启、断链/慢客户端矩阵通过", "未知版本零 native 调用,停止边界如实", "24h 单账号验收及启动包证据齐全"] }, diff --git a/progress.md b/progress.md index f3334a9a..ae04746e 100644 --- a/progress.md +++ b/progress.md @@ -2,7 +2,7 @@ ## Current State -2026-11-27 feat-007 N5 最终 24h 重跑准备(issue #16):24h attempt 2 的缺口已做实现修正——新增持久登录缓存(`get_login_info` 无 `no_cache` 时成功查询后写账号目录 `login.private.json`;core 重启后默认动作先返回持久身份,`no_cache=true` 仍走 native 查询;新增持久化/账号漂移/backend 短路测试)与 forward-WS 事件消费者(`scripts/n5/ws_drain.ps1`,只记消息数/字节数/重连数,不写正文;soak 在 attach 后启动,`require_event_consumer` 模式下要求 `event_consumer_active` 且 journal `Gap=0`)。新构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)的启动包/未知版本门 PASS;`init.ps1 -Mode all` default 509 / research 569、0 failed。最终 24h 于 `2026-11-27T01:38:44Z` 在新主根 `33284`(创建 `2026-11-27T01:37:42.0474720Z`,账号 B)启动,但在 8h 处发现两个缺陷:WS 消费者把 5s `ReceiveAsync` 取消当成断开,5,157 次重连只收到 309 条;`AccountActor::events_out` 只是 control `DrainEvents` 诊断队列,满时仍 degrade/拒绝 wrapper/projection 事件,导致 journal 564 Event + 2,848 Gap;control Stop 返回后 daemon 未退出,force-kill,bridge 保留。已修正:诊断队列满时 wrapper/projection 事件只增加 `events_deliverable_queue_dropped` 并继续 journal/OneBot 发布(不 Gap、不 degrade),WS 接收取消改为 30s、停止等待 45s;新增 runtime 回归。最终 24h 需新构建 + 新新鲜 QQ 重跑;定时任务已取消。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-final-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) +2026-11-27 feat-007 N5 最终 24h 重跑准备(issue #16):24h attempt 2 的缺口已做实现修正——新增持久登录缓存(`get_login_info` 无 `no_cache` 时成功查询后写账号目录 `login.private.json`;core 重启后默认动作先返回持久身份,`no_cache=true` 仍走 native 查询;新增持久化/账号漂移/backend 短路测试)与 forward-WS 事件消费者(`scripts/n5/ws_drain.ps1`,只记消息数/字节数/重连数,不写正文;soak 在 attach 后启动,`require_event_consumer` 模式下要求 `event_consumer_active` 且 journal `Gap=0`)。新构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)的启动包/未知版本门 PASS;`init.ps1 -Mode all` default 509 / research 569、0 failed。最终 24h 于 `2026-11-27T01:38:44Z` 在新主根 `33284`(创建 `2026-11-27T01:37:42.0474720Z`,账号 B)启动,但在 8h 处发现两个缺陷:WS 消费者把 5s `ReceiveAsync` 取消当成断开,5,157 次重连只收到 309 条;`AccountActor::events_out` 只是 control `DrainEvents` 诊断队列,满时仍 degrade/拒绝 wrapper/projection 事件,导致 journal 564 Event + 2,848 Gap;control Stop 返回后 daemon 未退出,force-kill,bridge 保留。已修正:诊断队列满时 wrapper/projection 事件只增加 `events_deliverable_queue_dropped` 并继续 journal/OneBot 发布(不 Gap、不 degrade),WS 接收取消改为 30s、停止等待 45s;新增 runtime/wrapper 回归,`init.ps1 -Mode all` default 510 / research 570、0 failed。新构建 `e9db64a`(EXE `58D9CAE9…2C99`、bridge `659CE4D1…CE14`)启动包/未知版本门 PASS;最终 24h 需新新鲜 QQ 重跑;原定时任务已取消。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-final-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) 2026-11-25 feat-007 N5 启动包/未知版本门与 2h 现场观察(issue #16):新增 `scripts/n5/verify-release.ps1`,按 CI 同源脚本构建并打包 default release,校验 zip sidecar、`build-info.json` 的 commit/version/target/mode/entrypoint 与包内逐文件 SHA-256;解压后的 packaged daemon 两次启动均回答 `get_version_info`(retcode 0),无 bridge 时 `get_login_info` 诚实返回 1502,控制停止后 journal 保留;篡改 `QQ.exe` 哈希后 `verify-manifest` 与 `qq-entry` 均在 gate 1 拒绝且不产生 report,默认构建 `inject` 先被 K4-D0 拒绝。固定构建 `caligo.exe` SHA-256 `820781DB…57CE5`、`caligo_bridge.dll` `1EBF6E35…44FC`。现场 2h(本轮零发送):新 QQ 主根 `26620`(创建 `2026-11-25T12:03:11.4979693Z`,登记账号 B)通过固定 manifest/模块、PE/backend 审计与唯一 Environment 后一次 attach;117 个采样、`version`/`status`/`login` 351/351 成功、0 探测失败;30/60/90 分钟 3/3 次 kill core 并以同 journal/pipe/token 重启,恢复 1.56/1.53/1.55s、journal 完整帧前缀保留、bridge 未重新 attach;期间 495 条真实入站事件,`event_seq` 1–495 无缺口、495 个唯一 native ID、0 重复,generation 始终 1;daemon working set 7.7→14.6 MiB、handles 102→102,控制停止 daemon 后默认 bridge 保留、QQ 响应。2h 样本不证明 24h、QQ 重启后新代次重绑或真实 TCP 背压;`CoreStopped` 后同一代次不能重新 attach,24h 需新新鲜 QQ。随后在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并于 `14:56:45Z` 启动 24h soak。attempt 1 在约 8h 处 incomplete 停止(`2026-11-25T23:00:15Z`):479 samples、version/status 958/958 成功、journal 持续增长到 4,409,381 bytes,但 `get_login_info` 从 `15:19:49Z` 起长期返回 1502(456 次);第 2 次 core 重启(`22:56:46Z`)后 daemon 启动、journal 继续增长,但登录查询 188s 超时,harness 判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实返回,不应作为常驻链失败或重启恢复唯一信号;`n5_soak.py` 已改为 version/status 作为探测与恢复信号、登录查询单独计数并保留 1502,离线 rehearsal(18s、含一次 core 重启)通过。24h 门未通过;原定 `2026-11-26T23:10` 的到点任务已取消。修正判据后,attempt 2 于 `2026-11-25T23:33:25Z` 在新主根 `43444`(创建 `2026-11-25T23:31:19.6213631Z`,账号 B)上重跑并完整跑满 86,420s:1438 个采样,version/status 2876/2876 成功,3/3 次 core 崩溃重启恢复(0.18/0.18/0.19s)、journal 完整帧前缀保留,attach 登录成功,控制停止后 bridge 保留、QQ 响应,daemon working set 7.7→~10 MiB、handles ~105 稳定。但 journal 3,020,642 bytes 含 896 个 Event(`event_seq` 1–896 无缺口、0 重复)和 **13,234 条 Gap**(本轮无 OneBot WS/SSE/POST 消费者,事件队列满后的有界拒绝),因此不是应用级 24h;`get_login_info` 1438 次中 215 次成功、265 次 1502、958 次 10s 超时(锁屏/重启后 default 动作走 native query),是待修产品可靠性缺陷。常驻链 24h 通过、应用级 24h 与登录动作可靠性仍未闭合;需 WS/SSE 消费者参与并修正默认登录查询后另行现场复验。原定时任务已取消。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/`、`feat007-n5-24h-20261125-unbound/` 与 `feat007-n5-24h-20261126-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) diff --git a/session-handoff.md b/session-handoff.md index f5c3b49f..306f1e4f 100644 --- a/session-handoff.md +++ b/session-handoff.md @@ -1,6 +1,6 @@ # Session handoff -2026-11-27 feat-007 N5 最终 24h(issue #16):修正 attempt 2 的登录查询与无消费者缺口。新构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)增加持久登录缓存(`login.private.json`;默认 `get_login_info` 走缓存,`no_cache` 走 native)与 forward-WS 事件消费者(`scripts/n5/ws_drain.ps1`,只记录计数)。离线启动包/未知版本门 PASS;`init.ps1 -Mode all` default 509 / research 569、0 failed。最终 24h 于 `2026-11-27T01:38:44Z` 在新主根 `33284`(创建 `2026-11-27T01:37:42.0474720Z`,账号 B)启动,8h 处发现 WS 消费者 5s 取消重连(5,157 次、309 条)与 control `DrainEvents` 诊断队列满时拒绝 wrapper/projection 事件(2,848 Gap);control Stop 后 daemon 未退出,force-kill,bridge 保留。已修正队列语义与 WS 30s 取消/45s 停止等待,并新增 runtime 回归;最终 24h 需新构建 + 新新鲜 QQ 重跑,原定时任务已取消。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-final-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) +2026-11-27 feat-007 N5 最终 24h(issue #16):修正 attempt 2 的登录查询与无消费者缺口。新构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)增加持久登录缓存(`login.private.json`;默认 `get_login_info` 走缓存,`no_cache` 走 native)与 forward-WS 事件消费者(`scripts/n5/ws_drain.ps1`,只记录计数)。离线启动包/未知版本门 PASS;`init.ps1 -Mode all` default 509 / research 569、0 failed。最终 24h 于 `2026-11-27T01:38:44Z` 在新主根 `33284`(创建 `2026-11-27T01:37:42.0474720Z`,账号 B)启动,8h 处发现 WS 消费者 5s 取消重连(5,157 次、309 条)与 control `DrainEvents` 诊断队列满时拒绝 wrapper/projection 事件(2,848 Gap);control Stop 后 daemon 未退出,force-kill,bridge 保留。已修正队列语义与 WS 30s 取消/45s 停止等待,新增 runtime/wrapper 回归,`init.ps1 -Mode all` default 510 / research 570;新构建 `e9db64a`(EXE `58D9CAE9…2C99`)启动包/未知版本门 PASS,最终 24h 需新新鲜 QQ 重跑,原定时任务已取消。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-final-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) 2026-11-25 feat-007 N5 离线启动包/未知版本门 + 2h 现场观察通过(issue #16):`scripts/n5/verify-release.ps1` 的 default release 打包、sidecar/build-info/包内哈希、两次 packaged daemon 启动与诚实无 bridge 登录失败、篡改 manifest 的 gate 1 拒绝均 pass;固定 `caligo.exe` `820781DB…57CE5`、bridge `1EBF6E35…44FC`。现场新 QQ `26620`(创建 `2026-11-25T12:03:11.4979693Z`,账号 B)一次 attach,零发送;117 samples、351/351 查询成功、3/3 次 core 崩溃重启约 1.5s 恢复、495 条入站事件无重复/缺口、控制停止后 bridge 保留。2h 样本不证明 24h/QQ 重启新代次/真实 TCP 背压;`CoreStopped` 后同代次不能重新 attach。已在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并启动 24h soak;attempt 1 在约 8h 处 incomplete(`2026-11-25T23:00:15Z`):version/status 958/958 成功、journal 持续增长,但 `get_login_info` 从 `15:19:49Z` 起长期返回 1502(456 次),第 2 次 core 重启后登录查询 188s 超时触发 fatal。已确认 1502 是 QQ 锁屏/会话不可用时的诚实返回;`n5_soak.py` 已改为 version/status 作为探测与恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 1 未通过,原定时核验任务已取消。修正判据后 attempt 2 于 `2026-11-25T23:33:25Z` 在新主根 `43444`(创建 `2026-11-25T23:31:19.6213631Z`,账号 B)重跑,完整跑满 86,420s:version/status 2876/2876 成功、3/3 次 core 重启恢复(约 0.2s)、bridge 保留、QQ 响应、内存/句柄稳定;但 journal 含 13,234 条 Gap(本轮无 OneBot 事件消费者,队列满后的有界拒绝),`get_login_info` 1438 次中 215 次成功、265 次 1502、958 次 10s 超时。常驻链 24h 通过,应用级 24h 与登录动作可靠性仍未闭合;需 WS/SSE 消费者参与并修正 default 登录查询(应优先返回持久身份或有界失败)后另行现场复验。原定时任务已取消,issue #16 不关闭。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/`、`feat007-n5-24h-20261125-unbound/` 与 `feat007-n5-24h-20261126-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) From 6caa6f47161d810875d1df9a9468fb53707c64d1 Mon Sep 17 00:00:00 2001 From: Vegetable <3089665724@qq.com> Date: Fri, 27 Nov 2026 22:11:31 +0800 Subject: [PATCH 10/13] docs(feat-007): record queue-fix 24h attempt --- docs/acceptance/2026-11-25-feat-007-n5-release.md | 10 +++++++--- feature_list.json | 2 +- progress.md | 2 +- session-handoff.md | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/acceptance/2026-11-25-feat-007-n5-release.md b/docs/acceptance/2026-11-25-feat-007-n5-release.md index b092663c..3043e1e2 100644 --- a/docs/acceptance/2026-11-25-feat-007-n5-release.md +++ b/docs/acceptance/2026-11-25-feat-007-n5-release.md @@ -120,14 +120,18 @@ attach 时仍要求一次登录成功。该修复通过离线 rehearsal(18s, - 更根本的是 `AccountActor::events_out` 只是 control `DrainEvents` 的诊断队列;生产 OneBot fanout 已直接发布。队列满时旧实现仍 `degrade` 并拒绝 wrapper/projection 事件,导致正常事件不再发布。 - 停止时 control Stop 返回 `stopped`,但 daemon 在队列压力下未退出(高 CPU),最终 force-kill;bridge 保留、QQ 响应。 -修正:wrapper/projection 事件在诊断队列满时只增加 `events_deliverable_queue_dropped` 计数,继续 journal/OneBot 发布,不再 Gap/degrade;WS 消费者接收取消改为 30s,soak 停止等待改为 45s。新增 runtime 回归,`init.ps1 -Mode all` default **510** / research **570**、0 failed。新构建 `e9db64a`(`caligo.exe` `58D9CAE9…2C99`、bridge `659CE4D1…CE14`)的启动包/未知版本门 PASS;该构建需要最终 24h 复验,未通过前不把本节视为通过。 +修正:wrapper/projection 事件在诊断队列满时只增加 `events_deliverable_queue_dropped` 计数,继续 journal/OneBot 发布,不再 Gap/degrade;WS 消费者接收取消改为 30s,soak 停止等待改为 45s。新增 runtime 回归,`init.ps1 -Mode all` default **510** / research **570**、0 failed。新构建 `e9db64a`(`caligo.exe` `58D9CAE9…2C99`、bridge `659CE4D1…CE14`)的启动包/未知版本门 PASS。 + +### 4.4 24h attempt 4(queue-fix build,running) + +`e9db64a` 在 `2026-11-27T14:10:19Z` 于新的新鲜 QQ 主根上启动最终 24h:一次 attach、零发送、60s 只读探测、持久登录缓存、forward-WS 事件消费者,+2h/+8h/+16h 各一次 core 重启,预计 `2026-11-28T14:10:19Z` 结束。到点由本机定时任务核验 `event_consumer_active`、`no_event_queue_gaps`、journal 无重复/缺口与 3/3 重启恢复,再更新本节。本轮通过前不把 24h 门标为完全通过,也不关闭 issue #16。 ## 5. 剩余门与边界 - **24h**:attempt 1 在 8h 处 incomplete(§4.1);attempt 2 完整跑满 24h 但应用级未闭合 (§4.2);attempt 3 在 8h 处发现事件诊断队列拒绝与 WS 消费者重连缺陷(§4.3),已停止并 - 修正。需要新构建 + 新新鲜 QQ 做最终 24h;重跑通过前不把 N5 24h 门标为完全通过,也不关闭 - issue #16。 + 修正。queue-fix 构建 `e9db64a` 的 attempt 4 于 `2026-11-27T14:10:19Z` 启动(§4.4), + 结果待到点核验;重跑通过前不把 N5 24h 门标为完全通过,也不关闭 issue #16。 - **QQ 重启**:需要操作者退出并重启 QQ,随后对新 PID/创建时间重新 preflight/attach; 旧代次的请求、映射和回调不得混入新实例。 - **启动包**:本轮为 default 构建;research 构建、真实 QQ 字段与发布 tag 流程是独立验收。 diff --git a/feature_list.json b/feature_list.json index 6ff09dad..83c80a68 100644 --- a/feature_list.json +++ b/feature_list.json @@ -110,7 +110,7 @@ "plan_steps": ["N5"], "dependencies": ["feat-006"], "status": "in-progress", - "evidence": "2026-11-25 离线启动包/未知版本门通过(scripts/n5/verify-release.ps1):default release 构建与 CI 同源打包,zip sidecar、build-info commit/version/target/mode 和包内逐文件 SHA-256 均匹配;解压后 packaged daemon 两次启动均回答 get_version_info、无 bridge 时 get_login_info 诚实返回 1502、控制停止后 journal 保留;篡改 QQ.exe 哈希后 verify-manifest 与 qq-entry 均在 gate 1 拒绝且不产生 report,默认构建的 inject 先被 K4-D0 拒绝。现场 2h 观察通过(零发送、60s 只读探测、30/60/90 分钟 core 崩溃重启):新 QQ 主根一次 attach,117 个采样、351/351 次查询成功、495 条真实入站事件无重复/缺口(event_seq 1–495),3/3 次 core 崩溃重启各约 1.5s 恢复且 journal 完整帧前缀保留,控制停止后默认 bridge 保留、QQ 响应。CoreStopped 后同一代次不能重新 attach,因此在新主根上启动 24h soak;attempt 1 在约 8h 处 incomplete:version/status 探测 958/958 成功、journal 持续增长,但 get_login_info 从 15:19Z 起长期返回 1502(456 次),第 2 次 core 重启后 harness 因登录查询超时判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实结果,不是常驻链失败;harness 已改为 version/status 作为探测与重启恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 2 已完整跑满 86,420s:version/status 2876/2876 成功、3/3 次 core 重启恢复(约 0.2s)、bridge 保留、QQ 响应、内存/句柄稳定,但 journal 含 13,234 条 Gap(本轮无 OneBot 事件消费者,队列满后的有界拒绝),且 get_login_info 1438 次中仅 215 次成功(265 次 1502、958 次 10s 超时,锁屏/重启后默认动作走 native query)。常驻链 24h 通过,应用级 24h 与登录动作可靠性仍未闭合。随后实现持久登录缓存(默认 get_login_info 返回确认身份,no_cache 仍走 native;core 重启后从 login.private.json 恢复)与 forward-WS 事件消费者(ws_drain.ps1,记录计数不写正文;soak 要求 event_consumer_active 且 journal Gap=0);新构建 17f5ec6(EXE 4C9B057D…02BB、bridge 659CE4D1…CE14)的启动包/未知版本门 PASS,但其 24h 在 8h 处发现事件诊断队列拒绝与 WS 消费者 5s 取消重连缺陷(WS 309 条/5,157 次重连,journal 564 Event + 2,848 Gap,停止时 daemon 未退出需 force-kill)。已修正:wrapper/projection 事件在 control DrainEvents 队列满时只计数并继续 journal/OneBot 发布,不再 Gap/degrade;WS 接收取消改为 30s,soak 停止等待 45s;新增 runtime/wrapper 回归,init.ps1 -Mode all default 510 / research 570、0 failed。新构建 e9db64a(EXE 58D9CAE9…2C99、bridge 659CE4D1…CE14)启动包/未知版本门 PASS;最终 24h 仍需新新鲜 QQ 重跑。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。", + "evidence": "2026-11-25 离线启动包/未知版本门通过(scripts/n5/verify-release.ps1):default release 构建与 CI 同源打包,zip sidecar、build-info commit/version/target/mode 和包内逐文件 SHA-256 均匹配;解压后 packaged daemon 两次启动均回答 get_version_info、无 bridge 时 get_login_info 诚实返回 1502、控制停止后 journal 保留;篡改 QQ.exe 哈希后 verify-manifest 与 qq-entry 均在 gate 1 拒绝且不产生 report,默认构建的 inject 先被 K4-D0 拒绝。现场 2h 观察通过(零发送、60s 只读探测、30/60/90 分钟 core 崩溃重启):新 QQ 主根一次 attach,117 个采样、351/351 次查询成功、495 条真实入站事件无重复/缺口(event_seq 1–495),3/3 次 core 崩溃重启各约 1.5s 恢复且 journal 完整帧前缀保留,控制停止后默认 bridge 保留、QQ 响应。CoreStopped 后同一代次不能重新 attach,因此在新主根上启动 24h soak;attempt 1 在约 8h 处 incomplete:version/status 探测 958/958 成功、journal 持续增长,但 get_login_info 从 15:19Z 起长期返回 1502(456 次),第 2 次 core 重启后 harness 因登录查询超时判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实结果,不是常驻链失败;harness 已改为 version/status 作为探测与重启恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 2 已完整跑满 86,420s:version/status 2876/2876 成功、3/3 次 core 重启恢复(约 0.2s)、bridge 保留、QQ 响应、内存/句柄稳定,但 journal 含 13,234 条 Gap(本轮无 OneBot 事件消费者,队列满后的有界拒绝),且 get_login_info 1438 次中仅 215 次成功(265 次 1502、958 次 10s 超时,锁屏/重启后默认动作走 native query)。常驻链 24h 通过,应用级 24h 与登录动作可靠性仍未闭合。随后实现持久登录缓存(默认 get_login_info 返回确认身份,no_cache 仍走 native;core 重启后从 login.private.json 恢复)与 forward-WS 事件消费者(ws_drain.ps1,记录计数不写正文;soak 要求 event_consumer_active 且 journal Gap=0);新构建 17f5ec6(EXE 4C9B057D…02BB、bridge 659CE4D1…CE14)的启动包/未知版本门 PASS,但其 24h 在 8h 处发现事件诊断队列拒绝与 WS 消费者 5s 取消重连缺陷(WS 309 条/5,157 次重连,journal 564 Event + 2,848 Gap,停止时 daemon 未退出需 force-kill)。已修正:wrapper/projection 事件在 control DrainEvents 队列满时只计数并继续 journal/OneBot 发布,不再 Gap/degrade;WS 接收取消改为 30s,soak 停止等待 45s;新增 runtime/wrapper 回归,init.ps1 -Mode all default 510 / research 570、0 failed。新构建 e9db64a(EXE 58D9CAE9…2C99、bridge 659CE4D1…CE14)启动包/未知版本门 PASS;attempt 4 已于 2026-11-27T14:10:19Z 在新新鲜 QQ 主根上启动(WS 消费者 + 登录缓存,+2h/+8h/+16h 重启,预计 2026-11-28T14:10:19Z 结束),到点核验。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。", "evidence_paths": ["docs/acceptance/2026-11-25-feat-007-n5-release.md", "scripts/n5/verify-release.ps1", "scripts/n5/preflight.ps1", "scripts/n5/attach.ps1", "scripts/n5/n5_soak.py", "docs/plans/2026-10-09-gitnexus-plan-caligo-snowluma-capability-parity.md"], "done_criteria": ["正常入口无需每消息交互", "core/QQ 重启、断链/慢客户端矩阵通过", "未知版本零 native 调用,停止边界如实", "24h 单账号验收及启动包证据齐全"] }, diff --git a/progress.md b/progress.md index ae04746e..331cacf0 100644 --- a/progress.md +++ b/progress.md @@ -2,7 +2,7 @@ ## Current State -2026-11-27 feat-007 N5 最终 24h 重跑准备(issue #16):24h attempt 2 的缺口已做实现修正——新增持久登录缓存(`get_login_info` 无 `no_cache` 时成功查询后写账号目录 `login.private.json`;core 重启后默认动作先返回持久身份,`no_cache=true` 仍走 native 查询;新增持久化/账号漂移/backend 短路测试)与 forward-WS 事件消费者(`scripts/n5/ws_drain.ps1`,只记消息数/字节数/重连数,不写正文;soak 在 attach 后启动,`require_event_consumer` 模式下要求 `event_consumer_active` 且 journal `Gap=0`)。新构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)的启动包/未知版本门 PASS;`init.ps1 -Mode all` default 509 / research 569、0 failed。最终 24h 于 `2026-11-27T01:38:44Z` 在新主根 `33284`(创建 `2026-11-27T01:37:42.0474720Z`,账号 B)启动,但在 8h 处发现两个缺陷:WS 消费者把 5s `ReceiveAsync` 取消当成断开,5,157 次重连只收到 309 条;`AccountActor::events_out` 只是 control `DrainEvents` 诊断队列,满时仍 degrade/拒绝 wrapper/projection 事件,导致 journal 564 Event + 2,848 Gap;control Stop 返回后 daemon 未退出,force-kill,bridge 保留。已修正:诊断队列满时 wrapper/projection 事件只增加 `events_deliverable_queue_dropped` 并继续 journal/OneBot 发布(不 Gap、不 degrade),WS 接收取消改为 30s、停止等待 45s;新增 runtime/wrapper 回归,`init.ps1 -Mode all` default 510 / research 570、0 failed。新构建 `e9db64a`(EXE `58D9CAE9…2C99`、bridge `659CE4D1…CE14`)启动包/未知版本门 PASS;最终 24h 需新新鲜 QQ 重跑;原定时任务已取消。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-final-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) +2026-11-27 feat-007 N5 最终 24h 重跑准备(issue #16):24h attempt 2 的缺口已做实现修正——新增持久登录缓存(`get_login_info` 无 `no_cache` 时成功查询后写账号目录 `login.private.json`;core 重启后默认动作先返回持久身份,`no_cache=true` 仍走 native 查询;新增持久化/账号漂移/backend 短路测试)与 forward-WS 事件消费者(`scripts/n5/ws_drain.ps1`,只记消息数/字节数/重连数,不写正文;soak 在 attach 后启动,`require_event_consumer` 模式下要求 `event_consumer_active` 且 journal `Gap=0`)。新构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)的启动包/未知版本门 PASS;`init.ps1 -Mode all` default 509 / research 569、0 failed。最终 24h 于 `2026-11-27T01:38:44Z` 在新主根 `33284`(创建 `2026-11-27T01:37:42.0474720Z`,账号 B)启动,但在 8h 处发现两个缺陷:WS 消费者把 5s `ReceiveAsync` 取消当成断开,5,157 次重连只收到 309 条;`AccountActor::events_out` 只是 control `DrainEvents` 诊断队列,满时仍 degrade/拒绝 wrapper/projection 事件,导致 journal 564 Event + 2,848 Gap;control Stop 返回后 daemon 未退出,force-kill,bridge 保留。已修正:诊断队列满时 wrapper/projection 事件只增加 `events_deliverable_queue_dropped` 并继续 journal/OneBot 发布(不 Gap、不 degrade),WS 接收取消改为 30s、停止等待 45s;新增 runtime/wrapper 回归,`init.ps1 -Mode all` default 510 / research 570、0 failed。新构建 `e9db64a`(EXE `58D9CAE9…2C99`、bridge `659CE4D1…CE14`)启动包/未知版本门 PASS;attempt 4 于 `2026-11-27T14:10:19Z` 在新主根 `22560`(创建 `2026-11-27T14:09:56.6234676Z`,账号 B)启动,带 WS 消费者与登录缓存,+2h/+8h/+16h 各一次 core 重启,预计 `2026-11-28T14:10:19Z` 结束;定时任务 `schedule-414615f1-3bb4-476d-be17-e17a099d6245` 在 `2026-11-28T22:30+08:00` 核验。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-final-20261127-unbound/` 与 `feat007-n5-final4-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) 2026-11-25 feat-007 N5 启动包/未知版本门与 2h 现场观察(issue #16):新增 `scripts/n5/verify-release.ps1`,按 CI 同源脚本构建并打包 default release,校验 zip sidecar、`build-info.json` 的 commit/version/target/mode/entrypoint 与包内逐文件 SHA-256;解压后的 packaged daemon 两次启动均回答 `get_version_info`(retcode 0),无 bridge 时 `get_login_info` 诚实返回 1502,控制停止后 journal 保留;篡改 `QQ.exe` 哈希后 `verify-manifest` 与 `qq-entry` 均在 gate 1 拒绝且不产生 report,默认构建 `inject` 先被 K4-D0 拒绝。固定构建 `caligo.exe` SHA-256 `820781DB…57CE5`、`caligo_bridge.dll` `1EBF6E35…44FC`。现场 2h(本轮零发送):新 QQ 主根 `26620`(创建 `2026-11-25T12:03:11.4979693Z`,登记账号 B)通过固定 manifest/模块、PE/backend 审计与唯一 Environment 后一次 attach;117 个采样、`version`/`status`/`login` 351/351 成功、0 探测失败;30/60/90 分钟 3/3 次 kill core 并以同 journal/pipe/token 重启,恢复 1.56/1.53/1.55s、journal 完整帧前缀保留、bridge 未重新 attach;期间 495 条真实入站事件,`event_seq` 1–495 无缺口、495 个唯一 native ID、0 重复,generation 始终 1;daemon working set 7.7→14.6 MiB、handles 102→102,控制停止 daemon 后默认 bridge 保留、QQ 响应。2h 样本不证明 24h、QQ 重启后新代次重绑或真实 TCP 背压;`CoreStopped` 后同一代次不能重新 attach,24h 需新新鲜 QQ。随后在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并于 `14:56:45Z` 启动 24h soak。attempt 1 在约 8h 处 incomplete 停止(`2026-11-25T23:00:15Z`):479 samples、version/status 958/958 成功、journal 持续增长到 4,409,381 bytes,但 `get_login_info` 从 `15:19:49Z` 起长期返回 1502(456 次);第 2 次 core 重启(`22:56:46Z`)后 daemon 启动、journal 继续增长,但登录查询 188s 超时,harness 判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实返回,不应作为常驻链失败或重启恢复唯一信号;`n5_soak.py` 已改为 version/status 作为探测与恢复信号、登录查询单独计数并保留 1502,离线 rehearsal(18s、含一次 core 重启)通过。24h 门未通过;原定 `2026-11-26T23:10` 的到点任务已取消。修正判据后,attempt 2 于 `2026-11-25T23:33:25Z` 在新主根 `43444`(创建 `2026-11-25T23:31:19.6213631Z`,账号 B)上重跑并完整跑满 86,420s:1438 个采样,version/status 2876/2876 成功,3/3 次 core 崩溃重启恢复(0.18/0.18/0.19s)、journal 完整帧前缀保留,attach 登录成功,控制停止后 bridge 保留、QQ 响应,daemon working set 7.7→~10 MiB、handles ~105 稳定。但 journal 3,020,642 bytes 含 896 个 Event(`event_seq` 1–896 无缺口、0 重复)和 **13,234 条 Gap**(本轮无 OneBot WS/SSE/POST 消费者,事件队列满后的有界拒绝),因此不是应用级 24h;`get_login_info` 1438 次中 215 次成功、265 次 1502、958 次 10s 超时(锁屏/重启后 default 动作走 native query),是待修产品可靠性缺陷。常驻链 24h 通过、应用级 24h 与登录动作可靠性仍未闭合;需 WS/SSE 消费者参与并修正默认登录查询后另行现场复验。原定时任务已取消。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/`、`feat007-n5-24h-20261125-unbound/` 与 `feat007-n5-24h-20261126-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) diff --git a/session-handoff.md b/session-handoff.md index 306f1e4f..1af8ac22 100644 --- a/session-handoff.md +++ b/session-handoff.md @@ -1,6 +1,6 @@ # Session handoff -2026-11-27 feat-007 N5 最终 24h(issue #16):修正 attempt 2 的登录查询与无消费者缺口。新构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)增加持久登录缓存(`login.private.json`;默认 `get_login_info` 走缓存,`no_cache` 走 native)与 forward-WS 事件消费者(`scripts/n5/ws_drain.ps1`,只记录计数)。离线启动包/未知版本门 PASS;`init.ps1 -Mode all` default 509 / research 569、0 failed。最终 24h 于 `2026-11-27T01:38:44Z` 在新主根 `33284`(创建 `2026-11-27T01:37:42.0474720Z`,账号 B)启动,8h 处发现 WS 消费者 5s 取消重连(5,157 次、309 条)与 control `DrainEvents` 诊断队列满时拒绝 wrapper/projection 事件(2,848 Gap);control Stop 后 daemon 未退出,force-kill,bridge 保留。已修正队列语义与 WS 30s 取消/45s 停止等待,新增 runtime/wrapper 回归,`init.ps1 -Mode all` default 510 / research 570;新构建 `e9db64a`(EXE `58D9CAE9…2C99`)启动包/未知版本门 PASS,最终 24h 需新新鲜 QQ 重跑,原定时任务已取消。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-final-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) +2026-11-27 feat-007 N5 最终 24h(issue #16):修正 attempt 2 的登录查询与无消费者缺口。新构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)增加持久登录缓存(`login.private.json`;默认 `get_login_info` 走缓存,`no_cache` 走 native)与 forward-WS 事件消费者(`scripts/n5/ws_drain.ps1`,只记录计数)。离线启动包/未知版本门 PASS;`init.ps1 -Mode all` default 509 / research 569、0 failed。最终 24h 于 `2026-11-27T01:38:44Z` 在新主根 `33284`(创建 `2026-11-27T01:37:42.0474720Z`,账号 B)启动,8h 处发现 WS 消费者 5s 取消重连(5,157 次、309 条)与 control `DrainEvents` 诊断队列满时拒绝 wrapper/projection 事件(2,848 Gap);control Stop 后 daemon 未退出,force-kill,bridge 保留。已修正队列语义与 WS 30s 取消/45s 停止等待,新增 runtime/wrapper 回归,`init.ps1 -Mode all` default 510 / research 570;新构建 `e9db64a`(EXE `58D9CAE9…2C99`)启动包/未知版本门 PASS。attempt 4 于 `2026-11-27T14:10:19Z` 在新主根 `22560`(创建 `2026-11-27T14:09:56.6234676Z`,账号 B)启动(WS 消费者 + 登录缓存,+2h/+8h/+16h 重启,预计 `2026-11-28T14:10:19Z` 结束);定时任务 `schedule-414615f1-3bb4-476d-be17-e17a099d6245` 在 `2026-11-28T22:30+08:00` 核验,不自动关闭 issue #16。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-final-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) 2026-11-25 feat-007 N5 离线启动包/未知版本门 + 2h 现场观察通过(issue #16):`scripts/n5/verify-release.ps1` 的 default release 打包、sidecar/build-info/包内哈希、两次 packaged daemon 启动与诚实无 bridge 登录失败、篡改 manifest 的 gate 1 拒绝均 pass;固定 `caligo.exe` `820781DB…57CE5`、bridge `1EBF6E35…44FC`。现场新 QQ `26620`(创建 `2026-11-25T12:03:11.4979693Z`,账号 B)一次 attach,零发送;117 samples、351/351 查询成功、3/3 次 core 崩溃重启约 1.5s 恢复、495 条入站事件无重复/缺口、控制停止后 bridge 保留。2h 样本不证明 24h/QQ 重启新代次/真实 TCP 背压;`CoreStopped` 后同代次不能重新 attach。已在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并启动 24h soak;attempt 1 在约 8h 处 incomplete(`2026-11-25T23:00:15Z`):version/status 958/958 成功、journal 持续增长,但 `get_login_info` 从 `15:19:49Z` 起长期返回 1502(456 次),第 2 次 core 重启后登录查询 188s 超时触发 fatal。已确认 1502 是 QQ 锁屏/会话不可用时的诚实返回;`n5_soak.py` 已改为 version/status 作为探测与恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 1 未通过,原定时核验任务已取消。修正判据后 attempt 2 于 `2026-11-25T23:33:25Z` 在新主根 `43444`(创建 `2026-11-25T23:31:19.6213631Z`,账号 B)重跑,完整跑满 86,420s:version/status 2876/2876 成功、3/3 次 core 重启恢复(约 0.2s)、bridge 保留、QQ 响应、内存/句柄稳定;但 journal 含 13,234 条 Gap(本轮无 OneBot 事件消费者,队列满后的有界拒绝),`get_login_info` 1438 次中 215 次成功、265 次 1502、958 次 10s 超时。常驻链 24h 通过,应用级 24h 与登录动作可靠性仍未闭合;需 WS/SSE 消费者参与并修正 default 登录查询(应优先返回持久身份或有界失败)后另行现场复验。原定时任务已取消,issue #16 不关闭。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/`、`feat007-n5-24h-20261125-unbound/` 与 `feat007-n5-24h-20261126-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) From 26f66b49a7562355c7d4e04436ee90b9ffb6654c Mon Sep 17 00:00:00 2001 From: Vegetable <3089665724@qq.com> Date: Sat, 28 Nov 2026 22:11:26 +0800 Subject: [PATCH 11/13] docs(feat-007): record passed final 24h run --- .../2026-11-25-feat-007-n5-release.md | 23 +++++++++++++++---- feature_list.json | 2 +- progress.md | 2 ++ session-handoff.md | 2 ++ 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/docs/acceptance/2026-11-25-feat-007-n5-release.md b/docs/acceptance/2026-11-25-feat-007-n5-release.md index 3043e1e2..183ce860 100644 --- a/docs/acceptance/2026-11-25-feat-007-n5-release.md +++ b/docs/acceptance/2026-11-25-feat-007-n5-release.md @@ -13,7 +13,7 @@ | 正常入口无需每消息交互 | feat-006 现场:daemon + 一次 attach 后真实应用经 HTTP/WS 收发;本轮 2h 现场:同一 daemon/attach 下 117 个采样、351/351 次只读查询成功,495 条真实入站事件入账,无每条消息 CLI 交互 | 24h 连续运行 | | core/QQ 重启、断链/慢客户端矩阵 | 离线 `core_restart_query_lab` 4/4、`recovery_contract` 13/13、`onebot_transport` 10/10;本轮 2h 现场 3/3 次 core 崩溃重启与 bridge 重连(各约 1.5s) | QQ 退出/重启后新代次重绑;真实 TCP 背压 | | 未知版本零 native 调用,停止边界如实 | 本轮离线门:篡改 manifest 后 `verify-manifest`/`qq-entry` 在 gate 1 拒绝,report 未产生;`inject` 在默认构建被 K4-D0 拒绝;现场控制停止后默认 bridge 保留 | 失败停止的现场负例仍未新增(沿用 feat-005/006 证据) | -| 24h 单账号验收及启动包证据齐全 | 本轮启动包:release zip、`build-info.json`、sidecar SHA-256、包内逐文件哈希、解压后 daemon 两次启动/停止与诚实无 bridge 登录失败;attempt 2 常驻链跑满 24h(version/status 2876/2876、3/3 重启、bridge/QQ 正常,§4.2) | 应用级 24h 未闭合:无 OneBot 事件消费者导致 13,234 条队列 Gap;`get_login_info` 锁屏/重启后 958 次超时;QQ 重启新代次矩阵未取证 | +| 24h 单账号验收及启动包证据齐全 | 启动包与未知版本门 PASS;attempt 4 完整跑满 86,426s:version/status 2878/2878、登录 1439/1439、3/3 重启、journal 4,837 Event 无缺口/0 重复/0 Gap、WS 消费者 4,708 条、bridge/QQ 正常(§4.4) | WS 客户端空闲重连窗口少收 129/4,837 条(客户端侧);真实 TCP 背压与 QQ 重启新代次矩阵未取证 | ## 2. 启动包与离线门 @@ -122,16 +122,29 @@ attach 时仍要求一次登录成功。该修复通过离线 rehearsal(18s, 修正:wrapper/projection 事件在诊断队列满时只增加 `events_deliverable_queue_dropped` 计数,继续 journal/OneBot 发布,不再 Gap/degrade;WS 消费者接收取消改为 30s,soak 停止等待改为 45s。新增 runtime 回归,`init.ps1 -Mode all` default **510** / research **570**、0 failed。新构建 `e9db64a`(`caligo.exe` `58D9CAE9…2C99`、bridge `659CE4D1…CE14`)的启动包/未知版本门 PASS。 -### 4.4 24h attempt 4(queue-fix build,running) +### 4.4 24h attempt 4(queue-fix build,pass) -`e9db64a` 在 `2026-11-27T14:10:19Z` 于新的新鲜 QQ 主根上启动最终 24h:一次 attach、零发送、60s 只读探测、持久登录缓存、forward-WS 事件消费者,+2h/+8h/+16h 各一次 core 重启,预计 `2026-11-28T14:10:19Z` 结束。到点由本机定时任务核验 `event_consumer_active`、`no_event_queue_gaps`、journal 无重复/缺口与 3/3 重启恢复,再更新本节。本轮通过前不把 24h 门标为完全通过,也不关闭 issue #16。 +`e9db64a` 在 `2026-11-27T14:10:19Z` 于新的新鲜 QQ 主根上启动最终 24h:一次 attach、零发送、60s 只读探测、持久登录缓存、forward-WS 事件消费者,+2h/+8h/+16h 各一次 core 重启,`2026-11-28T14:10:19Z` 结束。结果(包内 `soak-summary.json`,overall `pass`): + +| 项目 | 结果 | +|---|---| +| 时长/采样 | 86,426s(目标 86,400s),1439 个采样 | +| version/status | 2878/2878 成功,0 failure | +| 登录 | 1439/1439 成功,`login_1502=0`、`login_timeout=0`;attach 身份确认 | +| core 重启 | 3/3 恢复(0.18s / 0.19s / 0.19s),journal 完整帧前缀保留 | +| journal | 4,921,410 bytes;**4,837 个 Event,`event_seq` 1–4837 无缺口、0 重复、0 条 Gap** | +| WS 消费者 | 4,708 条消息、1,616,691 bytes;1,533 次连接/断开(30s 空闲取消导致的客户端重连)、3 次错误;`event_consumer_active=true` | +| 停止/资源 | control Stop 后 bridge 保留、QQ 响应;daemon working set 约 10–15 MiB、handles ~107 稳定 | + +**结论:24h 单账号常驻、核心重启、登录缓存与事件消费门通过。** 边界:WS 消费者在 1,533 次空闲重连窗口内少收 129/4,837 条事件(客户端侧缺口,journal 无 Gap、core 无丢失);真实 TCP 背压仍未证。QQ 退出/重启后的新代次重绑矩阵仍需单独样本。 ## 5. 剩余门与边界 - **24h**:attempt 1 在 8h 处 incomplete(§4.1);attempt 2 完整跑满 24h 但应用级未闭合 (§4.2);attempt 3 在 8h 处发现事件诊断队列拒绝与 WS 消费者重连缺陷(§4.3),已停止并 - 修正。queue-fix 构建 `e9db64a` 的 attempt 4 于 `2026-11-27T14:10:19Z` 启动(§4.4), - 结果待到点核验;重跑通过前不把 N5 24h 门标为完全通过,也不关闭 issue #16。 + 修正。queue-fix 构建 `e9db64a` 的 attempt 4 完整跑满 86,426s 并通过(§4.4)。24h 门按 + “常驻 + core 重启 + 登录缓存 + 事件消费”关闭;WS 客户端空闲重连造成的 129/4,837 条客户端 + 缺口、真实 TCP 背压与 QQ 重启矩阵仍作为边界保留。 - **QQ 重启**:需要操作者退出并重启 QQ,随后对新 PID/创建时间重新 preflight/attach; 旧代次的请求、映射和回调不得混入新实例。 - **启动包**:本轮为 default 构建;research 构建、真实 QQ 字段与发布 tag 流程是独立验收。 diff --git a/feature_list.json b/feature_list.json index 83c80a68..a96e963e 100644 --- a/feature_list.json +++ b/feature_list.json @@ -110,7 +110,7 @@ "plan_steps": ["N5"], "dependencies": ["feat-006"], "status": "in-progress", - "evidence": "2026-11-25 离线启动包/未知版本门通过(scripts/n5/verify-release.ps1):default release 构建与 CI 同源打包,zip sidecar、build-info commit/version/target/mode 和包内逐文件 SHA-256 均匹配;解压后 packaged daemon 两次启动均回答 get_version_info、无 bridge 时 get_login_info 诚实返回 1502、控制停止后 journal 保留;篡改 QQ.exe 哈希后 verify-manifest 与 qq-entry 均在 gate 1 拒绝且不产生 report,默认构建的 inject 先被 K4-D0 拒绝。现场 2h 观察通过(零发送、60s 只读探测、30/60/90 分钟 core 崩溃重启):新 QQ 主根一次 attach,117 个采样、351/351 次查询成功、495 条真实入站事件无重复/缺口(event_seq 1–495),3/3 次 core 崩溃重启各约 1.5s 恢复且 journal 完整帧前缀保留,控制停止后默认 bridge 保留、QQ 响应。CoreStopped 后同一代次不能重新 attach,因此在新主根上启动 24h soak;attempt 1 在约 8h 处 incomplete:version/status 探测 958/958 成功、journal 持续增长,但 get_login_info 从 15:19Z 起长期返回 1502(456 次),第 2 次 core 重启后 harness 因登录查询超时判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实结果,不是常驻链失败;harness 已改为 version/status 作为探测与重启恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 2 已完整跑满 86,420s:version/status 2876/2876 成功、3/3 次 core 重启恢复(约 0.2s)、bridge 保留、QQ 响应、内存/句柄稳定,但 journal 含 13,234 条 Gap(本轮无 OneBot 事件消费者,队列满后的有界拒绝),且 get_login_info 1438 次中仅 215 次成功(265 次 1502、958 次 10s 超时,锁屏/重启后默认动作走 native query)。常驻链 24h 通过,应用级 24h 与登录动作可靠性仍未闭合。随后实现持久登录缓存(默认 get_login_info 返回确认身份,no_cache 仍走 native;core 重启后从 login.private.json 恢复)与 forward-WS 事件消费者(ws_drain.ps1,记录计数不写正文;soak 要求 event_consumer_active 且 journal Gap=0);新构建 17f5ec6(EXE 4C9B057D…02BB、bridge 659CE4D1…CE14)的启动包/未知版本门 PASS,但其 24h 在 8h 处发现事件诊断队列拒绝与 WS 消费者 5s 取消重连缺陷(WS 309 条/5,157 次重连,journal 564 Event + 2,848 Gap,停止时 daemon 未退出需 force-kill)。已修正:wrapper/projection 事件在 control DrainEvents 队列满时只计数并继续 journal/OneBot 发布,不再 Gap/degrade;WS 接收取消改为 30s,soak 停止等待 45s;新增 runtime/wrapper 回归,init.ps1 -Mode all default 510 / research 570、0 failed。新构建 e9db64a(EXE 58D9CAE9…2C99、bridge 659CE4D1…CE14)启动包/未知版本门 PASS;attempt 4 已于 2026-11-27T14:10:19Z 在新新鲜 QQ 主根上启动(WS 消费者 + 登录缓存,+2h/+8h/+16h 重启,预计 2026-11-28T14:10:19Z 结束),到点核验。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。", + "evidence": "2026-11-25 离线启动包/未知版本门通过(scripts/n5/verify-release.ps1):default release 构建与 CI 同源打包,zip sidecar、build-info commit/version/target/mode 和包内逐文件 SHA-256 均匹配;解压后 packaged daemon 两次启动均回答 get_version_info、无 bridge 时 get_login_info 诚实返回 1502、控制停止后 journal 保留;篡改 QQ.exe 哈希后 verify-manifest 与 qq-entry 均在 gate 1 拒绝且不产生 report,默认构建的 inject 先被 K4-D0 拒绝。现场 2h 观察通过(零发送、60s 只读探测、30/60/90 分钟 core 崩溃重启):新 QQ 主根一次 attach,117 个采样、351/351 次查询成功、495 条真实入站事件无重复/缺口(event_seq 1–495),3/3 次 core 崩溃重启各约 1.5s 恢复且 journal 完整帧前缀保留,控制停止后默认 bridge 保留、QQ 响应。CoreStopped 后同一代次不能重新 attach,因此在新主根上启动 24h soak;attempt 1 在约 8h 处 incomplete:version/status 探测 958/958 成功、journal 持续增长,但 get_login_info 从 15:19Z 起长期返回 1502(456 次),第 2 次 core 重启后 harness 因登录查询超时判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实结果,不是常驻链失败;harness 已改为 version/status 作为探测与重启恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 2 已完整跑满 86,420s:version/status 2876/2876 成功、3/3 次 core 重启恢复(约 0.2s)、bridge 保留、QQ 响应、内存/句柄稳定,但 journal 含 13,234 条 Gap(本轮无 OneBot 事件消费者,队列满后的有界拒绝),且 get_login_info 1438 次中仅 215 次成功(265 次 1502、958 次 10s 超时,锁屏/重启后默认动作走 native query)。常驻链 24h 通过,应用级 24h 与登录动作可靠性仍未闭合。随后实现持久登录缓存(默认 get_login_info 返回确认身份,no_cache 仍走 native;core 重启后从 login.private.json 恢复)与 forward-WS 事件消费者(ws_drain.ps1,记录计数不写正文;soak 要求 event_consumer_active 且 journal Gap=0);新构建 17f5ec6(EXE 4C9B057D…02BB、bridge 659CE4D1…CE14)的启动包/未知版本门 PASS,但其 24h 在 8h 处发现事件诊断队列拒绝与 WS 消费者 5s 取消重连缺陷(WS 309 条/5,157 次重连,journal 564 Event + 2,848 Gap,停止时 daemon 未退出需 force-kill)。已修正:wrapper/projection 事件在 control DrainEvents 队列满时只计数并继续 journal/OneBot 发布,不再 Gap/degrade;WS 接收取消改为 30s,soak 停止等待 45s;新增 runtime/wrapper 回归,init.ps1 -Mode all default 510 / research 570、0 failed。新构建 e9db64a(EXE 58D9CAE9…2C99、bridge 659CE4D1…CE14)启动包/未知版本门 PASS;attempt 4 已完整跑满 86,426s 并通过:version/status 2878/2878、登录 1439/1439(1502/timeout 均为 0)、3/3 次 core 重启恢复(0.18/0.19/0.19s)、journal 4,837 Event(event_seq 1–4837 无缺口、0 重复、0 Gap)、WS 消费者 4,708 条消息/1,616,691 bytes(1,533 次空闲重连、3 次错误,客户端侧少收 129 条)、bridge 保留、QQ 响应、资源稳定。24h 门按常驻/core 重启/登录缓存/事件消费关闭;真实 TCP 背压与 QQ 重启新代次矩阵仍是边界。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。", "evidence_paths": ["docs/acceptance/2026-11-25-feat-007-n5-release.md", "scripts/n5/verify-release.ps1", "scripts/n5/preflight.ps1", "scripts/n5/attach.ps1", "scripts/n5/n5_soak.py", "docs/plans/2026-10-09-gitnexus-plan-caligo-snowluma-capability-parity.md"], "done_criteria": ["正常入口无需每消息交互", "core/QQ 重启、断链/慢客户端矩阵通过", "未知版本零 native 调用,停止边界如实", "24h 单账号验收及启动包证据齐全"] }, diff --git a/progress.md b/progress.md index 331cacf0..4afbc858 100644 --- a/progress.md +++ b/progress.md @@ -2,6 +2,8 @@ ## Current State +2026-11-28 feat-007 N5 24h 最终现场通过(issue #16):queue-fix 构建 `e9db64a`(EXE `58D9CAE9…2C99`、bridge `659CE4D1…CE14`)于 `2026-11-27T14:10:19Z`–`2026-11-28T14:10:19Z` 完整跑满 86,426s:1439 samples,version/status 2878/2878、登录 1439/1439(1502/timeout 均为 0),+2h/+8h/+16h 三次 core 重启分别 0.18/0.19/0.19s 恢复且 journal 完整帧前缀保留;journal 4,921,410 bytes、4,837 个 Event(event_seq 1–4837 无缺口、0 重复、0 Gap);forward-WS 消费者 4,708 条消息/1,616,691 bytes,1,533 次空闲重连、3 次错误,客户端侧少收 129 条(core 无丢失);停止后 bridge 保留、QQ 响应,daemon working set 约 10–15 MiB、handles ~107 稳定。24h 门按常驻/core 重启/登录缓存/事件消费关闭;真实 TCP 背压与 QQ 重启新代次矩阵仍未取证。原始材料只在 ignored `local-evidence/feat007-n5-final4-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) + 2026-11-27 feat-007 N5 最终 24h 重跑准备(issue #16):24h attempt 2 的缺口已做实现修正——新增持久登录缓存(`get_login_info` 无 `no_cache` 时成功查询后写账号目录 `login.private.json`;core 重启后默认动作先返回持久身份,`no_cache=true` 仍走 native 查询;新增持久化/账号漂移/backend 短路测试)与 forward-WS 事件消费者(`scripts/n5/ws_drain.ps1`,只记消息数/字节数/重连数,不写正文;soak 在 attach 后启动,`require_event_consumer` 模式下要求 `event_consumer_active` 且 journal `Gap=0`)。新构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)的启动包/未知版本门 PASS;`init.ps1 -Mode all` default 509 / research 569、0 failed。最终 24h 于 `2026-11-27T01:38:44Z` 在新主根 `33284`(创建 `2026-11-27T01:37:42.0474720Z`,账号 B)启动,但在 8h 处发现两个缺陷:WS 消费者把 5s `ReceiveAsync` 取消当成断开,5,157 次重连只收到 309 条;`AccountActor::events_out` 只是 control `DrainEvents` 诊断队列,满时仍 degrade/拒绝 wrapper/projection 事件,导致 journal 564 Event + 2,848 Gap;control Stop 返回后 daemon 未退出,force-kill,bridge 保留。已修正:诊断队列满时 wrapper/projection 事件只增加 `events_deliverable_queue_dropped` 并继续 journal/OneBot 发布(不 Gap、不 degrade),WS 接收取消改为 30s、停止等待 45s;新增 runtime/wrapper 回归,`init.ps1 -Mode all` default 510 / research 570、0 failed。新构建 `e9db64a`(EXE `58D9CAE9…2C99`、bridge `659CE4D1…CE14`)启动包/未知版本门 PASS;attempt 4 于 `2026-11-27T14:10:19Z` 在新主根 `22560`(创建 `2026-11-27T14:09:56.6234676Z`,账号 B)启动,带 WS 消费者与登录缓存,+2h/+8h/+16h 各一次 core 重启,预计 `2026-11-28T14:10:19Z` 结束;定时任务 `schedule-414615f1-3bb4-476d-be17-e17a099d6245` 在 `2026-11-28T22:30+08:00` 核验。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-final-20261127-unbound/` 与 `feat007-n5-final4-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) 2026-11-25 feat-007 N5 启动包/未知版本门与 2h 现场观察(issue #16):新增 `scripts/n5/verify-release.ps1`,按 CI 同源脚本构建并打包 default release,校验 zip sidecar、`build-info.json` 的 commit/version/target/mode/entrypoint 与包内逐文件 SHA-256;解压后的 packaged daemon 两次启动均回答 `get_version_info`(retcode 0),无 bridge 时 `get_login_info` 诚实返回 1502,控制停止后 journal 保留;篡改 `QQ.exe` 哈希后 `verify-manifest` 与 `qq-entry` 均在 gate 1 拒绝且不产生 report,默认构建 `inject` 先被 K4-D0 拒绝。固定构建 `caligo.exe` SHA-256 `820781DB…57CE5`、`caligo_bridge.dll` `1EBF6E35…44FC`。现场 2h(本轮零发送):新 QQ 主根 `26620`(创建 `2026-11-25T12:03:11.4979693Z`,登记账号 B)通过固定 manifest/模块、PE/backend 审计与唯一 Environment 后一次 attach;117 个采样、`version`/`status`/`login` 351/351 成功、0 探测失败;30/60/90 分钟 3/3 次 kill core 并以同 journal/pipe/token 重启,恢复 1.56/1.53/1.55s、journal 完整帧前缀保留、bridge 未重新 attach;期间 495 条真实入站事件,`event_seq` 1–495 无缺口、495 个唯一 native ID、0 重复,generation 始终 1;daemon working set 7.7→14.6 MiB、handles 102→102,控制停止 daemon 后默认 bridge 保留、QQ 响应。2h 样本不证明 24h、QQ 重启后新代次重绑或真实 TCP 背压;`CoreStopped` 后同一代次不能重新 attach,24h 需新新鲜 QQ。随后在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并于 `14:56:45Z` 启动 24h soak。attempt 1 在约 8h 处 incomplete 停止(`2026-11-25T23:00:15Z`):479 samples、version/status 958/958 成功、journal 持续增长到 4,409,381 bytes,但 `get_login_info` 从 `15:19:49Z` 起长期返回 1502(456 次);第 2 次 core 重启(`22:56:46Z`)后 daemon 启动、journal 继续增长,但登录查询 188s 超时,harness 判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实返回,不应作为常驻链失败或重启恢复唯一信号;`n5_soak.py` 已改为 version/status 作为探测与恢复信号、登录查询单独计数并保留 1502,离线 rehearsal(18s、含一次 core 重启)通过。24h 门未通过;原定 `2026-11-26T23:10` 的到点任务已取消。修正判据后,attempt 2 于 `2026-11-25T23:33:25Z` 在新主根 `43444`(创建 `2026-11-25T23:31:19.6213631Z`,账号 B)上重跑并完整跑满 86,420s:1438 个采样,version/status 2876/2876 成功,3/3 次 core 崩溃重启恢复(0.18/0.18/0.19s)、journal 完整帧前缀保留,attach 登录成功,控制停止后 bridge 保留、QQ 响应,daemon working set 7.7→~10 MiB、handles ~105 稳定。但 journal 3,020,642 bytes 含 896 个 Event(`event_seq` 1–896 无缺口、0 重复)和 **13,234 条 Gap**(本轮无 OneBot WS/SSE/POST 消费者,事件队列满后的有界拒绝),因此不是应用级 24h;`get_login_info` 1438 次中 215 次成功、265 次 1502、958 次 10s 超时(锁屏/重启后 default 动作走 native query),是待修产品可靠性缺陷。常驻链 24h 通过、应用级 24h 与登录动作可靠性仍未闭合;需 WS/SSE 消费者参与并修正默认登录查询后另行现场复验。原定时任务已取消。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/`、`feat007-n5-24h-20261125-unbound/` 与 `feat007-n5-24h-20261126-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) diff --git a/session-handoff.md b/session-handoff.md index 1af8ac22..9d82ebd5 100644 --- a/session-handoff.md +++ b/session-handoff.md @@ -1,5 +1,7 @@ # Session handoff +2026-11-28 feat-007 N5 24h 最终现场通过(issue #16):`e9db64a`(EXE `58D9CAE9…2C99`)在 `2026-11-27T14:10:19Z`–`2026-11-28T14:10:19Z` 跑满 86,426s:1439 samples、version/status 2878/2878、登录 1439/1439、3/3 次 core 重启 0.18/0.19/0.19s、journal 4,837 Event(无缺口/0 重复/0 Gap)、WS 消费者 4,708 条(1,533 次空闲重连、3 次错误,客户端少收 129 条)、bridge/QQ/资源正常。24h 门关闭;仍剩 QQ 退出/重启后的新代次重绑矩阵与真实 TCP 背压。下一步需用户另取新鲜 QQ 跑一次短的新代次 attach 样本,再决定是否关闭 issue #16;不要复用在跑的实例。原始材料只在 ignored `local-evidence/feat007-n5-final4-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) + 2026-11-27 feat-007 N5 最终 24h(issue #16):修正 attempt 2 的登录查询与无消费者缺口。新构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)增加持久登录缓存(`login.private.json`;默认 `get_login_info` 走缓存,`no_cache` 走 native)与 forward-WS 事件消费者(`scripts/n5/ws_drain.ps1`,只记录计数)。离线启动包/未知版本门 PASS;`init.ps1 -Mode all` default 509 / research 569、0 failed。最终 24h 于 `2026-11-27T01:38:44Z` 在新主根 `33284`(创建 `2026-11-27T01:37:42.0474720Z`,账号 B)启动,8h 处发现 WS 消费者 5s 取消重连(5,157 次、309 条)与 control `DrainEvents` 诊断队列满时拒绝 wrapper/projection 事件(2,848 Gap);control Stop 后 daemon 未退出,force-kill,bridge 保留。已修正队列语义与 WS 30s 取消/45s 停止等待,新增 runtime/wrapper 回归,`init.ps1 -Mode all` default 510 / research 570;新构建 `e9db64a`(EXE `58D9CAE9…2C99`)启动包/未知版本门 PASS。attempt 4 于 `2026-11-27T14:10:19Z` 在新主根 `22560`(创建 `2026-11-27T14:09:56.6234676Z`,账号 B)启动(WS 消费者 + 登录缓存,+2h/+8h/+16h 重启,预计 `2026-11-28T14:10:19Z` 结束);定时任务 `schedule-414615f1-3bb4-476d-be17-e17a099d6245` 在 `2026-11-28T22:30+08:00` 核验,不自动关闭 issue #16。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-final-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) 2026-11-25 feat-007 N5 离线启动包/未知版本门 + 2h 现场观察通过(issue #16):`scripts/n5/verify-release.ps1` 的 default release 打包、sidecar/build-info/包内哈希、两次 packaged daemon 启动与诚实无 bridge 登录失败、篡改 manifest 的 gate 1 拒绝均 pass;固定 `caligo.exe` `820781DB…57CE5`、bridge `1EBF6E35…44FC`。现场新 QQ `26620`(创建 `2026-11-25T12:03:11.4979693Z`,账号 B)一次 attach,零发送;117 samples、351/351 查询成功、3/3 次 core 崩溃重启约 1.5s 恢复、495 条入站事件无重复/缺口、控制停止后 bridge 保留。2h 样本不证明 24h/QQ 重启新代次/真实 TCP 背压;`CoreStopped` 后同代次不能重新 attach。已在新主根 `17504`(创建 `2026-11-25T14:54:38.7754423Z`,账号 B)完成 preflight 并启动 24h soak;attempt 1 在约 8h 处 incomplete(`2026-11-25T23:00:15Z`):version/status 958/958 成功、journal 持续增长,但 `get_login_info` 从 `15:19:49Z` 起长期返回 1502(456 次),第 2 次 core 重启后登录查询 188s 超时触发 fatal。已确认 1502 是 QQ 锁屏/会话不可用时的诚实返回;`n5_soak.py` 已改为 version/status 作为探测与恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 1 未通过,原定时核验任务已取消。修正判据后 attempt 2 于 `2026-11-25T23:33:25Z` 在新主根 `43444`(创建 `2026-11-25T23:31:19.6213631Z`,账号 B)重跑,完整跑满 86,420s:version/status 2876/2876 成功、3/3 次 core 重启恢复(约 0.2s)、bridge 保留、QQ 响应、内存/句柄稳定;但 journal 含 13,234 条 Gap(本轮无 OneBot 事件消费者,队列满后的有界拒绝),`get_login_info` 1438 次中 215 次成功、265 次 1502、958 次 10s 超时。常驻链 24h 通过,应用级 24h 与登录动作可靠性仍未闭合;需 WS/SSE 消费者参与并修正 default 登录查询(应优先返回持久身份或有界失败)后另行现场复验。原定时任务已取消,issue #16 不关闭。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-20261125-unbound/`、`feat007-n5-24h-20261125-unbound/` 与 `feat007-n5-24h-20261126-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) From 678e20326560822eabd86cfd9eb6a607be6ca126 Mon Sep 17 00:00:00 2001 From: Vegetable <3089665724@qq.com> Date: Sat, 28 Nov 2026 22:23:52 +0800 Subject: [PATCH 12/13] docs(feat-007): close N5 evidence with rebind sample --- .../2026-11-25-feat-007-n5-release.md | 20 +++++++++++++++++-- feature_list.json | 2 +- progress.md | 2 +- scripts/n5/attach.ps1 | 6 +++++- scripts/n5/preflight.ps1 | 4 ++++ session-handoff.md | 2 +- 6 files changed, 30 insertions(+), 6 deletions(-) diff --git a/docs/acceptance/2026-11-25-feat-007-n5-release.md b/docs/acceptance/2026-11-25-feat-007-n5-release.md index 183ce860..1f57d4a3 100644 --- a/docs/acceptance/2026-11-25-feat-007-n5-release.md +++ b/docs/acceptance/2026-11-25-feat-007-n5-release.md @@ -11,7 +11,7 @@ | done_criterion | 已有证据 | 仍未闭合 | |---|---|---| | 正常入口无需每消息交互 | feat-006 现场:daemon + 一次 attach 后真实应用经 HTTP/WS 收发;本轮 2h 现场:同一 daemon/attach 下 117 个采样、351/351 次只读查询成功,495 条真实入站事件入账,无每条消息 CLI 交互 | 24h 连续运行 | -| core/QQ 重启、断链/慢客户端矩阵 | 离线 `core_restart_query_lab` 4/4、`recovery_contract` 13/13、`onebot_transport` 10/10;本轮 2h 现场 3/3 次 core 崩溃重启与 bridge 重连(各约 1.5s) | QQ 退出/重启后新代次重绑;真实 TCP 背压 | +| core/QQ 重启、断链/慢客户端矩阵 | 离线 `core_restart_query_lab` 4/4、`recovery_contract` 13/13、`onebot_transport` 10/10;24h 现场 3/3 次 core 重启;新代次样本:旧 journal 不变、新 journal 仅 gen2(§4.5);feat-006 现场慢 POST/非读取 WS 与确定性 transport 回归 | 真实 TCP 背压(Windows loopback 无法稳定制造) | | 未知版本零 native 调用,停止边界如实 | 本轮离线门:篡改 manifest 后 `verify-manifest`/`qq-entry` 在 gate 1 拒绝,report 未产生;`inject` 在默认构建被 K4-D0 拒绝;现场控制停止后默认 bridge 保留 | 失败停止的现场负例仍未新增(沿用 feat-005/006 证据) | | 24h 单账号验收及启动包证据齐全 | 启动包与未知版本门 PASS;attempt 4 完整跑满 86,426s:version/status 2878/2878、登录 1439/1439、3/3 重启、journal 4,837 Event 无缺口/0 重复/0 Gap、WS 消费者 4,708 条、bridge/QQ 正常(§4.4) | WS 客户端空闲重连窗口少收 129/4,837 条(客户端侧);真实 TCP 背压与 QQ 重启新代次矩阵未取证 | @@ -136,7 +136,21 @@ attach 时仍要求一次登录成功。该修复通过离线 rehearsal(18s, | WS 消费者 | 4,708 条消息、1,616,691 bytes;1,533 次连接/断开(30s 空闲取消导致的客户端重连)、3 次错误;`event_consumer_active=true` | | 停止/资源 | control Stop 后 bridge 保留、QQ 响应;daemon working set 约 10–15 MiB、handles ~107 稳定 | -**结论:24h 单账号常驻、核心重启、登录缓存与事件消费门通过。** 边界:WS 消费者在 1,533 次空闲重连窗口内少收 129/4,837 条事件(客户端侧缺口,journal 无 Gap、core 无丢失);真实 TCP 背压仍未证。QQ 退出/重启后的新代次重绑矩阵仍需单独样本。 +**结论:24h 单账号常驻、核心重启、登录缓存与事件消费门通过。** 边界:WS 消费者在 1,533 次空闲重连窗口内少收 129/4,837 条事件(客户端侧缺口,journal 无 Gap、core 无丢失);真实 TCP 背压仍未证。 + +### 4.5 新代次重绑样本(2026-11-28) + +同一登记账号另取新鲜 QQ 主根,使用 `generation=2`、新 journal、新 pipe/token 做 108s 样本: + +| 项目 | 结果 | +|---|---| +| 准入/接入 | 新鲜主根通过只读 preflight;一次 gen2 attach,登录核验成功 | +| 短运行 | 21 samples、0 探测失败;一次 core 重启 0.18s 恢复,登录缓存可用;控制停止后 bridge 保留、QQ 响应 | +| 新 journal | 8 个 Event,`event_seq` 1–8,`session_generations=[2]`,无缺口/重复 | +| 旧 journal | 4,921,410 bytes、SHA-256 `A026E296…A833F`,样本前后完全一致(`old-journal-baseline.private.json`) | +| 隔离结论 | 新代次只写自己的 journal;旧 gen1 journal 不变;本轮零发送,因此无旧请求重放 | + +该样本补上“QQ 退出/重启后新代次重绑”的现场证据;不证明同一进程内换号、真实 TCP 背压或未证寿命的热卸载。 ## 5. 剩余门与边界 @@ -152,6 +166,8 @@ attach 时仍要求一次登录成功。该修复通过离线 rehearsal(18s, bridge 保留到 QQ 正常退出。 - **慢客户端**:确定性 transport 合同与 feat-006 现场慢 POST 已有证据;真实 TCP 背压仍未证。 +按 issue #16 的四条 done criteria 汇总:常驻无每消息交互(24h)通过;core/QQ 重启与断连/慢客户端矩阵通过(真实 TCP 背压作为已记录边界);未知版本零 native 调用与停止边界通过;24h 单账号与启动包证据齐全。因此 issue #16 可按证据关闭。`feat-007` 在 `feature_list.json` 仍保持 `in-progress`:其依赖 `feat-006` 未 done,项目整体仍 NOT READY;native 对象寿命/owner-stop 与真实 TCP 背压继续作为未闭合边界,不由本验收外推。 + ## 6. 复现命令 ```powershell diff --git a/feature_list.json b/feature_list.json index a96e963e..9cfb4bdf 100644 --- a/feature_list.json +++ b/feature_list.json @@ -110,7 +110,7 @@ "plan_steps": ["N5"], "dependencies": ["feat-006"], "status": "in-progress", - "evidence": "2026-11-25 离线启动包/未知版本门通过(scripts/n5/verify-release.ps1):default release 构建与 CI 同源打包,zip sidecar、build-info commit/version/target/mode 和包内逐文件 SHA-256 均匹配;解压后 packaged daemon 两次启动均回答 get_version_info、无 bridge 时 get_login_info 诚实返回 1502、控制停止后 journal 保留;篡改 QQ.exe 哈希后 verify-manifest 与 qq-entry 均在 gate 1 拒绝且不产生 report,默认构建的 inject 先被 K4-D0 拒绝。现场 2h 观察通过(零发送、60s 只读探测、30/60/90 分钟 core 崩溃重启):新 QQ 主根一次 attach,117 个采样、351/351 次查询成功、495 条真实入站事件无重复/缺口(event_seq 1–495),3/3 次 core 崩溃重启各约 1.5s 恢复且 journal 完整帧前缀保留,控制停止后默认 bridge 保留、QQ 响应。CoreStopped 后同一代次不能重新 attach,因此在新主根上启动 24h soak;attempt 1 在约 8h 处 incomplete:version/status 探测 958/958 成功、journal 持续增长,但 get_login_info 从 15:19Z 起长期返回 1502(456 次),第 2 次 core 重启后 harness 因登录查询超时判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实结果,不是常驻链失败;harness 已改为 version/status 作为探测与重启恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 2 已完整跑满 86,420s:version/status 2876/2876 成功、3/3 次 core 重启恢复(约 0.2s)、bridge 保留、QQ 响应、内存/句柄稳定,但 journal 含 13,234 条 Gap(本轮无 OneBot 事件消费者,队列满后的有界拒绝),且 get_login_info 1438 次中仅 215 次成功(265 次 1502、958 次 10s 超时,锁屏/重启后默认动作走 native query)。常驻链 24h 通过,应用级 24h 与登录动作可靠性仍未闭合。随后实现持久登录缓存(默认 get_login_info 返回确认身份,no_cache 仍走 native;core 重启后从 login.private.json 恢复)与 forward-WS 事件消费者(ws_drain.ps1,记录计数不写正文;soak 要求 event_consumer_active 且 journal Gap=0);新构建 17f5ec6(EXE 4C9B057D…02BB、bridge 659CE4D1…CE14)的启动包/未知版本门 PASS,但其 24h 在 8h 处发现事件诊断队列拒绝与 WS 消费者 5s 取消重连缺陷(WS 309 条/5,157 次重连,journal 564 Event + 2,848 Gap,停止时 daemon 未退出需 force-kill)。已修正:wrapper/projection 事件在 control DrainEvents 队列满时只计数并继续 journal/OneBot 发布,不再 Gap/degrade;WS 接收取消改为 30s,soak 停止等待 45s;新增 runtime/wrapper 回归,init.ps1 -Mode all default 510 / research 570、0 failed。新构建 e9db64a(EXE 58D9CAE9…2C99、bridge 659CE4D1…CE14)启动包/未知版本门 PASS;attempt 4 已完整跑满 86,426s 并通过:version/status 2878/2878、登录 1439/1439(1502/timeout 均为 0)、3/3 次 core 重启恢复(0.18/0.19/0.19s)、journal 4,837 Event(event_seq 1–4837 无缺口、0 重复、0 Gap)、WS 消费者 4,708 条消息/1,616,691 bytes(1,533 次空闲重连、3 次错误,客户端侧少收 129 条)、bridge 保留、QQ 响应、资源稳定。24h 门按常驻/core 重启/登录缓存/事件消费关闭;真实 TCP 背压与 QQ 重启新代次矩阵仍是边界。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。", + "evidence": "2026-11-25 离线启动包/未知版本门通过(scripts/n5/verify-release.ps1):default release 构建与 CI 同源打包,zip sidecar、build-info commit/version/target/mode 和包内逐文件 SHA-256 均匹配;解压后 packaged daemon 两次启动均回答 get_version_info、无 bridge 时 get_login_info 诚实返回 1502、控制停止后 journal 保留;篡改 QQ.exe 哈希后 verify-manifest 与 qq-entry 均在 gate 1 拒绝且不产生 report,默认构建的 inject 先被 K4-D0 拒绝。现场 2h 观察通过(零发送、60s 只读探测、30/60/90 分钟 core 崩溃重启):新 QQ 主根一次 attach,117 个采样、351/351 次查询成功、495 条真实入站事件无重复/缺口(event_seq 1–495),3/3 次 core 崩溃重启各约 1.5s 恢复且 journal 完整帧前缀保留,控制停止后默认 bridge 保留、QQ 响应。CoreStopped 后同一代次不能重新 attach,因此在新主根上启动 24h soak;attempt 1 在约 8h 处 incomplete:version/status 探测 958/958 成功、journal 持续增长,但 get_login_info 从 15:19Z 起长期返回 1502(456 次),第 2 次 core 重启后 harness 因登录查询超时判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实结果,不是常驻链失败;harness 已改为 version/status 作为探测与重启恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 2 已完整跑满 86,420s:version/status 2876/2876 成功、3/3 次 core 重启恢复(约 0.2s)、bridge 保留、QQ 响应、内存/句柄稳定,但 journal 含 13,234 条 Gap(本轮无 OneBot 事件消费者,队列满后的有界拒绝),且 get_login_info 1438 次中仅 215 次成功(265 次 1502、958 次 10s 超时,锁屏/重启后默认动作走 native query)。常驻链 24h 通过,应用级 24h 与登录动作可靠性仍未闭合。随后实现持久登录缓存(默认 get_login_info 返回确认身份,no_cache 仍走 native;core 重启后从 login.private.json 恢复)与 forward-WS 事件消费者(ws_drain.ps1,记录计数不写正文;soak 要求 event_consumer_active 且 journal Gap=0);新构建 17f5ec6(EXE 4C9B057D…02BB、bridge 659CE4D1…CE14)的启动包/未知版本门 PASS,但其 24h 在 8h 处发现事件诊断队列拒绝与 WS 消费者 5s 取消重连缺陷(WS 309 条/5,157 次重连,journal 564 Event + 2,848 Gap,停止时 daemon 未退出需 force-kill)。已修正:wrapper/projection 事件在 control DrainEvents 队列满时只计数并继续 journal/OneBot 发布,不再 Gap/degrade;WS 接收取消改为 30s,soak 停止等待 45s;新增 runtime/wrapper 回归,init.ps1 -Mode all default 510 / research 570、0 failed。新构建 e9db64a(EXE 58D9CAE9…2C99、bridge 659CE4D1…CE14)启动包/未知版本门 PASS;attempt 4 已完整跑满 86,426s 并通过:version/status 2878/2878、登录 1439/1439(1502/timeout 均为 0)、3/3 次 core 重启恢复(0.18/0.19/0.19s)、journal 4,837 Event(event_seq 1–4837 无缺口、0 重复、0 Gap)、WS 消费者 4,708 条消息/1,616,691 bytes(1,533 次空闲重连、3 次错误,客户端侧少收 129 条)、bridge 保留、QQ 响应、资源稳定。24h 门按常驻/core 重启/登录缓存/事件消费关闭。补做新代次重绑现场:新鲜 QQ 主根以 generation=2、新 journal/pipe/token 一次 attach,108s 样本 21 samples、0 探测失败、一次 core 重启 0.18s 恢复,新 journal 8 Event 且 session_generations=[2],旧 gen1 journal 4,921,410 bytes / SHA-256 A026E296…A833F 前后完全不变;零发送,无旧请求重放。issue #16 四条 done criteria 均有证据,可按证据关闭;feature 仍 in-progress(依赖 feat-006 未 done,产品 NOT READY)。真实 TCP 背压、native 寿命/owner-stop 仍是已记录边界。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。", "evidence_paths": ["docs/acceptance/2026-11-25-feat-007-n5-release.md", "scripts/n5/verify-release.ps1", "scripts/n5/preflight.ps1", "scripts/n5/attach.ps1", "scripts/n5/n5_soak.py", "docs/plans/2026-10-09-gitnexus-plan-caligo-snowluma-capability-parity.md"], "done_criteria": ["正常入口无需每消息交互", "core/QQ 重启、断链/慢客户端矩阵通过", "未知版本零 native 调用,停止边界如实", "24h 单账号验收及启动包证据齐全"] }, diff --git a/progress.md b/progress.md index 4afbc858..5a3ff561 100644 --- a/progress.md +++ b/progress.md @@ -2,7 +2,7 @@ ## Current State -2026-11-28 feat-007 N5 24h 最终现场通过(issue #16):queue-fix 构建 `e9db64a`(EXE `58D9CAE9…2C99`、bridge `659CE4D1…CE14`)于 `2026-11-27T14:10:19Z`–`2026-11-28T14:10:19Z` 完整跑满 86,426s:1439 samples,version/status 2878/2878、登录 1439/1439(1502/timeout 均为 0),+2h/+8h/+16h 三次 core 重启分别 0.18/0.19/0.19s 恢复且 journal 完整帧前缀保留;journal 4,921,410 bytes、4,837 个 Event(event_seq 1–4837 无缺口、0 重复、0 Gap);forward-WS 消费者 4,708 条消息/1,616,691 bytes,1,533 次空闲重连、3 次错误,客户端侧少收 129 条(core 无丢失);停止后 bridge 保留、QQ 响应,daemon working set 约 10–15 MiB、handles ~107 稳定。24h 门按常驻/core 重启/登录缓存/事件消费关闭;真实 TCP 背压与 QQ 重启新代次矩阵仍未取证。原始材料只在 ignored `local-evidence/feat007-n5-final4-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) +2026-11-28 feat-007 N5 24h 最终现场通过(issue #16):queue-fix 构建 `e9db64a`(EXE `58D9CAE9…2C99`、bridge `659CE4D1…CE14`)于 `2026-11-27T14:10:19Z`–`2026-11-28T14:10:19Z` 完整跑满 86,426s:1439 samples,version/status 2878/2878、登录 1439/1439(1502/timeout 均为 0),+2h/+8h/+16h 三次 core 重启分别 0.18/0.19/0.19s 恢复且 journal 完整帧前缀保留;journal 4,921,410 bytes、4,837 个 Event(event_seq 1–4837 无缺口、0 重复、0 Gap);forward-WS 消费者 4,708 条消息/1,616,691 bytes,1,533 次空闲重连、3 次错误,客户端侧少收 129 条(core 无丢失);停止后 bridge 保留、QQ 响应,daemon working set 约 10–15 MiB、handles ~107 稳定。24h 门按常驻/core 重启/登录缓存/事件消费关闭。随后补做新代次重绑样本:同一登记账号另取新鲜 QQ 主根,以 `generation=2` + 新 journal/pipe/token 一次 attach;108s 样本 21 samples、0 探测失败、一次 core 重启 0.18s 恢复,新 journal 8 Event 且 `session_generations=[2]`,旧 gen1 journal 4,921,410 bytes / SHA-256 `A026E296…A833F` 前后完全不变;零发送,无旧请求重放。issue #16 四条 done criteria 均有证据,可按证据关闭;`feat-007` 仍 in-progress(依赖 `feat-006` 未 done,产品 NOT READY)。真实 TCP 背压、native 寿命/owner-stop 仍是已记录边界。原始材料只在 ignored `local-evidence/feat007-n5-final4-20261127-unbound/` 与 `feat007-n5-rebind-20261128-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) 2026-11-27 feat-007 N5 最终 24h 重跑准备(issue #16):24h attempt 2 的缺口已做实现修正——新增持久登录缓存(`get_login_info` 无 `no_cache` 时成功查询后写账号目录 `login.private.json`;core 重启后默认动作先返回持久身份,`no_cache=true` 仍走 native 查询;新增持久化/账号漂移/backend 短路测试)与 forward-WS 事件消费者(`scripts/n5/ws_drain.ps1`,只记消息数/字节数/重连数,不写正文;soak 在 attach 后启动,`require_event_consumer` 模式下要求 `event_consumer_active` 且 journal `Gap=0`)。新构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)的启动包/未知版本门 PASS;`init.ps1 -Mode all` default 509 / research 569、0 failed。最终 24h 于 `2026-11-27T01:38:44Z` 在新主根 `33284`(创建 `2026-11-27T01:37:42.0474720Z`,账号 B)启动,但在 8h 处发现两个缺陷:WS 消费者把 5s `ReceiveAsync` 取消当成断开,5,157 次重连只收到 309 条;`AccountActor::events_out` 只是 control `DrainEvents` 诊断队列,满时仍 degrade/拒绝 wrapper/projection 事件,导致 journal 564 Event + 2,848 Gap;control Stop 返回后 daemon 未退出,force-kill,bridge 保留。已修正:诊断队列满时 wrapper/projection 事件只增加 `events_deliverable_queue_dropped` 并继续 journal/OneBot 发布(不 Gap、不 degrade),WS 接收取消改为 30s、停止等待 45s;新增 runtime/wrapper 回归,`init.ps1 -Mode all` default 510 / research 570、0 failed。新构建 `e9db64a`(EXE `58D9CAE9…2C99`、bridge `659CE4D1…CE14`)启动包/未知版本门 PASS;attempt 4 于 `2026-11-27T14:10:19Z` 在新主根 `22560`(创建 `2026-11-27T14:09:56.6234676Z`,账号 B)启动,带 WS 消费者与登录缓存,+2h/+8h/+16h 各一次 core 重启,预计 `2026-11-28T14:10:19Z` 结束;定时任务 `schedule-414615f1-3bb4-476d-be17-e17a099d6245` 在 `2026-11-28T22:30+08:00` 核验。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-final-20261127-unbound/` 与 `feat007-n5-final4-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) diff --git a/scripts/n5/attach.ps1 b/scripts/n5/attach.ps1 index 82b6a269..384e1963 100644 --- a/scripts/n5/attach.ps1 +++ b/scripts/n5/attach.ps1 @@ -42,11 +42,15 @@ if (Test-Path -LiteralPath $reservation) { throw 'Attach was already reserved fo $handle = [IO.File]::Open($reservation, [IO.FileMode]::CreateNew, [IO.FileAccess]::Write, [IO.FileShare]::None) $handle.Dispose() +$generation = 1 +if ($null -ne $state.session_generation) { $generation = [int]$state.session_generation } +if ($generation -lt 1) { throw 'State session_generation must be positive' } + $report = Join-Path $Pack 'entry.private.jsonl' & $exe cli qq-entry --pid $state.pid --created-filetime $state.filetime ` --bridge $bridge --manifest $state.manifest --report $report --wait-s 20 ` --confirm-designated-test-instance --daemon-pipe $daemon.bridge_pipe ` - --daemon-auth-file $state.token_file --daemon-generation 1 --daemon-account ([string]$state.account) *> (Join-Path $Pack 'attach.private.log') + --daemon-auth-file $state.token_file --daemon-generation $generation --daemon-account ([string]$state.account) *> (Join-Path $Pack 'attach.private.log') if ($LASTEXITCODE -ne 0) { throw 'Attach failed; no retry' } $p.Refresh() diff --git a/scripts/n5/preflight.ps1 b/scripts/n5/preflight.ps1 index 54e947bd..07055d3e 100644 --- a/scripts/n5/preflight.ps1 +++ b/scripts/n5/preflight.ps1 @@ -8,6 +8,7 @@ param( [double]$DurationHours = 24, [int]$SampleSeconds = 60, [int[]]$RestartAtMinutes = @(120, 480, 960), + [int]$Generation = 1, [switch]$RequireEventConsumer, [switch]$Rehearse ) @@ -54,6 +55,7 @@ function Get-FreePort { try { return ([Net.IPEndPoint]$listener.LocalEndpoint).Port } finally { $listener.Stop() } } +if ($Generation -lt 1) { throw '-Generation must be a positive session generation' } if (-not (Test-Path -LiteralPath $exe) -or -not (Test-Path -LiteralPath $bridge)) { throw 'Release binaries missing; run scripts/n5/verify-release.ps1 first' } @@ -73,6 +75,7 @@ $state = [ordered]@{ manifest = $manifest manifest_sha256 = (Get-FileHash -LiteralPath $manifest -Algorithm SHA256).Hash account = $Account + session_generation = $Generation pid = $TargetPid created = $ExpectedCreated filetime = 0 @@ -190,6 +193,7 @@ $preparation = [ordered]@{ sample_seconds = $state.sample_seconds restart_at_minutes = $state.restart_at_minutes require_event_consumer = $state.require_event_consumer + session_generation = $state.session_generation expected = [ordered]@{ resident = 'one daemon and one admitted bridge; OneBot get_version_info/get_status/get_login_info continue to answer without per-message CLI interaction' restart = 'each injected core crash is followed by the same journal/pipe/token, bridge reconnects, and login/query becomes available again' diff --git a/session-handoff.md b/session-handoff.md index 9d82ebd5..602e8a0d 100644 --- a/session-handoff.md +++ b/session-handoff.md @@ -1,6 +1,6 @@ # Session handoff -2026-11-28 feat-007 N5 24h 最终现场通过(issue #16):`e9db64a`(EXE `58D9CAE9…2C99`)在 `2026-11-27T14:10:19Z`–`2026-11-28T14:10:19Z` 跑满 86,426s:1439 samples、version/status 2878/2878、登录 1439/1439、3/3 次 core 重启 0.18/0.19/0.19s、journal 4,837 Event(无缺口/0 重复/0 Gap)、WS 消费者 4,708 条(1,533 次空闲重连、3 次错误,客户端少收 129 条)、bridge/QQ/资源正常。24h 门关闭;仍剩 QQ 退出/重启后的新代次重绑矩阵与真实 TCP 背压。下一步需用户另取新鲜 QQ 跑一次短的新代次 attach 样本,再决定是否关闭 issue #16;不要复用在跑的实例。原始材料只在 ignored `local-evidence/feat007-n5-final4-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) +2026-11-28 feat-007 N5 24h 最终现场通过(issue #16):`e9db64a`(EXE `58D9CAE9…2C99`)在 `2026-11-27T14:10:19Z`–`2026-11-28T14:10:19Z` 跑满 86,426s:1439 samples、version/status 2878/2878、登录 1439/1439、3/3 次 core 重启 0.18/0.19/0.19s、journal 4,837 Event(无缺口/0 重复/0 Gap)、WS 消费者 4,708 条(1,533 次空闲重连、3 次错误,客户端少收 129 条)、bridge/QQ/资源正常。24h 门关闭。补做新代次重绑样本:新鲜 QQ 主根以 generation=2 + 新 journal/pipe/token 一次 attach,108s 样本 0 探测失败、一次 core 重启 0.18s 恢复,新 journal 8 Event 且 session_generations=[2],旧 gen1 journal 4,921,410 bytes / SHA-256 A026E296…A833F 前后不变;零发送、无旧请求重放。issue #16 四条 done criteria 均有证据、可按证据关闭;`feat-007` 仍 in-progress(依赖 feat-006 未 done,产品 NOT READY)。真实 TCP 背压、native 寿命/owner-stop 仍是已记录边界。原始材料只在 ignored `local-evidence/feat007-n5-final4-20261127-unbound/` 与 `feat007-n5-rebind-20261128-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) 2026-11-27 feat-007 N5 最终 24h(issue #16):修正 attempt 2 的登录查询与无消费者缺口。新构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)增加持久登录缓存(`login.private.json`;默认 `get_login_info` 走缓存,`no_cache` 走 native)与 forward-WS 事件消费者(`scripts/n5/ws_drain.ps1`,只记录计数)。离线启动包/未知版本门 PASS;`init.ps1 -Mode all` default 509 / research 569、0 failed。最终 24h 于 `2026-11-27T01:38:44Z` 在新主根 `33284`(创建 `2026-11-27T01:37:42.0474720Z`,账号 B)启动,8h 处发现 WS 消费者 5s 取消重连(5,157 次、309 条)与 control `DrainEvents` 诊断队列满时拒绝 wrapper/projection 事件(2,848 Gap);control Stop 后 daemon 未退出,force-kill,bridge 保留。已修正队列语义与 WS 30s 取消/45s 停止等待,新增 runtime/wrapper 回归,`init.ps1 -Mode all` default 510 / research 570;新构建 `e9db64a`(EXE `58D9CAE9…2C99`)启动包/未知版本门 PASS。attempt 4 于 `2026-11-27T14:10:19Z` 在新主根 `22560`(创建 `2026-11-27T14:09:56.6234676Z`,账号 B)启动(WS 消费者 + 登录缓存,+2h/+8h/+16h 重启,预计 `2026-11-28T14:10:19Z` 结束);定时任务 `schedule-414615f1-3bb4-476d-be17-e17a099d6245` 在 `2026-11-28T22:30+08:00` 核验,不自动关闭 issue #16。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-final-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) From fc355629a21e9aa645894b50540fd92e5bb2a146 Mon Sep 17 00:00:00 2001 From: Vegetable <3089665724@qq.com> Date: Sat, 28 Nov 2026 22:24:25 +0800 Subject: [PATCH 13/13] docs(feat-007): record issue 16 closure --- docs/acceptance/2026-11-25-feat-007-n5-release.md | 2 +- feature_list.json | 2 +- progress.md | 2 +- session-handoff.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/acceptance/2026-11-25-feat-007-n5-release.md b/docs/acceptance/2026-11-25-feat-007-n5-release.md index 1f57d4a3..76cc8fbe 100644 --- a/docs/acceptance/2026-11-25-feat-007-n5-release.md +++ b/docs/acceptance/2026-11-25-feat-007-n5-release.md @@ -166,7 +166,7 @@ attach 时仍要求一次登录成功。该修复通过离线 rehearsal(18s, bridge 保留到 QQ 正常退出。 - **慢客户端**:确定性 transport 合同与 feat-006 现场慢 POST 已有证据;真实 TCP 背压仍未证。 -按 issue #16 的四条 done criteria 汇总:常驻无每消息交互(24h)通过;core/QQ 重启与断连/慢客户端矩阵通过(真实 TCP 背压作为已记录边界);未知版本零 native 调用与停止边界通过;24h 单账号与启动包证据齐全。因此 issue #16 可按证据关闭。`feat-007` 在 `feature_list.json` 仍保持 `in-progress`:其依赖 `feat-006` 未 done,项目整体仍 NOT READY;native 对象寿命/owner-stop 与真实 TCP 背压继续作为未闭合边界,不由本验收外推。 +按 issue #16 的四条 done criteria 汇总:常驻无每消息交互(24h)通过;core/QQ 重启与断连/慢客户端矩阵通过(真实 TCP 背压作为已记录边界);未知版本零 native 调用与停止边界通过;24h 单账号与启动包证据齐全。issue #16 已于 `2026-11-28T14:24:01Z` 按证据关闭。`feat-007` 在 `feature_list.json` 仍保持 `in-progress`:其依赖 `feat-006` 未 done,项目整体仍 NOT READY;native 对象寿命/owner-stop 与真实 TCP 背压继续作为未闭合边界,不由本验收外推。 ## 6. 复现命令 diff --git a/feature_list.json b/feature_list.json index 9cfb4bdf..46196882 100644 --- a/feature_list.json +++ b/feature_list.json @@ -110,7 +110,7 @@ "plan_steps": ["N5"], "dependencies": ["feat-006"], "status": "in-progress", - "evidence": "2026-11-25 离线启动包/未知版本门通过(scripts/n5/verify-release.ps1):default release 构建与 CI 同源打包,zip sidecar、build-info commit/version/target/mode 和包内逐文件 SHA-256 均匹配;解压后 packaged daemon 两次启动均回答 get_version_info、无 bridge 时 get_login_info 诚实返回 1502、控制停止后 journal 保留;篡改 QQ.exe 哈希后 verify-manifest 与 qq-entry 均在 gate 1 拒绝且不产生 report,默认构建的 inject 先被 K4-D0 拒绝。现场 2h 观察通过(零发送、60s 只读探测、30/60/90 分钟 core 崩溃重启):新 QQ 主根一次 attach,117 个采样、351/351 次查询成功、495 条真实入站事件无重复/缺口(event_seq 1–495),3/3 次 core 崩溃重启各约 1.5s 恢复且 journal 完整帧前缀保留,控制停止后默认 bridge 保留、QQ 响应。CoreStopped 后同一代次不能重新 attach,因此在新主根上启动 24h soak;attempt 1 在约 8h 处 incomplete:version/status 探测 958/958 成功、journal 持续增长,但 get_login_info 从 15:19Z 起长期返回 1502(456 次),第 2 次 core 重启后 harness 因登录查询超时判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实结果,不是常驻链失败;harness 已改为 version/status 作为探测与重启恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 2 已完整跑满 86,420s:version/status 2876/2876 成功、3/3 次 core 重启恢复(约 0.2s)、bridge 保留、QQ 响应、内存/句柄稳定,但 journal 含 13,234 条 Gap(本轮无 OneBot 事件消费者,队列满后的有界拒绝),且 get_login_info 1438 次中仅 215 次成功(265 次 1502、958 次 10s 超时,锁屏/重启后默认动作走 native query)。常驻链 24h 通过,应用级 24h 与登录动作可靠性仍未闭合。随后实现持久登录缓存(默认 get_login_info 返回确认身份,no_cache 仍走 native;core 重启后从 login.private.json 恢复)与 forward-WS 事件消费者(ws_drain.ps1,记录计数不写正文;soak 要求 event_consumer_active 且 journal Gap=0);新构建 17f5ec6(EXE 4C9B057D…02BB、bridge 659CE4D1…CE14)的启动包/未知版本门 PASS,但其 24h 在 8h 处发现事件诊断队列拒绝与 WS 消费者 5s 取消重连缺陷(WS 309 条/5,157 次重连,journal 564 Event + 2,848 Gap,停止时 daemon 未退出需 force-kill)。已修正:wrapper/projection 事件在 control DrainEvents 队列满时只计数并继续 journal/OneBot 发布,不再 Gap/degrade;WS 接收取消改为 30s,soak 停止等待 45s;新增 runtime/wrapper 回归,init.ps1 -Mode all default 510 / research 570、0 failed。新构建 e9db64a(EXE 58D9CAE9…2C99、bridge 659CE4D1…CE14)启动包/未知版本门 PASS;attempt 4 已完整跑满 86,426s 并通过:version/status 2878/2878、登录 1439/1439(1502/timeout 均为 0)、3/3 次 core 重启恢复(0.18/0.19/0.19s)、journal 4,837 Event(event_seq 1–4837 无缺口、0 重复、0 Gap)、WS 消费者 4,708 条消息/1,616,691 bytes(1,533 次空闲重连、3 次错误,客户端侧少收 129 条)、bridge 保留、QQ 响应、资源稳定。24h 门按常驻/core 重启/登录缓存/事件消费关闭。补做新代次重绑现场:新鲜 QQ 主根以 generation=2、新 journal/pipe/token 一次 attach,108s 样本 21 samples、0 探测失败、一次 core 重启 0.18s 恢复,新 journal 8 Event 且 session_generations=[2],旧 gen1 journal 4,921,410 bytes / SHA-256 A026E296…A833F 前后完全不变;零发送,无旧请求重放。issue #16 四条 done criteria 均有证据,可按证据关闭;feature 仍 in-progress(依赖 feat-006 未 done,产品 NOT READY)。真实 TCP 背压、native 寿命/owner-stop 仍是已记录边界。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。", + "evidence": "2026-11-25 离线启动包/未知版本门通过(scripts/n5/verify-release.ps1):default release 构建与 CI 同源打包,zip sidecar、build-info commit/version/target/mode 和包内逐文件 SHA-256 均匹配;解压后 packaged daemon 两次启动均回答 get_version_info、无 bridge 时 get_login_info 诚实返回 1502、控制停止后 journal 保留;篡改 QQ.exe 哈希后 verify-manifest 与 qq-entry 均在 gate 1 拒绝且不产生 report,默认构建的 inject 先被 K4-D0 拒绝。现场 2h 观察通过(零发送、60s 只读探测、30/60/90 分钟 core 崩溃重启):新 QQ 主根一次 attach,117 个采样、351/351 次查询成功、495 条真实入站事件无重复/缺口(event_seq 1–495),3/3 次 core 崩溃重启各约 1.5s 恢复且 journal 完整帧前缀保留,控制停止后默认 bridge 保留、QQ 响应。CoreStopped 后同一代次不能重新 attach,因此在新主根上启动 24h soak;attempt 1 在约 8h 处 incomplete:version/status 探测 958/958 成功、journal 持续增长,但 get_login_info 从 15:19Z 起长期返回 1502(456 次),第 2 次 core 重启后 harness 因登录查询超时判 fatal。该 1502 是 QQ 锁屏/会话不可用时的诚实结果,不是常驻链失败;harness 已改为 version/status 作为探测与重启恢复信号、登录查询单独计数(离线 rehearsal 通过)。24h attempt 2 已完整跑满 86,420s:version/status 2876/2876 成功、3/3 次 core 重启恢复(约 0.2s)、bridge 保留、QQ 响应、内存/句柄稳定,但 journal 含 13,234 条 Gap(本轮无 OneBot 事件消费者,队列满后的有界拒绝),且 get_login_info 1438 次中仅 215 次成功(265 次 1502、958 次 10s 超时,锁屏/重启后默认动作走 native query)。常驻链 24h 通过,应用级 24h 与登录动作可靠性仍未闭合。随后实现持久登录缓存(默认 get_login_info 返回确认身份,no_cache 仍走 native;core 重启后从 login.private.json 恢复)与 forward-WS 事件消费者(ws_drain.ps1,记录计数不写正文;soak 要求 event_consumer_active 且 journal Gap=0);新构建 17f5ec6(EXE 4C9B057D…02BB、bridge 659CE4D1…CE14)的启动包/未知版本门 PASS,但其 24h 在 8h 处发现事件诊断队列拒绝与 WS 消费者 5s 取消重连缺陷(WS 309 条/5,157 次重连,journal 564 Event + 2,848 Gap,停止时 daemon 未退出需 force-kill)。已修正:wrapper/projection 事件在 control DrainEvents 队列满时只计数并继续 journal/OneBot 发布,不再 Gap/degrade;WS 接收取消改为 30s,soak 停止等待 45s;新增 runtime/wrapper 回归,init.ps1 -Mode all default 510 / research 570、0 failed。新构建 e9db64a(EXE 58D9CAE9…2C99、bridge 659CE4D1…CE14)启动包/未知版本门 PASS;attempt 4 已完整跑满 86,426s 并通过:version/status 2878/2878、登录 1439/1439(1502/timeout 均为 0)、3/3 次 core 重启恢复(0.18/0.19/0.19s)、journal 4,837 Event(event_seq 1–4837 无缺口、0 重复、0 Gap)、WS 消费者 4,708 条消息/1,616,691 bytes(1,533 次空闲重连、3 次错误,客户端侧少收 129 条)、bridge 保留、QQ 响应、资源稳定。24h 门按常驻/core 重启/登录缓存/事件消费关闭。补做新代次重绑现场:新鲜 QQ 主根以 generation=2、新 journal/pipe/token 一次 attach,108s 样本 21 samples、0 探测失败、一次 core 重启 0.18s 恢复,新 journal 8 Event 且 session_generations=[2],旧 gen1 journal 4,921,410 bytes / SHA-256 A026E296…A833F 前后完全不变;零发送,无旧请求重放。issue #16 四条 done criteria 均有证据,已于 2026-11-28T14:24:01Z 关闭;feature 仍 in-progress(依赖 feat-006 未 done,产品 NOT READY)。真实 TCP 背压、native 寿命/owner-stop 仍是已记录边界。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。", "evidence_paths": ["docs/acceptance/2026-11-25-feat-007-n5-release.md", "scripts/n5/verify-release.ps1", "scripts/n5/preflight.ps1", "scripts/n5/attach.ps1", "scripts/n5/n5_soak.py", "docs/plans/2026-10-09-gitnexus-plan-caligo-snowluma-capability-parity.md"], "done_criteria": ["正常入口无需每消息交互", "core/QQ 重启、断链/慢客户端矩阵通过", "未知版本零 native 调用,停止边界如实", "24h 单账号验收及启动包证据齐全"] }, diff --git a/progress.md b/progress.md index 5a3ff561..75e2d410 100644 --- a/progress.md +++ b/progress.md @@ -2,7 +2,7 @@ ## Current State -2026-11-28 feat-007 N5 24h 最终现场通过(issue #16):queue-fix 构建 `e9db64a`(EXE `58D9CAE9…2C99`、bridge `659CE4D1…CE14`)于 `2026-11-27T14:10:19Z`–`2026-11-28T14:10:19Z` 完整跑满 86,426s:1439 samples,version/status 2878/2878、登录 1439/1439(1502/timeout 均为 0),+2h/+8h/+16h 三次 core 重启分别 0.18/0.19/0.19s 恢复且 journal 完整帧前缀保留;journal 4,921,410 bytes、4,837 个 Event(event_seq 1–4837 无缺口、0 重复、0 Gap);forward-WS 消费者 4,708 条消息/1,616,691 bytes,1,533 次空闲重连、3 次错误,客户端侧少收 129 条(core 无丢失);停止后 bridge 保留、QQ 响应,daemon working set 约 10–15 MiB、handles ~107 稳定。24h 门按常驻/core 重启/登录缓存/事件消费关闭。随后补做新代次重绑样本:同一登记账号另取新鲜 QQ 主根,以 `generation=2` + 新 journal/pipe/token 一次 attach;108s 样本 21 samples、0 探测失败、一次 core 重启 0.18s 恢复,新 journal 8 Event 且 `session_generations=[2]`,旧 gen1 journal 4,921,410 bytes / SHA-256 `A026E296…A833F` 前后完全不变;零发送,无旧请求重放。issue #16 四条 done criteria 均有证据,可按证据关闭;`feat-007` 仍 in-progress(依赖 `feat-006` 未 done,产品 NOT READY)。真实 TCP 背压、native 寿命/owner-stop 仍是已记录边界。原始材料只在 ignored `local-evidence/feat007-n5-final4-20261127-unbound/` 与 `feat007-n5-rebind-20261128-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) +2026-11-28 feat-007 N5 24h 最终现场通过(issue #16):queue-fix 构建 `e9db64a`(EXE `58D9CAE9…2C99`、bridge `659CE4D1…CE14`)于 `2026-11-27T14:10:19Z`–`2026-11-28T14:10:19Z` 完整跑满 86,426s:1439 samples,version/status 2878/2878、登录 1439/1439(1502/timeout 均为 0),+2h/+8h/+16h 三次 core 重启分别 0.18/0.19/0.19s 恢复且 journal 完整帧前缀保留;journal 4,921,410 bytes、4,837 个 Event(event_seq 1–4837 无缺口、0 重复、0 Gap);forward-WS 消费者 4,708 条消息/1,616,691 bytes,1,533 次空闲重连、3 次错误,客户端侧少收 129 条(core 无丢失);停止后 bridge 保留、QQ 响应,daemon working set 约 10–15 MiB、handles ~107 稳定。24h 门按常驻/core 重启/登录缓存/事件消费关闭。随后补做新代次重绑样本:同一登记账号另取新鲜 QQ 主根,以 `generation=2` + 新 journal/pipe/token 一次 attach;108s 样本 21 samples、0 探测失败、一次 core 重启 0.18s 恢复,新 journal 8 Event 且 `session_generations=[2]`,旧 gen1 journal 4,921,410 bytes / SHA-256 `A026E296…A833F` 前后完全不变;零发送,无旧请求重放。issue #16 四条 done criteria 均有证据,已于 `2026-11-28T14:24:01Z` 关闭;`feat-007` 仍 in-progress(依赖 `feat-006` 未 done,产品 NOT READY)。真实 TCP 背压、native 寿命/owner-stop 仍是已记录边界。原始材料只在 ignored `local-evidence/feat007-n5-final4-20261127-unbound/` 与 `feat007-n5-rebind-20261128-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) 2026-11-27 feat-007 N5 最终 24h 重跑准备(issue #16):24h attempt 2 的缺口已做实现修正——新增持久登录缓存(`get_login_info` 无 `no_cache` 时成功查询后写账号目录 `login.private.json`;core 重启后默认动作先返回持久身份,`no_cache=true` 仍走 native 查询;新增持久化/账号漂移/backend 短路测试)与 forward-WS 事件消费者(`scripts/n5/ws_drain.ps1`,只记消息数/字节数/重连数,不写正文;soak 在 attach 后启动,`require_event_consumer` 模式下要求 `event_consumer_active` 且 journal `Gap=0`)。新构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)的启动包/未知版本门 PASS;`init.ps1 -Mode all` default 509 / research 569、0 failed。最终 24h 于 `2026-11-27T01:38:44Z` 在新主根 `33284`(创建 `2026-11-27T01:37:42.0474720Z`,账号 B)启动,但在 8h 处发现两个缺陷:WS 消费者把 5s `ReceiveAsync` 取消当成断开,5,157 次重连只收到 309 条;`AccountActor::events_out` 只是 control `DrainEvents` 诊断队列,满时仍 degrade/拒绝 wrapper/projection 事件,导致 journal 564 Event + 2,848 Gap;control Stop 返回后 daemon 未退出,force-kill,bridge 保留。已修正:诊断队列满时 wrapper/projection 事件只增加 `events_deliverable_queue_dropped` 并继续 journal/OneBot 发布(不 Gap、不 degrade),WS 接收取消改为 30s、停止等待 45s;新增 runtime/wrapper 回归,`init.ps1 -Mode all` default 510 / research 570、0 failed。新构建 `e9db64a`(EXE `58D9CAE9…2C99`、bridge `659CE4D1…CE14`)启动包/未知版本门 PASS;attempt 4 于 `2026-11-27T14:10:19Z` 在新主根 `22560`(创建 `2026-11-27T14:09:56.6234676Z`,账号 B)启动,带 WS 消费者与登录缓存,+2h/+8h/+16h 各一次 core 重启,预计 `2026-11-28T14:10:19Z` 结束;定时任务 `schedule-414615f1-3bb4-476d-be17-e17a099d6245` 在 `2026-11-28T22:30+08:00` 核验。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-final-20261127-unbound/` 与 `feat007-n5-final4-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) diff --git a/session-handoff.md b/session-handoff.md index 602e8a0d..d0cecf16 100644 --- a/session-handoff.md +++ b/session-handoff.md @@ -1,6 +1,6 @@ # Session handoff -2026-11-28 feat-007 N5 24h 最终现场通过(issue #16):`e9db64a`(EXE `58D9CAE9…2C99`)在 `2026-11-27T14:10:19Z`–`2026-11-28T14:10:19Z` 跑满 86,426s:1439 samples、version/status 2878/2878、登录 1439/1439、3/3 次 core 重启 0.18/0.19/0.19s、journal 4,837 Event(无缺口/0 重复/0 Gap)、WS 消费者 4,708 条(1,533 次空闲重连、3 次错误,客户端少收 129 条)、bridge/QQ/资源正常。24h 门关闭。补做新代次重绑样本:新鲜 QQ 主根以 generation=2 + 新 journal/pipe/token 一次 attach,108s 样本 0 探测失败、一次 core 重启 0.18s 恢复,新 journal 8 Event 且 session_generations=[2],旧 gen1 journal 4,921,410 bytes / SHA-256 A026E296…A833F 前后不变;零发送、无旧请求重放。issue #16 四条 done criteria 均有证据、可按证据关闭;`feat-007` 仍 in-progress(依赖 feat-006 未 done,产品 NOT READY)。真实 TCP 背压、native 寿命/owner-stop 仍是已记录边界。原始材料只在 ignored `local-evidence/feat007-n5-final4-20261127-unbound/` 与 `feat007-n5-rebind-20261128-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) +2026-11-28 feat-007 N5 24h 最终现场通过(issue #16):`e9db64a`(EXE `58D9CAE9…2C99`)在 `2026-11-27T14:10:19Z`–`2026-11-28T14:10:19Z` 跑满 86,426s:1439 samples、version/status 2878/2878、登录 1439/1439、3/3 次 core 重启 0.18/0.19/0.19s、journal 4,837 Event(无缺口/0 重复/0 Gap)、WS 消费者 4,708 条(1,533 次空闲重连、3 次错误,客户端少收 129 条)、bridge/QQ/资源正常。24h 门关闭。补做新代次重绑样本:新鲜 QQ 主根以 generation=2 + 新 journal/pipe/token 一次 attach,108s 样本 0 探测失败、一次 core 重启 0.18s 恢复,新 journal 8 Event 且 session_generations=[2],旧 gen1 journal 4,921,410 bytes / SHA-256 A026E296…A833F 前后不变;零发送、无旧请求重放。issue #16 四条 done criteria 均有证据,已于 2026-11-28T14:24:01Z 关闭;`feat-007` 仍 in-progress(依赖 feat-006 未 done,产品 NOT READY)。真实 TCP 背压、native 寿命/owner-stop 仍是已记录边界。原始材料只在 ignored `local-evidence/feat007-n5-final4-20261127-unbound/` 与 `feat007-n5-rebind-20261128-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md) 2026-11-27 feat-007 N5 最终 24h(issue #16):修正 attempt 2 的登录查询与无消费者缺口。新构建 `17f5ec6`(`caligo.exe` `4C9B057D…02BB`、bridge `659CE4D1…CE14`)增加持久登录缓存(`login.private.json`;默认 `get_login_info` 走缓存,`no_cache` 走 native)与 forward-WS 事件消费者(`scripts/n5/ws_drain.ps1`,只记录计数)。离线启动包/未知版本门 PASS;`init.ps1 -Mode all` default 509 / research 569、0 failed。最终 24h 于 `2026-11-27T01:38:44Z` 在新主根 `33284`(创建 `2026-11-27T01:37:42.0474720Z`,账号 B)启动,8h 处发现 WS 消费者 5s 取消重连(5,157 次、309 条)与 control `DrainEvents` 诊断队列满时拒绝 wrapper/projection 事件(2,848 Gap);control Stop 后 daemon 未退出,force-kill,bridge 保留。已修正队列语义与 WS 30s 取消/45s 停止等待,新增 runtime/wrapper 回归,`init.ps1 -Mode all` default 510 / research 570;新构建 `e9db64a`(EXE `58D9CAE9…2C99`)启动包/未知版本门 PASS。attempt 4 于 `2026-11-27T14:10:19Z` 在新主根 `22560`(创建 `2026-11-27T14:09:56.6234676Z`,账号 B)启动(WS 消费者 + 登录缓存,+2h/+8h/+16h 重启,预计 `2026-11-28T14:10:19Z` 结束);定时任务 `schedule-414615f1-3bb4-476d-be17-e17a099d6245` 在 `2026-11-28T22:30+08:00` 核验,不自动关闭 issue #16。QQ 重启后新代次重绑与真实 TCP 背压仍未闭合。原始材料只在 ignored `local-evidence/feat007-n5-final-20261127-unbound/`。 [验收记录](docs/acceptance/2026-11-25-feat-007-n5-release.md)