Skip to content

[PR] fix: gate auxiliary usage settles off the main session's decision state (#4425) - #4504

Open
ranxianglei wants to merge 10 commits into
masterfrom
2026-10-24_4425-aux-settle-gate
Open

ranxianglei wants to merge 10 commits into
masterfrom
2026-10-24_4425-aux-settle-gate

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

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):

  1. cleared the emergency shrink arm (emergencyShrinkAt/Estimate) — a 50-token aux settle disarmed protection before the real overflow;
  2. wiped the overflow evidence (overflowArmTokens, overflowArmCompletionReserve);
  3. burned the post-rebuild meter anchor (clearPostRebuildAnchor → dsh 缓存失效 #1592 ghost path);
  4. consumed/rolled the main turn's k̂ pending calibration pair — on hosts that fire an aux call before every tool call the pair never lines up and k̂ starves permanently;
  5. booked cache-ledger lines whose body pairing points at the aux request (seam forensics attributes breaks to the wrong request).

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:

  • Settle gate (settleUsageReport, the single chokepoint all three response paths funnel through): a sample billing less than 1/10 of the established session input scale (lastInputTokens + active compressCreditTokens) is 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; a rejected sample self-heals within one main turn.
  • Prepare guard (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)

  • Old: every total > 0 usage 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).
  • New: samples billing < 10% of the established session input scale are billing-only (inputTokens accumulator; outputTokens was always accumulated at the call sites).
  • One existing test updated to the new contract: tests/issue3148-upstream-circuit.test.ts settled 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. warnCacheCollapse left as-is (diagnostics-only watcher, no decision state, ignores inputs < 8K).

Tests

Closes #4425

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-24_4425-aux-settle-gate (3f1801b)

Latest build — install this exact version

