Repository navigation
[PR] fix(#4665): carry identity + retired_at across archive/restore - #4672
Conversation
The archive dump SELECT and restore INSERT predated #4390's v8 row-state columns: every restored row landed with identity='' (the full-ingest JOIN key can never match again -> next full save re-mints every message beside the restored copy = duplicate messages) and retired_at=NULL (a rolled-back row resurrects as live). Both backends now carry both fields verbatim; pre-fix dumps lacking them fall back to recomputing identity from the CAS body (the v8 migration backfill formula) and restore retired rows as live (state unrecoverable there).
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.6158-pr.4672.2e3e7caThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4672.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 检索 open+closed 的 issue/PR(按 archive/restore/identity/retired_at 失败签名):本 PR 是 #4665 的唯一修复 PR;相邻条目均不同机制——#4664/#4670 是 export 车道漏带 retired 行(读侧),#4390/#4395 是本缺陷的引入方(v8 行状态列迁移)。无同根因在途工作。 标签: bug + scope/storage + p1 + review中(存储层数据完整性缺陷:恢复后重复消息/回滚行复活,envelope-only 保存下永久;按 10-19 政策属数据完整性类 p1)。 开始独立审核:先审原 issue 方向、再清点 dump/restore 既有行为、逐行读 diff、验测试有效性、看 CI。结论稍后按八问体例给出。 |
(ai: vllm-qwen/qwen3.8-27b) 审核结论(独立审,非复读 issue)八问
CI 状态与处置:head b9f6112 上 6 个 test 分片红 = 继承性失败(master 8b24d1f 自身同批分片红,#4599 floor 139;逐片日志核对,失败用例全部落在已知 born-red 族:storage golden/engine-proofs ×6、plugin-fork HTTP fork revision、orphan-recovery cold load,与本 PR diff 零重叠)。ci-fixes 已包含于 master(merge no-op),故把分支同步到 master d1b46fc(merge commit 判定:代码侧 ready-to-merge(方向正确、双后端对称、回归钉住、diff 干净、行为变更已如实披露);唯一阻塞 = 继承性 CI 红,非本 PR 代码问题。已在 #4599 留一行状态。 |
…help-merge sweep)
…help-merge sweep)
…help-merge sweep)
…help-merge sweep)
master window commits 293ae65/de5e03659 bumped kernel/package.json to 0.0.165 without regenerating the lockfiles; lock-sync re-resolution then rewrites the stale recorded versions (root 0.0.163, kernel 0.0.164) and fails. Pure recorded-version sync via npm install --package-lock-only; no dependency or semantic change.
Closes #4665
What
The archive dump SELECT and restore INSERT predated #4390's v8 row-state columns (
identity,retired_at). Consequences after an archive→restore:identity = ''— the full-ingest JOIN key (Four storage-layer defects: identity hash contaminated with positional metadata (truncation triggers identity swap) / sw | 存储层四缺陷:身份哈希掺位置元数据(截断即换血)/清扫删除回退历史/渲染接缝图片只比长度/fork 谱系死列 #4390 moved it offcontent_hash) can never match again, so the next full save re-mints every message at a fresh seq beside the restored copy: duplicate messages in the served history until acompleteLogsweep converges (and permanently for envelope-only saves);retired_at = NULL— rolled-back rows resurrect as live messages immediately.This is a regression against pre-v8 behavior, where the content_hash-based JOIN let restore self-heal.
Fix (both backends)
src/storage/store.ts) + mysql (src/storage/mysql.ts): dump SELECT now carriesidentity, retired_at; restore writes both back verbatim.identityOfStoredContent— the exact formula the v8 migration backfill used; retire state is unrecoverable there and restores as live (documented boundary).Behavior change disclosure
Old → new, all intended by the fix:
identity''(JOIN dead → re-mint/duplicates)retired_atidentity,retired_at(additive; readers tolerate absence via the fallback)No schema change, no config surface change, no kernel/
pi-subagents/change.Evidence
tests/issue4665-archive-restore-identity.test.ts: round-trip (dump carries fields → restore preserves seq/identity/retire state → re-ingest mints nothing), legacy-dump fallback path, mysql-lane twin (DSN-gated, runs in CI). Both sqlite tests FAIL on the pre-fix code (verified via stash) and pass with the fix.testlanes on this head.