Skip to content

[PR] fix(#4805): side-lane usage samples can no longer pollute the session anchor (settle gate + meter size guard) - #4849

Merged
ranxianglei merged 11 commits into
masterfrom
2026-10-26_anchor-lane-pollution
Oct 27, 2026
Merged

ranxianglei merged 11 commits into
masterfrom
2026-10-26_anchor-lane-pollution

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

(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(源头) usage 样本比当前 usage 级锚点小 8 倍以上、且无 compress credit ⇒ 判为旁路流量:只累计计数,锚点字段不写 污染根本写不进去
effectiveTokenCount(计量) 载荷自身上界 ≥ 锚点 8 倍且绝对差 >25K ⇒ 锚点不可能描述这个请求,回退本地估算 就算锚点已被污染,nudge 也能按真实载荷触发

方向性设计(只拦「远小」,不拦「远大」)+ 折叠豁免(post-fold 重发带 credit,缩小是我们自己的折叠造成的,不是换车道)+ 25K 绝对差下限(早期会话增长不会误伤)。

测试

tests/issue4805-anchor-pollution.test.ts 3/3:旁路样本被拦 + 三种豁免(空锚点/estimate 级/post-fold credit)+ 计量守卫(污染锚点下 1.2M 载荷按估算计)。preflight 家族全绿。

与 #4720 / #3978 的关系

边界

  • 无 config 面变化、无 kernel 变化
  • 阈值 8×/25K 是保守量级判断:主车道重发不可能一夜间缩 8 倍(带 credit 的折叠除外,已豁免);增长方向的 usage 永远照写

…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.
@ranxianglei ranxianglei changed the title fix(#4805): side-lane usage samples can no longer pollute the session anchor (settle gate + meter size guard) [PR] fix(#4805): side-lane usage samples can no longer pollute the session anchor (settle gate + meter size guard) Oct 26, 2026
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-26_anchor-lane-pollution (11763ac)

Latest build — install this exact version

npm install -g billion-context@0.0.6324-pr.4849.5ae844f

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
11763ac billion-context@0.0.6324-pr.4849.5ae844f build
08cae44 billion-context@0.0.6319-pr.4849.2d17f97 build
8b733bc billion-context@0.0.6313-pr.4849.673323b build
23a4833 billion-context@0.0.6306-pr.4849.a56e5bc build
f65b7b4 billion-context@0.0.6305-pr.4849.abba8bb build
c037fe6 billion-context@0.0.6301-pr.4849.47c04ca build
2918e45 billion-context@0.0.6300-pr.4849.3792ce7 build
1715f9c billion-context@0.0.6282-pr.4849.001bc57 build
f371501 billion-context@0.0.6260-pr.4849.cc56dae build
83e5cb4 billion-context@0.0.6259-pr.4849.1421e6f build

Download artifact

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

Install 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).
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复,但有一处在途重叠需要 owner 后续拍板收敛:

标签: bug / p1 / scope/kernel(旁路样本毒化锚点致压缩停摆数小时+上下文撑爆窗口,属核心能力停摆级;改动面在 session 统计/折叠判定层,归 kernel 域;宿主车道从报告无法判定,不打客户端标签)。

正在做:① lane-guard CI 红的定性(继承 vs 自身);② pr-4849 上定向跑测试(issue4805 + preflight 家族 + settleUsageReport 相关套件);③ 代码审查结论(含回归清点)稍后按八问体例给出。

@ranxianglei ranxianglei added bug Something isn't working p1 scope/kernel labels Oct 26, 2026
ci-check added 2 commits October 26, 2026 21:09
…-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.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(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(推荐):接受新语义。把 #1492B 改为钉住「stale-high 锚点不被单个远小且无 credit 的样本重锚;恢复路径 = fold credit / 增长回 anchor/8 以上 / estimate-grade 内部写入」。代价:每事件一次多余 nudge + raw 字段留旧值(有界、可观测、每次拦截有日志行)。收益:diff 最小,p1 修复原样成立。owner 选 A 的话我直接推 #1492B 测试更新。
  • B:把门收窄为「仅当现任锚点是先前 settleUsageReport 写入时才拦」(provenance flag,~10 行 + 1 个持久化字段,升级安全默认)。保住 #1492B 原文(其毒是 armFailureShrink 内部写入),仍修 Bypass requests overwrite the main session's usage anchor, causing long sessions to permanently stop compressing. | 旁路请求覆盖主会话 usage 锚点,导致长会话永久停止压缩 #4805(其现任锚点是 settle 写入)。代价:新增状态;真实世界的 window-shrink 变体(incumbent 也是 settle 写入)照样被拦,B 相对 A 净收益边际。
  • C:lane-aware——否决:污染体不在现有 side 分类里,需要无流量证据的新结构分类器,违反 evidence-permitlist 纪律。

推荐 A:混淆是本质的,错误方向站守卫一边,实测代价有界。若 owner 特别看重 #1492 类自愈合,选 B。

顺带发现(已处置)

  1. 魔法数字 8 / 25_000 内联 → 具名常量 SIDE_LANE_SHRINK_RATIO(两守卫共享,保证「锚点无法描述该请求」语义一致)/ SIDE_LANE_ANCHOR_MIN_ABS_DELTA,已推(1fd8419)。
  2. PR 正文声称「增长方向的 usage 永远照写」但无测试钉住 → 补 T1c(far-larger write-through),已推(f371501)。
  3. 「直接覆盖 effectiveTokenCount: stale lastInputTokens (and a 0 fallback) override the current request size, so big sessions never cross the compress threshold #4720」的说法需收紧:effectiveTokenCount: stale lastInputTokens (and a 0 fallback) override the current request size, so big sessions never cross the compress threshold #4720 的显示症状(usage 显示 5%)走 statusInputBaseline(session.ts:808),本 PR 未触碰该函数;治显示症状的是 master 已合入的 [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 读侧守卫,本 PR 增加的是写侧预防(污染写不进来了)。准确表述:effectiveTokenCount: stale lastInputTokens (and a 0 fallback) override the current request size, so big sessions never cross the compress threshold #4720 的「不再复发」被覆盖,「存量污染状态的修复」不被覆盖(与 master 相同)。
  4. 代码整洁度:命名/注释/风格合仓库惯例,无死代码,过审。

八问

  1. 是什么问题:同一 session id 下,一个 2 条消息的旁路辅助请求把极小的 usage 样本(5100 tok)写进主对话锚点(300K+),nudge 增长永远够不到阈值,压缩永久停摆,上下文一路涨到 1.2M 撑爆窗口;失败请求不回 usage,锚点无法自愈,死锁数小时。
  2. 什么原因导致的:settleUsageReport 无条件信任任何正数 usage 样本作为会话锚点——样本本身不携带车道信息,而时间陈旧守卫([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 一类)抓不到只有几秒新的污染。
  3. 影响范围与严重程度:任何会在主 session id 下发辅助调用的宿主(大输出预算的辅助调用,max_tokens=5000 这类会逃过 ≤200 的 title-gen 启发式)× 失败时不回 usage 的上游 → p1(压缩停摆数小时 → 窗口撑爆)。
  4. 怎么修复的:两道独立守卫,各自单独解开死锁——源头侧 settle 量级门(远小 ≥8× 且无 credit ⇒ 只累计计数、锚点不写)+ 计量侧尺寸降级(载荷上界 ≥8× 锚点且绝对差 >25K ⇒ 锚点不可能描述该请求,回退本地估算);方向性(只拦远小)、post-fold credit 豁免、25K 绝对差下限防早期会话误伤。
  5. 是否有回归问题:有,一处——「真实 usage 报告自愈 stale-high 锚点」的钉死契约(#1492B,issue1492-stale-estimate-view.test.ts:237)被打破,PR 正文未披露;实测代价有界(每事件一次多余 nudge 注入 + raw 字段留旧值,一轮后 cycle-stale 接管)。其余审计过的既有行为全绿:[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 双向守卫、The symptom is that switching models causes a hang, suspected to be triggered by dsh native compression. | 症状是切模型卡住疑似触发 dsh 原生压缩 #4288 fit-exit、cache ledger: non-streaming rewriter path never records usage samples (ledger blind for stream:false sessions) #1547 ledger、[Gap] Anonymous failure fallback can bypass an existing usage-grade anchor #2033 匿名锚点、nudge-decide、preflight: one failed summarization call fails the whole turn with a non-retryable 502 and blocks the session #1987 baseline-anchor、dsh上下文700K不触发压缩 #3004 selfheal、fork-nudge-deadzone/trigger、silent-backend-nudge;wire/cache/持久化/config 面未变(diff 核验)。
  6. 是否破坏缓存:前缀缓存/重试/增量游标不受影响;被拦样本跳过 ledger line booking(归因更干净,列入行为变更披露)。
  7. 是否改了设计方向:无架构变化;一个语义契约位移(锚点重锚策略:从「任何真实报告重锚」到「远小且无 credit 的报告不重锚」)——待 owner 拍板(A/B/C)。
  8. 是否引入新配置:无(env/config/默认值零变化)。

行为变更披露(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 则我来推测试更新,作者无需再动。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI 处置(自动修复车道 attempt 2/2):lane-guard 红已修;test 车道 8 shard 红定位为本 PR 设计取舍问题,已停手并立决策请求 #4859(p1),等你拍板。

八问:

  1. 是什么问题:本 PR 的两个 Bypass requests overwrite the main session's usage anchor, causing long sessions to permanently stop compressing. | 旁路请求覆盖主会话 usage 锚点,导致长会话永久停止压缩 #4805 守卫(settle gate + meter size guard)把合法主车道的小 usage 报告也当成 side-lane 污染拒收,三个原本绿的回归 pin 变红,全部 8 个 test shard 复现。
  2. 什么原因:两个守卫共用「样本比当前锚小 8×(且绝对差 >25K)」当 side-lane 签名;但窗口/模型切换收缩(The symptom is that switching models causes a hang, suspected to be triggered by dsh native compression. | 症状是切模型卡住疑似触发 dsh 原生压缩 #4288/emergency shrink / preflight 的本地估算用错了视图:超长会话(客户端历史 127 万,压缩后 outbound 仅 ~16 万)在上游失败无 usage report 时,bili 按原始历史估算 #1492,无 credit 可豁免)和 post-rebuild 重锚后的首轮真实报告(post-rebuild usage estimate inflates ~3.4x after a big fold, firing an EMERGENCY T1 nudge into an over-budget context #1820)也会远小于旧锚——size 判据分不清「污染」和「合法收缩」。能分清的是请求级 lane 分类(派发前已判定),守卫没用上。
  3. 影响范围与严重程度:合并即回归,三类会话受影响:切小窗口/模型的会话(自愈被堵、锚停在陈旧值)、preflight rebuild 后会话(usage 快速路径失效,nudge 按错误尺寸走)、一切真实报告远小于旧锚的主车道场景。核心计量路径语义破坏,p1。
  4. 怎么修复的:test 红未改代码——超出小修范畴,属设计取舍。决策请求 decision request: #4849 anchor-pollution guards reject legitimate small usage reports — 3 green pins now red (#1492B self-heal / #1820B fast path / window-switch e2e) #4859 已列四个选项,推荐 A:用 lane provenance 替换量级判据(side-lane 样本永不写锚、主车道样本恒写)+ 移除 meter guard;唯一同时满足「Bypass requests overwrite the main session's usage anchor, causing long sessions to permanently stop compressing. | 旁路请求覆盖主会话 usage 锚点,导致长会话永久停止压缩 #4805 根治 + 三个既有契约零削弱」的路径。(lane-guard 红已在本车道修复:commit 83e5cb406,side-lane-invariants suite 补 (K)/(K2),该项已绿。)
  5. 是否有回归问题:是——本 PR 自身引入三处既有契约回归:issue1492-stale-estimate-view.test.ts:237(期望 5000→实际 1200000)、issue1820-post-rebuild-anchor.test.ts:218(期望 5000→实际 15000)、preflight-compress.test.ts:183(期望 1000→实际 292624)。本地定向复现与 CI 双向确证;三个测试文件与 master(341e76c28)逐字节相同,红完全归因于本 PR 新增代码,非继承红。
  6. 是否破坏缓存:不直接涉及缓存键/去重策略;影响的是 usage 锚(nudge/preflight 的尺寸输入),间接影响压缩时机,不改变缓存内容正确性。
  7. 是否改了设计方向:若按推荐选项 A,判据从「量级启发式」转向「provenance」,与并行处理中的 decision request: preflight round-exit comparator — stale usage baseline vs real overflow evidence (#4288 vs #1492/#847) #4853(round-exit 比较器,model-stamp 方案)同族,建议两个 stamp(lane + model)合并设计一次落地。注意:decision request: preflight round-exit comparator — stale usage baseline vs real overflow evidence (#4288 vs #1492/#847) #4853 OP 对 emergency shrink / preflight 的本地估算用错了视图:超长会话(客户端历史 127 万,压缩后 outbound 仅 ~16 万)在上游失败无 usage report 时,bili 按原始历史估算 #1492 B 的描述与当前 master 不符(现已按 The symptom is that switching models causes a hang, suspected to be triggered by dsh native compression. | 症状是切模型卡住疑似触发 dsh 原生压缩 #4288 re-land 期望 nonStream===0),已在 decision request: #4849 anchor-pollution guards reject legitimate small usage reports — 3 green pins now red (#1492B self-heal / #1820B fast path / window-switch e2e) #4859 标注供核对。
  8. 是否引入了新的配置:无(现状与选项 A 均无配置面变化)。

判定:不合并不收工——等 owner 在 #4859 拍板后按选项实施;在此之前本车道不再改动本分支。

…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.
@ranxianglei

Copy link
Copy Markdown
Owner Author

(ai: zhipuai-lb/glm-5.3)

回复 @ranxianglei 的 HOLD 评审(评审对象是旧头 f371501;新头 1715f9c 已按同一根因重做,并给出了 A/B 之外的第三条路,无需 owner 在「改 #1492B 契约」和「加 provenance 字段」之间二选一):

结论对照

评审的核心发现完全成立,且与我自己 CI 复盘的结论一致:settle 层的量级守卫分不清「#4805 旁路污染」和「#1492B 合法自愈」——本地同样红在 tests/issue1492-stale-estimate-view.test.ts:237(expected 5000, actual 1200000),外加 #1820 B 也红(诚实锚点 5000 被计量守卫降级)。

但「混淆是本质的、量级是唯一可用信号」这个判断不成立——还有一个维度:settle 时刻锚点的生产者自己的载荷规模。污染体的生产者是一个 2 条消息的小请求;自愈体的生产者是主车道全量重发。两类在这个维度上相差两个数量级,不需要新增 provenance 字段,localInputEstimate(每次 prepare 都会写,settle 时正好等于「产生本锚点的请求」的出站上界)就是现成的快照源。

新头 1715f9c 的设计

  • settle 无条件接受 usage 样本(self-heal 契约原文保住,#1492B 原测试不动就绿),同时在写入锚点时快照 stats.lastUsagePayloadUpper = localInputEstimate;
  • 计量守卫只在「当前载荷同时 ≥ 锚点×8 且 ≥ 生产者快照×8,绝对差 >25K」时拒绝:
  • 对照 A/B:A 要改 #1492B 契约、B 要加持久化字段;新设计两者都不用,且没有引入 A 的「每事件一次多余 nudge」成本。
  • 评审推的两个小修都保留在分支上(T1c 的断言被新的 T1 顺带覆盖;SIDE_LANE_SHRINK_RATIO 随 settle 门删除,SIDE_LANE_ANCHOR_MIN_ABS_DELTA 保留、新增 SIDE_LANE_ANCHOR_IMPOSSIBLE_RATIO)。

验证

typecheck 干净;锚点/缓存全家族 271 + 定向 44(含 #1492 全部、#1820 全部、#4383×2、side-lane-invariants 重写后的 (K)/(K2)、#4805 重写后的 T1/T1b/T2)全绿;CI 正在 1715f9c 上重跑。

残余(如实披露)

压缩死锁(p1)已修;但污染持续期间状态面板的 usage 百分比仍会读被污染的锚点(settle 无条件写 contextTokensSource="usage",statusInputBaseline 的 #4383 stale 路径不再接管)——直到下一次主车道 settle 重新锚定。这是显示层面的残余,与 #4720 的表象同源;若认为值得单独处理,可在 acp_status 侧复用同一「生产者快照」判据,不在本 PR 扩面。

关于 #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.
@ranxianglei

Copy link
Copy Markdown
Owner Author

(ai: zhipuai-lb/glm-5.3)
第二道守卫已推(2918e45b):settle 侧身份重合度门。

设计(与 @qwen 讨论收敛后的形状,纯 id 证据、零内容哈希):

测试 6/6(门闩 + 豁免/重铸自愈 + 证据提取三层),side-lane-invariants/1820/4383/anthropic-lane/4316 回归全绿,typecheck 干净。与已落地的 meter 侧尺寸门(anchorImpossible)互补:尺寸门拦「锚点不可能描述当前载荷」,身份门拦「报告根本不是这个对话产生的」。

ework-agent added 2 commits October 26, 2026 23:42
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.
@ranxianglei
ranxianglei force-pushed the 2026-10-26_anchor-lane-pollution branch from f65b7b4 to 23a4833 Compare October 26, 2026 16:20
@ranxianglei

Copy link
Copy Markdown
Owner Author

(ai: zhipuai-lb/glm-5.3)

护栏二简化:家族名单 → 单针探针(23a48338,采纳评审讨论中的提议)

原实现的「准入 id 家族(≤4000 条)」降级为只记一条 id——会话最近一条已准入消息的 id(needle)。判定逻辑:这次请求的重发历史含不含这条 id。

状态量 O(1)(一条 id + 一个数字),测试 7/7,plugin-fork 49/49,1820/side-lane-invariants/4316 回归绿,typecheck 干净。

…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.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

needle 重构独立复审 + 红门修复(CI 车道)

设计复审 —— 通读了 src/request-membership.ts 与全部接线 diff(cache-ledger / plugin / 两条 prepare 车道 / session),此前担心的三个点都成立:

本地验证(隔离 worktree @ 23a4833):issue4805 + side-lane-invariants 20/20;全部 fork 相关套件 + 三个曾红的 pin(#1492B / #1820B / window-switch e2e)169/169;tsc 干净。

CI 红修复 —— unused-exports 门在 c037fe6(6 项)与 23a4833(2 项:MEMBERSHIP_RECORD_SCALE_RATIO、RequestMembership)都报 INTERNAL_ONLY,引用全在自己文件内。按门自带的修法去掉前置 export(2 行,零行为变化):commit 8b733bc9。本地门干净 + 测试绿 + tsc OK;新 CI 已在此 sha 上排队。

小瑕疵(不动,留给你):src/cache-ledger.ts else 分支内的缩进比 if/else 包裹后浅一级——纯空白,不为它再逼一轮全量 CI。另建议把 PR 描述同步到当前设计(标题还写着「settle gate + meter size guard」,实际已是 producer-snapshot 尺寸门 + needle 身份探针)。

八问

  1. 是什么问题:side-lane usage 样本污染主会话锚点(Bypass requests overwrite the main session's usage anchor, causing long sessions to permanently stop compressing. | 旁路请求覆盖主会话 usage 锚点,导致长会话永久停止压缩 #4805);本轮 = needle 重构的独立复审 + CI 红门修复。
  2. 什么原因导致的:量级启发式分不清「污染」与「合法收缩」;改为出身证据——重发历史必须含本会话最近一条已准入消息 id(needle)。
  3. 影响范围与严重程度:p1 核心计量路径;修复前三个绿 pin 变红(自愈 / usage 快路径 / 窗口切换 e2e),现已本地恢复。
  4. 怎么修复的:meter 侧 producer-payload-snapshot 尺寸门 + settle 侧 needle 身份门 + fork 继承;我的 commit 仅删两个冗余 export。
  5. 是否有回归:无——三个 pinned 契约本地通过;settle 语义回到「usage 恒超旧」;证据不足时弃权、行为与修复前一致。
  6. 是否破坏缓存:否——前缀缓存/增量游标不受影响;lastUsagePayloadUpper 为附加持久化字段,needle 内存态 O(1)。
  7. 是否改了设计方向:是——量级启发式 → 出身证据(与 decision request: preflight round-exit comparator — stale usage baseline vs real overflow evidence (#4288 vs #1492/#847) #4853 model-stamp 同道义);状态 O(4000 ids) → O(1)。
  8. 是否引入新配置:无——模块级具名常量,未加 env/config。

判定:等 8b733bc9 全量 CI 绿,owner 可合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

(ai: zhipuai-lb/glm-5.3)

实测配套:#4879(msgid 连续性实测,五真实客户端 × 模型切换 × 工具回合,单针探针零误判)。

要点:

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI 状态确认 + #4879 实证

判定不变:主 CI 分片全绿后,owner 可合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b) Merge guard sync: merged origin/master (60 commits behind → 0) into 2026-10-26_anchor-lane-pollution, clean auto-merge with no conflicts; pushed head 8b733bc93..08cae4426. PR now mergeable (no conflict); merge state is blocked only on required checks running in CI.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b) Merge-guard re-trigger for "behind" was stale: head 08cae4426 already contains all of master (23158db38, verified git rev-list --left-right --count origin/master...head = 0/10) — no new sync or push needed. CI on this head: 14 green, 12 skipped, 11 still queued; no failures.

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.
@ranxianglei
ranxianglei merged commit 52cd3b8 into master Oct 27, 2026
55 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.870-master.52cd3b8 (rolling master tag).

npm install -g billion-context@0.0.870-master.52cd3b8  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

ranxianglei pushed a commit to Louie0806/billion-context that referenced this pull request Oct 29, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working p1 scope/kernel

Projects

None yet

1 participant