Skip to content

[PR] fix: plugin-fold anchor integrity + Claude watchdog health payload validation - #7231

Open
ranxianglei wants to merge 3 commits into
masterfrom
2026-11-19_rc-plugin-mode
Open

ranxianglei wants to merge 3 commits into
masterfrom
2026-11-19_rc-plugin-mode

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Root-cause PR for the plugin-mode aggregation thread (GitHub #7229).

Fixes #5866
Fixes #7218

#5866 — plugin-lane array-form folds end with zero full summaries on the wire

After the first post-fold turn, the kernel's hideConsumedCompressCalls
stubs the re-sent compress call's summary to a 200-char prefix, but the
host's stripKernelSummaries only checked range-pair EXISTENCE (not whether
the call still carries the full text), so it stripped the in-place anchor too
— leaving zero full summary carriers on the wire.

Option A (host-side, no kernel change): strip the anchor only when some
matching re-sent call's summary is verbatim-equal to the anchor's body. A
stubbed (or drifted) call keeps the anchor as the sole full carrier.

  • buildCarrierIndex now tracks per-range summary texts in a single parse
    pass (ensureRangeSummaries).
  • stripKernelSummaries compares the call's summary against
    extractAnchorBody(anchor.text) before stripping (plugin blocks with refs
    only; proxy-mode id-match and legacy no-ref paths unchanged).

Regression tests: tests/issue5866-anchor-integrity.test.ts pins the
fresh-call (stripped) and stubbed-call (kept) directions, content-array form,
empty-summary, trim normalization, mixed fresh+stub, absent-anchor, and
proxy-mode cases. Existing carrier-index tests updated to carry a matching
summary field.

#7218 — Claude native MCP watchdog accepts HTTP-200 HTML / {"ok":false}

Cherry-picked from PR #7220 (commit 7e69d5b, author Afloat) with -x.
The watchdog's default health probe now requires a decoded JSON payload with
ok===true under a single 2000ms timeout; recovery chain (ensure→repin→
follow), threshold (3), and interval (30s) are untouched.

New suite tests/claude-watchdog-health-payload.test.ts (15 tests, 11 red on
base).

Behavior change disclosure

@ranxianglei ranxianglei added root-cause bug Something isn't working p1 labels Nov 18, 2026
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-19_rc-plugin-mode (db7c615)

Latest build — install this exact version

npm install -g billion-context@0.0.10902-pr.7231.1ebacb2

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
db7c615 billion-context@0.0.10902-pr.7231.1ebacb2 build
7c74eca billion-context@0.0.10899-pr.7231.8522082 build
a6db332 billion-context@0.0.10898-pr.7231.732345d build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr7231.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix: plugin-fold anchor integrity + Claude watchdog health payload validation [PR] fix: plugin-fold anchor integrity + Claude watchdog health payload validation Nov 18, 2026
ci-check and others added 2 commits November 19, 2026 05:45
After the first post-fold turn, hideConsumedCompressCalls stubs the
re-sent compress call's summary to a 200-char prefix, but
stripKernelSummaries only checked range-pair EXISTENCE (not whether the
call still carries the full text), so it stripped the in-place anchor
too — leaving zero full summary carriers on the wire.

Option A (host-side, no kernel change): strip the anchor only when some
matching re-sent call's summary is verbatim-equal to the anchor's body.
A stubbed (or drifted) call keeps the anchor as the sole full carrier.

buildCarrierIndex now tracks per-range summary texts in a single parse
pass (ensureRangeSummaries); stripKernelSummaries compares the call's
summary against extractAnchorBody(anchor.text) before stripping.

Regression tests: tests/issue5866-anchor-integrity.test.ts pins the
fresh-call (stripped) and stubbed-call (kept) directions, content-array
form, empty-summary, trim normalization, mixed fresh+stub, absent-anchor,
and proxy-mode (summary match does not apply) cases. Existing
carrier-index tests updated to carry a matching summary field.

Closes #5866
@ranxianglei
ranxianglei force-pushed the 2026-11-19_rc-plugin-mode branch from a6db332 to 7c74eca Compare November 18, 2026 21:46
…ndard

Drive-by style fix found in review of #7231: the rewritten function
carried a leading space on its declaration line and a 5-space body,
off by one from the surrounding code. Whitespace only, no behavior
change.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重: 不重复。 No other open [PR] row targets this thread. The only related open PR is #7220 (the original watchdog fix by Afloat) — this PR cherry-picks its commit with -x and fully absorbs its content; #7220 should be closed by the owner after this merge (agents don't close). No competing PR exists for #5866 or #7218.

标签: bug, p1, scope/wiring, claude-code, opencode, root-cause(现建) — both fixes are wire/protocol-behavior defects with no kernel change; p1 because #5866 breaks the core compression promise (the full summary is the only record) on the wire for every plugin-lane array-form fold whose summary exceeds 200 chars; claude-code for the watchdog lane, opencode for the #5866 repro lane.

Verdict: reviewed, mergeable pending CI green on the new head. Both fixes were verified against source, not just the PR description:

#5866 (anchor integrity) — mechanism confirmed byte-for-byte:

