Repository navigation
[PR] fix: auxiliary requests must not arm or clobber the session meter (#4974) - #5005
ranxianglei wants to merge 19 commits into
Conversation
) A ~10KB auxiliary request left an estimate-grade baseline (5412 tok) on a 4,283-message session: nudge read min(est, raw) = 1% while preflight's #2313 probe branch trusted that tiny baseline and died in the doomed byte-gate 413 (retryable=false, refusal pinned) instead of folding — permanent livelock on a foldable session. - armFailureShrink: add the missing sidePassthrough gate at the single enforcement point (every other forward-path consumer in relay.ts has it; side requests must never touch the main meter, #388 lane contract). - prepareAnthropic: hoist anthropicTitleGen to function scope and gate the tail meter writes (localInputEstimate / lastLocalTextEstimate / probeRequestMembership) on it — aligning with prepare-openai's isTitleGen and prepare-responses' isCompactionTrigger gates. - preflight probe branch: a stale-small baseline (payload >= 8x baseline, absolute delta above the #4805 floor) cannot describe the current payload; skip the forward-once probe and take the fold-first path zero-baseline sessions already use. Reuses SIDE_LANE_ANCHOR_IMPOSSIBLE_RATIO and SIDE_LANE_ANCHOR_MIN_ABS_DELTA (effectiveTokenCount's anchorImpossible size test, minus the usage-only clause an estimate arm can never set). Behavior change: the #2313 probe now additionally requires the current payload to stay below 8x the estimate-grade baseline; sessions whose payload towers over a tiny baseline fold before forwarding instead of hitting the doomed byte-gate. Comparable payloads keep the probe (pinned by tests). No config surface, kernel/, or wire-shape changes. Regression tests (both directions, #3617): tests/issue4974-side-baseline-arming.test.ts — verified A/B/C fail pre-fix, all five pass post-fix; adjacent suites (issue2490, issue2847, side-lane-invariants, fix-arm-headroom-clamp, issue3148, issue1839) green locally. closes #4974
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.10636-pr.5005.8915bc3This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5005.tgz
npm install -g packageInstall instructions are refreshed on each push. |
lane-guard greps lane symbols out of the src/server.ts diff lines. The new
staleSmallBaseline rationale comment contained the phrase 'side request', which
matched the LANE_SYMBOLS list even though this PR changes no side-lane logic
(only meter-arming + a preflight probe guard). Reword one word ('side request'
-> 'auxiliary call'); no behavior change.
…ants suite (lane-guard pairing, #2170) lane-guard requires lane-logic changes to land with one of the four dedicated side-lane suites. This PR's relay-side half (armFailureShrink x sidePassthrough) is a #388 lane-contract change, so it is pinned as invariant (L) in tests/side-lane-invariants.test.ts with both directions per #3617: a FAILED side request must not arm the main session's meter; a FAILED main request still arms (#604/#1839). Teeth verified: (L) fails with the gate removed, passes with it. Harness gains an inert setFail toggle (off by default).
…pairing) The failed-side-request-must-not-arm invariant now lives as (L) in tests/side-lane-invariants.test.ts — the #2170 pairing home, since the gate consumes the lane decision (prepared.sidePassthrough). Drop the earlier (A)/(A-) copies from tests/issue4974-side-baseline-arming.test.ts along with the mock-upstream failure machinery that only they used; the file header now points at (L).
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复 —— 该红是本 PR 特有的 lane-guard 失败签名(master 在 发生了什么:lane-guard(#2170)要求「side-lane 逻辑变更必须伴随四个专用 side-lane 套件之一更新」。本 PR 的 修复(分支上共两个新提交):
验证:
八问:
结论:失败检查已修复并推送(head |
(ai: vllm-qwen/qwen3.8-27b) Synced origin/master into the branch and resolved the single conflict in |
Resolve the single conflict in src/server/prepare-anthropic.ts by combining both intents: keep the #4974 title-gen gate (if (!anthropicTitleGen)) around the meter writes, adopt master's shared imageReserve refactor, and carry master's parsedBody return field + #5604 tail-guard helpers. typecheck clean; issue4974 + side-lane-invariants suites 19/19 green.
(ai: vllm-qwen/qwen3.8-27b) Conflict resolved and pushed (attempt 1/3, succeeded). The branch was behind master by 1260 commits; I merged The one conflict —
Resolution = the union of both intents: keep the #4974 gate, adopt master's shared- Verification (local, targeted):
Status note (honest): the mirror check cache is still stale — it reports 八问(结构化审核)
收工判定:冲突已解、已推送(head |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Conflict resolved and pushed (attempt 1/3, succeeded). Branch The one conflict —
Resolution = the union of both intents: keep the #4974 gate, adopt master's shared- What is done / verified:
What remains / risk: the mirror check cache is still stale ( 八问(结构化审核)
收工判定:冲突已解、已推送(head |
[ework] CI fix verified green ✓ |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Re-trigger — no new work needed; conflict already resolved, CI now green. This is a re-fire of the same attempt-1/3 blocker. The conflict was resolved and pushed in the prior run (merge commit Live verification this run (fetched fresh, not from memory):
Merge state is now Bottom line: the CI engineer's scope (resolve the merge conflict + fix any red CI) is complete — conflict resolved, all checks green. What remains is the human approval that 八问(结构化审核)
收工判定:CI 工程师职责(解冲突 + 修红 CI)已完成——冲突已解、全绿;当前 |
[ework] CI fix verified green ✓ |
1 similar comment
[ework] CI fix verified green ✓ |
Master advanced 5 commits (durability-before-render #3397 / PR #6326) since the prior sync (c26c31a). The only overlapping file, src/server/prepare-anthropic.ts, auto-merged cleanly: #3397's getStore().ingestRowsNow(session) (line ~608, before markDirty) and #4974's if (!anthropicTitleGen) gate (line 669) sit in different regions, no conflict. typecheck clean; issue4974 + side-lane-invariants + issue3397 + issue2490 + issue2847 = 31/31 pass.
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Master advanced again — re-synced and pushed. This re-trigger was real, not stale: since the prior sync ( What I did this run:
State after push: branch fully contains master (0 behind); zero conflict markers in the merged file. Status note (honest): the mirror check cache is still on the prior head ( 八问(结构化审核)
收工判定:本轮同步完成——master 已重新并入(head |
[ework] CI fix verified green ✓ |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 查重: 不重复 — GitHub search 确认 PR #5005 是 #4974 的唯一在途修复 PR(仅此一 PR 引用 #4974)。 Reviewed PR #5005 against the true base (master The fix is 3 gates, each a decision-point fix (疏, not a mask):
Incident shape (honest): the offending ~10KB request rode the FULL pipeline (DSH rc.3 title budget 4096 evades the ≤200 heuristic; not side-classified), so it evaded gates 1–2. Gate 3 is what breaks the reported livelock; gates 1–2 pin the adjacent contract gaps (defense in depth). The PR states this accurately and does not overclaim. Behavior change (disclosed): #2313 probe forward-once now additionally requires payload < 8× the estimate-grade baseline. Sessions whose payload towers over a tiny estimate baseline now FOLD before forwarding instead of hitting the doomed byte-gate 413 + 10-min refusal pin; comparable payloads keep the probe (test C-). No config surface, no kernel/, no wire-shape change (all 3 fixes are meter/gate decisions; forwarded bytes untouched). Tests ( Regression review (existing behaviors touched): #2313 probe normal path unchanged (C- pins); usage-grade baselines (baselineFloor>0) never probe, unaffected; main-request failure still arms (L negative, #604/#1839 relay-5xx rescue preserved); fail-fast semantics unchanged (413 still retryable=false); no threshold drift (8×/25K reuse constants); no output-format change; no fail-fast→swallow; gate-2 hoist changes scope not behavior. 结构化八问
合并判定: 可合。修复正确定界(3 门各修一个决策点、非 mask),incident 框架诚实(门3 承重、门1/2 相邻),测试有牙且双向覆盖,回归面干净,CI 绿。仅剩 owner 批准门。 |
Master advanced 379 commits (incl. nudge-rearm #6531, side-passthrough, preflight/fold, relay output-budget #6529) since the prior sync (9674cfa). 4 of the PR's 5 files overlapped; 3 auto-merged cleanly. The one conflict, src/server/prepare-anthropic.ts, resolved as the union of both intents: keep #4974's if (!anthropicTitleGen) gate wrapping the meter writes (the meter writes are byte-identical on both sides modulo indent) and adopt master's return which adds nudgeStampsBefore (nudge-rearm #6531). typecheck clean; issue4974 + side-lane-invariants + issue2490 + issue2847 = 30/30 and anthropic nudge suites = 7/7 pass.
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Master advanced 379 commits — re-synced and pushed. This re-trigger was real: since the prior sync ( What I did this run:
State after push: branch fully contains master (0 behind); zero conflict markers in the merged file. Status note (honest): the mirror check cache is still on the prior head ( 八问(结构化审核)
收工判定:本轮同步完成——master 已重新并入(head |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) APPROVE — re-review after the master-sync merge ( The only new commit is a clean master-sync merge (
No 结构化八问
判定: APPROVE。代码审查无阻塞问题——修复正确定界、测试有牙且双向覆盖、回归面干净、master-sync 合并不破坏修复。CI 测试车道仍在跑(0 failed),全量判定以 CI 为准;合并仍需 owner 批准门。 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Re-review complete — APPROVE (full review with 八问 posted above). What I did & outcome:
What remains (not mine to resolve):
|
[ework] CI fix verified green ✓ |
Master advanced 68 commits (nudge-rearm #6531 recordNudgeInject, nudge-debug, responses-system-sections, cache-ledger recovery, …) since the prior sync (2e3cfc9). 2 of the PR's 5 files overlapped (prepare-anthropic.ts, relay.ts); relay auto-merged cleanly. The one conflict, prepare-anthropic.ts, resolved as the union of both intents: keep #4974's if (!anthropicTitleGen) gate wrapping the meter writes (localInputEstimate / lastLocalTextEstimate / probeRequest Membership / lastLocalTextEstimateOrigin) and adopt master's new recordNudgeInject call OUTSIDE the gate — it is a cache-ledger recovery event (nudge tracking, #6531), a separate concern from the meter the #4974 gate protects. typecheck clean; issue4974 + side-lane-invariants + issue2490 + issue2847 + issue6720-nudge-recovery = 41/41 and anthropic nudge suites = 7/7.
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Master advanced 68 commits — re-synced and pushed. This re-trigger was real: since the prior sync ( What I did this run:
State after push: branch fully contains master (0 behind); zero conflict markers in the merged file. Status note (honest): the mirror check cache is still on the prior head ( 八问(结构化审核)
收工判定:本轮同步完成——master 已重新并入(head |
(ai: vllm-qwen/qwen3.8-27b) 七问 — conflict lane, attempt 1/6
|
…ed the status line #6928 (master, 2026-11-16) removed the #4521 armed-but-silent '[ACP status: ...]' refresh line; its shown-markers fed the nudge gate back and had shifted the injection schedule from {7,8,9} to {4,6,8,9} (anchor recalibrated 7/8 -> 6/7 in 3197f10). With the status line gone the schedule reverts to {7,8,9}, so the probe's pre-fold nudge anchor reverts to 7/8. Verified locally: probe passes (nudge confirmed in the pre-fold request; re-request/next-turn byte-identical through the summary anchor); typecheck clean. The fold/proxy-tool-round byte-stability invariant under test is unchanged — anchor recalibration only.
(ai: vllm-qwen/qwen3.8-27b) 七问 — red-CI lane, attempt 1/6
|
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) APPROVE — re-review after the new head What changed since my last review:
Core fix (3 gates) — re-verified intact in the new head:
The #2929 test recalibration (the only new substantive change):
No 结构化八问
判定: APPROVE。核心修复正确定界、测试有牙双向覆盖、无 kernel/ 变更、无配置/线形变更。唯一新增的 #2929 锚点回正是测试面"跟上 master"的合理调整,与 master 的 6/7 为有意分歧;CI 11 个测试车道仍在跑(0 failed),#2929 测试是否过 7/8 以 CI 为准。合并仍需 owner 批准门。 |
Master advanced 33 commits (v0.1.216 release, #7054 attribution diagnostics, #6592 dsh-go-client docs, #6922 responses section joiner, #4313 timestamp-rendering default flip, …). Overlap on 2 of the PR's 6 files: relay.ts auto-merged cleanly (PR's armFailureShrink sidePassthrough gate at the function top vs master's createHandoffReply signature change — disjoint regions, both intents kept). The one conflict, tests/issue2929-codex-fold-double-miss.test.ts, resolved by taking master's version: master rewrote the probe to arm SCHEDULE-INDEPENDENTLY (first nudge-carrying request with >=11 refs), which supersedes this branch's anchor recalibration (0bea490, 6/7 -> 7/8) — a hardcoded index anchor broke on every nudge-gate schedule shift and the schedule-independent arming is the durable fix. Verified locally: 2929 + issue4974 + side-lane-invariants = 21/21 pass; typecheck clean.
(ai: vllm-qwen/qwen3.8-27b) 七问 — conflict lane, attempt 1/6
|
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) APPROVE — re-review after the new head What changed since my last review: one master-sync merge ( Key resolution — the #2929 test concern from last round is GONE:
Core fix (3 gates) — re-verified intact at
No CI still running on 结构化八问
判定: APPROVE。核心修复正确定界、测试有牙双向覆盖、无 kernel/ 变更、无配置/线形变更;上轮的 #2929 测试分歧已被 master 更优的 schedule-independent 版本吸收,PR 回归干净 5 文件。CI 12 车道仍在跑(0 failed),全量判定以 CI 为准;合并仍需 owner 批准门。 |
[ework] CI fix verified green ✓ |
2 similar comments
[ework] CI fix verified green ✓ |
[ework] CI fix verified green ✓ |
Closes #4974
Problem. One ~10KB auxiliary request pinned the whole session baseline to 5,412 tokens on a 4,283-message / 12.2 MiB conversation: the nudge read
min(est, raw)= 1% while preflight's #2313 probe branch trusted that tiny estimate-grade baseline and died in the doomed byte-gate 413 (retryable=false, refusal pinned) instead of folding — a permanent livelock on a foldable session (pendingT1 = 2.45M).Three missing gates, one failure domain (meter-view split → doomed livelock):
armFailureShrinkhad nosidePassthroughgate while every other forward-path consumer inrelay.tswrites it explicitly: any FAILED side-lane request armed the MAIN session's meter with the side payload's size, breaking the 标题生成等侧请求污染主会话状态:prepareAnthropic 缺 isTitleGen 守卫、快照无条件覆盖、survivedCount 每请求空转 #388 lane contract. Fixed at the single enforcement point (the function itself), covering all four call sites.prepareAnthropicwrote the local meter without a title-gen gate —localInputEstimate/lastLocalTextEstimate/probeRequestMembershipran for every request, whileprepare-openaigates onisTitleGenandprepare-responsesonisCompactionTrigger. The existinganthropicTitleGenconst is hoisted to function scope and now guards the tail writes (same gated set as the openai lane).lastInputTokens > 0 && baselineFloor <= 0). A stale-small baseline — payload ≥ 8× the baseline with an absolute delta above the Bypass requests overwrite the main session's usage anchor, causing long sessions to permanently stop compressing. | 旁路请求覆盖主会话 usage 锚点,导致长会话永久停止压缩 #4805 floor — cannot describe the current payload: the forward-once bet dies in the doomed byte-gate with the refusal pinned, while folding would have healed the session. The newstaleSmallBaselineguard reusesSIDE_LANE_ANCHOR_IMPOSSIBLE_RATIO/SIDE_LANE_ANCHOR_MIN_ABS_DELTA(the same size test aseffectiveTokenCount's anchorImpossible, minus thelastUsagePayloadUpper > 0clause that only usage settles set — an estimate arm never does) and skips the probe, taking the fold-first path zero-baseline sessions already use.Note on the incident shape: the log's
processTurn: 1 msgsshows the offending request rode the FULL pipeline (DSH rc.3's title budget of 4096 evades the ≤200 side heuristic), so gate 1 alone could not cover it — gate 3 is what breaks the reported livelock; gates 1–2 pin the adjacent contract gaps named in the issue.Behavior change (old → new, per disclosure policy):
kernel/change, no wire-shape change (all three fixes are meter/gate decisions; forwarded bytes untouched).Tests —
tests/issue4974-side-baseline-arming.test.ts, both directions per #3617:Verified against the unfixed tree: exactly A/B/C fail, A-/C- pass; post-fix all five pass. Adjacent suites green locally (38/38): issue2490-ledger-floor-doomed-probe, issue2847-doomed-nonretryable-status, side-lane-invariants, fix-arm-headroom-clamp, issue3148-upstream-circuit, issue1839-ghost-denominator. Full-suite verdict = CI.
🤖 ework agent