Repository navigation
[PR] fix: gate auxiliary usage settles off the main session's decision state (#4425) - #4504
ranxianglei wants to merge 10 commits into
Conversation
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.10588-pr.4504.6ce7f63This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4504.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 收到 PR #4504(修 #4425:辅助小请求的用量 settle 污染主会话账本)。开始按 PR Review 规范审:先核对原 issue 方向、再读 diff 做回归清点、然后看 CI。 当前 CI 快照(仍在跑):ubuntu 分片全绿(27 passed),windows-latest node22 的 3 个 test 分片红了(shard 1/2/4),8 个还在 in_progress。我会查这 3 个 Windows 失败是不是本 PR 引入的(还是既有 flaky / 与本改动无关),稍后给结构化八问结论。 |
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复——open+closed issue/PR 按失败签名(non-main sample / sub-scale settle / 基线自愈)检索无既有条目。相关项差异:#4383 是同根 read 侧(修复 PR #4413 在途)、#4443 是本人此前对 #4425 的并行修复(已声明冗余)、#2683/PR#2725 是高基线读侧退役——均非「write 侧门误伤合法主轮」这一机制。 判定:非小修——需要设计拍板,按 auto-fix lane 规则停止(未向分支 push 任何改动)。 一句话:这个 PR 的「小样本只记账、不动决策状态」幅度门,把要挡的辅助请求之外的东西也挡了——所有「大事件后回到真实小规模」的合法主轮 settle 全部被拒,13 个钉住恢复路径行为的既有回归套件全红;两条既有设计教义正面冲突,选哪条是 owner 决策。 证据
八问
选项对比
storage 两案(issue3250/media-cas)与本 PR 无关(base SHA 本地同样红、该 SHA master CI 绿);gate 修复重跑后若仍红,另行作为独立发现处理。 等 owner 拍板(A/B/C);拍板后 attempt 2 直接在本分支实现并推 CI。 |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复 —— 本 PR 是 #4425 的唯一修复 PR;在途 PR 中没有同机制的平行修复(读侧孪生 #4383 已由 #4413→#4443 合入)。 结论先行:拦下,暂不可合并。 方向对、代码质量好,但核心判别器(纯量级阈值)被本仓自己的 e2e 语料证伪:CI 11/11 个 test shard 全红,全部同一机制——门把「合法缩小后的主回合恢复 settle」误判成辅助。已本地复现 + master A/B 对照确认非 flake。 结构化八问
证据
判定拦下。代码干净、测试有牙,但纯量级判别器在结构上分不开「辅助 sidecar」与「合法缩小的主回合」——本仓 e2e 语料在这里就是 ground truth,它说 no。建议按方案 A 重做判别器(或 B),force-push 后我立即复审。 |
…te (#4425) An auxiliary/sidecar request that slips past the side-request lane's evidence allowlist shares the main session id and ran settleUsageReport's full effect set on the main ledger: it cleared the emergency shrink arm, wiped overflow evidence, burned the post-rebuild meter anchor, consumed or rolled the main turn's k-hat pending pair, and booked cache-ledger lines whose body pairing pointed at the aux request. - settleUsageReport treats a sample billing < NON_MAIN_USAGE_RATIO (1/10) of the established session input scale (lastInputTokens + active compress credit) as non-main: raw billing counters accumulate, every decision-layer side effect is suppressed. resetSessionCompression zeroes the baseline at native-compaction boundaries, so post-compaction small settles bootstrap freely. - noteLocalTextEstimate (new shared prepare-lane helper) refuses to let an aux-sized body clobber the outstanding main-turn calibration pair, so the main settle still consumes its own consistent pair (k-hat no longer starves on hosts that fire an aux call before every tool call). Behavior change: previously EVERY total>0 usage sample ran the full decision-layer effect set; now sub-scale samples are billing-only. No config surface change; kernel/ untouched. Tested: tests/issue4425-aux-settle-gate.test.ts (both directions per Closes #4425
…sub-scale settle contract A1 reported a constant 5000-token usage against a ~78KiB payload (a 12.7x gap vs the char-bound arm estimate). Under the new non-main settle gate, once the failure round armed lastInputTokens to the char-count bound (~63.5K), that sub-scale report was rejected as aux-shaped and contextTokensSource never flipped back to usage. Same-class fixture correction as this PR's issue3148-upstream-circuit update: the relay now bills at chars/4 (billing caliber) so every report tracks its payload's scale, and the assertions reference the actual billed value. Test intent unchanged: a real same-scale usage report retires the arm and the anchored anonymous session sizes on it, not the raw-history bound.
976abf9 to
7c7e914
Compare
|
(ai: vllm-qwen/qwen3.8-27b) Rebased onto master@931c66a2f (branch was dirty after ~440 commits of drift; work triggered from field instance #4805). Both conflicts were additive:
One extra labeled commit (test-only): Verification on pushed head 7c7e914: typecheck + build green; targeted batch 98/98 (issue4425-aux-settle-gate, issue3148-upstream-circuit, issue4383-stale-anchor-fallback, issue4383-stale-usage-anchor, issue1933-preflight-calibration, issue1569/1820/1987/2033 anchor family, issue3900-overflow-teaches-calibration, cache-ledger). Full-suite verdict = remote CI on this head. Non-blocking follow-up recorded on #4425: the gate's incumbent ( |
(ai: vllm-qwen/qwen3.8-27b) 收到 rebase 状态。在推送 head 7c7e914 上做了本地核验(先重建了 kernel/pi-subagents 产物——master 漂移后旧 dist 缺 冲突解法核对: issue2033 修复确认有效:A1/A2 本地转绿(fixture 按 chars/4 计费口径对齐后,断言意图「真实同规模 usage 报告退役手臂」保住)。 但其余 12 个文件仍红,签名逐字相同(每个失败断言前都是
关键判断:issue2033 的「fixture 对齐」不能推广到这 12 个。 #2033 A1 的报告-vs-载荷 12.7× 差距是 mock 假象(relay 按 chars/4 计费后即同规模);而剩下 12 个钉住的行为恰恰是「更小规模的真报告必须覆盖更大的 incumbent」——生产恢复路径里 fold 后的重发载荷合法地远低于 char-bound 武装值/污染值计费(压缩比就是 bili 的本体,一次 fold 3×、多 fold 10-50× 都正常)。把它们的 fixture/断言改成同规模 = 选项 C = 复活 #1492 当年修的永久锁死病理,回归钉失去意义。 关于你记的非阻塞 follow-up(incumbent 可为 estimate-grade 武装值 → 失败后立即扩大拒绝区,#4805 级联):同意,与我判定第 3 点是同一机制族。#4383 reader 降级只限住读侧暴露 ≤1 轮;写侧锁死不受它约束——baseline 因为被门挡永远降不下来。「per-send measurement 并入 incumbent」这个加固方向与选项 A 重叠,A 直接吸收它(锚定恒随真实报告 → incumbent 永远是真值,拒绝区不再被 estimate-grade 膨胀)。 仍待拍板(A/B/C,见上一条八问):
拍板后 attempt 2 在本分支实现并推 CI。 |
…n current master Union-of-intent resolution of the four prepare-lane conflicts: - keep master's #4805 probeRequestMembership evidence calls and its one-tree-walk precomputed imageReserve calibers; - re-land the #4425 guard through noteLocalTextEstimate (aux-sized bodies must not clobber the outstanding main-turn k-hat pair), writing the pair origin atomically with the value instead of a separate assignment; - cache-ledger gate path now also bills the USD ledger (#4899 parity): non-main samples bill input/cache like every other settled sample.
…ide-lane suites The T1/T1b/(K) tests asserted the #4805 review decision that settle stays unconditional ("usage-grade samples supersede unconditionally"). The #4425 write-side gate deliberately supersedes that decision: sub-scale samples (billing < 1/10 of the established load) are auxiliary-shaped and settle billing-only. The ambiguity the #4805 review flagged (far-smaller sample vs #1492 B self-heal) resolves by failure direction — a gated sample overstates the context (conservative folds, healed by the next main-scale report), an accepted one understates it (preflight-floor collapse, overflow 400s) — and every realistic shrinkage path keeps its samples above the ratio (post-fold re-requests bill the unfolded body; native compaction resets the anchor). The reader-side meter guard (lastUsagePayloadUpper + effectiveTokenCount size refusal) is kept as defense-in-depth. Suite headers updated to record the decision evolution.
The #4425 non-main settle gate classified any sample below 1/10 of the established session load as auxiliary and suppressed its decision-state effects. Legitimate MAIN turns can bill far below the incumbent: a model switch onto a smaller window (preflight-compress e2e) or a preflight fold off a poisoned/armed incumbent (#1492 self-heal). Their real reports were kept billing-only, so lastInputTokens stayed poisoned/unset and the anchor grade degraded to estimate — six pinned e2e contracts broke on every shard. The discriminator is whether the sample matches the prepared body it bills: the pending k-hat pair noted at prepare time on the same route. A same-route sample within the calibration plausibility band [0.2, 5]x of that pair (>= the 2k floor) is this request's own report and takes the normal settle path; an aux slip's own pair was refused by the noteLocalTextEstimate clobber guard, so its sample stays outside the band and remains gated billing-only. Fixtures converted to chars/4 billing caliber (same conversion as #2033): the issue1492 and preflight-compress mocks billed constants an order of magnitude below their payloads, which reads as aux-shaped against any established incumbent. issue1839 needs no fixture change — its constant report sits inside the band.
… reports (#4504) Round 2 of the #4425 gate follow-up. The own-body plausibility band from the first commit cannot see through two legitimate sub-scale MAIN shapes, both pinned by e2e contracts that went red on head c0d5cb1: - #2313 a / #2490 c: the incumbent was measured on a route that no longer matches (dead-route provenance). A report from the CURRENT route is a route-change recovery — #1933 F2 already treats cross-origin measurements as non-comparable evidence, so such a sample is admitted (disjunct b). - #2313 b/d: the probe-400 arms re-stamp the origin to the live route, and the shim bills at a divergent ~200 B/token caliber (chars/40), putting the retry's report below the calibration band against its own prepared body. Against an ESTIMATE-sourced incumbent there is no real evidence to protect, so a same-route sample corresponding to its own body is admitted down to a DIVERGENT_CALIBER_FLOOR of 5% of the pair (disjunct c). USAGE-sourced incumbents keep the strict band — that is the #4425/#4805 protection surface; all pinned unit contracts (issue4425 8/8, side-lane K/K2, issue4805 9/9) stay gated.
🔶 需要决策 本 PR(#4504,#4425 的 aux 结算门禁)CI 有 6 个测试分片红,但根因只有两个,且都是本 PR 自己引入的回归,不是 master 继承红。判据:我把这两个失败用例分别在「master 版 cache-ledger.ts」和「全量 master src(5 个差异文件)」下复跑——去掉本 PR 改动后两个都绿;ci-fixes 对这两个文件没有任何改动,所以「merge ci-fixes」也救不了。 两个回归都卡在 #4425 量级门禁 vs 既有已钉住契约 这个设计上,属 load-bearing 语义改动(§7.4 人类把关区)。按 auto-fix 车道规则我不擅自改门禁、也不强改钉住测试断言来糊 CI,先请拍板。 回归 1 — tests/issue793-zero-usage-abort.test.ts:178「positive samples still settle」
回归 2 — tests/issue857-image-baseline.test.ts:177「poisoned baseline … recovers to real usage」
选项(两个一起定):
推荐 A;若下一轮前 owner 未回复,默认按 A 的最小实现推进(仅补「incumbent 不可信 + 来样 usage-grounded → 放行」这一条豁免 + 对齐 issue793 控制用例)——它是唯一既不削弱 #4425 防 aux 污染能力、又不牺牲 #857/#793 既有保护、且改动最小的路径。此改动仍属 load-bearing,合入前需 owner 明确点头(§7.4),我不会在无拍板时自行合入。 本轮做了什么(结构化八问):
结论:本 PR 暂不合。两个失败既非 CI 抖动也非 master 继承红,而是 #4425 门禁与既有契约的设计冲突,需 owner 在 A/B/C 拍板(默认 A)。已打 |
|
(ai: vllm-qwen/qwen3.8-27b) 结论:APPROVE — 方向正确、实现收敛在单一 chokepoint、测试双向且有牙、行为变更已披露。 ① 是什么问题:绕过 recognized-side allowlist 的 aux sidecar 请求(title-gen/classify 等,几十 token 量级)与主会话共享 session id,它们的 usage report 对主账本执行了完整决策层效果集(清 arm/evidence、烧 post-rebuild anchor、消费主回合 k̂ pending pair、记错配 body 的 cache line)——#4383/#4413 读侧修复的写侧孪生。 ② 什么原因导致的:settleUsageReport 没有「样本归属」概念——任何 total>0 的报告都跑完整效果集;读侧(#4413)只修了锚陈旧,写侧一直裸露。 ③ 影响范围与严重程度:每个工具调用前都发 unrecognize-shape aux 的宿主(pi/opencode/zcode/claude-code/kimi 车道;dsh 被 persona fork 豁免):主 meter 被反复拉到 aux 量级 → preflight floor collapse / overflow 400 / k̂ 永久饥饿 / #1592 ghost anchor。现场复现里压缩永久停摆,p1 级可用性缺陷。 ④ 怎么修复的:单一 chokepoint 上的 magnitude gate(NON_MAIN_USAGE_RATIO=0.1,establishedScale = lastInputTokens + active credit):sub-scale 样本 billing-only(inputTokens + USD ledger 照记),决策层副作用全抑制;三条准入路径保住合法形状(own-body band [0.2,5]×pair / cross-origin recovery #2313 / divergent-caliber [0.05,5]×pair 仅限 estimate incumbent);prepare 车道 noteLocalTextEstimate 加 clobber 保护(aux 量级 body 不得覆盖主回合 pending pair);resetSessionCompression 清零基线使 compaction 后小 settle 自由 bootstrap。 ⑤ 回归审查(逐项过既有行为,均独立验证非照抄 PR 描述):
⑥ 是否破坏缓存:prefix/prompt cache 路径不受影响;k̂ calibration ring 正是本 PR 要保护的(aux 不再污染 pending pair 与 ring)。 ⑦ 是否改了设计方向:无转向——即 issue 要求的「lane-gated settle」方向,用 magnitude 作判别器(aux 样本无 id,id-membership 单独救不了它;magnitude 是物理不变量:主回合报告总与其 own prepared body 同量级)。 ⑧ 是否引入新配置:无。NON_MAIN_USAGE_RATIO / DIVERGENT_CALIBER_FLOOR 是模块常量,不是配置面。 两条残余观察(非阻塞,均为有意的、代码内已记录的取舍):
CI green(head df7c052,15 success / 0 failed,镜像缓存核对)。本地未跑套件——worktree 无 node_modules,定向本地跑不可行;按 §7.2 以 CI 为准,另做了全量代码路径核查。 合并判定:可合。无需要顺手修的小问题(两条残余均为已文档化的取舍,非缺陷)。 |
[bot] 🏷 审核完成:APPROVE,可合(head df7c052)。完整八问结论见上方审核评论。
|
…ogle/responses import conflicts on current master
(ai: vllm-qwen/qwen3.8-27b) Merge conflict resolved and pushed. The PR was What conflicted and why — master evolved How I resolved it — for both files I took master's import block (the newer, authoritative structure) plus this branch's single new Verification & state — no conflict markers remain; committed as a two-parent merge ( Two notes for the owner:
8问(结构化审核)
判定:冲突已解决并推送,PR 恢复可合并( |
…thropic conflict on current master (301e1a5)
(ai: vllm-qwen/qwen3.8-27b) Merge conflict resolved and pushed. The PR branch What conflicted and why. Exactly one file: How it was resolved. I kept master's Verification. 0 conflict markers repo-wide; the #4425 gate is intact ( Note on the known regressions. This run cleared only the conflict. The two #4425 design regressions ( 八问:
判定: 冲突已解决并推送(3f1801b,fast-forward,无 force),merge state 已脱离 dirty,CI 正在跑(29 checks,0 failed,22 pending)。#4425 的两个测试回归(issue793-zero-usage-abort / issue857-image-baseline)仍待 owner A/B/C 决策(上次已 🔶 需要决策 升级),本次 merge 未触碰,会在这次全量 CI 里如实报出。 |
[ework] CI fix verified green ✓ |
1 similar comment
[ework] CI fix verified green ✓ |
Problem
Auxiliary small requests (classify / title-gen sidecars) that slip past the side-request lane's evidence allowlist share the main session id and ran
settleUsageReport's full decision-layer effect set on the main session ledger (#4425):emergencyShrinkAt/Estimate) — a 50-token aux settle disarmed protection before the real overflow;overflowArmTokens,overflowArmCompletionReserve);clearPostRebuildAnchor→ dsh 缓存失效 #1592 ghost path);Note: recognized side-passthrough requests (#388) already settle nowhere — this covers the UNRECOGNIZED shapes (e.g. the claude-code no-stop s2 shape documented at #2740 as "takes the normal lane"). This is the write-side twin of #4383's read-side anchor-staleness fix (#4413): together they form the contract "main turns settle the ledger, auxiliary turns only pass through".
Fix
Two magnitude guards, one constant
NON_MAIN_USAGE_RATIO = 0.1:settleUsageReport, the single chokepoint all three response paths funnel through): a sample billing less than 1/10 of the established session input scale (lastInputTokens+ activecompressCreditTokens) is non-main → raw billing counters accumulate, every decision-layer side effect is suppressed.resetSessionCompressionzeroes the baseline at native-compaction boundaries, so post-compaction small settles bootstrap freely; a rejected sample self-heals within one main turn.noteLocalTextEstimate, new shared helper used by all four prepare lanes): an aux-sized body (< 1/10 of the outstanding pair) cannot clobber the main turn's pending k̂ pair — without this, the main settle would consume a (auxEstimate, mainBilled) mispair the plausibility band rejects, keeping k̂ starved even with the settle gate in place.Threshold margin (verified case-by-case in tests): aux samples typically bill < 2% of session load (rejected); the smallest legitimate main settle after an armed round still bills ≥ ~23% of the arm estimate (char-based estimator inflation caps around 4.4×, #4383 evidence) — so 1/10 separates the two with margin in both directions. The read side uses a looser 0.25 because its incumbent is a value being read; here the incumbent is evidence being destroyed.
Behavior change (disclosed per policy)
total > 0usage sample ran the full decision-layer effect set (anchor writes, arm/evidence clears, post-rebuild anchor clear, calibration pair consumption + roll-forward, cache sample + ledger line + seam forensics, image learning).inputTokensaccumulator;outputTokenswas always accumulated at the call sites).tests/issue3148-upstream-circuit.test.tssettled a 1000-token report against a 15K-scale fixture and asserted the arm marker cleared — that sub-scale shape is exactly what this fix gates; the report is now main-grade (15K), preserving the test's intent.No config surface change. No persistence format change.
kernel/untouched.warnCacheCollapseleft as-is (diagnostics-only watcher, no decision state, ignores inputs < 8K).Tests
tests/issue4425-aux-settle-gate.test.ts— 8 tests, both directions per Test Blind Spot Retrospective: Reinforcing Negative Assertion Discipline, Tightening Fake Upstream Strictness, Thin Inst | 测试盲区复盘:补反向断言纪律、假上游严格化、薄安装冒烟、形态矩阵与生命周期覆盖 #3617: aux settle keeps arm/evidence/anchor/pair/ledger intact while billing stays honest; main settle runs the full effect set (no over-suppression); fresh-session + constant-small upstream bootstrap (post-rebuild usage estimate inflates ~3.4x after a big fold, firing an EMERGENCY T1 nudge into an over-budget context #1820 B / 任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839 G1 invariants); armed-round recovery re-anchors ([Bug] statusInputBaseline falls back to lastUsageGradeTokens instead of the calibrated local estimate — so one 4.7k side-request sample blocks folding for 4 hours | #1595 承诺的"改用本地估算"兜底在 statusInputBaseline 里没有实现,一次 4.7k 侧请求样本即可挡住折叠 4 小时 #4383 shape); post-fold unfolded re-request passes + folded steady state continues; k̂ starvation sequence fixed end-to-end; boundary semantics (strictly below 1/10) pinned on both guards.Closes #4425