Repository navigation
fix(#2592): sniff the unattributed raw-URL branch for the dsh compaction envelope - #2763
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3039-pr.2763.bc08d66This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2763.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…ion envelope The #1117 unattributed-raw-URL branch was the last lane an agentless dsh compaction call could LAND through: no settings overlay routes it, the takeover gate refuses attribution, so the fetch sent direct to the provider (the 4/49 field-report leak shape; only the post-hoc rebase floor #2742 caught it afterwards). Divert ONLY marker-sniffed POSTs into the proxy's unattributed passthrough lane (same x-bili-passthrough stamp the overlay-routed case uses), where the #2709 guard runs the marker-decisive last-user-message check: refused (403, dsh logs 'step compaction failed' and continues the turn) or, with allowDshCompaction (#2028), relayed verbatim by explicit user decision. - client prefilter mirrors DSH_COMPACTION_MARKER_SNIFF (first 48 chars of the directive); over-matches cost one loopback hop, the server stays decisive - body forms: string / URLSearchParams / Uint8Array / ArrayBuffer / Blob inspected; Request-object input probed via clone (#2496-safe); ReadableStream/FormData fail OPEN to today's direct send (#2742 backstops) - dead proxy (origin not ready) fails open to direct send Verified live end-to-end: unattributed raw-URL envelope -> 403 dsh_compaction_refused with ZERO bytes reaching the upstream; ordinary unattributed traffic unaffected (200, verbatim at the upstream).
…rror instead of re-deriving slice(0, 48) Review finding on #2763: the client-side fetch patch re-derived the same 48-byte dsh compaction directive prefix locally (DSH_COMPACTION_INSTRUCTION_PREFIX.slice(0, 48)). If the server sniff length ever changed, the two mirrors would silently diverge (client stops diverting what the server would refuse). Export the server constant and import it — no semantic change. Verified: tsc clean, unused-export gate clean, native-intercept + dsh-compaction guard/#2709/#2658 suites 111/111, build bundles the marker into dist/agent/dsh-native.js.
a2a6e15 to
62f41f7
Compare
[bot] 🏷 Review 完成 — 结论:可合(merge 由人执行) 审核过程:先对原 issue #2592(机制族 F1–F5)做方向关——本 PR 关闭的是该族最后一个"compaction checkpoint 能落地到 provider"的通道(client fetch patch 的 #1117 unattributed-raw-URL 分支),与 #2709(passthrough 道)、#1835(pipeline 道)、#2742(rebase floor 兜底)共同封死;方向正确,修的是机制(未归因通道缺少内容判定)而非症状。逐行读了两个文件的 diff + 周边 dispatch 路径(takeoverGate、apig-resign 早退、routed 分支、正常 rewrite 路径),两种压缩模式都推演过:passthrough lane 在 session 之前、plugin/proxy 模式均不受影响。测试有效性:7 个新 case 断言有牙(divert sink URL、 结构化八问:
本地验证(rebased head):分支原落后 master 46 个提交,已 rebase 到当前 master 顺手小修(已推,labeled commit 可选加固(不阻塞):live full-chain 证明(真 startServer + fake upstream:envelope→403、upstream 零字节)是 ad-hoc 跑的,未落成常驻 e2e test;两端各有 unit 层钉住,组合是直通管道,可接受。 新 head |
[bot] 🏷 补充:CI 全绿,状态更新 新 head 期间 master 又前进了一个大批次(#2690 unified SQLite storage + #2765 v0.1.192 元数据同步,64 文件 +6088/-44),PR 因此显示 BEHIND。已核查:该批次与本 PR 触碰的 结论不变:可合,merge 由人执行。#2763 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.284-master.4d13c4a # this exact build
npm install -g billion-context@master # always the newest merged build
|
What
Closes the last lane an agentless dsh compaction call could land through (#2592 field-report shape): the native fetch patch's
#1117unattributed-raw-URL branch.Leak chain being closed: dsh background/manual compaction is agentless (no initiator attribution) →
takeoverGaterefuses it → without the settings overlay nothing routed the URL to/bili/→ the fetch sent direct to the provider → the checkpoint landed and destroyed the compression substrate. Previously only the two proxy-side lanes were guarded (pipeline #1835 + passthrough #2709 — "45 refused, 4 landed" report), and after landing only the post-hoc rebase floor (#2742, just merged) contained the damage.Change (client-side divert, server stays decisive)
In
src/agent/native-intercept.ts, the unattributed-raw-URL branch now body-sniffs POSTs for the dsh compaction directive (client mirror ofDSH_COMPACTION_MARKER_SNIFF— first 48 ASCII chars ofDSH_COMPACTION_INSTRUCTION_PREFIX) and diverts only marker hits into the proxy's unattributed passthrough lane, stampedx-bili-passthrough: 1exactly like the overlay-routed case. The #2709 guard there runs the marker-decisive last-user-message check:dsh_compaction_refused(dsh logsstep compaction failed: …; continuing the turn, history untouched, turn continues — same recovery the 45 pipeline refusals proved in the field);allowDshCompaction(在bili网页配置界面支持关闭和开启dsh的自动压缩功能 #2028 opt-out), relayed verbatim by explicit user decision.Fail-open discipline (unchanged #1117 semantics for everything else):
Request-object inputs are probed through a clone so the original stays sendable (#2496).init.bodywins over the Request's own body (spec order, mirrorsfetchMethodOf).Tests
tests/native-intercept.test.ts: divert + passthrough stamp + onDispatchrewrite; no-marker direct; not-ready fail-open; Uint8Array divert / URLSearchParams form-encoding cannot carry the raw marker (documented); ReadableStream fail-open; Request-object divert withbodyUsed === false.startServerproxy + fake upstream + installed patch): unattributed raw-URL envelope → 403dsh_compaction_refused, zero bytes reach the upstream; ordinary unattributed traffic → 200, upstream receives the body verbatim.tscclean,npm run build(directive verified bundled intodist/agent/dsh-native.js), e2e-native-dsh 2/2. (The oneopencode-nativefailure is pre-existing on clean master in this environment.)Together with #2709 (both proxy lanes), #2658/#2474 (auto-compaction off), #2622-lineage routing and #2742 (rebase floor + receipts), dsh compaction now has no unguarded path to a provider while bili is alive.
Refs #2592, closes the residual leak tracked there. Follow-up: none known.