Repository navigation
external-summary: consolidate #2646 + #2661 + #2723 + #2761 (fresh budgets, pool knob, concurrent batches, Go session header) - #2806
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3116-pr.2806.f460f5aThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2806.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…ure detail #2806 review follow-up: when a fold pass stops on the #2657 x #2678 fusion condition (whole batch settled deadline with zero dispatched attempts -> poolQueueDrop), the client-visible failure detail still carried the generic 'each was below minCompressRange, had an unusable summary, or failed to apply' cause even though nothing was ever attempted. Use accurate wording in that case only; all other scenarios keep their existing text (issue1372 + preflight-multi-range wording pins still pass).
[bot] 🏷 Review complete — mergeable (head Method — read the full 19-file diff in segments (hot zones: executor scope-pool + worker-pool, preflight nomination/batch/fusion-stop, http Go stamping, settings parse, wire-contract ledger), cross-checked every cherry-picked commit against its source PR by ① Source-issue direction (verified, not taken on faith)
Parity check (patch-id, all 8 cherry-picks): 4 verbatim (#2678 trio + the unused-export drop); 4 conflict-resolved, and each diff-of-diffs contains ONLY the documented resolution:
② Regression audit — existing behaviors on touched paths:
Intentional behavior changes (all disclosed in the PR body, all verified in code): (a) long preflight folds may now run up to count×totalTimeoutMs instead of fast-failing at totalTimeoutMs; (b) a whole batch dying in the pool queue with zero dispatched attempts now stops the fold pass (walk included) instead of queueing more rounds behind congestion — next turn retries, no backoff; (c) batch failure log reports the first failing range, not slot 0; (d) batch worker count is scope-aware ( ③ Fusion fixes scrutinized: ④ Test validity: all four new suites have teeth — issue2639 (hermetic plan reuse across a lapsed budget; verified to fail without the fix in the source thread), issue2678 (real proxy E2E measuring actual request-interval overlap ≥2, failed-range retry counts, oldest-chunk-first-wave timing, block counts — each assertion fails under the corresponding old behavior), executor-parallel (pool bound, out-of-order alignment, cancel-latch dispatch counting, mocked-clock deadline prefix), WC-016 (validation-parity fake in the ledger per #1304, negative control proving no fabricated session id, BOTH-modes lanes, detection edge table). Rewritten 'ordered fallback chain' assertion is parallel-safe (per-target subsequence order) rather than pinning the bug. ⑤ Diff cleanliness: 19 files, every line in scope; no whitespace churn, no generated artifacts, docs en/zh mirrored. Small fix pushed directly (小问题直接修, additive commit 结构化八问
判定:可合。 head |
ConfiguredSummaryPlan baked its budget as ONE construction-time wall-clock
point (`this.deadline = performance.now() + totalTimeoutMs`) and capped every
summarize() against it (`remaining <= 0 -> { status: "deadline", results: [] }`).
Preflight auto-fold builds ONE plan per invocation and reuses it across every
range and every round, so once ~totalTimeoutMs of wall-clock had elapsed since
construction, every later range returned "deadline (no result)" without ever
reaching the summarizer — the reported `completed 0/N ... batch=deadline (no
result)` volume. Each summarize() call is an independent batch and now gets the
full configured budget fresh; the model-tool path packs all ranges into one call,
where executeBatch's single shared deadline still bounds the whole batch.
Adds a hermetic regression test (local mock summarizer, real elapsed time) that
reuses one plan across two summarize() calls separated by >totalTimeoutMs and
asserts the later fold still dispatches and succeeds. Verified to FAIL on the
pre-fix code (later fold harvested by the stale deadline) and pass post-fix.
compress.externalSummary.concurrency (integer 1..32, default 4) sizes the process-wide summary pool: every session's preflight auto-fold and model-initiated compress calls share one ExternalSummaryExecutor, whose size was hard-coded at 4. The pool now grows to the largest value demanded by in-flight batches (refcounted scopes) and returns to base when they settle, so chains with different values can coexist; absent key keeps today's behavior exactly.
…gate SUMMARY_CONCURRENCY_MIN/MAX and SummaryPoolOptions are referenced from no other module — the gate requires them unexported.
…2667) executeBatch awaited each work item end-to-end, so the pool bounded cross-session calls but never a single batch: k ranges in one summarize() call still cost k sequential round trips, and the shared per-pass deadline cut multi-range passes off with whole ranges never dispatched. Workers now pull indices from a shared counter so up to `concurrency` items are in flight; results stay index-aligned as the dense prefix of settled ranges, and an early stop (caller abort / any range hitting the shared deadline) latches the workers so unstarted ranges are never dispatched.
The preflight fold pass submitted one external-summary request per range, sequentially, inside the session lock: k viable ranges cost k x ~20-40s of user-visible stall before the shared 180s pass deadline cut the rest off (v0.1.191 evidence: fold passes median 59s, max 180365ms, ~1.85 ranges/pass). A round now nominates up to MAX_PREFLIGHT_SUMMARY_BATCH=4 disjoint ranges (oldest first, largest span each, same preview/content/chunking gates as the walk) into a SINGLE plan.summarize() call that the concurrent executor runs in parallel; successful summaries commit through the same apply path as the walk (commitFold), failed ranges fall through to the serial walk unchanged and get their halving/transient retries there. Log line reports real batch sizes (was hardcoded '1/1 range(s)'). Gated on the external lane and >=2 viable ranges; single-range, legacy-streaming, and emergency-digest paths stay byte-identical.
…nk ranges (#2678) Review findings on the #2678/#2667 batch-fold change, corrected in place: - Span selection: nomination took spans[0] of the REVERSED worklist — the newest tail chunk — while the mirrored walk pops the oldest full-budget chunk first. Now identical (spans.pop()). - SkipSet poisoning: a rejected preview or empty render during nomination added the WHOLE range to skipSet, where the walk only continues to the next span. A sub-minimum newest tail therefore killed a range whose older chunks were foldable for the rest of the pass. Removed both adds. - Call accounting: nominations reserved summaryCalls before knowing whether the batch would fire (≥2 nominations); a sub-batch set falls through to the walk, which reserves its own calls — double booking could trip budgetHit early. Reservations now commit only when the batch fires. - rangesTried counted a range at both sites (nomination AND walk); now deduped per range key so the failure detail reports distinct ranges.
…2678) - New E2E: a multi-chunk kernel range (same-role run with an over-budget message and a sub-minimum tail) must carry its OLDEST full-budget chunk in the first batch wave and keep folding chunk by chunk (≥5 blocks). Under the previous tail-first + poison behavior this fails: the range never enters any batch and only the tail range folds. - New E2E: a batch-failed range is retried across later rounds (≥3 attempts) while siblings keep folding. - Corrected the header/test comments claiming every batch-failed range 'falls through to the serial walk': while siblings fold, retries are re-nominations into later batches; the walk takes over only once the batch applies nothing in a round.
#2760) OpenCode Go (/zen/go) rejects independent summary calls lacking a stable x-opencode-session header (HTTP 400 MissingSessionID). The external-summary path built only auth headers, so Go targets always failed. Thread the session id through both plan-build sites (the compress-tool lane covers plugin+proxy modes; the preflight/auto-fold lane covers growth folding) and stamp x-opencode-session plus bili's own user agent at request generation for explicit Go targets only. It is derived from bili's own conversation id, never copied from the client's inbound session/auth headers. Non-Go targets and legacy preflight are untouched. Adds WC-016 to the wire-constraint ledger as a header rule with a validation-parity fake and BOTH-modes regression tests.
…ueue With fresh per-call budgets (#2639) plus multi-round batched preflight (#2678), a queue-dropped round no longer ends the pass: every later round builds a fresh-budget batch that queues behind the same holders, serializing the whole turn behind pool congestion (observed: a 500ms budget turn burning 2.5s of rounds and finally dispatching into the freed pool mid-test). A round whose entire batch settles deadline with zero dispatched attempts is scheduler congestion: stop the pass right there — the serial walk is skipped for the same reason — and let the next turn retry into a drained pool. Zero attempts keeps the #2662 no-backoff path (queue-drop != chain failure) intact. Also disclose in CONFIGURATION(.zh-CN).md that the concurrency knob is grow-only (values 1..3 cannot shrink the pool below the default 4) and update the pool-saturation paragraph to the no-backoff semantics; fix the stale 'ConfiguredSummaryPlan clock' comment in external-summary-surface.ts (#2646 review).
isOpenCodeGoTarget matched any /zen/go* prefix, so a hypothetical /zen/golang endpoint would also get the x-opencode-session stamp. Match exactly /zen/go or /zen/go/... and pin the boundary with tests (#2761 review, minor 1).
…ure detail #2806 review follow-up: when a fold pass stops on the #2657 x #2678 fusion condition (whole batch settled deadline with zero dispatched attempts -> poolQueueDrop), the client-visible failure detail still carried the generic 'each was below minCompressRange, had an unusable summary, or failed to apply' cause even though nothing was ever attempted. Use accurate wording in that case only; all other scenarios keep their existing text (issue1372 + preflight-multi-range wording pins still pass).
…es (#2806 review) fork-adoption-wires + issue2033-anonymous-anchor drive ANONYMOUS clients whose identity rides prefix-affinity.json in the shared default state dir. Without isolation they hydrate foreign chains written by sibling test files running concurrently in the same CI job and co-write the file underneath each other; once this stack added four more test files (incl. heavy multi-proxy e2e) the interference flipped both suites' assertions on all four CI nodes while every parent tree stayed green. Isolate with the established #2719 idiom.
…review) The zero-block scan iterates EVERY forked session in the process-wide table (src/session.ts module Map, cap 256 — no eviction at these sizes, and setRegistryForTest is the models.dev catalog, not sessions). Sibling wire scenarios above leave their adopted forked children in that table; on loaded runners those children can carry blocks from load-shifted compress demands, flipping the scan. Reset the table to this scenario's scope before booting — same idiom as fork-side-request-lane.test.ts and issue2407-google-khat-lane.test.ts. On clean runners siblings' children stay block-less so the old global scan passed; the reset makes the assertion immune to either outcome.
6d1179a to
ff6a98e
Compare
[bot] 🏷 CI 红已定位并修复,新 head 先更正我上一条回复里的错误:失败的不是 issue1372/issue2678(我读错日志),实际红的是两个 master 既有的匿名前缀亲和 e2e 套件(node-22/24 + windows 全挂,guards 全绿):
按八问:
诚实声明:本机是舰队共享盒子(常驻环境负载),A1 的 anchor 漂移在本地仍 100% 复现(hermetic 之后也一样)——本地无法完全模拟干净 runner;hermetic 隔离针对的是 CI 日志实证的跨文件搅动向量,session-reset 修掉的是确定性污染路径。若新 head 的 CI 里 A1 仍红,下一步拿完整 TAP 错误定位 anchor 漂移的具体路径再处理,不会带红合入。 判定:等 |
[bot] 🏷 Review 收工 — 最终判定:可合并。 最终 head 结构化八问(覆盖整个 PR,不只 CI 事故):
诚实备注:本机是共享舰队机,裸 master 在 ambient load 下同样会偶发这两个套件失败(非本 PR 引入,未在本 PR 处理;hermetic 化已消除跨文件状态串扰这一确定性污染源,残余 load 敏感性如再出现建议另行立项)。 合并后收尾(按 PR 正文):关闭 #2646、#2661、#2723、#2761 为 superseded(内容已逐字或冲突消解地收入本栈);#2666(reasoning tax)保持打开不动。合并操作本身按规约由人工执行:#2806 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.291-master.1e71738 # this exact build
npm install -g billion-context@master # always the newest merged build
|
What
Consolidates the four open external-summary PRs — #2646, #2661, #2723, #2761 — into one reviewable stack (8 cherry-picked commits, conflict-resolved) plus two fusion fixes that only exist because the four land together. Each source PR was independently reviewed first; this PR is the rebased union on current master (d0cebb9) plus the cross-PR semantics.
Fixes #2639, fixes #2657, fixes #2667, fixes #2760.
Why one PR
All four touch the same three files (
src/external-summary.ts,src/external-summary-runtime.ts,src/preflight.ts) and their semantics interlock: #2646 (fresh per-call budgets) × #2678 (multi-round batched preflight) interact in exactly the spot #2661's pool knob and #2761's plan plumbing pass through. Reviewer on #2661: "that stack, not this branch, delivers what CONFIGURATION.md promises."The stack
c0d6d772— fix: give each external-summary summarize() call a fresh budget (#2639) #2646: drop the construction-time plan deadline; eachsummarize()gets a fresh budget ([Bug][external-summary] batch deadline harvests queued ranges ("completed 0/N; batch=deadline (no result)") — per-range truth lost, whole-batch refusal, fold-reconcile drift #2639: ranges starved as "batch=deadline (no result)"). Conflict with master's auto-fold backoff arms on pure queue-drops (attempts=[]) as if the summary service had failed #2662 stats accounting resolved by keeping stats + removing the cached clock.fe32d55e+36032dbb— feat(#2657): expose external-summary pool concurrency as config #2661:compress.externalSummary.concurrencyknob (1..32, default 4, grow-only) over the refcounted scope pool ([Feature] expose external-summary concurrency as config — hard-coded ExternalSummaryExecutor(4) throttles every session on the host #2657: single 15-session host at 7% success).bd7f0474…1d0bd94d— fix: fold several preflight ranges in ONE external-summary call (#2678, #2667) #2723/[Feature][preflight] fold several ranges in ONE summary call - preflight currently issues one request per range, sequentially, inside the session lock #2678: worker-pool batches (up to N ranges in flight per batch instead of serial) + multi-range nomination per round (oldest-chunk discipline).1291fe0d— fix: stamp x-opencode-session on OpenCode Go external summary requests (#2760) #2761:x-opencode-session+ UA stamp for OpenCode Go targets (WC-016), session id threaded from both plan-construction sites.Fusion fixes (new in this PR)
f3c55ff2— with fresh budgets × multi-round retries, a queue-dropped round no longer ends the pass: later rounds queue behind the same holders with fresh budgets each and serialize the whole turn behind pool congestion (observed live: a 500ms-budget turn burning 2.5s of rounds, then dispatching mid-test into the freed pool). A round whose whole batch settlesdeadlinewith zero dispatched attempts now stops the fold (serial walk skipped too); zero attempts keeps the auto-fold backoff arms on pure queue-drops (attempts=[]) as if the summary service had failed #2662 no-backoff path — next turn retries into a drained pool. Also documents the grow-only knob in CONFIGURATION(.zh-CN).md and fixes the queue-drop paragraph there (it still claimed queue-drops arm the 10-minute backoff) + the stale "ConfiguredSummaryPlan clock" comment (fix: give each external-summary summarize() call a fresh budget (#2639) #2646 review).a47b574b—isOpenCodeGoTargetnow segment-bounds/zen/go(no/zen/golangfalse positive), with tests (fix: stamp x-opencode-session on OpenCode Go external summary requests (#2760) #2761 review minor 1).Worker-pool count uses the scope-aware
effectiveConcurrency()(batch options raise the pool viabeginScope), fusing #2661's resize semantics with #2678's worker pool.Verification
npm run buildOK; config-surface guard OK (124 leaves).After merge
Close #2646, #2661, #2723, #2761 as superseded (their content lives here verbatim or conflict-resolved); #2666 (reasoning tax) remains open and untouched — it needs a typed reasoning knob, deliberately not part of this stack.