npm install -g billion-context@0.0.10588-pr.4504.6ce7f63

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
3f1801b billion-context@0.0.10588-pr.4504.6ce7f63 build
67b057b billion-context@0.0.9704-pr.4504.095aaa0 build
df7c052 billion-context@0.0.8053-pr.4504.e4b66a2 build
c0d5cb1 billion-context@0.0.8050-pr.4504.4bf1742 build
1475997 billion-context@0.0.8048-pr.4504.b4bb05c build
dcdc960 billion-context@0.0.6180-pr.4504.6d096f2 build
1415ad9 billion-context@0.0.6094-pr.4504.58247e4 build
976abf9 billion-context@0.0.5418-pr.4504.b8c4c62 build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix: gate auxiliary usage settles off the main session's decision state (#4425) [PR] fix: gate auxiliary usage settles off the main session's decision state (#4425) Oct 24, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[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 / 与本改动无关),稍后给结构化八问结论。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(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 决策。

证据

  1. 11 个红 job = 两类失败。
    • gate 家族(PR 所致,13 文件/20 case):每个失败断言前都有新日志行 [acp-usage] non-main sample input=X (<10% of established Y) — decision state kept, billing only (#4425):tests/issue1492-stale-estimate-view.test.ts A/B/C、tests/issue1839-ghost-denominator.test.ts G2、tests/issue2033-anonymous-anchor.test.ts A1、tests/issue793-zero-usage-abort.test.ts、tests/issue857-image-baseline.test.ts A、tests/issue767-pixel-billing.test.ts ×2、tests/e2e-overflow-selfheal.test.ts(context window problem continues #987/使用pi 压缩后就提示prompt is too long #1195 T1)、tests/e2e-relay-5xx-selfheal.test.ts ×2(arm emergency shrink on upstream failure to break relay-5xx deadlock #604)、tests/preflight-max-output-tokens.test.ts ×2(fix: Codex preflight summaries fail with unsupported max_output_tokens #663)、tests/issue1195-overflow-refold.test.ts A、tests/issue2490-ledger-floor-doomed-probe.test.ts c、tests/issue2313-probe-forward.test.ts a/b/d、tests/preflight-compress.test.ts e2e ×2。
    • storage 家族(非本 PR 所致):tests/issue3250-wal-checkpoint.test.ts(WAL 截断超 cap 47KiB)+ tests/media-cas.test.ts(media ref 未释放)。本地实测:在本 PR 的 base(master tip 02f544d)单文件跑同样失败,而该 SHA 的 master CI 是绿的 → 环境/调度敏感,与本 diff 无关(diff 零存储代码)。
  2. 本地复现:PR head 上单独跑 issue1492 三例全挂,日志行与 CI 逐字一致(确定性,非 flake)。
  3. 根因:门的隐含不变量「任何合法主轮 settle 都计费 ≥ establishedScale 的 10%」不成立。establishedScale = lastInputTokens + compressCredit 追踪的是未折叠规模,而代码库里每一条恢复路径的形状都是「失败事件先确立高规模 → 下一个成功主轮合法地远低于它计费」:污染基线自愈(emergency shrink / preflight 的本地估算用错了视图:超长会话(客户端历史 127 万,压缩后 outbound 仅 ~16 万)在上游失败无 usage report 时,bili 按原始历史估算 #1492:POISON=1.2M vs 真实 5K = 240×,永久锁死——更新本身被门挡,lastInputTokens 永远回不下来)、probe(dsh压缩与bili压缩冲突 #2490 c:3614 vs established 7.3M)、溢出救援重试(使用pi 压缩后就提示prompt is too long #1195/context window problem continues #987/arm emergency shrink on upstream failure to break relay-5xx deadlock #604 截断重试)、learned-rejection 恢复(fix: Codex preflight summaries fail with unsupported max_output_tokens #663)、image/pixels 陈旧基线恢复([Question] 非白名单上游(如 DeepSeek)图片按 b64/4 估算,实测高估约 100×;且该估算被写回 lastInputTokens 并自愈成 confirmed 窗口,使 #496 逃生门永久失效 #857/[Bug] #496 后续:旧 baseline 超窗时官方 Codex 图片估算持续误触发 502 #767)、匿名锚([Gap] Anonymous failure fallback can bypass an existing usage-grade anchor #2033)、显示 grade(任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839 G2)、credit net-out([Bug] Anthropic 流式请求被中断后,可能把 lastInputTokens 错误覆盖为 0 #793)。交付评论里「拒绝是瞬态的,下一主轮 incumbent 更新即自愈」在污染/陈旧高场景下不成立——incumbent 恰恰因为被门挡而永远不更新。

八问

  1. 是什么问题:Usage settle of auxiliary small requests pollutes the main session ledger: erroneously clears shrink-arm/overflow eviden | 辅助小请求的用量 settle 污染主会话账本:误清收缩手臂/溢出证据,饿死 k̂ 校准(#4383 write 侧) #4425 的 write 侧幅度门(<1/10 确立负载判非主、降级纯计费)误伤了全部「计费低于确立规模」的合法主轮 settle,破坏 13 个已发布恢复路径行为。
  2. 什么原因导致的:用「计费额 vs 确立规模比值」作为主/辅判定的唯一依据;该比值无法区分「辅助小请求」与「大事件后的主轮回落到真实小规模」——两者数值形态完全相同。实施前的 margin 分析只覆盖了稳态 aux vs main,没覆盖恢复路径族(这正是 emergency shrink / preflight 的本地估算用错了视图:超长会话(客户端历史 127 万,压缩后 outbound 仅 ~16 万)在上游失败无 usage report 时,bili 按原始历史估算 #1492/dsh压缩与bili压缩冲突 #2490/使用pi 压缩后就提示prompt is too long #1195/arm emergency shrink on upstream failure to break relay-5xx deadlock #604/fix: Codex preflight summaries fail with unsupported max_output_tokens #663/[Question] 非白名单上游(如 DeepSeek)图片按 b64/4 估算,实测高估约 100×;且该估算被写回 lastInputTokens 并自愈成 confirmed 窗口,使 #496 逃生门永久失效 #857/[Bug] #496 后续:旧 baseline 超窗时官方 Codex 图片估算持续误触发 502 #767/[Gap] Anonymous failure fallback can bypass an existing usage-grade anchor #2033/任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839/[Bug] Anthropic 流式请求被中断后,可能把 lastInputTokens 错误覆盖为 0 #793 各自钉住的行为)。
  3. 影响范围与严重程度:若按现状合入——凡经历过污染基线或溢出武装的会话,nudge/preflight 永久骑在陈旧高值上、probe 永远不结算基线、救援后手臂永不退役;受影响宿主同 Usage settle of auxiliary small requests pollutes the main session ledger: erroneously clears shrink-arm/overflow eviden | 辅助小请求的用量 settle 污染主会话账本:误清收缩手臂/溢出证据,饿死 k̂ 校准(#4383 write 侧) #4425(pi/opencode/zcode/claude-code/kimi)。严重度:p1 级缓存决策病理——比原 Usage settle of auxiliary small requests pollutes the main session ledger: erroneously clears shrink-arm/overflow eviden | 辅助小请求的用量 settle 污染主会话账本:误清收缩手臂/溢出证据,饿死 k̂ 校准(#4383 write 侧) #4425(p2,1-2 事件自愈的污染)更糟:这是永久锁死,且 emergency shrink / preflight 的本地估算用错了视图:超长会话(客户端历史 127 万,压缩后 outbound 仅 ~16 万)在上游失败无 usage report 时,bili 按原始历史估算 #1492 当年修的正是这个自愈机制。
  4. 怎么修复的(推荐选项 A):把 settleUsageReport 拆两层——基线锚定字段(lastInputTokens / lastUsageGradeTokens / contextTokens / source 戳)始终跟随真实 usage 报告(恢复 13 套件语义:真实计费是 ground truth,emergency shrink / preflight 的本地估算用错了视图:超长会话(客户端历史 127 万,压缩后 outbound 仅 ~16 万)在上游失败无 usage report 时,bili 按原始历史估算 #1492/[Bug] Anthropic 流式请求被中断后,可能把 lastInputTokens 错误覆盖为 0 #793/任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839 教义);决策效果集(清 shrink 手臂、退役 overflow-arm 证据、烧重建锚、消费 k̂ 校准对、记缓存账行)保留 1/10 幅度门(Usage settle of auxiliary small requests pollutes the main session ledger: erroneously clears shrink-arm/overflow eviden | 辅助小请求的用量 settle 污染主会话账本:误清收缩手臂/溢出证据,饿死 k̂ 校准(#4383 write 侧) #4425 facet 1–5 除锚改写外全保住)。prepare 侧 noteLocalTextEstimate 覆写门保留(独立且成立)。PR 自身测试里「aux 不得改写锚」的断言需同步调整。
  5. 是否有回归问题:选项 A 相对 master 零回归(13 套件全部恢复钉住行为);残留风险 = 被 aux 命中后基线按 aux 规模错一回合(arm 标记保留,preflight 仍按载荷估计判断,下一主轮自愈)——严格优于 master(全污染)与当前 PR head(永久锁死)。选项 B 残留:无 fp 证据的未识别形状仍不可控 = 原 bug 半开。选项 C 复活 emergency shrink / preflight 的本地估算用错了视图:超长会话(客户端历史 127 万,压缩后 outbound 仅 ~16 万)在上游失败无 usage report 时,bili 按原始历史估算 #1492 病理。
  6. 是否破坏缓存:三个选项都不触碰前缀缓存行为与失效策略,只改 settle 写哪些字段。
  7. 是否改了设计方向:无架构转向——是两条既有教义的取舍裁决:「真实用量是 ground truth」(emergency shrink / preflight 的本地估算用错了视图:超长会话(客户端历史 127 万,压缩后 outbound 仅 ~16 万)在上游失败无 usage report 时,bili 按原始历史估算 #1492/[Bug] Anthropic 流式请求被中断后,可能把 lastInputTokens 错误覆盖为 0 #793/任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839)vs「辅助轮只路过」(Usage settle of auxiliary small requests pollutes the main session ledger: erroneously clears shrink-arm/overflow eviden | 辅助小请求的用量 settle 污染主会话账本:误清收缩手臂/溢出证据,饿死 k̂ 校准(#4383 write 侧) #4425)。推荐裁决:锚定归 ground truth,效果集归幅度门。属 §7.4 人审域(load-bearing 缓存决策路径语义变更、影响所有车道与两种压缩模式),故不单方面决定。
  8. 是否引入新配置:无(均保持单一常量 NON_MAIN_USAGE_RATIO=0.1,无新配置面)。

选项对比

选项 修法 #4425 解决度 13 套件 残留风险 代价
A(推荐) 锚定恒随真实报告;效果集留幅度门 ✔(facet 1–5 除锚改写) ✔ 全恢复 aux 命中后错一回合,次轮自愈 小(~20 行 + 测试断言)
B system 指纹连续性判主/辅(KDD #9 许可清单纪律) 部分(已知 persona 类) ✔ 未识别形状仍不可控,原 bug 半开 大(逐宿主流量证据)
C 接受锁死语义,重写 13 套件断言 ✔ ✘ 复活 #1492 永久锁死 污染会话永不恢复 中,方向错误

storage 两案(issue3250/media-cas)与本 PR 无关(base SHA 本地同样红、该 SHA master CI 绿);gate 修复重跑后若仍红,另行作为独立发现处理。

等 owner 拍板(A/B/C);拍板后 attempt 2 直接在本分支实现并推 CI。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复 —— 本 PR 是 #4425 的唯一修复 PR;在途 PR 中没有同机制的平行修复(读侧孪生 #4383 已由 #4413→#4443 合入)。
标签: bug / scope/kernel / p2 / pi / opencode / zcode / claude-code / kimi(辅助请求 settle 污染主会话决策状态;受影响宿主 = 主/辅共享 session id 的车道)。

结论先行:拦下,暂不可合并。 方向对、代码质量好,但核心判别器(纯量级阈值)被本仓自己的 e2e 语料证伪:CI 11/11 个 test shard 全红,全部同一机制——门把「合法缩小后的主回合恢复 settle」误判成辅助。已本地复现 + master A/B 对照确认非 flake。

结构化八问

  1. 是什么问题: Usage settle of auxiliary small requests pollutes the main session ledger: erroneously clears shrink-arm/overflow eviden | 辅助小请求的用量 settle 污染主会话账本:误清收缩手臂/溢出证据,饿死 k̂ 校准(#4383 write 侧) #4425 —— 未被识别的辅助小请求(classify/title-gen sidecar 等)与主会话共享 session id、走普通车道,其 usage settle 在主账本上跑 settleUsageReport 全套决策层副作用:清 emergency-shrink arm、抹 overflow 证据、烧 post-rebuild anchor、销毁主回合的 k̂ pending pair、污染 cache-ledger 行配对。本 PR 意图 = 「主回合 settle 账本,辅助回合只计账」。
  2. 什么原因导致回归: 修法用纯量级判别——billed < 1/10 × established scale(lastInputTokens + compressCreditTokens)⇒ 判为辅助。但量级无法区分两种情形:辅助 sidecar 天然账单小,和主回合在 fold/refold/truncation rescue 之后 payload 合法缩到基线的一小部分。PR 描述的 margin 论证称「armed round 后最小的合法主 settle 仍 ≥ arm estimate 的 ~23%」——本仓 e2e 套件直接证伪:真实恢复路径 settle 为 5000/125776≈4.0%、5000/113499≈4.4%、1000/292624≈0.3%、500/50000=1.0%——全在 1/10 以下。阈值落在合法恢复分布内部,不在其下方。
  3. 影响范围与严重程度: 若合入,overflow-rescue/re-anchor 整面回归:11 个测试文件 19 个命名 subtest 红(清单见下)。用户可见后果:窗口溢出 + 请求内救援后,baseline 钉死在膨胀的 armed estimate 而非重锚到真实 usage,lastInputTokensSource 停在 estimate/overflow-arm,arm/evidence 不退役——正是 context window problem continues #987/使用pi 压缩后就提示prompt is too long #1195/arm emergency shrink on upstream failure to break relay-5xx deadlock #604/billion-context 卡死问题 —— 上报材料 usage获取不到导致上下文估计失误 #2313/emergency shrink / preflight 的本地估算用错了视图:超长会话(客户端历史 127 万,压缩后 outbound 仅 ~16 万)在上游失败无 usage report 时,bili 按原始历史估算 #1492 这些测试写来防的失败形态。proxy/plugin/relay 三车道同等受影响。属 p1 级回归(溢出路径上的核心自适应能力失效),故必须拦。
  4. 怎么修(建议): 保留意图(aux = billing-only),prepare 侧守卫整体保留(noteLocalTextEstimate 独立修掉 facet 4 的 k̂ clobber,本身无问题);settle 侧把判别器从「纯量级」改为「量级 + 结构佐证」:
    • 方案 A(推荐): 以 pending k̂ pair P 为主证据——P 是 prepare 为本请求记下的本地 estimate(有 prepare 守卫后,aux 体无法覆写它)。billed 落在 P 的可信带内(P/4…4P,与 CALIBRATION_SAMPLE_MIN/MAX 同纪律)⇒ 它就是那个 prepare 过它的请求的报告 ⇒ main-grade,与 established scale 的距离无关;billed ≪ P 且 ≪ scale ⇒ non-main。残余洞:紧跟主 settle(刚消费掉 pair)之后的 aux 会 prepare 进空槽、记下自己的小 pair、通过带检——补一个结构信号:本次转发体与上一次 settled 体的头部分歧(settleUsageReport 里 byteLcp/messagesArrayCloseOffset 机制已存在,目前算在门之后,提前即可;rescued 主回合共享会话前缀 → append/tail,sidecar 换 system/preamble → head divergence),或稀疏的 METADATA_SYSTEM_FP 失配作第二信号。
    • 方案 B(较弱): 保留量级门,但对「该轮应用了 fold/refold/truncation 的请求族」豁免(本轮做了 emergency shrink/preflight fold ⇒ 无条件接受其 settle)。更简单,但「主回合合法小于基线」的一般情形仍暴露,且要把 fold 事件状态 plumb 进 settle。
    • 验收标准无论选哪个:全 e2e 语料绿——这套语料就是该机制的 ground truth;作者本地 236/236 batch 显然没覆盖 rescue 路径文件。
  5. 是否有回归问题: 有——即第 3 问清单(逐条见下)。高危模式逐项过:wire shape 不变(settle 纯服务端统计,零 payload 改动);配置面不变;持久化格式不变;kernel/ 未触碰;update.ts 未触碰;warnCacheCollapse 正确地留在门外。PR 披露的行为变更(旧:任何 total>0 跑全套副作用 → 新:<10% billing-only)方向有意,但实测过度抑制——连合法主恢复 settle 一起压掉;issue3148 fixture 改动(1000→15_000)属如实披露,该项无问题。
  6. 是否破坏缓存: 客户端前缀缓存不受影响(无任何 wire-visible 变化)。内部 cache-ledger:被误门的主样本不再记账行/cacheSample——恢复窗口内 seam forensics 少报,是同一根因的次生症状,判别器修好后随之消失。
  7. 是否改了设计方向: 无架构转向,仍是 settle 单咽喉点;prepare 侧 shared helper 与常量注释质量都好,无论选哪个方案都可复用。问题只在判别器设计,不在代码工艺。
  8. 是否引入新配置: 无。NON_MAIN_USAGE_RATIO 是内部常量不是配置旋钮(符合 env-var 纪律);判别器改后如需调参,建议仍保持内部,除非 owner 另行决定。

证据

判定

拦下。代码干净、测试有牙,但纯量级判别器在结构上分不开「辅助 sidecar」与「合法缩小的主回合」——本仓 e2e 语料在这里就是 ground truth,它说 no。建议按方案 A 重做判别器(或 B),force-push 后我立即复审。

ci-check added 2 commits October 26, 2026 13:42
…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.
@ranxianglei
ranxianglei force-pushed the 2026-10-24_4425-aux-settle-gate branch from 976abf9 to 7c7e914 Compare October 26, 2026 05:57
@ranxianglei

Copy link
Copy Markdown
Owner Author

(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): tests/issue2033-anonymous-anchor.test.ts. A1 reported a CONSTANT 5000-token usage against a ~78KiB payload (12.7x gap vs the char-bound arm estimate). Under the new sub-scale settle contract, once the failure round armed lastInputTokens to the char-count bound (~63.5K), that report is rejected as aux-shaped and contextTokensSource never flips back to "usage" — the display-grade assertion failed. Same class as this PR's existing issue3148-upstream-circuit fixture update: the relay now bills at chars/4 (billing caliber) so every report tracks its payload's scale, and 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.

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 (lastInputTokens + compressCredit) can be an ESTIMATE-grade armed value, which widens the reject zone right after failures; #4805 shows the pollution can cascade before the final poisoning sample lands. The merged #4383 reader demotion bounds the exposure to ≤1 round today; folding per-send measurements into the incumbent is a candidate hardening for this PR if you agree.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

收到 rebase 状态。在推送 head 7c7e914 上做了本地核验(先重建了 kernel/pi-subagents 产物——master 漂移后旧 dist 缺 restampContentStore 导出,首次跑全崩,重建后结果有效):

冲突解法核对:src/cache-ledger.ts 两个 helper(#4383 noteOutboundContextEstimates + 本 PR noteLocalTextEstimate)并存、settle gate 原样保留、prepare-anthropic 取 helper-call 形态并保 master 的 judgeBaseline —— 加性合并正确。PR-only diff(8 文件,+281/-24)与 rebase 前语义一致,gate 代码零变化。

issue2033 修复确认有效:A1/A2 本地转绿(fixture 按 chars/4 计费口径对齐后,断言意图「真实同规模 usage 报告退役手臂」保住)。

但其余 12 个文件仍红,签名逐字相同(每个失败断言前都是 [acp-usage] non-main sample input=X (<10% of established Y) — … (#4425)),CI 已于 05:57Z 在 7c7e914 触发,预计同一族再红一遍:

文件 仍失败 case
tests/issue1492-stale-estimate-view.test.ts A / B / C(污染基线自愈,POISON 1.2M vs 真实 5K = 240×,永久锁死)
tests/issue1839-ghost-denominator.test.ts G2(显示 grade 不翻回 usage)
tests/issue1195-overflow-refold.test.ts A(救援后 grade 停在 overflow-arm)
tests/e2e-overflow-selfheal.test.ts T1(#987/#1195 武装→请求内救援)
tests/e2e-relay-5xx-selfheal.test.ts #604 两例(relay 5xx / 网络级故障武装→截断重试恢复)
tests/preflight-max-output-tokens.test.ts #663 order-A / model scoping
tests/issue2490-ledger-floor-doomed-probe.test.ts c(probe 结算 usage 基线,3614 vs established 7.3M)
tests/issue2313-probe-forward.test.ts a / b / d(probe 基线结算、refold 恢复 ×2)
tests/issue767-pixel-billing.test.ts 3 e2e(pixels 计费救活陈旧基线会话等)
tests/issue857-image-baseline.test.ts A(legacy 污染基线经 #496 hatch 恢复到真实用量)
tests/issue793-zero-usage-abort.test.ts applyUsageSample 正样本 credit net-out
tests/preflight-compress.test.ts e2e fresh-session / model-switch 两例(fold 后基线更新)

关键判断: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。

ci-check added 4 commits November 4, 2026 03:09
…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.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

🔶 需要决策
(ai: vllm-qwen/qwen3.8-27b)

本 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),我不会在无拍板时自行合入。

本轮做了什么(结构化八问):

  1. 是什么问题:本 PR 的 Usage settle of auxiliary small requests pollutes the main session ledger: erroneously clears shrink-arm/overflow eviden | 辅助小请求的用量 settle 污染主会话账本:误清收缩手臂/溢出证据,饿死 k̂ 校准(#4383 write 侧) #4425 量级门禁误伤了两条既有已钉住的结算/恢复路径,使 6 个 CI 分片各挂一个用例(实为 2 个不同用例)。
  2. 什么原因导致的:门禁以「样本 < 已有量级 ×0.1 且无自身 body 证据 ⇒ 辅助样本」判定;而 [Bug] Anthropic 流式请求被中断后,可能把 lastInputTokens 错误覆盖为 0 #793 的正样本、[Question] 非白名单上游(如 DeepSeek)图片按 b64/4 估算,实测高估约 100×;且该估算被写回 lastInputTokens 并自愈成 confirmed 窗口,使 #496 逃生门永久失效 #857 的「污染基线→真实 usage 恢复」样本天然满足该形状,又都落在三条恢复豁免之外 → 被门成只计费。
  3. 影响范围与严重程度:本 PR 未合入前仅限 CI;若按现状合入,线上会复现 [Question] 非白名单上游(如 DeepSeek)图片按 b64/4 估算,实测高估约 100×;且该估算被写回 lastInputTokens 并自愈成 confirmed 窗口,使 #496 逃生门永久失效 #857/PR #489 后续: 默认图片计费 b64/4 在像素 tile 计费上游(官方 Anthropic/OpenAI)会硬 502 误杀多模态会话 #496 的 502 死循环(截图会话永久卡死)= p1 级回归,并让 [Bug] Anthropic 流式请求被中断后,可能把 lastInputTokens 错误覆盖为 0 #793 的小额正样本不再刷新基线(成本/体验侧轻微偏差)。
  4. 怎么修复的(推荐方案):见选项 A——补「不可信 incumbent + usage-grounded 来样」的恢复豁免 + 对齐 issue793 控制用例;待拍板后再动手。
  5. 是否有回归问题:本次 CI 仅这 6 个分片红、对应上述 2 个用例,其余分片全绿,未见第三个隐藏回归;高危模式里唯一的语义漂移就是这两处误伤本身。
  6. 是否破坏缓存:不涉及缓存/重试/游标失效策略;影响的是 usage 基线与 k̂ 校准对的结算时机。
  7. 是否改了设计方向:未动架构/数据流;只是 Usage settle of auxiliary small requests pollutes the main session ledger: erroneously clears shrink-arm/overflow eviden | 辅助小请求的用量 settle 污染主会话账本:误清收缩手臂/溢出证据,饿死 k̂ 校准(#4383 write 侧) #4425 门禁判定边界需一处「可信恢复」例外,属同一机制内的精修。
  8. 是否引入新配置:无新 env/config/默认值。

结论:本 PR 暂不合。两个失败既非 CI 抖动也非 master 继承红,而是 #4425 门禁与既有契约的设计冲突,需 owner 在 A/B/C 拍板(默认 A)。已打 needs-decision 标签并停手;拿到方向后我按 auto-fix 车道落地并回推分支。

@ranxianglei

Copy link
Copy Markdown
Owner Author

(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 是模块常量,不是配置面。

两条残余观察(非阻塞,均为有意的、代码内已记录的取舍):

  1. usage-source incumbent 下 mid-session 切到 same-origin divergent-caliber 路由(chars/40 类,billion-context 卡死问题 —— 上报材料 usage获取不到导致上下文估计失误 #2313 shim profile 形状),合法 sub-band 报告可能被持续拒绝 → meter/display 陈旧,方向安全(高估 headroom,永不触发过度压缩),route change / 更大 body / native compaction 自愈。放宽此路径会为 usage-source 会话重开 Usage settle of auxiliary small requests pollutes the main session ledger: erroneously clears shrink-arm/overflow eviden | 辅助小请求的用量 settle 污染主会话账本:误清收缩手臂/溢出证据,饿死 k̂ 校准(#4383 write 侧) #4425 的洞——取舍已在 DIVERGENT_CALIBER_FLOOR 注释中记录。
  2. cross-origin 且无 id 的 aux:magnitude gate 放行(route-change 形状),Bypass requests overwrite the main session's usage anchor, causing long sessions to permanently stop compressing. | 旁路请求覆盖主会话 usage 锚点,导致长会话永久停止压缩 #4805 membership 弃权期间执行完整效果集 → 一轮 meter 污染,下一主 settle 自愈。这是既有行为(PR 之前此类样本无条件跑完整效果集),读侧 [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 会降级 stale anchor,非本 PR 引入。

CI green(head df7c052,15 success / 0 failed,镜像缓存核对)。本地未跑套件——worktree 无 node_modules,定向本地跑不可行;按 §7.2 以 CI 为准,另做了全量代码路径核查。

合并判定:可合。无需要顺手修的小问题(两条残余均为已文档化的取舍,非缺陷)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 审核完成:APPROVE,可合(head df7c052)。完整八问结论见上方审核评论。

  • 判定:方向正确、实现收敛在单一 chokepoint(settleUsageReport 三调用点全覆盖无旁路)、计费双分支照记、bootstrap/k̂ pair/seam forensics 逐项核查无回归、六个测试改动均为诚实契约更新、行为变更(全效果集 → sub-scale billing-only)已披露且即被修缺陷本身。
  • 两条残余观察均为代码内已记录的有意取舍(divergent-caliber 路由切换下 meter 陈旧——安全方向自愈;cross-origin 无 id aux 一轮污染——既有行为),非阻塞、无需立项。
  • 顺手修:无机械性小缺陷;需要决策:不触发(kernel/ 未触碰)。
  • CI green(镜像缓存核对:15 success / 0 failed);本地 worktree 无 node_modules,按 §7.2 以 CI 为准。
  • 备注:正式 APPROVE event 被 GitHub 拒绝(bot 身份 = PR 作者,不能自批),结论以评论形式发出;tracker 中未检索到本车道独立协调 issue,此行状态兼作完成报告。

…ogle/responses import conflicts on current master
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Merge conflict resolved and pushed. The PR was dirty against its base; I merged origin/master into the PR branch and resolved the two import-block conflicts.

What conflicted and why — master evolved src/server/prepare-google.ts and src/server/prepare-responses.ts after this branch forked: it moved repairResponsesAssistantOrdering into responses-ordering.ts, dropped makeFoldPointReasoningDroppable, and added a recordNudgeObservation import — while this branch added the noteLocalTextEstimate import in the same import block. Those overlapping lines couldn't auto-merge (the other 10 changed files merged cleanly).

How I resolved it — for both files I took master's import block (the newer, authoritative structure) plus this branch's single new noteLocalTextEstimate import, and dropped the symbols master removed that the merged bodies no longer reference. I verified by grep on the actual merged files that every kept symbol is both used in the body and exported by its module, and every dropped symbol is absent from the body. No logic or behavior changed — this is pure import reconciliation.

Verification & state — no conflict markers remain; committed as a two-parent merge (67b057b0f7, parents df7c052d0b + e1f31ad9d5) and fast-forward pushed to the PR branch (no force-push). The mirror cache now reports mergeable_state: blocked (mergeable, no conflict) with fresh CI runs queued on 67b057b0f7.

Two notes for the owner:

8问(结构化审核)

  1. 是什么问题:PR 分支与 base(master)冲突(merge state dirty),无法合并。
  2. 什么原因导致的:分支 fork 后 master 重构了 prepare-google/responses 的 import 块(repairResponsesAssistantOrdering 移到 responses-ordering.ts、删除 makeFoldPointReasoningDroppable、新增 recordNudgeObservation),而本分支在同一 import 块新增了 noteLocalTextEstimate,两侧改动重叠,git 无法自动合并。
  3. 影响范围与严重程度:仅合并层面——2 个文件(prepare-google/responses)的 import 块冲突,其余 10 个文件自动合并;解决本身不改变任何运行时行为。严重度:解决前 PR 不可合并(blocked),解决后可合并。
  4. 怎么修复的:把 origin/master 合并进 PR 分支(双亲 merge commit,未 rebase、未 force-push);两处冲突均取 master 的 import 块 + 本分支唯一新增的 noteLocalTextEstimate,并删掉 master 已移除、合并后正文不再引用的符号;逐一 grep 核对每个保留符号「正文用到 + 模块导出」、每个删除符号「正文不引用」。
  5. 是否有回归问题:纯 import 对齐,无逻辑/行为变更;无残留冲突标记,所有 import 均解析到既有导出,合并后正文使用的符号与 import 完全一致,未触碰任何既有行为。上次发现的 Usage settle of auxiliary small requests pollutes the main session ledger: erroneously clears shrink-arm/overflow eviden | 辅助小请求的用量 settle 污染主会话账本:误清收缩手臂/溢出证据,饿死 k̂ 校准(#4383 write 侧) #4425 两个测试回归(issue793/issue857)本合并未改动(gate 代码原样保留),仍待 owner 拍板。
  6. 是否破坏缓存:不涉及——未触碰任何缓存/重试/游标/去重逻辑。
  7. 是否改了设计方向:不涉及——机械合并,无架构/数据流转向。
  8. 是否引入新配置:不涉及——无新增 env/config/默认值。

判定:冲突已解决并推送,PR 恢复可合并(blocked,等待 CI)。#4425 的两个测试回归仍挂起在 owner 的 A/B/C 决策上,非本次合并范围。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Merge conflict resolved and pushed. The PR branch 2026-10-24_4425-aux-settle-gate was dirty (conflict) against master, which had advanced to 301e1a5459 (68 commits past the previous merge base). I merged current master into the branch and resolved the single conflict.

What conflicted and why. Exactly one file: src/server/prepare-anthropic.ts (the return block, lines 697–703). Master had evolved that block since the fork — it added a recordNudgeInject(session, nudge) call, a nudgeStampsBefore field on the returned Prepared object, and a line if (upstreamOrigin) session.stats.lastLocalTextEstimateOrigin = upstreamOrigin; — in the very block the PR's #4425 work rewrote (it replaced the direct origin assignment with noteLocalTextEstimate(...)). Overlapping lines in one block → git conflict. The other 10 files (incl. cache-ledger.ts) auto-merged cleanly.

How it was resolved. I kept master's recordNudgeInject call and the nudgeStampsBefore return field (both are master's existing features, in scope, and present in the Prepared type), and dropped master's lastLocalTextEstimateOrigin = upstreamOrigin line — because the PR's noteLocalTextEstimate (src/cache-ledger.ts:1980) already sets that origin internally with the #4425 aux-gating. Keeping the direct line would let an aux-sized body clobber the origin and silently defeat the gate. The resolution is byte-consistent with the three sibling lanes (prepare-openai.ts:668-669, prepare-google.ts:425-426, prepare-responses.ts) which auto-merged with the identical shape.

Verification. 0 conflict markers repo-wide; the #4425 gate is intact (NON_MAIN_USAGE_RATIO cache-ledger.ts:1834, noteLocalTextEstimate :1976, settle gate :1998). Merge commit 3f1801b9e1 has parents 67b057b0f7 (PR) + 301e1a5459 (master); pushed as the unmarked final head (this branch's one full CI pass), a clean fast-forward (no force). Push verified via ls-remote. The mirror cache sha was still lagging (~60s+) at check time but mergeable_state is blocked (no longer a conflict) and CI is re-queued (29 checks, 0 failed, 22 pending).

Note on the known regressions. This run cleared only the conflict. The two #4425 design regressions (issue793-zero-usage-abort, issue857-image-baseline) remain pending the owner's A/B/C decision from the prior 🔶 需要决策 escalation — they are load-bearing design choices, not mechanical, so I did not touch them here; they will report honestly on this fresh CI pass. Local env had no node_modules, so no local typecheck was possible — CI is the authoritative gate.

八问:

  1. 是什么问题: PR [PR] fix: gate auxiliary usage settles off the main session's decision state (#4425) #4504 分支与 master 冲突(merge state = dirty),master 已前进到 301e1a5,src/server/prepare-anthropic.ts 的 return 块冲突,PR 无法合并。
  2. 什么原因导致的: master 在 fork 之后给 prepare-anthropic.ts 的同一 return 块加了 recordNudgeInject(session, nudge) 调用、return 里的 nudgeStampsBefore 字段、以及一行 if (upstreamOrigin) session.stats.lastLocalTextEstimateOrigin = upstreamOrigin;;而本 PR 的 Usage settle of auxiliary small requests pollutes the main session ledger: erroneously clears shrink-arm/overflow eviden | 辅助小请求的用量 settle 污染主会话账本:误清收缩手臂/溢出证据,饿死 k̂ 校准(#4383 write 侧) #4425 改动把 origin 的写入收敛进了 noteLocalTextEstimate(带 aux-gating)。两边在同一块动过 → git 冲突。
  3. 影响范围与严重程度: 仅 prepare-anthropic.ts 一个文件的 return 前几行;冲突期间 PR 被挡住不能合。解决后无运行时行为变化(纯 import/return 调和,与 openai/google/responses 三个兄弟车道一致)。
  4. 怎么修复的: 把当前 master(301e1a5)merge 进 PR 分支,解决唯一冲突——保留 master 的 recordNudgeInject 调用 + 带 nudgeStampsBefore 的 return,丢弃 master 那行冗余的 lastLocalTextEstimateOrigin = upstreamOrigin(因为 noteLocalTextEstimate 已在 cache-ledger.ts:1980 内部带 Usage settle of auxiliary small requests pollutes the main session ledger: erroneously clears shrink-arm/overflow eviden | 辅助小请求的用量 settle 污染主会话账本:误清收缩手臂/溢出证据,饿死 k̂ 校准(#4383 write 侧) #4425 aux-gating 设置 origin,保留那行会让 aux 尺寸的 body 覆盖 origin、破坏 Usage settle of auxiliary small requests pollutes the main session ledger: erroneously clears shrink-arm/overflow eviden | 辅助小请求的用量 settle 污染主会话账本:误清收缩手臂/溢出证据,饿死 k̂ 校准(#4383 write 侧) #4425 门)。
  5. 是否有回归问题: 无。Usage settle of auxiliary small requests pollutes the main session ledger: erroneously clears shrink-arm/overflow eviden | 辅助小请求的用量 settle 污染主会话账本:误清收缩手臂/溢出证据,饿死 k̂ 校准(#4383 write 侧) #4425 门完整保留(NON_MAIN_USAGE_RATIO=0.1、noteLocalTextEstimate、settle gate 三处都在);丢弃的 origin 行正是 Usage settle of auxiliary small requests pollutes the main session ledger: erroneously clears shrink-arm/overflow eviden | 辅助小请求的用量 settle 污染主会话账本:误清收缩手臂/溢出证据,饿死 k̂ 校准(#4383 write 侧) #4425 要防的覆盖路径;recordNudgeInject/nudgeStampsBefore 是 master 既有功能,保留不改变本 PR 语义。本地无 node_modules 无法 typecheck,以 CI 为准。
  6. 是否破坏缓存: 不涉及(纯 import/return 调和,不碰缓存/重试/游标/去重键)。
  7. 是否改了设计方向: 不改。保持 Usage settle of auxiliary small requests pollutes the main session ledger: erroneously clears shrink-arm/overflow eviden | 辅助小请求的用量 settle 污染主会话账本:误清收缩手臂/溢出证据,饿死 k̂ 校准(#4383 write 侧) #4425 的设计(usage settle 门 + aux-gating),只是把 master 的新字段接到本 PR 分支上。
  8. 是否引入了新的配置: 不涉及。

判定: 冲突已解决并推送(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 里如实报出。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[ework] CI fix verified green ✓

1 similar comment
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[ework] CI fix verified green ✓

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

Labels

bug Something isn't working claude-code kimi needs-decision opencode p2 pi scope/kernel zcode 改动范围:内核之外的主机侧接线(src/agent 适配器、server 路由、注入拦截)/范围兜底/客户端标签

Projects

None yet

1 participant