Skip to content

[PR] fix(preflight): defer doom probe to post-fold judgment (#7261) - #7667

Closed
ranxianglei wants to merge 1 commit into
masterfrom
2026-11-24_doom-probe-defer-fold
Closed

ranxianglei wants to merge 1 commit into
masterfrom
2026-11-24_doom-probe-defer-fold

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Summary

The doom probe rejected oversized payloads by UTF-8 byte count BEFORE preflightCompress was ever attempted. The control experiment (same payload on a matching route → 200, foldable) proved the brick is entirely from the probe's route-anchored ordering, not the payload's compressibility.

Now the doom probe defers: it records the would-be rejection and lets preflightCompress run first. After the fold, the doom threshold is re-checked on the compressed result. If the fold cannot bring the payload under the threshold, the rejection still fires — but now it is a true "truly doomed" verdict, not a "we never tried" one.

Behavior change

  • A payload that is over the doom threshold but foldable now gets a 200 (compression succeeds) instead of a 413.
  • A payload that is over the doom threshold and NOT foldable still gets a 413, but the message now comes from the failFast path (compression attempted but insufficient) rather than the old doom-probe byte-math wording.

Tests

  • Updated tests/issue2490-ledger-floor-doomed-probe.test.ts and tests/issue2847-doomed-nonretryable-status.test.ts to match the new failFast message.
  • All 9 tests in issue2490-ledger-floor-doomed-probe.test.ts pass.
  • All 1 test in issue2847-doomed-nonretryable-status.test.ts passes.
  • Typecheck clean.

Remaining work (separate PRs / kernel change requests)

  • Finding B (syncBlocks ANY-match): kernel change — the stillPresent check in kernel/src/sync.ts:186-193 uses ANY-match, so a single surviving id keeps the whole block active. Needs a kernel change request.
  • Finding C (pendingFoldUsage cold load): the pendingFoldUsage latch is intentionally NOT restored on cold load (src/persist.ts:4308-4313). Needs a decision on whether to persist it.

Closes #7261

The doom probe rejected oversized payloads by UTF-8 byte count BEFORE
preflightCompress was ever attempted. The control experiment (same payload
on a matching route -> 200, foldable) proved the brick is entirely from
the probe's route-anchored ordering, not the payload's compressibility.

Now the doom probe defers: it records the would-be rejection and lets
preflightCompress run first. After the fold, the doom threshold is
re-checked on the compressed result. If the fold cannot bring the payload
under the threshold, the rejection still fires — but now it is a true
'truly doomed' verdict, not a 'we never tried' one.

Behavior change: a payload that is over the doom threshold but foldable
now gets a 200 (compression succeeds) instead of a 413. A payload that
is over the doom threshold and NOT foldable still gets a 413, but the
message now comes from the failFast path (compression attempted but
insufficient) rather than the old doom-probe byte-math wording.

Fixes #7261 (Finding A — the death chain).
@ranxianglei ranxianglei added bug Something isn't working p1 scope/wiring labels Nov 24, 2026
@ranxianglei ranxianglei changed the title fix(preflight): defer doom probe to post-fold judgment (#7261) [PR] fix(preflight): defer doom probe to post-fold judgment (#7261) Nov 24, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

查重: 同失败域但被取代——本 PR 与 master 上的 #7537 同属「preflight doom 探针本地拒绝」这一失败域,但 #7537(owner 2026-11-22 裁定,晚于本 PR 分叉 2 天才落地 master)已用「转发、以上游自己的裁决为准」取代「本地估计拒绝」。所以这不是简单重复,而是方向冲突 / 被 #7537 取代(superseded)。

Review conclusion: do not merge. Two independent blockers, the second being decisive:

1. Stale base + merge conflicts. Forked from 1e357bf2d66 (2026-11-20); master is now 3afa91562ac5 (2026-11-24), ~200 commits ahead. mergeable_state: dirty; a local git merge-tree reproduces conflicts in src/server.ts and both test files.

2. Semantically contradicted by #7537 (owner ruling 2026-11-22). #7537 removed all local-estimation-based 413 rejections from preflight and made the doom probe forward the payload so the upstream's own verdict is authoritative. This PR re-introduces exactly that removed behavior — a local estimate-based 413 — merely deferred to post-fold.

The contradiction is visible in the very test this PR edits. For the identical scenario (a multi-MB core-text payload past both doom bars):

Same input, opposite expected status. Merging the PR (resolving the textual conflict in the PR's favor) would flip master's 200 / forward back to 413 / refuse — a direct regression of the owner's #7537 ruling.

八问:

  1. 是什么问题: PR 要修 [P0] 0.1.216 cold-load silently zeroed a 20-day compression ledger — a 3.35M-token session is now permanently unusable #7261(P0:0.1.216 冷加载把 20 天压缩账本清零,3.35M-token 会话永久不可用)中的一个面——doom 探针在 preflightCompress 尝试折叠之前,就用本地 UTF-8 字节数学拒绝超大 payload,导致「探针读的是 fold 从未触碰过的 payload」。

  2. 什么原因导致的: 探针的 route-anchored 顺序:在 fold 之前做本地字节数学裁决。但 [P0] 0.1.216 cold-load silently zeroed a 20-day compression ledger — a 3.35M-token session is now permanently unusable #7261 是多因 P0:(a) 存储冷加载迁移失败静默清零账本(8.37MB 的 session-order.json 超 4MB 单值上限,数据丢失);(b) doom 探针先于 fold 拒绝;(c) kernel syncBlocks ANY-match 导致「fold 报成功但 payload 不变」。本 PR 只修 (b)。

  3. 影响范围与严重程度: 若合并,会在当前 master 上重新引入 Preflight: don't reject based on local estimation — after folding, forward unconditionally; if it exceeds the window, le | preflight 不用本地估算拒发:折叠后一律转发,超窗让上游自己说(413 拒发家族总根因) #7537 已整体移除的「本地估计拒绝」——对所有走 preflight 的超大 payload,把「转发让上游裁决」改回「bili 本地 413」。波及所有 preflight 车道,且与 owner 2026-11-22 裁定直接冲突。严重度:高(设计方向回退)。

  4. 怎么修复的: PR 把 pre-fold doom 探针的 413 改为「记录待决 + 放行 fold」,fold 后用 result.payloadEstimate × 7.5 重对 doom 阈值,仍超则 413。思路(先 fold 再判)本身合理,但裁决依据仍是本地估计,不是 Preflight: don't reject based on local estimation — after folding, forward unconditionally; if it exceeds the window, le | preflight 不用本地估算拒发:折叠后一律转发,超窗让上游自己说(413 拒发家族总根因) #7537 要求的「上游证据」。

  5. 是否有回归问题: 是,相对当前 master 是回归:

    • pre-fold:master 已 return prepared(转发),PR 改回「记录待决」;
    • post-fold:master 已「byte-math doom after maximum folding — forward anyway」,PR 改回本地 413;
    • 测试:master 已把同一场景钉成 200 / forward,PR 改回 413 / refuse;
    • noteLocalRefusal 写入时机变化会多写本地拒绝账本,影响后续同 scope 请求的 localRefusalHere 判定。
      且 PR 未 rebase,合并会带进 ~200 个提交的语义冲突。
  6. 是否破坏缓存: 不直接破坏 prompt-cache。但会改变 local refusal ledger 的写入(见第 5 问),间接影响路由拒绝判定。

  7. 是否改了设计方向: 是,且是逆向。master 方向(Preflight: don't reject based on local estimation — after folding, forward unconditionally; if it exceeds the window, le | preflight 不用本地估算拒发:折叠后一律转发,超窗让上游自己说(413 拒发家族总根因) #7537,owner 2026-11-22 裁定):「不做本地估计拒绝,转发让上游裁决;唯一保留的本地 413 是上游已证明墙(statedWall)的证据型拒绝」。本 PR 把方向改回「本地估计拒绝(推迟到 post-fold)」。这是设计方向回退,需 owner 明确是否要推翻 Preflight: don't reject based on local estimation — after folding, forward unconditionally; if it exceeds the window, le | preflight 不用本地估算拒发:折叠后一律转发,超窗让上游自己说(413 拒发家族总根因) #7537。

  8. 是否引入了新的配置: 否。无新 env / config / 默认值。

建议(待 owner 拍板):

CI 状态: PR 创建约 15 分钟,CI 尚未运行(check-runs total 0,镜像无缓存)。鉴于上述结论,CI 绿红不影响「不应合并」的判断。

测试有效性: PR 只把两个测试的断言正则从旧 doom-probe 措辞改成通用 failFast 的 "could not bring it under",没有新增覆盖 PR 新加的 post-fold doom 判定分支(src/server.ts:4379,它返回的是另一句 "could not reduce the payload below the doom threshold")的用例——新分支未被测试钉住;且如前所述,master 已把同一场景钉成 200 / forward,PR 的 413 断言与 master 直接冲突。若 PR 被重新 pursuing,需按 #3617 gate 纪律补正/负向用例并对齐 #7537 语义。

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: superseded by #7537 — do not merge; recommend closing as superseded.

Verified against v0.1.216 (6a641f37) and master (23841dab):

  1. The fix already exists on master through a different design. Issue #7537 (owner ruling 2026-11-22, two days before this incident was reported) removed the entire "local estimate-refusal" class: PR #7548 (merge 9236576c1, commits 7b3a17193 / 033c679db) turned the pre-fold doom probe into a forward instead of a 413. On current master the probe branch logs "forwarding per #7537 (no local estimate-refusal); the upstream's own size verdict is authoritative" and returns the prepared payload — there is no local 413 left in that path. #7261 Finding A (the death chain: probe rejects before any fold is attempted) no longer exists on master.

  2. This PR would re-introduce exactly what #7537 removed. The doomProbeDeferred post-fold gate returns a local byte-math 413 after preflightCompress — the same refusal class the owner ruling deliberately abolished ("keep only EVIDENCE-based size refusals"). Merging would put the local estimate-refusal back, contradicting the ruling.

  3. Branch is v0.1.216-based and CONFLICTING — master's src/server.ts moved ~532 lines past the tag, concentrated in this very function.

Local verification of the branch as-is: its two test files pass 10/10, the adjacent preflight/probe suites (issue2313-probe-forward, preflight-fail-fast, issue4079-egress-window-fuse, issue3846-local-refusal-evidence) pass 25/25, tsc --noEmit clean. The code is not wrong on its own base — the design it implements is superseded.

For the #7261 thread: the actual fix ships with the next release (latest tag is still v0.1.216, so nobody has #7537 yet). Findings B and C remain open — B is #7668 and C is #7669 (the earlier "8 questions" comment cross-referenced B as #7669 and cited #7670; that number does not exist).

@ranxianglei

Copy link
Copy Markdown
Owner Author

Closing as superseded: #7537 (owner ruling 2026-11-22) removed the local estimate-refusal class and is already merged on master (PR #7548, merge 9236576). The pre-fold doom 413 this PR defers no longer exists there, and this PR's post-fold byte-math 413 would re-introduce exactly the refusal the ruling abolished. The fix ships with the next release (latest tag is still v0.1.216).

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

Labels

bug Something isn't working p1 scope/wiring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P0] 0.1.216 cold-load silently zeroed a 20-day compression ledger — a 3.35M-token session is now permanently unusable

1 participant