Skip to content

fix(#2451): address review findings M1–M3 + two nits - #2460

Merged
ranxianglei merged 5 commits into
masterfrom
pr2451-review-fixes
Oct 9, 2026
Merged

ranxianglei merged 5 commits into
masterfrom
pr2451-review-fixes

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Review follow-up to #2451 (full review: #2451 (comment)). #2451 itself is a version-bump release PR — these are the forward-fix items, not merge blockers.

M1 — dsh native compaction rebase missing on the /v1/responses lane (db585eff)

#2432 landed the dsh local-compaction rebase on the openai lane only, but CONFIGURATION.md names responses "the lane dsh desktop's compaction actually rides" (#2360). prepare-responses.ts now runs the same detector: dsh-bound session + checkpoint framing + decimated fold coverage → rebase in the same turn. New e2e tests/issue2451-dsh-responses-compaction.test.ts (4 tests; folds driven through /__bili/plugin/tool since plugin mode suppresses the compress loop).

M2 — receipt ↔ acp_status contradiction on substrate-destruction breakers (08bf3556)

The post-compress receipt ordered "run acp_status, then compress a range it reports" while armed-breaker acp_status suppressed ranges and said "Do not attempt to compress now". acp_status now re-derives live ranges from the current resent view when the armed breaker's failures were substrate-destruction, and carries exactly one order per state.

M3 — tool-xml runaway lane had no corroborator (f3d7fe4b)

Trip now also requires avg gap-per-fragment ≤ 64 bytes (TOOL_XML_GAP_AVG_BYTES): genuine skeleton floods pack fragments back-to-back; fragments spread over real content (#1039 user intent) no longer trip.

Nits (67dc6ae3)

Tests: tsc clean; 38/38 across the compaction suites (codex #2372 5, dsh openai #2432 6, breaker-awareness 8 incl. new recovery-path test, runaway-guard 14 incl. 4 new, new responses-lane 4); e2e-native-dsh 2/2; update-host-guard + update-desktop-inplace 12/12; responses-lane neighbors (compat-drop/roles, previous-response-id, plugin-dev-position, chain-self-exemption) 62/62.

The #2432 dsh local-compaction rebase landed on the openai lane only,
while CONFIGURATION.md names responses "the lane dsh desktop's
compaction actually rides" (#2360). A dsh-bound session replaying
[checkpoint summary, retained tail…] on this wire kept the pre-#2432
death spiral: partially-alive blocks, self-destructing fold anchors,
every later compress failing to anchor (#2451 review M1).

prepare-responses.ts now runs the same detector as prepare-openai.ts:
dsh-bound session (metadata.pluginAgent === "dsh") + checkpoint framing
in a resent message (carriesDshLocalCompactionSummary) + decimated fold
coverage (missing >= DSH_LOCAL_COMPACTION_MIN_MISSING and >= half the
covered set) -> markNativeCompactionBoundary + reconcile back-to-back,
re-seeding refs onto the compacted view in the SAME turn. The codex
detector (#2372) is preserved verbatim on its own lane branch; decimated
coverage without either producer's framing stays on the churn paths.

Folds in the new e2e are driven through POST /__bili/plugin/tool —
plugin mode suppresses the compress loop, so the model-fold fixture
from the codex tests cannot drive a dsh-bound session. Negatives pin:
intact history with framing (paste analog), a session never dsh-bound,
and foreign (codex) framing on a dsh-bound session.
@ranxianglei ranxianglei mentioned this pull request Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: pr2451-review-fixes (5b6b7a0)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.2673-pr.2460.a238ee3

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

Option B — Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

ci 失败

@ranxianglei

Copy link
Copy Markdown
Owner Author

M2 — receipt ↔ acp_status contradiction on substrate-destruction breakers (08bf355)

详细解释 这个是把 acp status 改成啥了

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 M2 到底把 acp_status 改成了啥 —— 详细拆解

先说它治的病(#2360 形态的自相矛盾)

改动全在 src/acp-status.ts,四步:

  1. 把一个笼统布尔拆成三个独立判定。原来 substrateInvalid = cause 以 "substrate-destruction" 或 "stale-ref" 开头 —— 两种失败混在一个标志里,没法区别对待。现在:

    • staleRef = cause 是 stale-ref(旧代 ref,resent view 前进前锚不上)
    • substrateDestroyed = cause 是 substrate-destruction(带外历史改写、fold substrate 没了)
    • reanchorThroughBreaker = breaker !== undefined && substrateDestroyed ← 新增核心概念:"在 substrate-destruction 上 ARMED 的 breaker"
  2. 「范围表是否可见」规则改写

    • 旧:if (!breaker && !substrateInvalid && (有范围))
    • 新:rangesVisible = (breaker===undefined && !staleRef && !substrateDestroyed) || reanchorThroughBreaker
    • 逐条:未 ARMED(n=1/2)跟以前一样,只要有 stale-ref 或 substrate-destruction 判定就继续压制;ARMED 且归因 substrate-destruction(reanchorThroughBreaker)时现在会列出范围,而且是从当前 resent view 重新推导的(processTurn(ctx.messages) → compressibleRanges),不是缓存里的旧 ref —— 这是唯一的新豁免分支,即新的恢复路径;ARMED 且归因 stale-ref / 未分类则仍旧压制(原文逐字保留)。
  3. ARMED breaker 那段文案分叉

    • reanchorThroughBreaker 时换成新句:"上次失败归因 substrate-destruction(带外历史改写)。上面那张可压缩范围表是从当前 resent view 重新推导的:按回执只压其中列出的范围,一次成功即解除本 breaker;若没列出任何范围,就别压、继续任务。"
    • 否则保留原句 "SUPPRESSED… Do not attempt to compress now" 一字不动。
  4. 独立的 substrate 段落(FOLD BASE GENERATION MISMATCH / FOLD SUBSTRATE INVALID "start a fresh conversation")收成只在未 ARMED 时打印:if (staleRef || (substrateDestroyed && breaker===undefined))。这样 ARMED+substrate-destruction 时不会再冒出一句 "start a fresh conversation",避免一个输出里又叠出两条指令(又回到 bili 插件模式下 allowDshCompaction 在 responses 线路上完全失效 —— DSH 原生压缩落地、折叠基底被摧毁、compress 连片失败 #2360 形态)。

一句话总结:acp_status 现在区分两种 substrate 失败——stale-ref 仍一律压制(ref 换代前锚不上,让模型下次请求后再查);substrate-destruction 一旦 ARMED,就从当前 resent view 重算出能锚定的范围并真的列出来,配"一次成功解除 breaker"的回执,给模型一条真实可走的恢复路径;每个状态恰好一条指令,不再自相矛盾。

要看住的一个前提:这条恢复路径成立,靠的是"substrate-destruction 后从当前 resent view 重推的范围确实锚得上"(区别于 stale-ref 的旧代 ref)。新增的 recovery-path 测试钉的就是这个,控制组验证 armed+stale-ref 仍保持压制。


另:CI 失败我并行在处理 —— failure 定位到 unused-exports job(node scripts/check-unused-exports.mjs),正在本地复现,修完单独回帖。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 CI 失败已定位并修掉 —— 已推新提交到分支

结论:红的不是测试,是 unused-exports 门禁(node scripts/check-unused-exports.mjs)。已修并 push,commit 4243e284c(在 pr2451-review-fixes 上)。

八问

  1. 是什么问题:CI unused-exports job 失败(exit 1),把 PR 顶成 blocked、无法合并。
  2. 什么原因导致的:本 PR 的 M3(f3d7fe4b)给 runaway tool-xml lane 加了个 corroborator 常量,写成 export const TOOL_XML_GAP_AVG_BYTES = 64,但它只在 src/runaway-guard.ts 内部(trip 判定那行)用到,全仓无任何外部引用 → 门禁判为 INTERNAL_ONLY(每个引用都落在声明文件内)。
  3. 影响范围与严重程度:只影响 CI 门禁;不改变任何运行时行为或产物。严重度 = 合并被卡住,非功能缺陷。
  4. 怎么修复的:按门禁对 INTERNAL_ONLY 的推荐处置,去掉多余的 export,把它降为模块私有 const TOOL_XML_GAP_AVG_BYTES = 64。单行改动,未加 WAIVERS(它没有外部消费者,无理由保留公开)。
  5. 是否有回归问题:不涉及。纯删一个无外部消费者的 export 关键字,逻辑/语义/运行路径零变化。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及。
  8. 是否引入新配置:不涉及。

本地复跑该门禁已绿(✓ unused-export gate: clean (2 waived))。这次 push 会触发全量 CI 重跑,我盯一下结果回你。M2 的详细解释已在上一条回帖里。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 CI 状态更新(commit 4243e284c)

  • unused-exports:✅ 已转绿 —— 就是它之前把 PR 顶成 blocked,现在修好了。
  • 其余门禁全绿,0 failure:kernel-guard / pi-subagents-guard / version-guard / docs-sync / docs-coverage / lane-guard / build-artifact / e2e / 全部 real-client lane / hermetic registry e2e 均 success。
  • 仅剩 4 个全量 test job(ubuntu/windows × node 22/24)还在 in_progress。这些是标准全量套件,跟我的改动无关——本次修复只是删掉一个无外部引用的 export 关键字(单行),不可能影响任何测试;它们在上一版 commit 上也是同一批在跑。

等这 4 个翻绿即可合并(合并按规矩由你来操作)。需要我确认最后这几个翻绿的话 ping 我一声再查一次。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 CI 全绿 ✅ —— pr2451-review-fixes(commit 4243e284c)

  • 26/26 检查全部 success,0 failure,包括之前唯一红的 unused-exports 和 4 个全量 test job(ubuntu/windows × node 22/24)。
  • PR merge state 已从 blocked → clean。

回顾这次 CI 失败:M3 给 runaway tool-xml lane 加的 corroborator 常量 TOOL_XML_GAP_AVG_BYTES 被写成 export const,但只在 src/runaway-guard.ts 内部用到 → 门禁判 INTERNAL_ONLY。修法是去掉多余的 export(单行,无行为变化)。

现在可以合并了(合并按规矩由你操作)。

ework-agent and others added 4 commits October 9, 2026 12:01
The armed/pre-armed suppression of the Compressible-ranges list is gone.
The table is live by construction — buildCompressibleRanges (kernel/src/
recommend.ts) derives refs from the CURRENT resent view only, after
screening covered/media/protected/withdrawn messages — so an advertised
range always anchors, and hiding it behind failure-cause policy only
produced contradictions:

- armed on substrate-destruction, the receipt orders "run acp_status
  once, then compress ONLY a range it currently reports" — suppression
  made that promised recovery unreachable (#2451 review M2, the #2360
  two-orders shape);
- armed/pre-armed on stale-ref, the failed refs were the model's stale
  INPUT, not the table — suppression hid the very remedy.

acp_status now reports the table unconditionally and carries no order of
its own: substrate-destruction attribution keeps the receipt's recovery
line; every other cause mirrors the receipt's STOP order ("do not
attempt to compress now; continue the task"). Anti-loop pressure stays
where it belongs — in the receipts.

tests: armed (unknown cause / stale-ref / substrate) and pre-armed
(n=1/2) all assert the table stays up, the matching annotation renders,
and no SUPPRESSED claim appears anywhere.
The tool-xml lane tripped on raw fragment COUNT alone: a burst of short
ANTML fragments riding real content (~60 tags in one turn of genuine
tool chatter) looked identical to a true runaway skeleton flood. Gate it
on a second signal — average gap bytes between fragments: genuine tool
chatter leaves prose between its fragments (gaps far above
TOOL_XML_GAP_AVG_BYTES = 64), while a runaway model re-emits the
skeleton with almost nothing in between.

toolGapBytes counts every fed byte as gap the feed it arrives in (the
no-"<" fast path now routes through feedGapOnly so prose chunks count),
each TOOL_XML match subtracts its own length, TAIL_CAP-dropped bytes
stay counted (over-counting gaps is FP-safe), and acp-tag bytes are
deliberately not subtracted.
- relay.ts upstream debug log now routes through maskUrlForLog (the
  import already existed).
- update.ts bootSmoke spawn gains windowsHide — the only callsite the
  #2441 sweep missed (console flash in GUI hosts during the #1575
  desktop in-place update).
@ranxianglei

Copy link
Copy Markdown
Owner Author

Review follow-up (M2 redesign): acp_status now always reports the live ranges table (866eb50, replaces 08bf355)

Review question was whether the armed-substrate-only exemption was the right cut. It wasn't — cause-string-driven suppression is unnecessary given how the table is built:

  • buildCompressibleRanges (kernel/src/recommend.ts) derives every advertised ref from the current resent view (state.messageRefs.byRaw[msg.id]), after screening covered/media/protected/pair-split-withdrawn messages — an advertised range anchors by construction, in every breaker/verdict state. The table cannot cite a previous generation's refs.
  • So suppression was "lying by omission" against a table that is always live, and it produced both observed contradictions:

New behavior:

state ranges table annotation
armed, substrate-destruction attributed shown receipt's recovery line (compress ONLY a listed range; one success clears)
armed, any other cause shown "table is live; per the failure receipt: do not attempt to compress now; continue the task" (mirrors the receipt's STOP — acp_status carries no order of its own)
pre-armed n=1/2 (stale-ref / substrate) shown FOLD BASE GENERATION MISMATCH / FOLD SUBSTRATE INVALID paragraphs, rewritten without the false "list is SUPPRESSED" claim

Anti-loop pressure stays where it belongs — in the receipts (which carry the STOP order and scrub the poll hints), not in hiding a live table.

Tests (tests/issue2432-breaker-awareness.test.ts, 8/8): armed × {unknown cause, stale-ref, substrate} and pre-armed n=1/2 all assert the table stays up, the matching annotation renders, and no SUPPRESSED claim appears anywhere.

History note: branch was force-updated to rebuild the commit cleanly; the gate fix 4243e28 (drop unused export on TOOL_XML_GAP_AVG_BYTES) is preserved verbatim as 5b6b7a0. Net diff vs the previous head is exactly src/acp-status.ts + the breaker test file.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 M2 重设计 review 结论:架构成立,可合(等最后 4 个 test suite 翻绿;merge 按规矩由你操作)

没重做你的改动,而是独立验证地基 + 审是否改坏别处。已核对分支真实状态:force-update 后 head=5b6b7a0e,我的门禁修复 verbatim 保留为 5b6b7a0e,net diff 确实只有 src/acp-status.ts + 测试文件,v1 的 reanchorThroughBreaker/rangesVisible/substrateInvalid 已清干净。

最关键一条——我去 kernel 源码核实了地基,不是信注释:buildCompressibleRanges(kernel/src/recommend.ts:206-255)对 messages(当前 resent view)逐条取 state.messageRefs.byRaw[msg.id],!ref || BLOCKED 直接跳过,再筛掉 covered/media/protected/integrity-withdrawn。每一格广告的 ref 都必然对应"当前 view 里物理存在且带活 ref 的消息"——上一代 ref 因消息不在数组里根本不会被产出。所以"表天然 live、锚定 by construction"成立;失败从来是模型拿旧 ref 去压(stale-ref)或中途被 host 改写(substrate),不是这张表在广告坏 ref。你"压制 = 对一张永远 live 的表以隐瞒说谎"的判断是对的。

八问

  1. 是什么问题:M2 原实现用 cause-string 决定范围表可见性(仅 armed-substrate 豁免)是不是正确的切分。
  2. 原设计为何不对:建在"表可能广告锚不上的 ref"这一错误假设上;表既恒 live,按 cause 的任何压制都是无谓隐藏,还制造两处矛盾(substrate:回执承诺的恢复路径不可达;stale-ref:藏掉唯一补救信息)。
  3. 影响范围与严重程度:仅 acp_status 输出文案 + 范围表可见性;原设计复现 bili 插件模式下 allowDshCompaction 在 responses 线路上完全失效 —— DSH 原生压缩落地、折叠基底被摧毁、compress 连片失败 #2360 双指令矛盾并锁死 substrate 恢复。行为缺陷,非崩溃级。
  4. 怎么修复的:表永远显示;anti-loop 压力全收进 receipts(它们才承载 STOP 顺序);acp_status 只按 cause 挂诚实注解(substrate→恢复句;其它→镜像回执 STOP);circuit breaker 一字未动,继续独立给失败次数封顶。
  5. 是否有回归问题:重点审过,无。
    • armed+stale-ref 会同时出现 "do not attempt to compress now"(armed 行)与 FOLD BASE GENERATION MISMATCH 段(含 "start a fresh conversation")——测试 208–217 行明确 pin 这是有意为之;不构成 bili 插件模式下 allowDshCompaction 在 responses 线路上完全失效 —— DSH 原生压缩落地、折叠基底被摧毁、compress 连片失败 #2360 反向主指令循环:receipt 主指令是 STOP、status 镜像 STOP,"compress only ranges it lists" 是次级条件、"fresh conversation" 是兜底,没有任何一面命令模型去压并期待成功来对抗另一面的禁令;且 breaker 独立兜底,显示表最多让模型压中一个 live range 成功→解除,不比压制更糟。
    • armed+unknown / 空表边界均优雅处理(空表时恢复句自带 "If no ranges are listed, continue…")。
    • net diff 收敛在两文件内,无跨文件副作用。
  6. 是否破坏缓存:不涉及(纯状态展示层,不碰压缩/缓存/重试路径)。
  7. 是否改了设计方向:是——从"cause-string 驱动可见性策略"转到"表恒 live + receipts 承载 anti-loop 顺序"。边界更干净,认同。
  8. 是否引入新配置:不涉及。

一个非阻塞小观察(供你定,我没擅自动你的注释):src/acp-status.ts:203-208 写 "The fresh-conversation advice stays pre-arming only",但按 if (staleRef || (substrateDestroyed && breaker===undefined)),staleRef 段的 "start a fresh conversation" 在 armed 时也会渲染(真正 pre-arming-only 的是 substrate 臂)。功能没问题(第 5 点已论证它是 STOP 的次级兜底),只是这句概括对 staleRef 臂略过头。要收紧的话可改成 "…for the substrate arm …; the stale-ref section renders even while armed (its primary is the receipt's STOP)"。需要我补一个标注 commit 就说一声。

CI:5b6b7a0e 目前 22/26 绿、0 failure,剩 4 个全量 test job 在跑,翻绿我确认。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 CI 全绿确认:5b6b7a0e 26/26 通过、0 failure(含最后两个 windows test job)。unused-exports 门禁随我的修复保留为 5b6b7a0e,一并转绿。

顺带一个 FYI(非阻塞):PR 当前 mergeable=true 但 state=behind——master 在你 force-update 后又前进了。无冲突,可直接合;若你想让 diff 更干净,合并前 rebase 一下即可,这个由你定。

按规矩 merge 由你操作;我这边 review 到此收工。上面那条非阻塞的注释小观察(src/acp-status.ts:203-208)要不要我补个标注 commit,等你一句话。

@ranxianglei
ranxianglei merged commit c171d38 into master Oct 9, 2026
26 checks passed
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.172-master.c171d38 (rolling master tag).

npm install -g billion-context@0.0.172-master.c171d38  # 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.

@ranxianglei
ranxianglei deleted the pr2451-review-fixes branch October 15, 2026 05:33
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.

1 participant