Repository navigation
[PR] refactor: unify relay recovery re-sends through one egress chokepoint (#6003) - #6028
Conversation
…#6003) The five recovery re-send rungs in forwardCaptured (ws-byte-shed, role-ladder, pck-strip, image-count-shed, context-overflow refold) each re-inlined the same two-step egress tail before their fetchWithTimeout: re-sign (#1884) then v1internal re-wrap (#3129). Extract that tail into a single finalizeEgress() so the final re-sign -> wrap decision lives in one place instead of five copies, and so a future user egress-transform pipeline has exactly one hook to attach to (before the re-sign, so the signature always covers the shipped bytes). Zero behavior change: byte-identical bodies, headers, and fetch calls; only the duplication is removed. Groundwork for the user-registerable egress pipeline (#6003); the pipeline itself is not added here. The main send keeps its inline re-sign/wrap because the pre-send gate stack consumes the signed inner body between the two steps; fake-completion keeps its own option-based path (its wrap->sign order differs from every other site).
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.8801-pr.6028.b8c1191This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr6028.tgz
npm install -g packageInstall instructions are refreshed on each push. |
Duplicate check: not a duplicate. No other open PR targets the #6003 egress-transform groundwork or the relay egress chokepoint — PR #6028 is the only one (checked the mirror's open I pulled the branch and did an independent review of the diff (single commit, What I verified (zero behavior change holds)
Two things to handle before merge (neither needs a design decision)A. Rebase to current master. The head is stale (behind master by several commits incl. #5998 and #6006/#6009). I dry-ran the rebase: it's clean — the result is still only B. Pick up the sixth rung (#5998). Master's #5998 (already merged) added a new recovery re-send — the strict thinking-signature strip-and-resend probe — which uses the identical Design note for the #6003 phase (non-blocking here)The main send stays inline because the pre-send gate stack (outbound-body check, egress window fuse, image-fact capture) sits between the sign and the wrap/fetch. Consequence: the chokepoint covers only recovery re-sends, not the primary send. If the future user-registerable transform is meant to hit all outbound bodies, the main send needs its own hook-point decision relative to that gate stack — worth settling in the pipeline phase, not this groundwork. CINo failures on the current head — the core 结构化八问(PR review 结论)
合入判定:重构本身正确、零回归、diff 干净、方向合理。合入前必须处理两点机械收尾(都不依赖决策取舍):A rebase 到当前 master(已验证干净);B 把 #5998 那个第 6 处 thinking 探针重发也转成 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.1125-master.539c56c # this exact build
npm install -g billion-context@master # always the newest merged build
|
What
Unifies the five recovery re-send rungs in
forwardCaptured(src/server/relay.ts) through a single egress chokepoint,finalizeEgress(). Each rung used to re-inline the same two-step egress tail before itsfetchWithTimeout— re-sign (#1884) then v1internal re-wrap (#3129); that tail now lives in one place instead of five copies.This is groundwork for the user-registerable egress-transform pipeline (#6003): it gives the future pipeline exactly one hook to attach to (inside
finalizeEgress, before the re-sign, so the signature always covers the shipped bytes). The pipeline itself is NOT added here.Zero behavior change
Byte-identical bodies, headers, and fetch calls across all five resends (ws-byte-shed, role-ladder, pck-strip, image-count-shed, context-overflow refold). Only the duplication is removed. Verified locally: typecheck clean + 119 targeted tests green on the rebased head (the five mechanisms + fake-completion + egress-wiring + window-fuse + main-path-retry). Full-suite verdict comes from CI.
Why the main send & fake-completion stay inline
resolveFakeCompletion) is a separate option-based function whose wrap → sign order differs from every other site; preserving it byte-for-byte is intentional. Its differing order is flagged for the pipeline-phase hook-point design.The compress-loop lane (
src/loop/core.tsfetchUpstream) is already a single chokepoint receiving resign/wireTransform as options — the pipeline will pass its transform the same way; not touched here.Related to #6003 (phase 1 of 2 — unification groundwork; the pipeline is pending owner sign-off on direction/naming/trust model).