Repository navigation
fix: seam detector no longer false-flags no-baseline first bills (#1891) - #1893
Conversation
The #1606 seam detector flagged the FIRST measurable sample of a session as a suspected mid-history prefix break: with no previous ledger baseline, decomposeSample(prev=null) forces growth=0 and books the entire uncached initial bill as ttlRepay, which detectSeam misreads as an unexplained residual (all five field events in #1891 had unexplained == input - cached exactly). Rebook the no-baseline residual as new content (closure invariant missed === nc+cr+tr preserved), mark the line nb and skip it in detectSeam, surface initialBills in the /acp-cache invalidation section. Second half of the same failure domain: the main send path never captured outbound bodies, so streaming /bili/ lanes got 'aggregate flag only' with no byte forensics - noteForwardedBody now runs at the single main chokepoint (fetchWithTransportRetry site), and the non-streaming note records the exact final wire bytes.
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1888-pr.1893.e780e46This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1893.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 PR #1893 review 结论(已核对代码、独立复现 mutation、验证合并到最新 master、CI 全绿) 结构化七问:
测试有效性:断言有牙,我独立复现了两个 mutation——禁用 rebooking → 恰好 3 红(opener / 字段签名 / e2e);删 chokepoint note → 恰好 1 红(streaming e2e)。字段签名测试逐字编码 #1891 现场数据(25074/1024);over-suppression guard 防过度掩盖。本地定向套件 57/57 绿;typecheck + build 绿;对最新 master(6cab41b)做验证性 merge:无冲突、typecheck 绿、定向 45/45 绿。全量回归由 CI 把关,已 14/14 全绿(含 ubuntu/windows 22/24 矩阵、e2e、hermetic registry、real-client lanes)。 diff 整洁度:4 文件全在主题内(2 src + 2 tests),单一线性 commit,无 lockfile/生成物/version bump。通过。
已知限制(已单独跟踪,非阻塞):in-request 代理自发的重发 hop(compat-role ladder、overflow refold、fake-completion retry)成功后不重记 body,该样本的取证配对用首次尝试字节。仅诊断层面(字节指针仍指向真实分歧点;严格优于修复前的 prepared.body)。已立项:#1894。 判定:可合并(human merge)。方向正确、根因修复(非止血)、闭包不变式保持、mutation 双向独立复现、CI 全绿;唯一需要 owner 做的是确认与 #1856 的合并顺序。 |
Closes #1891
What & why
The
[cache-seam]warnings in #1891's log are FALSE POSITIVES of the #1606 seam detector, not real prefix breaks: all five field events fire on the session's FIRST measurable sample (no ledger baseline), where acp-kernel'sdecomposeSample(prev=null)forces growth=0 and books the ENTIRE uncached initial bill asttlRepay— whichdetectSeamthen misreads as an "unexplained mid-history break" (field signature: unexplained == input − cached, exactly). Every event was followed by 85–99% hits.Two sub-defects in the same seam-diagnostics failure domain:
src/cache-ledger.ts) — rebook the no-baseline residual ttlRepay → newContent (closure invariantmissed === nc+cr+trpreserved), mark the linenb, skip it indetectSeam(also keeps it out of the rewind/provider-side body-pair classifications), and surfaceinitialBillsin the CACHE INVALIDATION section so users can verify opener bills are not counted as re-pay.src/server.ts) —noteForwardedBodyran only at the non-streaming settle and loop re-fetch; streaming/plugin-pipe lanes (the reporter's/bili/lane) got "aggregate flag only" with no byte forensics possible. It now runs at the single main chokepoint (fetchWithTransportRetrysite; skips GET/HEAD and side requests that never settle usage), and the non-streaming note records the exact final wire bytes (wireBodyafter compat-role/steering/chain-stamp rewrites) instead of the pre-rewrite prepared body.Behavior changes (old → new)
ttlRepaybucket; now booked innewContent. In/acp-cache:ttlRepayandinvalidation.remainingno longer inflate by every new session's opener bill;newContentgrows by exactly that amount. Closure invariant unchanged (residual stays 0). WHY: with no prior bill nothing could have expired — booking it as re-pay was the category error behind 缓存泄露问题 #1891's false warnings.[cache-seam]warn + CACHE SEAM report section: no longer fires on no-baseline openers; genuine mid-history breaks still fire (regression-tested, mutation-verified).initialBillsblock + one extra CACHE INVALIDATION line when present. Ledger persistence stays v:1 with additive optional fields (nb,nbSamples,nbInput), normalized on load for pre-upgrade ledgers.buildCacheReporton no-baseline samples (kernel still books them as ttlRepay); bili never renders the kernel batch path — the parity test documents the exact delta. Kernel-side alignment is a cross-repo follow-up if wanted.Tests
tests/issue1891-seam-nobaseline.test.ts: unit tests (rebooking, the 25074/1024 field signature, over-suppression guard for real breaks, unknown-sample quarantine, pre-upgrade ledger normalization) + an e2e streaming/bili/lane test proving the chokepoint capture yields byte-level forensics. Both mutations verified red (rebooking disabled → 3 fails; chokepoint note removed → e2e fail).tests/cache-ledger.test.tsthat pinned the old buggy semantics (cold-start-in-ttl assertion; kernel-batch parity expectations).