Skip to content

[PR] fix(fork): restore cold parents from verified unified raw tails (#5140) - #5141

Closed
abworks-dev wants to merge 1 commit into
ranxianglei:masterfrom
abworks-dev:2026-10-29_cold-fork-raw-tail
Closed

abworks-dev wants to merge 1 commit into
ranxianglei:masterfrom
abworks-dev:2026-10-29_cold-fork-raw-tail

Conversation

@abworks-dev

@abworks-dev abworks-dev commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Closes #5140

Scope and provenance

This is the narrow persisted cold-source execution for #4266 item 4. It complements #3024, rather than replacing it or reproducing its native retryable-409, resident warm-tail selection, divergent-head replacement, or compaction-reset work. Those changes remain with the existing author PR. It does not include the separate HTTP200 error work tracked in #4979 or the preflight receipt work in #5100.

Version inspected: 0.1.209. This branch starts from current master 1fad21de and leaves the version unchanged.

Remaining defect

A parent without a prior public fork contract intentionally has no retained raw snapshot after restart. In shadow mode its JSON envelope can be folded even though unified storage still has the complete independently stored raw tail. Repeated snapshot requests cannot recover that source through pluginSnapshot alone. PR #3024's resident-tail fallback deliberately does not treat a folded cold restore as raw.

Fix

  • Read the existing unified logical tail, not append-log order or the folded envelope. Require an unfolded, gap-free full ordered lastPassIds match, and equal compression state, block contents and CCR. Ignore only the non-content refLedgerAligned stamp on copied states; changed mappings still fail.
  • Keep an existing retained snapshot (including an empty one) as the primary source. Use the verified persisted source only when that snapshot is absent; keep all ref/order/CCR/opaque checks. Respect the existing capped flag and the current retention cap in UTF-8 bytes.
  • Use the same verified raw source for legacy revision validation and the child's raw baseline. GET does not permanently retain a copy. Only a successfully published fork installs/retains the recovered parent source for subsequent continuity. Existing-child conflicts are unchanged.

Coexistence / review

The three snapshot source-selection call sites overlap textually with open #3024; merging both needs union-of-intent sequencing: retained source first, #3024's valid warm-tail policy, then this strict persisted cold fallback only when no usable source exists. The broader #3011/#4266 work remains separate; #3024 retains its original scope and authorship. Human review is requested because this is a fork-source fallback/identity boundary.

Validation

  • 133/133 targeted tests pass, zero skipped: plugin-fork 69/69 (54 existing + 15 new), plus eight adjacent fork/persistence/native-adoption files 64/64.
  • Corrected pre-fix run: 54 pass / 15 new fail. Both full/shadow positive fixtures fail at the actual cold HTTP GET with 409 SNAPSHOT_UNAVAILABLE; green fixtures really compress, save, close SQLite, lose residency, reopen, GET a snapshot and POST a fork with the saved block/raw prefix intact. The 13 negative variants first prove a valid cold source and then prove refusal on damaged/capped/opaque witnesses.
  • Positive fixtures also pin current UTF-8 cap enforcement, GET and rejected-POST non-retention, legacy revision, retained empty snapshots, replay and existing-child conflict.
  • Typecheck, production build (including dist import/external checks), and git diff --check pass. Independent scoped static review found no concrete blocker; it did not execute tests or exhaustively audit the underlying storage engine.

All local tests use isolated temporary HOME/DSH/XDG/application-data directories and loopback mocks, never a private user database or a real model. Full suite was not run locally; full-suite authority remains remote CI.

Honest limits

  • Supports the existing synchronous SQLite unified view in full and shadow modes. Async-only/MySQL, legacy-only, missing/stale/partial/folded raw sources, cap violations or generation/witness mismatches remain unavailable (409); no guessing from summaries.
  • Does not overwrite already populated children, repair an already failed live branch, call a model to warm a parent, automatically replay a request, install a package, or restart a host. No real-user recovery claim.
  • No config surface, schema/persistence-version, kernel, pi-subagents, dependency/lockfile, wire-format, release or version change.

ranxianglei pushed a commit that referenced this pull request Oct 29, 2026
…ments cite #5139, not #5141

Owner correction on #5144: the Codex separator-endpoint bug report is GitHub issue #5139 (kuviki), not #5141 (an unrelated in-flight external PR). Renames tests/issue5141-turn-separator-ranges.test.ts -> tests/issue5139-turn-separator-ranges.test.ts and re-points every in-code citation. No behavior change: comments, test names/session-id prefix only.
@ranxianglei

Copy link
Copy Markdown
Owner

(ai: sglang-gpu0/qwen3.8-27b)

你最新一轮 CI(run 40870271809,head 220af4e)的 4 个红 shard(ubuntu-latest 22/2、24/2;windows-latest 22/1、22/2)我在本地按 CI 同款 preload 链复现了,根因不在你的修复代码,而是分支树里 tests/preload-test-env.mjs 仍无条件 pin process.env.BILI_CONFIG_FILE=<tmp>/absent-config.json:这个 env 在 src/paths.ts 的 configFile() 里优先于 XDG_CONFIG_HOME,于是所有「把配置写进自己的 $XDG_CONFIG_HOME 再读」的用例(resolveNativeAttachUrl / AttachExternal / LanePriority / AttachPolicy 这族)读到的都是空文件,断言全红。master 已合入等效修复 cf99d93(#4599 un-shadow fixture configs),但 CI checkout 的是你的分支头——请把 origin/master 合进你的分支再 push,红就会消失(合并时 preload 那个 hunk 与 master 重复,直接取 master 侧即可)。本地验证:在你的树上叠上该修复后同一测试文件转绿。并行 PR #5144(同样修 #5140)里的 preload 改动引用的正是同一个雷 #4599,合并 master 后它那份也会自动归零。

—— 批量 triage agent,只做了复现与诊断,没有改你的任何提交。

ranxianglei pushed a commit to Louie0806/billion-context that referenced this pull request Oct 29, 2026
ranxianglei#5141)

repairResponsesAssistantOrdering inserts acp_turn_sep_* user markers into the
Responses SEND view only; they never exist in the original history (the apply
view). liveCompressionRanges / uncoveredHistoryRuns / the post-compress
recovery path re-run processTurn on the send view while screening candidates
against the apply view, so any candidate unit that endpoints on a marker ref
throws BoundaryNotFoundError in projectUnit and screenRecommendedUnits
demotes it to a gap silently — large amounts of offerrable history vanish
from the acp_status offer ("little left to fold" while ~180K was recoverable).

Analysis entry points now strip outbound-only markers before processTurn
(withoutTurnSeparators, zero-copy when absent). Real-message refs are
id-stable across views, so every offered endpoint resolves in the apply view
again. Ordering repair, tool pairing and turn-integrity protection are
untouched — only the analyzed array class changes.

Behavior change: ranges previously dropped behind separator endpoints
reappear in acp_status / compress-receipt offers; the "little left to fold"
pressure note stops firing while a large pending mass is actually offerrable.
@ranxianglei

Copy link
Copy Markdown
Owner

(ai: sglang-gpu0/qwen3.8-27b)

关闭说明:本 PR 与 #5144 为同一 issue #5140 的并行修复(triage 查重时已标 duplicate,见此前讨论)。#5144 现已合入 master——保留其实现(含专属回归测试与四车道 e2e 适配)。感谢你的贡献与快速跟进同步建议;如后续发现 #5144 遗漏了本 PR 覆盖的行为,请重开或另开 issue,我会补回归。

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][fork] Cold restore cannot use an intact unified raw tail for a non-retained parent (#4266 item 4)

2 participants