Repository navigation
[PR] fix: hash-free lite fold anchors for past-cap tool cores (#3752) - #3753
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4589-pr.3753.bdbce66This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3753.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复 —— 按失败签名检索过 open+closed 的 issue 与 PR(past-cap / lite anchor / MAX_ANCHORS / re-key mass-unfold / downgrade churn):无同类在途条目。本 PR 是 #3752 止血方案的直接实现(Option A lite anchors)。唯一同文件在途项是 #3257(verified-incremental prefix fast path,#3248 phase 1)——不同机制、不同目的,非重复,但两者都改 标签: bug + opencode + scope/kernel + p1(缺陷类;宿主 = OpenCode 2.0.28;失败域 = 上下文管理/reconcile 核心逻辑;严重度 = 缓存命中崩坏→成本爆炸+周级折叠状态丢失,正中 p1)。 说明:本 PR 是我上一会话( |
(ai: vllm-qwen/qwen3.8-27b) 独立复核完成(不复读 issue 结论,重读了 diff、逐点核了回归面与测试有效性)。先给判定:代码与测试质量达标、机制正确、回归面已逐项核过 → 可合;唯一前置是主 CI 的均衡 test 分片在当前 head 上还没跑出一次「跑完到绿」(详见第 5 问后),合并前请确认一次干净 re-run。 结构化八问1. 是什么问题:超长会话在 bili 侧 identity re-key(0.1.200→0.1.201 = #3658 canonical-identity 换键)后发生大规模 unfold——超过 2. 什么原因导致的:根因分两层——R1: 3. 影响范围与严重程度:触发条件 = 会话覆盖 id 数 > 16384 AND 发生 bili 侧 identity re-key(或等量漂移)。严重度 p1:缓存命中崩坏→成本爆炸 + 周级折叠状态丢失(事故实测单会话 125906→997959 input tokens)。仅命中「超长会话 + re-key」组合,非全量用户。 4. 怎么修复的:Option A —— 为窗口外 tool core 铸 hash-free lite anchor 5. 是否有回归问题:我把 6. 是否破坏缓存:不破坏,方向相反——修复本身恢复缓存命中(减少 unfold→减少 prefix 失效)。full-anchor 预算、steady-state 零工作契约(#2334/#1930-2)保持不变;持久化是 7. 是否改了设计方向:否。仍是 order-centric reconciliation 框架内补一条 hash-free 通道,未改架构/边界/数据流。R2 的完整迁移层(Option C,identityEpoch + sticky alias table)仍待 owner 决策,本 PR 明确不越界、诚实标注了边界(首个 re-key pass 的死区 core 仍会 unfold 一次,下次 fold 收敛,之后对该长度的 tool core drift-proof)。 8. 是否引入了新的配置:否。无新 env/config/默认值。 测试有效性(④)三个测试都有牙、非恒真:
diff 整洁度 / 代码整洁(⑤/⑤b)3 文件 +326/-15,全部与本 PR 目的相关(CHANGELOG 条目含一处标注的 #3642 措辞勘误——合规的顺手小修)、fix、回归测试。命名达意、注释讲 why(带 incident 溯源)、无死代码/魔法数(复用 CAP 常量)、风格一致、无新依赖。达标。 CI 现状(诚实)head
越界发现(不在本 PR 范围,已点名不留空)
收工判定可合,前提是先拿到主 CI 均衡 test 矩阵的一次干净绿色(触发 re-run 或等其自然落定)。PR 链接:#3753。 |
a2badbc to
3e85b3e
Compare
The MAX_ANCHORS=16384 seed-loop cap (#2334) dropped every covered id past the window entirely, leaving the positional scan as their only recovery channel — and that scan dies after MAX_RESYNC_GAPS accumulated breaks. On long sessions with weeks of genuine drift, the 0.1.200->0.1.201 identity re-key (#3658) therefore mass-unfolded thousands of folded messages per session in both directions (upgrade and downgrade). Past-cap tool cores now persist a hash-free lite anchor ({r,c,t,b}): Pass 1's toolCallId channel consumes exactly those fields, so they re-anchor at any session length with zero added hashing and no new misattribution surface (claim discipline unchanged). Non-tool past-cap cores keep the positional-only status quo; the full-anchor cap and the #2334 zero-work steady-state contract are untouched (lite anchors reuse verbatim). FoldAnchor.n becomes optional (norm-keyed passes skip absent n); the seed loop continues past the cap for tool cores instead of breaking. Regression tests pin mint shape, the channel (via the reconciler's own counter), and the pre-fix-ledger convergence replay; all red without the fix, green with it.
3e85b3e to
fca804d
Compare
|
红了 |
Merging master into this branch pulled in #3811, which added maskUrlForPublish to src/log-mask.ts. It is called only by maskUrlsForPublish in the same file; #3811's external consumer (src/web/diagnostics.ts) imports the wrapper, never this helper. The unused-exports gate therefore classifies it INTERNAL_ONLY. Drop the leading export per the gate's prescription. Behavior-neutral: the internal caller is unaffected and no dist export surface changes.
The master merge left two duplicated config-table rows in CONFIGURATION.md / CONFIGURATION.zh-CN.md: a stale 'storage.unified defaults to shadow' row alongside the current '#3818 flip -> full' row, and an older 'storage.sqliteAutoDownload' row lacking the #3788 retry-cooldown sentence alongside the current one. Re-running the single-source generator (tools/gen-config-docs.mjs) collapses each key to its current seed row. Retained rows carry the newest semantics; no knob is lost. Satisfies the docs-sync drift guard.
(ai: vllm-qwen/qwen3.8-27b) 合入 master 后有两个静态门禁红了。都是合并产物,不是 lite-anchor 逻辑本身的问题——两个我已经在分支上修好、对应门禁本地也过了,但这个环境当前连不上 github.com,推不上去,先把状态说清。 两个红灯 + 修法:
八问:
行为变更声明:无 —— 两处都是可见性/产物级,无阈值/默认值/时序/输出格式变化。 推送状态:受阻 —— 这个环境此刻连不上 git push 用的主机(github.com:直连超时、走代理被重置;api.github.com 反而是通的)。两个 commit 已在你的合并提交之上做好(干净 fast-forward),egress 一恢复我就推上去并确认这两个门禁在 CI 上转绿。不用你做什么,先同步。 |
(ai: vllm-qwen/qwen3.8-27b) egress 恢复了,已推上去。PR #3753 新 head: CI 上两个红灯都转绿了:
其余静态门禁(kernel-guard / config-surface-guard / version-guard / docs-coverage / lane-guard / lock-sync / build-artifact …)也全绿。剩下的均衡 两个 commit( |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.631-master.fa47f78 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #3752
What & why
The
MAX_ANCHORS= 16384 seed-loop cap (#2334) dropped every covered id past the window entirely. Ids past the cap therefore had exactly ONE recovery channel left — the positional scan — and that scan dies afterMAX_RESYNC_GAPS(8) accumulated fingerprint breaks. On a long session with weeks of genuine drift the whole tail region is positional-dead, so the 0.1.200→0.1.201 canonical-identity re-key (#3658) mass-unfolded thousands of folded messages per session in BOTH directions (the field incident: one Anthropic session 125K→998K input tokens in one turn, cache hit 2%; downgrade re-churned identically). Repro harness confirmed the mechanism before the fix: with 17.4K covered ids + scattered genuine edits, the capped ledger lost 660 of 8.5K missing ids while an uncapped control lost only the genuinely-edited cells (honest drift).Past-cap TOOL cores now persist a hash-free lite anchor (
{r, c, t, b}— role, content class, protocol tool id, text length). Pass 1's toolCallId channel consumes exactly those fields, so they re-anchor at any session length with zero added hashing and no new misattribution surface (claim discipline unchanged: unique unclaimed candidate per (toolCallId, role)).Scope decisions:
Behavior changes (disclosed per owner policy 2026-09-22)
foldAnchorsrecords gain lite entries{r,c,t,b}for covered tool-core ids beyond index 16384 in block order (~60–80 B each; a 17K-core session adds ~1MB worst case vs today's zero). Old builds reading them degrade gracefully: their Pass 1 already consumes exactly{t,r}, norm-keyed passes skip the absentn.sh/wh) as textless in its shape-census predicate, so a fully-fenced count-exact run of ≤2 consecutive tool cells could be k-th paired by the old build's textless tier (that tier has no role check — pre-existing looseness). Rare, bounded, and confined to the downgrade scenario where the old build is already re-churning the rest of the session. Not fixed here (would mean editing released code paths); noted for the record.Tests
tests/issue3752-lite-anchors.test.ts(3 tests): mint shape (full == cap exactly, lite field-shape exact, non-tool past-cap stays anchor-less), channel proof (asserts on the reconciler's ownby toolCallIdcounter, not just outcomes, plus no-cross-pairing), and the incident-trajectory convergence replay (true pre-fix ledger → re-keyed drifted resend → refold → frozen steady-state ledger). All three RED without the fix, GREEN with it (3.7 s).Config surface
None — no new env vars, config keys, or defaults.
Kernel change
None —
kernel/untouched (host-side reconcile only).