Repository navigation
[PR] batch-4: 13 community fixes across dsh / claude / opencode / pi / egress (verbatim cherry-picks, authorship preserved) - #7196
ranxianglei wants to merge 33 commits into
Conversation
The claude-native-bootstrap hook destroyed stdin and then called process.exit(0) in the same tick, which triggers a libuv win async-handle close assertion on Node 24.15.0. Route it through runSessionStartHook so the event loop drains naturally, with the unref'd backstop only as a leak guard. Refs #7093 (cherry picked from commit 128d8bf)
#2943) Review addition for the Claude hook graceful-exit fix: the zcode lane already carries a spawn-level 'real entry exits 0 promptly and does not hang' test in this file; the claude lane had only the injectable-deps coverage plus manual verification. Add the claude counterpart — spawn the real src/claude-native-bootstrap.ts entry with BILLION_CONTEXT_PROXY set (plan action "exit": earliest safe return, no proxy/config side effects) and assert a prompt clean exit 0. Bounded by an 8s SIGKILL so the suite can never hang. (cherry picked from commit 50a705b)
) cordis dispatches internal/config as waterfall('internal/config', fiber, next): the first argument is the event name, so no this is bound (thisArg null) and the listener receives (fiber, next). Reading this.entry always yielded undefined, so every covered entry was recorded as unnamed-entry, sawFactoryPreset never latched, and PR #5994's #5248 restore could never fire. Tests dispatch through a real cordis Context; the existing mock hosts call the captured middleware directly, which is why the defect stayed green. (cherry picked from commit a9973eb)
These three files invoked the captured internal/config middleware as mw.call(entryLike, null, next), passing the entry name as `this`. That is not how cordis dispatches (thisArg is null, the fiber is the first argument), so the mocks were asserting a binding the host never produces — which is why #7112 shipped green. Move the entry-like object to the first parameter; the assertions themselves are unchanged. (cherry picked from commit 8461f55)
…missed (#7112) 8461f55 moved the entry-like object to the first parameter in most mock calls but left two issue3662 sites still passing it as `this` (mw.call(PRESET_SELF, null, next)) — they only stay green because their assertions are name-independent, so the broken binding survives exactly where a future name-keyed branch (e.g. #5994's #5248 restore) would be exercised. Move those two calls to the real binding and rename the identifiers that now lie (PRESET_SELF/self/raw → the fiber they carry), so the mocks cannot silently drift back to the pre-#7112 convention. (cherry picked from commit f7059d7)
…#7113) dsh replaces a patch row's whole config and compaction-basic defaults auto to true, so any layer applied after bili that restates id compaction-basic silently re-arms native auto-compaction; the first symptom is a landed checkpoint destroying the fold base. The gate entry now scans the composed loader tree once the loader is available (optional, never a hard dependency) and logs one loud line naming the offending row and the fix. Detection is pure and covered both ways: healthy declaration silent, dropped auto reported, stock-disabled web row silent, unrelated rows ignored. (cherry picked from commit d67fe40)
The type is only referenced inside the module; the repo's unused-exports gate rejects exported types with no external consumer. (cherry picked from commit 81780db)
…it a cold window headersFor stamped x-bili-plugin-model / -context-window for the model the session header names (#2381), but an llm/stream dispatch can stream to a different model: auxiliary calls (compaction, title, subagent) running on another model carried the session model's numbers, so the proxy's exact-match gate discarded the header channel and the request was sized against the fallback window. The window resolve was also fire-and-forget, so a model's first dispatch always went out with no window header. The dispatch scope now carries the model the dispatch streams to (GenerateOptions.provider + model, falling back to the session header and the global default). A dispatch whose model has no cached window waits for the in-flight resolve before its first fetch, bounded to 2s from the resolve's start so a slow or hung resolver can never stall the stream. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit ffbcdbf)
…ile (#7111) cordis entry-level inject has no optional form, no timeout and no fallback, so gating the four Web presets on biliBasicCompactionPolicy meant any missing gate service left them pending forever: session creation failed with agent-presets/not-found while the host kept booting and serving its UI. Measured on dsh 0.2.2-rc.4: with the gate row disabled, resolve('standard') throws and four entries report pending. The presets are no longer gated. The always-on gate entry reconciles the presets mounted before it activated (entry.update re-runs internal/config, so the overlay rewrites them exactly as on a cold resolve) and the loader is awaited in a child fiber, never injected hard. Losing the gate service now costs the overlay (stock compaction, wire guard #1729 as backstop), not the session. Verified on a real host: gate disabled => resolve ok + zero pending; gate enabled => all four presets still carry disabled compaction-basic/command-compact rows. (cherry picked from commit 9ec1e6f)
… gate) Both types are referenced only inside their own module; the repo's unused-exports gate rejects exports with no external consumer. (cherry picked from commit 23d42c3)
#7111 made the four Web presets fail-open, so disabling the bili-compaction-gate entry no longer re-creates the pending-latch brick. The real consequence is that native compaction stays ARMED while bili owns the lane (no overlay to stand it down), which risks destroying the compression substrate — the #1729 wire-level refusal is only the backstop. Update the 'Disabling vs removing' section in both docs to say that instead of the now-stale 're-creates the brick' claim. (cherry picked from commit 18be132)
(cherry picked from commit 2c2dc37)
The 4000/10000 deadline literals are meaningful constants; name them to match the file's MAX_BYTES/MAX_ENTRIES style. No behavior change. (cherry picked from commit 96cf627)
The best-effort onLate cleanup runs after the round already settled (deadline or caller abort); a failure there must not surface past the settled outcome. Comment-only, no behavior change. (cherry picked from commit 9b951ef)
(cherry picked from commit 50823a7)
(cherry picked from commit f56bfe6)
…sted by name (cherry picked from commit 214d908)
…e/architecture.md (cherry picked from commit 6d7a479)
… traffic off real DNS pi-web-access 0.46 only sets __piWebAccessProxyFetch when the wrapped fetch already has it, and marks its own wrapper with __piWebAccessSharedProxyFetch instead. The fetch chain only knew the old name, so the #2435 coexistence branch was unreachable and every install fell into the generic re-chain. The #1662 escape then handed the rewritten INLINE_ORIGIN request to the oldest live anchor, a real DNS lookup that dies ENOTFOUND, and only the first occurrence is logged, so every later model call failed silently. Recognize both markers in the depth-1 branch, the install guard, and the marker the chain forwards, and never route pseudo-origin traffic to the anchor: send it down the chain instead, where the hop stamp lets the inline transport serve it in-process. (cherry picked from commit 8895a2c)
…s proxy scope on (#6829) With a pi-web-access proxy scope active, the wrapper sitting above the inline link curls INLINE_ORIGIN URLs itself, so the #1662 depth-1 fix never runs on that path and 0/2 inline-origin requests reach the engine (scope OFF: 2/2). A second leak exists for requests inheriting a stale dispatchDepth (#5614 shape), which skip dispatchBody entirely. Fix (routing-only, no default/budget change): - fetch-chain: exact-origin classifier isInlineOriginUrl (URL-parse; http only, exact hostname, default port, no credentials) and a classify-first check in patched — INLINE_ORIGIN requests run the link's own dispatch at a fresh depth 1 instead of being handed down the chain. The old depth-1 prefix route-down is removed. - pi-inline: the serve logic is extracted as exported serveInlineOrigin (undefined when not installed or not an inline-origin URL); the link dispatch delegates to it. - native-intercept: the dispatch's send is wrapped so every INLINE_ORIGIN send is served in-process via serveInlineOrigin; all other sends pass through untouched. Unconditional: bili cannot observe the wrapper's scope state from outside, so there is no signal to divert on. Tests: three new regression tests in tests/pi-inline.test.ts (proxy-scope ON/OFF, stale dispatchDepth, exact-origin classification) plus an updated #6829 expectation (the wrapper never sees pseudo-origin traffic now); 11/11 pi-inline, 29/29 self-heal + #5614 neighbours. Fixes #6829 (cherry picked from commit 2e97c3e)
#554 guard meter (#6828) A dual-shape body carries the conversation under two top-level keys: the lane's native field (messages[] on openai/anthropic, input[] on responses) plus another protocol's field (a Responses-native host such as dsh sends `input` alongside `messages`). The upstream bills only the native field, so the protocol-blind meter counted the conversation twice and the egress fuse false-tripped on the phantom total (1,815,699 measured vs ~380K billed, 4.77x), while preflight's protocol-aware estimate saw only ~135K and never compressed. Thread the lane's protocol through measuredOutbound and the preflight measured-body doom tiers so the meter skips the foreign conversation fields for that lane, top level only. Without a protocol the meter keeps its fail-closed count-everything behavior. Regression test: tests/issue6828-guard-meter-dual-shape.test.ts (cherry picked from commit 1e3ebba)
…uard meter (#6828) Review supplement to the PR: the egress fuse (relay) and the preflight measured-body tiers were made protocol-aware, but sideRequestGuard() still metered the raw body protocol-blind even though the lane protocol is a parameter of the function. A dual-shape body's foreign conversation field double-counted there too, false-blocking the compress/nudge side call — the very request that would shrink the session. - sideRequestGuard: pass the lane protocol to estimateRawBodyTokens - regression test: a dual-shape body must not false-block the side request (verified red without the fix, green with it) (cherry picked from commit 3d16a8a)
…te (#2170 lane-guard) The lane-guard gate (#2170) requires that a change to src/server/side-request.ts land alongside one of the dedicated side-lane suites. The previous commit put the #6828 dual-shape regression in tests/issue6828-guard-meter-dual-shape.test.ts (the meter's file), which does not satisfy the gate. Move it to tests/side-request-isolation.test.ts, the canonical home for sideRequestGuard tests. (cherry picked from commit d143fbd)
(cherry picked from commit f9579cb)
The first commit inserted the MODEL_HIDDEN_BODY_KEYS declaration in the middle of the #554 comment paragraph, orphaning the 'fails closed.' line below the new const. Move the declaration (with its own complete comment) after NON_TEXT_BODY_KEYS; no behavior change. (cherry picked from commit 3aa825a)
…#6844) Issue #6844 item 3: the measured-doom 413 lists four buckets, but 'other' is a catch-all — attributing it took manual arithmetic (the incident's 88%-other body needed a body dump to identify dsh_session_log). Independent of any exemption mechanism: the next unknown host-attached field will still 413, and the operator-facing message must say WHICH field is metered. - estimateRawBodyBreakdown tracks per-top-level-field token counts for the other bucket in the same single walk (new RawBodyBreakdown.otherTop, descending; empty when other is empty; top-level arrays attribute to no field, as before). - measuredBreakdownClause appends '(top field: <k> ~N)' when other is non-empty — all three 413 sites (egress fuse, preflight measured gate, fresh-session gate) inherit it. - raw-body-walk-depth shape pin updated for the additive otherTop field. - unit tests: per-field attribution + sum-to-bucket, hidden fields leave no attribution, clause naming + bare clause when other is empty. (cherry picked from commit 2542369)
- a body whose mass is a model-hidden DSH top-level field (5M-char dsh_session_log, ~1.25M measured tokens vs the 1M floored bar) forwards to the upstream — the incident shape no longer 413s; the fuse is a meter, not a filter, so the field still rides byte-exact; - an equally sized UNKNOWN top-level field still stops at the fuse (the exemption is a documented-field allowlist, not a hole — #3617 gate discipline) and the 413 names the dominating field. (cherry picked from commit 9299436)
…ed usage An advisor reply bundles several model calls (executor, advisor, executor) and its top-level usage sums the executor calls, about twice the real context. bili read that sum as the context size: in session ccda2ec4 it logged 488,488 tokens, 122% of a 400K window, when the context was about 241K, and fired emergency nudges and preflight folds on it. The reply's usage also lists each call in `iterations`. The context the next request carries is what the last executor call read, so the usage paths (plugin stream, proxy loop, non-streaming relay) now pass that number to settleUsageReport, which uses it for lastInputTokens and the calibration pair. Billing still counts the full sum. A one-call reply is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 1c212cd)
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.10863-pr.7196.3dd1366This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr7196.tgz
npm install -g packageInstall instructions are refreshed on each push. |
#7196 的 4 个红 shard 是同一个测试,根因是批次内两处调用约定冲突结论: 根因:同一批次里两个提交对
mw.call({ entry: { options: { name: "preset-dsh-go-companion" } } }, null, () => cfg);第一参数是 建议修法(一行 fixture): mw.call(null, { entry: { options: { name: "preset-dsh-go-companion" } } }, () => cfg);参照片内已绿的 边界说明: |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 查重: 不重复 — 这是本线程自己的 batch PR,无并列的第二个修复 PR 指向同一主题(已核对 open [PR] 行)。 Reviewed the batch at source (all 13 fixes read commit-by-commit against current master, not just the PR description), plus the assembly mechanics. Verdict: mergeable, with one process gap to close first (details below). Assembly mechanics — verified
Per-fix verdicts (all SAFE, with teeth)Each fix matches its description and ships a regression test that actually asserts the behavior (real cordis
|
…ads (#7196) #7115 changed the internal/config listener to read the entry name from the fiber argument (cordis dispatches waterfall('internal/config', fiber, next) with this=null), but this pre-existing #6770 fixture still passed the entry as `this` — so entryNameOf(null) degraded to "unnamed-entry" and the assertion failed on every OS/Node. Pass the entry object as the first argument, matching how cordis actually dispatches (and how tests/issue7112-config-hook-fiber drives it).
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) @resec 诊断正确,我已独立验证并当场修复 + 推送到 PR 分支。 独立验证(不依赖你的描述,逐条核对):
已修复(顺手修,一行 fixture,commit // 旧:名字塞 this(旧签名)
mw.call({ entry: { options: { name: "preset-dsh-go-companion" } } }, null, () => cfg);
// 新:名字作为 fiber 第一参数(与 cordis 真实派发 + tests/issue7112 一致)
mw.call(null, { entry: { options: { name: "preset-dsh-go-companion" } } }, () => cfg);本地验证:issue6770 + issue7112/7113/7111/3354/3662/4147 共 40 用例全绿(先 纠正你的一条侧边说法: CI 状态: 我推送后 |
batch-4: 13 community fixes across dsh / claude / opencode / pi / egress (verbatim cherry-picks, authorship preserved)
One batch PR carrying 13 independently-reviewed fixes from 8 community authors (issues #7111–#6826 era). Every PR was reviewed commit-by-commit against current master, all 13 got a SAFE verdict, and each is cherry-picked as-is with
-x(original author, message, and content preserved — see 著作权 below). No design-level change is included; everything here is a scoped bugfix with a regression test.What's in it
dsh lane (5)
this, but cordis dispatches string events withthisArg = null(verified in cordis 4.1.0events.ts:163) — so the name-dependent branches (diagnostics + the #5994 basic-package restore) silently never ran. Reads from the fiber argument now, via the exportedentryNameOf().compaction-basicrow's whole config silently re-arms dsh native auto-compaction (autodefaults to true) and a landed checkpoint destroys the fold base — with zero log. Boot-time alarm (one warn line, pure observability, fails safe on any loader-shape surprise).biliBasicCompactionPolicyservice were fail-closed: any missing gate service left all presets pending forever →agent-preset/not-foundon session create while the host kept booting (triggers: subpath resolve failure, user toggling the gate row, interrupted install). Now fail-open: presets mount immediately and the always-on gate entry reconciles them post-load viaentry.update()through the exact same overlay path as cold resolve. Losing the gate now costs the overlay (stock compaction + the #1729 wire-level refusal backstop), not the session.llm/streamdispatches stamped their context-window headers from the session model instead of the dispatch's own model → cross-model dispatches sized against the wrong window. Per-dispatchmodelTargetwith a cold-refresh wait (2 s, unref'd; timeout = exact pre-fix bytes). #5614 boundary semantics and sid/msgIds scoping verified intact.llm/streamhandler tests.process.exit(0)infinallyafter destroying stdin — a Windows+Node 24 libuv assertion crash (a #2943 sweep miss). Routes through the existingrunSessionStartHook()natural-exit path with an unref'd 5 s backstop; non-Windows exit codes unchanged.Egress metering / fuse (3)
input+messages); the #554 side-request guard meter counted both → 4.77× phantom total → fuse false-trip. The foreign protocol's field is now excluded, top level only, protocol-gated (absent protocol = old fail-closed behavior). Does not under-size the fuse: each upstream consumes exactly one shape.dsh_session_log,dsh_plugin_packages) as top-level fields, which the meter priced → ordinary requests 413'd at the fuse with 88% of the body in the hidden field. Exact top-level exclusion (nested same-name keys stay counted) + the doom receipt now names the field dominating theotherbucket (otherTop[]). Landed after #6840 so both exclusions compose insrc/preflight.ts.iterations[]usage as context (two iterations = 488K recorded for a ~241K turn) → the ledger baseline lied → spurious nudge + fold. Now takes the lastmessageiteration's input + cache reads; the billing ledger keeps the correct summed total.Timeouts & failure loops (3)
WeakSetsentinel (64 B) + invalidate at all 5 release sites + evict-oldest captures the pre-flush weight.Detection (2)
__piWebAccessSharedProxyFetch), so bili saw an unknown wrapper → the #1662 depth-1 cutoff re-anchored the inline origin to the oldest anchor → real-network ENOTFOUND on in-process traffic. Both markers recognized; inline-origin serving now also fires unconditionally inside a pi-web-access proxy scope, and the inline-origin check tightened fromstartsWithto exact origin (closes a latent sibling-domain bypass).permission: "allow"— in opencode that string is the action name rules match against, so name-based allow lists could never match (anomalyco/opencode#64051). Dropped; restrictive-ruleset users get the ask/prompt flow they actually configured, default users are untouched (*catch-all).著作权 (authorship)
All 32 commits are verbatim cherry-picks with
-x— original author, date, message, and (except the three mechanical conflict resolutions below) byte-for-byte content:Merge commits from the PR branches' own upstream syncs were not cherry-picked (
--no-merges); only the actual fix/test/doc commits came in, in original order.The only three edits made during assembly (mechanical conflict resolutions, no semantic changes)
src/agent/dsh-compaction-gate.ts/dsh-compaction-disable.ts— [PR] fix(dsh): alarm when the host-plane compaction-basic override is gone (#7113) #7116 and [PR] fix(dsh): replace the fail-closed preset gate with a post-load reconcile (#7111) #7117 both touch the always-on gate entry (7116 adds the boot alarm, 7117 adds the reconcile). Resolved by keeping both: onectx.inject(["loader"])callback runsreconcileLoadedPresets()then the host-plane warning; both exported helpers survive.src/preflight.ts(×2) — [PR] fix(server): exclude the foreign protocol's conversation field from the guard meter #6840 and [PR] fix: exclude model-hidden DSH fields from the measured body (#6844) #6860 both add top-level exclusions to the measured-body walks. Resolved by keeping both exclusion checks (foreign?.has(k)thenMODEL_HIDDEN_BODY_KEYS.has(k)) inestimateRawBodyTokensandestimateRawBodyBreakdown; [PR] fix: exclude model-hidden DSH fields from the measured body (#6844) #6860'sotherTop[]restructure composed with [PR] fix(server): exclude the foreign protocol's conversation field from the guard meter #6840'sprotocolparameter.Both resolution sites are covered by the PRs' own regression tests, which pass on this branch.
Verification
tsc --noEmit+ build: clean.ci:fulllabeled).After this merges
The 13 source PRs — #7115 #7116 #7117 #7066 #7094 #6840 #6860 #6961 #6912 #6905 #6911 #6841 #6825 — will have landed content identical to theirs; close (or merge, which will apply cleanly as no-ops) to avoid duplicate landings.
Fixes #7112, fixes #7113, fixes #7111, fixes #7065, fixes #7093,
fixes #6828, fixes #6844, fixes #6959, fixes #6910, fixes #6903,
fixes #6909, fixes #6829, fixes #6826.