Repository navigation
fix: index stripKernelSummaries carrier evidence in one pass (#2042) - #2043
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2082-pr.2043.f9a413eThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2043.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Review started on PR #2043 (head Initial checks done:
Semantic-equivalence audit (old vs new branch by branch) is complete and holds — details in the final review reply once the CI test jobs land. |
[bot] 🏷 PR review 完成(agent-authored PR,按「拉分支核对代码 + CI 确认 + 报告结论」执行,未重做)。head 结构化七问
其他审查项
收工判定:建议合并。 方向正确、根因修复、语义等价经独立模糊验证 + 全套 CI 双重钉死;唯一注意点是与 #2036/#1449 的合并顺序。 |
Closes #2042
What
stripKernelSummaries()(src/server.ts) looked up each active block's summary carrier by rescanning the entire post-kernel history once per block: plain blocks viamessages.some(...), plugin-fold blocks viainboundCompressPairPresent()which also re-parsed every compress call's args per block. With B active blocks and N messages the worst case was O(B×N) plus O(B×C) JSON parses (C = compress calls). The shared function sits on all four protocol prepare paths, count_tokens, and the post-compress re-request path.Fix
Single pass at function entry (
buildCarrierIndex) building:{startId,endId}and{content:[...]}formats).Block loop then does O(1) lookups; final order-preserving filter unchanged. Cost: O(N+B+R), R = total ranges across compress args, paid only when plugin exact-matching is needed.
Semantics preserved exactly (pinned by tests):
Behavior changes
None on the wire: output is byte-identical to the old implementation for every input (old-vs-new equivalence pinned per case). Performance-only change:
.somescans — cheaper for B≥2, tied in the worst case at B=1, and one extra O(N) pass on fresh pre-compression sessions (the old code scanned nothing when no active block existed).Config surface
Not applicable — no config fields added/renamed/re-semantics'd.
Verification (rebased head b464af4 on master d19a546)
npm run typecheckclean;npm run buildclean.tests/issue2042-carrier-index.test.ts(16 cases): carrier hit/miss per branch, flat/content range args, bad JSON, legacy refs, preflight, inactive, non-tool-call decoy, mixed-branch order preservation, parse-once pin, deterministic visit-count probes (no timing thresholds).ci-e2e.ymlauto-runs on this diff (touches src/server.ts) with the real upstream.