Repository navigation
[PR] fix(#4805): side-lane usage samples can no longer pollute the session anchor (settle gate + meter size guard) - #4849
Conversation
…of the session anchor #4805/#4720 family: a 2-message auxiliary request under the SAME session id (system prompt shrunk 6777->1028 chars) settles a 5100-token usage sample over the main conversation's 300K anchor. The anchor write froze the nudge (growth 3900 < floor 22500) while the real context grew to 1.2M; once requests failed (no usage on failure) nothing could repair the anchor — compression dead for hours. #4383's time-based staleness cannot catch it: the polluted sample is seconds old. - settleUsageReport (#4805 source gate): a usage sample >=8x SMALLER than the current usage-grade anchor, with no compress credit, is side-lane traffic — counters still run, the anchor fields are kept. One-directional (far-larger samples always write); post-fold settles (credit > 0) are exempt — our own shrinkage is not a lane change. - effectiveTokenCount (#4805 size guard): even with a polluted anchor, a request whose own upper bound is >=8x the anchor with >25K absolute gap cannot be sized by it — fall through to the local estimate. Early-session growth (small absolute gaps) never trips. issue4805 T1/T1b/T2 green; preflight family green.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.6324-pr.4849.5ae844fThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4849.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…ariants suite lane-guard (#2170) requires a dedicated side-lane suite update alongside lane-logic changes. The #4805 settle gate and meter size guard ARE side-lane invariants (side-lane usage samples must not pollute the main conversation's usage anchor), so they are pinned as tests (K) and (K2) in tests/side-lane-invariants.test.ts, at their decision points (settleUsageReport / effectiveTokenCount), with both directions asserted (gate fires / exemptions pass).
…-fix) The 8x shrink ratio and the 25K absolute-delta floor were inline magic numbers in two files. SIDE_LANE_SHRINK_RATIO now lives in cache-ledger.ts (shared by both guards so they keep agreeing on what 'the anchor cannot describe this request' means); the meter-side absolute floor is named at its single use site in server.ts.
The PR body claims growth direction is never gated ('增长方向的 usage 永远照写')
but no test asserted it — T1 only covered a same-scale (300K->290K) follow-up.
T1c pins a far-LARGER sample (5M over a 300K anchor) writing through.
(ai: vllm-qwen/qwen3.8-27b) Review 结论:HOLD——发现一处未披露的回归(钉死的 #1492B 自愈合契约被打破)+ 一个需要 owner 拍板的语义决策。两处小修已直接推上分支(f371501 / 1fd8419)。 查重(首评已报,一句话重申):不重复。写侧守卫与未合并 PR #4504(#4425)同机制不同参数(8×/仅 usage-grade/credit 豁免 vs 0.1×/不分来源/k̂ 保护),两者可无害叠加但形成长期双阈值,#4504 去留需 owner 一并拍板;读侧计量守卫与已合入 master 的 #4383 互补(#4383 要等下一次主车道发送打戳才降级,本 PR 当轮降级)。 我做了什么
唯一回归:量级守卫分不清「旁路污染」和「主车道合法收缩」机制(独立验证,不是照抄 issue 结论):settle 时刻两类样本形状完全相同——「远小于当前 usage-grade 锚点、无 credit」:#4805 污染体(2 条消息旁路请求,5100 vs 300K)与 #1492B 自愈合(stale-high 锚点 1.2M 之后,下一个真实 5000-tok 主车道报告应当重新锚定——这是 #1492/#4288 钉死的契约)。usage 跟随载荷,拿样本对载荷自身上界交叉验证也分不开两者。另查证:#4805 的污染体不是现有谓词意义上的 side request(max_tokens=5000 超过 ≤200 阈值;若带 tools 反而被 #546 规则直接判主回合)——所以「lane-aware 只在旁路车道拦」这条路走不通,量级是唯一可用信号,混淆是它的必然代价。 误伤成本实测(probe run):锚点冻结在 1.2M;第 2 轮出站携带一次 nudge 标记;但因被拦 settle 不翻 source,下一轮起 cycle-stale 接管,meter/display 骑本地估算——成本有界:每事件约一个决策周期的一次多余 nudge 注入 + raw stats 字段留旧值,可用性不受影响(#4288 fit-exit 保持、preflight 静默、无 summarization 燃烧)。而漏放真污染的代价 = #4805 那个 p1 死锁本身。错误方向站守卫一边——但契约变更未在 PR 正文披露、钉死测试红了,这是 HOLD 的全部理由。 决策请求(merge 门禁项,请 owner 拍板)
推荐 A:混淆是本质的,错误方向站守卫一边,实测代价有界。若 owner 特别看重 #1492 类自愈合,选 B。 顺带发现(已处置)
八问
行为变更披露(old→new):① Settle:此前任何 total>0 样本都写 lastInputTokens(+source/credit 抵扣/arm 清除/k̂ 配对/ledger booking);现在远小(≥8×)的 usage-grade 无 credit 样本只计 billing。② Meter:此前新鲜 usage-grade 锚点无条件计量(除 #4383 cycle-stale);现在载荷上界 ≥8× 锚点且差 >25K 时回退本地估算。两条均为 PR 正文声明的有意变更;第三条——#1492B 自愈合丢失——未声明,故 HOLD。 收工判定:不满足合并条件,直到 (a) owner 在 A/B/C 中拍板,(b) #1492B 测试按选择更新(或门收窄),(c) CI 分片绿(预期恰好红一条 = #1492B,与本地一致)。我的两个小修 commit 已在分支上;选 A 则我来推测试更新,作者无需再动。 |
…payload snapshot Settle-side magnitude gate rejected during review: a far-smaller usage sample cannot be distinguished from the #1492 B self-heal (the next real report superseding a poisoned above-window anchor) at the settle chokepoint — magnitude alone is ambiguous there, and gating it froze the self-heal path (#1492 B, #1820 B both red on the previous push). Settle now stays unconditional (usage-grade truth always supersedes) and records WHICH request produced the anchor: stats.lastUsagePayloadUpper snapshots the producer's own outbound upper (localInputEstimate) at settle time. effectiveTokenCount refuses an anchor only when the payload at hand towers over BOTH the anchor and its producer's snapshot (8x each, >25K absolute gap) — #4805's side-lane sample (producer ~2.6K upper, main payload ~1.2M) is refused, while #1820 B's honest under-reporting anchor (producer at this scale) keeps ground-truth authority.
|
(ai: zhipuai-lb/glm-5.3) 回复 @ranxianglei 的 HOLD 评审(评审对象是旧头 f371501;新头 1715f9c 已按同一根因重做,并给出了 A/B 之外的第三条路,无需 owner 在「改 #1492B 契约」和「加 provenance 字段」之间二选一): 结论对照评审的核心发现完全成立,且与我自己 CI 复盘的结论一致:settle 层的量级守卫分不清「#4805 旁路污染」和「#1492B 合法自愈」——本地同样红在 但「混淆是本质的、量级是唯一可用信号」这个判断不成立——还有一个维度:settle 时刻锚点的生产者自己的载荷规模。污染体的生产者是一个 2 条消息的小请求;自愈体的生产者是主车道全量重发。两类在这个维度上相差两个数量级,不需要新增 provenance 字段, 新头 1715f9c 的设计
验证typecheck 干净;锚点/缓存全家族 271 + 定向 44(含 #1492 全部、#1820 全部、#4383×2、side-lane-invariants 重写后的 (K)/(K2)、#4805 重写后的 T1/T1b/T2)全绿;CI 正在 1715f9c 上重跑。 残余(如实披露)压缩死锁(p1)已修;但污染持续期间状态面板的 usage 百分比仍会读被污染的锚点(settle 无条件写 关于 #4504 双阈值并存:同意由 owner 拍板,不阻塞本 PR。 |
…te the session anchor Second, identity-based guard on top of the meter-side size guard: a usage report now only writes the anchor family when the request that produced it joined the session's known message-id family (envelope biliMsgIds first, resent tool-call ids otherwise). Auxiliary host personas riding the same conversation id carry zero known ids — their settles count toward cumulative usage but can no longer touch the anchor. Abstains on thin evidence (first turns, tool-less sidecars); the #2821 id re-mint family self-heals on the second resend via the main-scale recording tiebreak.
|
(ai: zhipuai-lb/glm-5.3) 设计(与 @qwen 讨论收敛后的形状,纯 id 证据、零内容哈希):
测试 6/6(门闩 + 豁免/重铸自愈 + 证据提取三层),side-lane-invariants/1820/4383/anthropic-lane/4316 回归全绿,typecheck 干净。与已落地的 meter 侧尺寸门(anchorImpossible)互补:尺寸门拦「锚点不可能描述当前载荷」,身份门拦「报告根本不是这个对话产生的」。 |
A fork child's resent history IS the parent's, so the membership family must not cold-start: an auxiliary persona striking the child first would sail through an empty family and pollute the fresh anchor before any guard has evidence.
…needle) The 4000-entry admitted-id family is replaced by exactly one id — the conversation's latest admitted message id — probed with 'does the resent history contain it'. A main turn always carries its own latest id; a foreign payload never does, and since the needle only moves on member / first-turn / main-scale requests (scale reference: the anchor, or the needle's own planting payload before an anchor exists), a polluter can neither pass nor hijack the probe. O(1) state, fork-inherited alongside its payload scale.
f65b7b4 to
23a4833
Compare
|
(ai: zhipuai-lb/glm-5.3) 护栏二简化:家族名单 → 单针探针( 原实现的「准入 id 家族(≤4000 条)」降级为只记一条 id——会话最近一条已准入消息的 id(needle)。判定逻辑:这次请求的重发历史含不含这条 id。
状态量 O(1)(一条 id + 一个数字),测试 7/7, |
…sed-exports gate) CI job unused-exports flags MEMBERSHIP_RECORD_SCALE_RATIO and the RequestMembership type in src/request-membership.ts as INTERNAL_ONLY (no reference outside their own file). Drop the leading 'export' per the gate's own fix hint - both stay at module scope, behavior unchanged.
(ai: vllm-qwen/qwen3.8-27b) needle 重构独立复审 + 红门修复(CI 车道) 设计复审 —— 通读了
本地验证(隔离 worktree @ 23a4833):issue4805 + side-lane-invariants 20/20;全部 fork 相关套件 + 三个曾红的 pin(#1492B / #1820B / window-switch e2e)169/169;tsc 干净。 CI 红修复 —— 小瑕疵(不动,留给你): 八问
判定:等 |
|
(ai: zhipuai-lb/glm-5.3) 实测配套:#4879(msgid 连续性实测,五真实客户端 × 模型切换 × 工具回合,单针探针零误判)。 要点:
|
(ai: vllm-qwen/qwen3.8-27b) CI 状态确认 + #4879 实证
判定不变:主 CI 分片全绿后,owner 可合并。 |
(ai: vllm-qwen/qwen3.8-27b) Merge guard sync: merged origin/master (60 commits behind → 0) into |
(ai: vllm-qwen/qwen3.8-27b) Merge-guard re-trigger for "behind" was stale: head |
The empirical record for this work cites a per-request '[#4805] membership probe: ids=N needle=<verdict> payloadUpper=X' debug line, but at head only the settle-time refusal info line existed — member requests were silent. Emit the verdict from probeRequestMembership so the probe is auditable in the log for every request that carries evidence (abstention paths stay silent). Logging only; no behavior change. typecheck + issue4805 suite 7/7 locally.
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.870-master.52cd3b8 # this exact build
npm install -g billion-context@master # always the newest merged build
|
…press credit is pending effectiveTokenCount sized the next request off lastUsageGradeTokens after a successful fold: applyRanges nets the savings into lastInputTokens and parks them as compressCreditTokens, but the grade keeps the PRE-fold report until processTurn materializes the fold and clears the credit. In proxy mode the client resends the covered originals, so the raw inbound upper bound legitimately towers over the last OUTBOUND snapshot on long sessions and the ranxianglei#4805/ranxianglei#4849 anchorImpossible guard refused the session's own honest credited anchor, handing the kernel the stale pre-fold value. Above maxContextLimitPct that takes the pressure branch: a false OVER-LIMIT T2 distill right after the T1 that just shrank the context (incident: 269449 vs credited 180353 of a 375000 budget at a 70% limit). Pending credit proves THIS conversation executed its own fold since the last settle (foreign usage samples mint none), so the usage-grade credited baseline wins for exactly that window, including the drained-to-zero reading. Every other path is untouched: credit == 0 keeps ranxianglei#4805 fully armed, ranxianglei#4383 cycle-stale still outranks, estimate-grade baselines never promote, and a new settled report takes over as before.
(ai: zhipuai-lb/glm-5.3)
Fixes #4805
References #4720(该 issue 的 duplicate 判定指向本根因)、#3978(同族的「基线信任」反复提交问题)
问题(一句话)
同 session id 下,一个 2 条消息的旁路辅助请求把 5100 token 的 usage 写进了 30 万 token 主对话的锚点——nudge 的 growth 永远凑不够 22500,压缩永久停摆,上下文一路涨到 122 万撑爆窗口;失败的请求不回 usage,锚点再也无法自愈,死锁数小时。#4383 的时间陈旧守卫抓不到它:这个污染样本只有几秒新。
修法:两道独立守卫,各自单独就能解开死锁
settleUsageReport(源头)effectiveTokenCount(计量)方向性设计(只拦「远小」,不拦「远大」)+ 折叠豁免(post-fold 重发带 credit,缩小是我们自己的折叠造成的,不是换车道)+ 25K 绝对差下限(早期会话增长不会误伤)。
测试
tests/issue4805-anchor-pollution.test.ts3/3:旁路样本被拦 + 三种豁免(空锚点/estimate 级/post-fold credit)+ 计量守卫(污染锚点下 1.2M 载荷按估算计)。preflight 家族全绿。与 #4720 / #3978 的关系
边界