Repository navigation
[PR] fix: give-up direct send must not ship the lane-rewritten payload (#3304) - #3535
ranxianglei wants to merge 4 commits into
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4209-pr.3535.59c1064This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3535.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 收到,开始独立审阅本 PR。先报查重结论(动手前): 查重: 重复 —— 与 PR #3529 同 issue(#3304)、同症状、同机制。 两个 PR 都 Closes #3304、都在修「give-up 降级直连把增量车道改写后的 envelope 原样发给裸上游」这一个根因,只是实现形态不同(#3529 = 接下来按 PR Review 规范走:①原 issue 方向核对 → ②既有行为回归清点 → ③逐行代码审查 → ④测试有效性 → ⑤diff 整洁度/代码质量,本地只做定向测试,全量看 CI。有结论按八问体例跟帖。 |
…re suite Review supplement for #3535: the intercept-level suite covered the respawn-fail, routed give-up and bootstrap-fail exits, but not the unattributed gate-fail direct send — the third exit reachable with an opencode pre-swapped envelope (the V2 hook swaps before fetch, so the body is already the lane envelope when the attribution gate refuses the caller). Add the missing case: refused attribution + pre-swapped body must travel upstream as the original payload.
3b4ab02 to
8d8d985
Compare
…re suite Review supplement for #3535: the intercept-level suite covered the respawn-fail, routed give-up and bootstrap-fail exits, but not the unattributed gate-fail direct send — the third exit reachable with an opencode pre-swapped envelope (the V2 hook swaps before fetch, so the body is already the lane envelope when the attribution gate refuses the caller). Add the missing case: refused attribution + pre-swapped body must travel upstream as the original payload.
(ai: vllm-qwen/qwen3.8-27b) 冲突已解决,rebase 完成并推送。分支现在在 master 冲突点(仅一处):
顺手小修(独立标注 commit 验证(rebased head 本地定向):typecheck clean;build green(含 八问
收工判定:分支已与 master 干净对齐、可合状态待 CI 绿灯;评审结论(含与 #3529 的去留取舍)仍由评审线程给出,本次仅完成冲突处理。 |
…dVerdict aliases (#3304) The unused-exports gate (scripts/check-unused-exports.mjs) flags both type aliases: they are referenced only inside native-intercept.ts (the lane guards are typed structurally through NativeInterceptState.directGuard). Dropping the leading `export` is the gate's prescribed INTERNAL_ONLY fix; no import changes anywhere. Reviewer-side CI fix on top of cc1db28.
(ai: vllm-qwen/qwen3.8-27b) Review 结论:可合并(两件待你拍板的事见文末)结构化八问
测试有效性:tests/issue3304-giveup-restore.test.ts(11 例)断言有牙——fakeFetch sink 证明「routed 尝试携带 ENVELOPE、直发携带 ORIGINAL」;refuse 例断言上游流量为零;throwing-guard 例断言 fail closed;omp/opencode 是 lane 级真实 probe server 证明;pi ledger 覆盖 note/consume/clear/TTL。原 bug 回归时抓得住。 review 中发现的小问题,已直接修进 PR 分支(标注 commit):
CI 证据(远程,head ee5e9d6):主 CI 19/19 jobs 全绿(unused-exports/typecheck/build/全部 test shards ubuntu+windows × node22+24/red-signal/static-gates)+ e2e 全 lane 全绿(real codex、native-dsh/opencode/pi、codex-persona、fake-codex、local-registry、windows overlay、pi-codex-ws)。唯一红的 重复 PR 处置建议(待你拍板):#3529 与本 PR 重复(同 issue #3304、同症状、同机制,首条回复已给查重结论)。建议保留本 PR、关闭 #3529 为 superseded:本 PR 已 rebase 干净、覆盖全部四条 lane(含 triage 后期才发现的 pi)、fail-closed 语义更强(本地 503 vs TypeError)、CI 全绿;#3529 对 master dirty,其设计(prepareDirectSend hook + turn-id token stash TTL 5min + pi envelope sniffing)已被团队自己的后续重做取代。注意:这偏离字面「先来后到」(会保留更早的 #3529),理由是后者在实现与状态上均严格更优——请确认或另行指示。 治理点(非阻塞,一句话):#3304 floor 14 写「收到拍板:方案一(A+B 混合)」,但 thread 里 floor 13→14 之间没有 owner 消息。实现方向与 issue 自身建议的方案 A + B 安全网一致,也符合你 floor 5 的指示(「这个master修复了吗 没有修复提交pr」),所以不拦;若你其实倾向纯 B(不还原、只拒绝),说一下我再调。 判定:方向对(根因修在源头层间交接,不在症状层堵),回归逐项清点无漂移,CI 全绿,发现的小问题已直接修——可合并。待你:① 合 PR(我不能合,请自行操作:https://github.com/ranxianglei/billion-context/pull/3535);② 确认关 #3529;③ 如介意,补一句 A+B 方案的正式确认。 |
|
(ai: zhipuai-lb/glm-5.3) 陈旧票清理(第三批动作①):目标 issue #3304 已关。为避免重复劳动关闭本 PR;如判断有误请直接 reopen 并留言。 |
Closes #3304
What was broken
When the bili proxy dies mid-session, the fetch intercept degrades to a DIRECT send of the model request (the documented #1130 fallback). If an incremental lane had already swapped that request's body into its envelope (seed / delta / resync —
{conversationId, sinceSeq, path, request{...}, messages}), the bare upstream cannot parse it: the old code shipped the rewritten body anyway. Same for a pre-fetch swap (opencode) or the pi extension's payload replacement. Result: silent content corruption on exactly the turns where the user is already losing compression.The fix
Every one of the six direct-send exits in
src/agent/native-intercept.tsnow consults an optionalstate.directGuardarmed by each lane that swaps bodies:(body, headers)at swap time, keyed by init identity (WeakMap); the guard restores them.Requestin aWeakMap<Request, Request>; the guard rebuilds a direct request from it (refuses if its body stream was already consumed).event.payloadin a shared per-sid ledger (incremental-client.ts, TTL-bounded); the pi-native guard reads the sid fromx-bili-plugin-conversationand restores. The ledger entry is cleared on every non-swap path so an entry only ever exists while the current request was actually swapped.Verdict semantics: restored pair → sent verbatim; unrestorable or throwing guard → fail closed with a local
503+x-bili-gate:giveup-restore-refusal(+retry-after: 1, provider-shaped error body) instead of shipping a lane envelope to a provider that cannot read it. A dead proxy is transient infrastructure state, not a request error — the next turn re-plans against the respawned proxy.Behavior change (old → new)
No config surface added. No kernel change. No wire-format change for any working path.
Evidence
New suite
tests/issue3304-giveup-restore.test.ts(10 tests): intercept-level coverage of every exit class (rewrite give-up restore, unswapped byte-identical anchor, refuse → local 503 with zero upstream traffic, throwing guard → fail closed, routed give-up, pre-swap bootstrap failure) plus lane-level restore proofs for omp / opencode (real probe server + real swap) and the pi ledger semantics (note/consume/clear/TTL) + pi-native guard header routing.Local targeted run on the rebased head (origin/master @ 3f513c2): typecheck clean, 217/217 across
issue3304-giveup-restore,native-intercept,native-intercept-selfheal,incremental-lane,incremental-client-recovery,opencode-incremental,omp-native-incremental,issue3343-incremental-divert-authz,apig-resign,pi-omp-fork-adopt,plugin-fork; build green incl. the dist zod gate. Full-suite verdict: remote CI.