Repository navigation
[PR] Outbound invariant judge: add I3 pairing invariant — folded/split tool_use/tool_result no longer marked clean (#4862) | 出站不变量判官补 I3 配对不变量:折叠拆断的 tool_use/tool_result 不再判 clean(#4862) - #4984
Conversation
…e/tool_result half-pairs no longer judge clean (#4862) The judge's I1/I2 only reconcile entry↔exit continuity; the folded region was a free zone, so a fold that ate ONE half of a tool pair earned a clean fold verdict right before the upstream answered 400 (tool_use ids without tool_result blocks). I3 checks the exit body's own protocol structure: every tool-call answered by a later same-id tool-result, every tool-result preceded by a same-id tool-call — kernel-parity directional walk (prune.ts #3046), fold-split agnostic, all four modes (legacy/render-lane/main/loop). Attribution stays 'whose fault': host-sent half-pairs skipped per-id, a volume guard arbitrates id re-mints (#2821), compress calls stay exempt (hideConsumedCompressCalls parity). Pure detection — zero outbound bytes changed, never blocks, diagnostics.invariantJudge knob as before. Tests: 12 rows (NEG half-pair folds/render prefix/re-mint laundering; POS host-broken echo/compress in-flight/whole-pair fold/same-id precedence; wired main+loop lanes). Existing judge suites (46) stay green.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.6532-pr.4984.ea025bfThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4984.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(bot 说明: 查重:不重复。 检索了 open+closed issue/PR(按「invariant judge / pairing / unpaired tool_use / I3 / #4862」多组关键词+失败签名),无其他条目触碰判官的出站配对缺口。关联项均已在 PR 正文挂链且机制不同:#4862 = 本 PR 修的对象;#4774 = 根修(子代理不再共享 session id,消除主触发源);#4769/#4352/#4409 = 共享 id 线的历史面。 标签:bug / claude-code / scope/wiring / p2 —— 判官观测缺口修复(纯检测、零拦截),触发形状来自 claude-code 子代理车道;p2 因为本层不改任何出站字节,用户侧行为不变(上游 400 的根治仍在 #4774/第 2 层)。 审核进行中(独立重做,未照抄 issue 结论):
两点小观察(不影响方向,终审里一并处理):① PR 正文把「clean fold verdict 最容易被误读成『bili 没问题』」标为 owner 原话,实际出处是 #4862 floor 3 的 agent triage 评论(#4862 无 owner 评论),归属小误;② defaultSink 日志前缀 |
…ine (#4862 review follow-up) The defaultSink labeled every violation by folded-ness (I2 when a fold carrier is present, else I1). An I3-only violation on a non-folded request read as "I1 violation: unpaired-tool-call" — exactly the misread this invariant exists to prevent. Label by the invariant that actually fired.
…ume counts (#4862 review follow-up) POS row: entry ships one host-broken non-compress call plus an in-flight compress call, exit re-mints both ids. Compress must be excluded from BOTH the exit and entry volume counts or the re-minted compress inflates the exit side into a false positive.
(ai: vllm-qwen/qwen3.8-27b) PR #4984 审核完成。方向、实现、测试、回归全部独立复核过;审核中发现两处小问题已直接在 PR 分支修掉(两个独立标注 commit,已推送);未发现阻断项。 八问
行为变更披露(旧→新)日志行原为按 folded-ness 打标( 审核中推送到 PR 分支的两处小修(新 head
|
(ai: vllm-qwen/qwen3.8-27b) Merge guard sync done: merged origin/master (9b6ec23) into branch |
(ai: vllm-qwen/qwen3.8-27b) 收工小结(审核已完成,详见上方八问回复与补充):
|
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.893-master.9d2ac52 # this exact build
npm install -g billion-context@master # always the newest merged build
|
修什么
一句话:判官(出站不变量校验)此前只对账「入站 vs 出站的连续性」,从不检查出站体自己的协议结构——折叠把一对 tool_use/tool_result 拆掉半侧送出去,判官照样判 clean 放行,直到上游用 400
tool_use ids were found without tool_result blocks打回来。日志里那条 clean fold verdict 正是最容易被误读成「bili 没问题」的行(owner 在 #4862 的 triage 评论原话)。根因
src/invariant-judge.ts只定义两条不变量,全是 entry↔exit 连续性对账:#4862 的形状:折叠/渲染只送出一对工具调用的半侧 → 差异全在折叠区 → I2 判合法 → clean 放行 → 上游 400。
修法
新增 I3 出站配对不变量(纯检测、零拦截、零出站字节改动):
kernel/src/prune.tsstripOrphanedToolCalls/stripOrphanedToolResults,[Bug] prune strip guards pair tool calls by id-set, so duplicate host ids ship an unpaired half (upstream 400, session bricked) #3046,precedence-only);测试
tests/issue4862-invariant-judge-unpaired.test.ts12 例(#3617 正负双向):既有判官三件套(46 例)原样全绿;折叠/压缩/孤儿相关回归(issue4292、compress-success-tail、loop-responses-orphan、issue3222、affinity-crosswire-fold,38 例)全绿;typecheck 过。
划界
第 2 层(真正拦 400 的出口修复:剥孤儿半侧 / anthropic 邻接楔入上提)是 wire/message-shape 变更,属人工审核层,不在本 PR——等本层判官红线在真实流量确认命中形状后单独决策。与 #4774(根修共享 session id,消除主触发源)正交且互补。
关联 #4862 #4769 #4774