#7218 (watchdog) — cherry-pick is faithful: the src/claude-mcp-entry.ts patch is byte-identical to 7e69d5b, the test file byte-identical, authorship (Afloat) preserved, -x marker present. The probe now requires a decoded JSON ok===true under the same single 2000 ms timeout; the real health contract (src/server/admin.ts:299) is 200 {"ok":true,...} / 503 {"ok":false,"reason":"starting"}, so the new check matches the server's own behavior. Recovery chain (ensure→repin→follow), threshold 3, interval 30s untouched.

Tests — all green locally on the PR head (targeted runs; full-suite verdict is CI):

  • tests/issue5866-anchor-integrity.test.ts + tests/issue2042-carrier-index.test.ts: 24/24 (both directions pinned: fresh→stripped, stubbed→kept; content-array form; empty summary; trim normalization; mixed fresh+stub; absent anchor; proxy mode)
  • tests/claude-watchdog-health-payload.test.ts: 15/15 (9 invalid payload shapes each drive the FULL recovery chain; 2 valid content types; 503+ok rejected; consecutive-failure reset; stalled headers/body)
  • tests/invariant-judge.test.ts: 47/47 · tests/fold-reconcile.test.ts + tests/issue4241-judge-render-baseline.test.ts: 73/73 · tests/invariant-judge-e2e.test.ts: 5/5

顺手修: the rewritten buildCarrierIndex shipped with a leading space on its declaration line and a 5-space body (off by one from the repo's 4-space standard, src/server.ts:2767-2813). Fixed in place — commit db7c615 (whitespace only, tests re-run green). Non-blocking observation: the per-block anchor lookup is an O(B×N) find (B = active plugin-fold blocks, small in practice); the #2042 single-pass index claim still holds for the index itself.

Notes:

8问:

  1. 是什么问题: ① 插件车道 array-form 折叠后,第一轮出站起 wire 上就没有完整摘要了——模型只看到 200 字符 stub,却以为那是完整记录;② Claude 原生 MCP 看门机把 HTTP-200 的 HTML 页面或 {"ok":false} 当健康,跳过恢复,死掉的 lane 一直死着。
  2. 什么原因导致的: ① 两个已上线特性互相抵消——kernel 先把保留调用的摘要 stub 成 200 字符(hideConsumedCompressCalls,先跑),host 的 stripKernelSummaries 却只按 range-pair 存在与否剥 anchor,不检查调用此刻是否还带全文 → 零完整载体;② 探针只信 HTTP 状态码(res.ok),不信健康载荷内容。
  3. 影响范围与严重程度: ① 所有插件车道(pi/opencode/omp/dsh-mcp)中用 array-form 提交且摘要超 200 字符的折叠——此后每轮静默「截断冒充完整」,核心承诺(摘要即唯一记录)失灵 → p1;② Claude 原生 MCP 车道:代理死亡且响应为 200-HTML/ok:false 时不自动恢复,需手动重启 → 单独看 p2。
  4. 怎么修复的: ① issue 推荐的 option A(完整性感知剥离):只有某个匹配重发调用的摘要与 anchor 正文逐字相等(trim 归一)才剥 anchor,stub/漂移/缺失一律保留 anchor 作为唯一完整载体——稳态收敛为「stub 调用 + 完整 render」,每轮恰好一份完整副本,与 line-form 一致;② 探针要求解码后的 JSON ok===true,同一 2000ms 预算。
  5. 是否有回归问题: 未发现。逐项审过既有行为:proxy-mode id-match 不变;legacy 无 ref 插件路径不变;fresh 完整载体仍被剥(不产生重复);pruned-client fail-safe(保留)未动;After repeated folding of long conversations, I1 mid-history-drop occurs (1104 times/day), manifesting as the model an | 长会话反复折叠后出现 I1 mid-history-drop(1104 次/天),表现为模型答上一个问题 #4401 judge twin 证明互补不冲突(stub 调用半仍需要它,保留的 anchor 是标准 fold-coverage 形状),judge/fold-reconcile 套件全绿;看门机恢复链/阈值/间隔/超时均未动。唯一行为变化即 PR 已披露的 intended 变更(旧→新已写明)。
  6. 是否破坏缓存: 不。anchor 字节由 kernel 确定性渲染,保留它对前缀缓存友好;剥离判定每请求从当前历史现算,无新状态/游标/去重键。wire 体积相对「零副本」的坏状态每轮多付一份完整 anchor——这是 option A 明确接受的代价(proxy 模式今天就这么付)。
  7. 是否改了设计方向: 没有。纯 host 侧(src/server.ts + src/claude-mcp-entry.ts),kernel 零改动;KDD feat: bili CLI + debug in config + README rewrite #7 双模式契约与 plugin mode: in-place acp_summary never stripped when the client's own compress pair rides inbound — double summary carrier on every post-fold turn #1567 载体交接不变——修复让插件车道兑现 plugin mode: in-place acp_summary never stripped when the client's own compress pair rides inbound — double summary carrier on every post-fold turn #1567 注释早已承诺的不变量(「active fold never ends up with zero carriers」)。
  8. 是否引入了新的配置: 没有。无新 env/config key/默认值。

判定: 可合并 — 方向正确(修根因不修症状)、机制对照 kernel 源码逐字节核实、cherry-pick 保真、测试有牙且全绿、审计过的既有行为无回归、不碰 config/persistence/kernel 面。等 db7c615 的 CI 转绿即可合;合并后请 owner 关闭已被吸收的 #7220。

This branch has not been deployed

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

Projects

None yet

2 participants