Skip to content

[PR] fix: recover orphan-frozen indexes on cold load - #4373

Merged
ranxianglei merged 4 commits into
ranxianglei:masterfrom
z0d0dOr:2026-10-22_orphan-cold-load-recovery
Oct 23, 2026
Merged

ranxianglei merged 4 commits into
ranxianglei:masterfrom
z0d0dOr:2026-10-22_orphan-cold-load-recovery

Conversation

@z0d0dOr

@z0d0dOr z0d0dOr commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

A session whose index was frozen by orphan-skipped ingests still cold-loads old fold/ref state after upgrading to #4249. The next request can replay raw history and spend minutes compressing stale ranges before a save finally attempts convergence.

When the indexed view contains retained orphan originals, compare the recovery envelope's request counter and fold cursor with the index. Import and serve the envelope only when that progress is strictly ahead, before preflight runs. Healthy/equal/newer indexes remain authoritative. Recovery retains originals and persists even without a subsequent request/save. This is a narrow follow-up to #4249; the existing orphan-save fix is reused.

Validation:

  • Red regression on the previous cold-load path: requests 390 returned instead of 876; fold cursor 3 instead of 4.
  • 20/20 tests pass across storage-orphan-recovery, storage-orphan-representable and storage-full-flip.
  • npm run typecheck and npm run build pass on cda5676.
  • Two private affected-session copies restored all 36/19 blocks and original content; both reload correctly from the repaired index with their envelopes removed. No private fixtures are included.
  • Additional existing persist-rollback-guard and issue3573-cold-load-diagnostics tests hit Windows EPERM during temporary SQLite directory teardown; these are not reported as passing. Full-suite verdict is left to CI per the repository policy.

No schema, config or version change.

Fixes #4370

@ranxianglei ranxianglei changed the title fix: recover orphan-frozen indexes on cold load [PR] fix: recover orphan-frozen indexes on cold load Oct 23, 2026
z0d0dOr and others added 3 commits October 23, 2026 15:09
…-gated (ranxianglei#4216/ranxianglei#4370)

The orphan fingerprint gates recovery too narrowly: a journal-write
failure or an async-backend importRecord miss freezes the index with no
retained orphan contents in the view. Probe the envelope once per cold
load and let progress decide (requests strictly greater, or equal with
a greater fold cursor — the freshness proxy owner-ruled for cross-writer
generations, ranxianglei#4323). Equal/behind keeps the index authoritative, so
rollback safety is unchanged; ranxianglei#4323 B4 negative gate narrowed to
equal-progress (fold richness alone never displaces the index).
@ranxianglei
ranxianglei force-pushed the 2026-10-22_orphan-cold-load-recovery branch from cda5676 to e6c7396 Compare October 23, 2026 07:22
@ranxianglei

Copy link
Copy Markdown
Owner

(ai: zhipuai-lb/glm-5.3)

审查结论 + 一个增强提交(e6c7396,rebase 到 master 后追加):

原补丁审查:通过。 触发→严格进度比较(requests 严格更大,或持平且 nextBlockId 更大)→同步 importRecord 重灌 → 失败回退 envelope 视图,回滚防护(平/落后不回退)、损坏 envelope 隔离、裸 id 命名池,方向和降级语义都对;rebase 与 #4323 的 drift-latch 分支无冲突(它先返回,不受影响)。

增强:防御性同步,不再依赖孤儿指纹。 冻结形状比指纹宽——journal 写失败、异步后端 importRecord 返回 null 的腿,索引冻结时视图里没有留存的孤儿原文,原触发器永远不亮。现在冷加载无条件探测一次 envelope,进度说了算:严格领先才前滚(领先只可能是更新的一代,不可能复活旧代,#4323 的进度代理原则);持平/落后仍索引权威,回滚安全不变。代价是冷加载多一次读+解析(冷加载罕见,#3128)。

一处既有测试语义收窄(必须随本 PR 合并,否则 master CI 红): #4323 B4 负向门从「无锁存时无论计数如何都统一优先」收窄为「进度持平时统一优先」——原夹具(envelope 99 requests vs 索引 5)正是防御性同步要恢复的无锁存冻结形状;折叠块更多但进度持平仍不 displacement(负向保留)。

测试:storage-orphan-recovery 9→11(新增无指纹恢复、领先前滚、持平权威双向);storage/persist/4216/4323 相邻 256+56 全绿;typecheck 干净。CI 全量以后续 lane 为准。

@ranxianglei

Copy link
Copy Markdown
Owner

ework

@ranxianglei

Copy link
Copy Markdown
Owner

接单

1 similar comment
@ranxianglei

Copy link
Copy Markdown
Owner

接单

@ranxianglei
ranxianglei merged commit fdbddd0 into ranxianglei:master Oct 23, 2026
22 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.760-master.fdbddd0 (rolling master tag).

npm install -g billion-context@0.0.760-master.fdbddd0  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cold loads keep serving an index frozen by pre-#4249 orphan-skipped ingests

2 participants