Repository navigation
[PR] fix(agent/dsh): decode content-encoded request bodies in fork-adoption and recall body gates - #4832
Conversation
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.6248-pr.4832.1daa378This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4832.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复。 本 PR 是 #4829 的唯一实现入口(检索 open+closed issues/PRs:没有其它在途 PR 修同一机制—— 标签:bug / dsh / scope/wiring / p1(理由:seeded fork 子会话继承被永久放弃 = p1 ①类,与 #4829 一致;镜像 web 面当前未实现标签 API,在此如实申报,原 issue 标签已就位)。 正在复审本 PR(代码 + 既有行为回归清单 + CI 状态),结构化结论随后评论。 |
(ai: vllm-qwen/qwen3.8-27b) lock-sync 红 → 已修复并推送,新 head
备注:上一车道在历史里留了一个空提交 判定:新 head 全部门禁绿,可进入 owner 审查/合并。 |
…call body gates (#4829) The Codex SSE transport (pi-ai) ships zstd-compressed Uint8Array request bodies with a content-encoding header. bodyJsonOf() parsed byte bodies as plain UTF-8 text only, so every such body failed the fork-adoption body-parse gate: seeded fork children of long compressed conversations could never adopt the parent's compression state (resume-inheritance miss -> multi-million-token preflight compression -> client disconnects before the model request was forwarded). The same blind parse also made the #4082 negotiated recall silently skip encoded retries. - bodyJsonOf now reads content-encoding from init.headers (Headers / pairs / record shapes) and decodes through the server-side codec table (src/content-encoding.ts: gzip/x-gzip/br/zstd via fzstd/deflate) before JSON.parse; decoding is INSPECTION ONLY — outgoing bytes are untouched. - Every failure mode (undecodable bytes, unsupported coding, decoded-size cap via limitsDecodedBytes) still yields undefined = today's behavior; string bodies parse as-is (a JS string cannot be compressed). - maybeNegotiatedClaim becomes async; the takeover gate's none arm settles via .then() preserving today's control flow exactly (streak reset only on non-claim). The gate contract already tolerates Promise verdicts (threw arm); the WS lane never passes init, so its sync call path is unchanged. - Behavior change (intended): gzip/x-gzip/br/zstd/deflate request bodies are now decoded for inspection in the dsh lane (fork-adoption gate, recall claim/learn); previously ANY non-plain-text byte body failed the gates. Outgoing request bytes are unchanged in all cases. - Gate warn line now says 'after content-encoding decode' (#4215 wording preserved for log consumers). - Tests: new suite tests/issue4829-zstd-fork-gate.test.ts pins both directions (#3617) — zstd/gzip bodies reach the adopter protocol, undecodable/unsupported encodings hit the gate once, plain-text behavior unchanged; three dsh-native gate assertions updated to await the now-async none arm (same idiom the threw arm already used).
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复。 本条是系统转发的本 PR 冲突处置任务(conflict-worker 车道),非新立项;查重结论已在 floor 8 给出。标签维持:bug / dsh / scope/wiring / p1(floor 8 已申报,未变更)。 冲突处理完成:分支已与 master 同步,GitHub 报告 mergeable=true(当前状态 blocked = 等 CI 检查,开放 PR 的正常态)。 八问:
未出现需要设计决策的冲突,故未开 decision-request issue(auto-fix 车道规则)。等待 |
…r the WS-lane consumer (#4829 review) The #4829 change made the none arm settle via maybeNegotiatedClaim(...).then(...), which returns a Promise in every case. native-ws-intercept.ts compares its gate result with === false WITHOUT awaiting — a Promise never equals false, so an unattributed no-init (WS-shaped) call would stop being refused and be rewritten onto the proxy instead of going direct. Without init there is no body to decode and the claim can never succeed (maybeNegotiatedClaim returns undefined immediately), so fast-path that shape synchronously: exact pre-change verdict class restored, async decode kept for HTTP shapes only. dsh-native.test.ts now pins the sync verdict class (raw === false before the await).
…mit (review nit)
fcdb843 to
06964c6
Compare
(ai: vllm-qwen/qwen3.8-27b) 复审完成。结论先行:本 PR 可合并(最终 head 结构化八问
披露的行为变更(旧 → 新)
验证与 CI
判定可合并。合并后 #4829 自动关闭(Closes #4829)。后续跟进见 #4841(p3,WS 车道契约缺口,A/B 修法待拍板)。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.854-master.9d59116 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #4829
What & why
The Codex SSE transport (pi-ai) ships request bodies as zstd-compressed
Uint8Arraywith acontent-encoding: zstdheader.bodyJsonOf()insrc/agent/dsh-native.tsparsed byte bodies as plain UTF-8 text only, so every such body failed the fork-adoption body-parse gate: seeded fork children of long compressed conversations could never adopt the parent's compression state (resume-inheritance miss → multi-million-token preflight compression → client disconnect before the model request was forwarded). The same blind parse also made the #4082 negotiated recall silently skip encoded retries.Fix
bodyJsonOfnow readscontent-encodingfrominit.headers(Headers instance /[name, value]pairs / record shapes) and decodes through the server-side codec table (src/content-encoding.ts: gzip/x-gzip/br/zstd-via-fzstd/deflate) before JSON.parse. Decoding is inspection-only — outgoing bytes are never touched.limitsDecodedBytes()knob) still yieldsundefined= today's behavior; string bodies parse as-is (a JS string cannot be compressed).maybeNegotiatedClaimbecomes async; the takeover gate'snonearm settles via.then()preserving today's control flow exactly (streak reset only on non-claim). The gate contract already tolerates Promise verdicts (threw arm). Review refinement (61f31b9): the no-init shape fast-paths SYNCHRONOUSLY — no init means nothing to decode and the claim can never succeed — so the WS-lane consumer that compares its gate result with=== falseWITHOUT awaiting (src/agent/native-ws-intercept.ts) keeps receiving exactly today's synchronous verdict for that shape;dsh-native.test.tspins the raw (non-awaited) verdict.Behavior changes (intended, disclosed)
skipped at the body-parse gateis preserved).dist/agent/dsh-native.jsgrows ~15 KB (codec wiring; the zstd/WASM decode base was already in this agent entry on master).Config surface
No new config. Reuses the server-side codec table and the existing
network.decodedBodyBytes/BILI_DECODED_BODY_BYTEScap (default 10 GiB), so lane and proxy share one understanding of which codings are understood.Tests
tests/issue4829-zstd-fork-gate.test.tspins both directions (Test Blind Spot Retrospective: Reinforcing Negative Assertion Discipline, Tightening Fake Upstream Strictness, Thin Inst | 测试盲区复盘:补反向断言纪律、假上游严格化、薄安装冒烟、形态矩阵与生命周期覆盖 #3617): zstd and gzip bodies reach the adopter protocol; undecodable bytes under a supported coding and unsupported codings hit the body-parse gate exactly once; plain-text failures keep hitting the gate with the updated message.dsh-native.test.tsgate assertions updated to await the now-async none arm (same idiom the threw arm already used).=== falseassertion pinning the no-init sync verdict class (thenative-ws-intercept.tsconsumer contract).kernel-change declaration — superseded by rebase (2026-10-26)
An earlier revision of this branch (fcdb843) merged origin/ci-fixes into the PR, which carried two
kernel/package-lock.jsonlines (recorded versions synced with acp-kernel 0.0.165) into the diff and tripped the coarse kernel-guard Rule 1; akernel-change:declaration was then added to the body to unblock the gates. That branch form has been REPLACED by a rebase onto master (341e76c), whose lockfiles are already in step with acp-kernel 0.0.166 — the PR diff now contains ZERO kernel/ files, so the guard cannot fire and the declaration is no longer needed (left noted here for provenance). Branch history is now linear: fix (308c009) + review refinement (61f31b9) + whitespace nit (06964c6).