Repository navigation
[PR] fix: explicit plugin host identity outranks Codex UA guessing for host-side policy (#3686) - #3696
Conversation
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 按失败签名(host 身份判定 vs wire profile 分离、 标签: 独立审查进行中:方向/回归/代码/测试有效性/diff 逐项核对,CI 当前 pending。结论稍后按八问给出。 |
9527233 to
f37c820
Compare
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4718-pr.3696.61fc2a3This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3696.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) Rebase 完成,冲突已解。分支 八问:
收工判定:冲突已清除,等 CI 绿即可进入人工审核(identity/session-binding 类,按设计不走 auto-merge)。 |
(ai: vllm-qwen/qwen3.8-27b) 独立审查结论:可合(待 CI 绿);需人工合并(触碰 identity/session-binding,auto-merge gate 按设计不通过)。 审查方式(独立于作者描述重做):全 diff 逐段通读;枚举全仓 ① 方向(审原 issue):正确,打到根因。根因是一个谓词同时承担两种语义不同的决策(宿主身份 vs wire profile),修复是拆谓词+逐点重指,不是在某层过滤症状。拆分边界划对了:wire shape 跟随呈现的字节(#2733 relay 验证的是 presented bytes),host policy 跟随声明身份。作者未动的两处相邻点我独立核过: 结构化八问:
④ 测试有效性:新套件是真测试——谓词矩阵(含 array UA、token fallback、空 marker fallthrough、假设性 declared-codex)、control(真 codex 在两 bar 之间折叠:≥1 summary call 且全部 codex-shaped、block active)、bug pin(declared pi 同尺寸 → 恰好 1 次上游请求、零 summary call、无 fold)、#2733 pin(超满窗折叠且 summary call 保留 codex 签名,否则 strict fake relay 400)。band 算术确定(listen(0)、defaultCountTokens、实测 19.7K/18.2K 夹在 18K/20K 之间),本地复现 7/7。一个非阻塞缺口:preflight bar 之外重指的站点(CCR/image arming、compact-trigger dispatch、forge gate、 ⑤/⑤b diff 与代码整洁:单 commit、6 文件 +362/−11,每行都与 PR 目的相关,无无关改动/空白噪音;命名达意( Open item( 收工判定:方向正确、根因修复、回归清单全过、测试有效、diff 干净——可合;等 CI test lanes 绿后由人工合并。 |
(ai: vllm-qwen/qwen3.8-27b) 补充(rebase 复核 + CI 状态 + gate-plugins 红叉说明): 1. 分支已 rebase 到最新 master,修复内容未变。 10:59Z head 从 9527233 变为 f37c820(父提交现为 master tip 6d9620f)。我逐行对比了两个 head 的 fix diff:6 个文件的改动逐字节一致,仅 hunk 行号平移,外加一行上下文是 master 自身在 handle.ts 注释里把 2. CI 状态(新 head f37c820): 13 条侧车道全绿(real codex / codex-persona / pi-ws / dsh native+plugin / opencode / fake-codex / image / theorem / windows codex overlay / local-registry / artifact);主 CI 矩阵 18 腿中 17 腿绿,仅剩 3. ci-gate-plugins.yml 的红叉不是本 PR 造成的。 这是全仓已知现象:自 #3416 的 gate 工作流进 master 起,每次 push(含 master)都会多出一条「幽灵 run」——零 job、秒失败、annotations 404、run 名显示为原始文件路径。今天 master 自己的两次 push(runs 39119866740 / 39118844763)同样失败。该现象已有跟踪项 #3532(closed),我在那里补了最新证据并请求处置决定(重开,或注明「可接受噪声」)。它不在 required checks 里,不实际阻塞合并。 结论不变:CI 全绿后可合;需人工合并(identity/session-binding 类变更,auto-merge 门按设计不适用)。 |
(ai: vllm-qwen/qwen3.8-27b) CI 终局:主 CI(run 39121394573)completed/success——test / static-gates / guard 矩阵全绿(唯一非绿项 最终判定:可合。本变更属 identity/session-binding 类,auto-merge 门按设计不适用,需人工合并;合并后 #3686 由 Closes 自动关闭。 PR 内遗留的唯一待决项(不阻塞合并): |
|
冲突 |
isCodexClient conflated two signals: which HOST is sending (codex-only compaction policy) and what WIRE PROFILE it presents to the relay (#2733 summary payload shape). A native Pi request that deliberately carries a codex-shaped User-Agent for relay compatibility was read as "host is codex" and inherited every codex-only policy — most visibly the 0.9 preflight health bar, which starts compressing at 90% of the window although pi has no native auto-compaction to race against. Split the predicates in src/codex-compact.ts: - isCodexHost: an explicit x-bili-plugin marker declares the host identity and outranks UA guessing; absent -> UA detection unchanged. The marker name is read directly (no plugin.js import: plugin.ts reaches this module's top-level constants through loop/tag-echo-filter.ts, so importing it back closes an ESM cycle and crashes on the TDZ of CODEX_FORGED_HANDOFF_HEADER; same literal-read discipline as session-id.ts / anon-provenance.ts). - codexHealthBarApplies = isCodexHost && BILI_CODEX_COMPACT=intercept. Host-policy sites now use isCodexHost: preflight overflow target (server.ts), codexLane local-compaction reconcile + growth-fold nudge caps, forge gate, /responses/compact gate (prepare-responses.ts), CCR + image-rescale arming + compaction-trigger dispatch (handle.ts), and the lane-decisions wire-client registry's codex entry (explicit markers are declared identities, not observed headerless clients). Wire-profile sites stay UA-based (preflight summary shape, #2733); codexAlignedWindow stays UA-gated per the #321 PR-E1 contract. Tests: tests/issue3686-pi-codex-ua-host-policy.test.ts — predicate matrix (string/array UAs, token fallback, blank markers, declared codex), plus loopback e2e through a strict #2733-style relay: genuine codex still folds at the lowered bar; declared pi at the same size makes zero summary calls (the bug pin); declared pi past the full window folds with every summary call keeping the codex wire shape.
f37c820 to
c0ae98d
Compare
(ai: vllm-qwen/qwen3.8-27b) 上游冲突已解决:分支已 rebase 到当前 master( 冲突点(唯一一处): 解法取双方意图的并集:保留 master 的 #3450 本地定向验证(全量回归以远程 CI 为准):typecheck 干净; 八问:
收工判定:冲突已清除,等 CI 绿后可合。 |
(ai: vllm-qwen/qwen3.8-27b) 刚用 API 复核过当前状态:冲突已不存在——
如果你那边面板仍显示 dirty,是镜像同步滞后,GitHub 侧已是干净状态。现在只剩 CI 跑完变绿,之后由你合入即可。若你指的是别的冲突(比如某个具体文件或与其他在途 PR 的语义撞车),说一声位置,我马上查。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.660-master.76d4c7a # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #3686
查重: 不重复。相关条目: #2733 (strict-relay summary wire shape — this PR keeps it UA-driven and extends its fixture to the declared-pi case); #3663 (author-stated separate reporting problem, untouched); #3270/#3266/#3272 (origin of the CCR/image-rescale codex-lane disarm now narrowed to true codex hosts); #150/#1106 (instructions-fingerprint allowlist whose codex entry gains the explicit-marker exclusion). No existing issue/PR implements the host-vs-wire identity split.
Root cause
isCodexClient(headers)(UA sniffing) was serving TWO different decisions at once:/responses/compactinterception, CCR + image-rescale disarming, instructions-fingerprint session keying.include:["reasoning.encrypted_content"]).For headerless clients the UA is the only evidence for both — fine. For an explicit plugin host (
x-bili-plugin), the marker IS the authoritative identity, and a codex-shaped UA on that traffic is user-chosen relay compatibility. A native Pi request markedx-bili-plugin: piwith a Codex UA therefore inherited every codex-only policy: most visibly the preflight bar at 90% of the window (issue repro: 272000 − 68000 output reservation = 204000 budget, compression starting near 183600) although pi has no native auto-compaction to race against — so every early fold was pure cost, amplified when summaries failed.Fix — one predicate split, sites re-pointed
src/codex-compact.ts:isCodexHost(headers)— explicitx-bili-pluginmarker declares the host and outranks UA guessing (agent === "codex"; no marker → UA detection byte-identical to before). The marker name is read as a local literal — importing plugin.js back would close an ESM cycle (plugin.ts → loop/tag-echo-filter.ts top-level read ofCODEX_FORGED_HANDOFF_HEADER) and crash in the TDZ; same literal-read discipline as session-id.ts / anon-provenance.ts.codexHealthBarApplies(headers)=isCodexHost && BILI_CODEX_COMPACT === "intercept"— the single gate behind both lowered-bar sites.Site checklist (host policy →
isCodexHost, wire profile staysisCodexClient):isCodexClient && mode==interceptcodexHealthBarAppliescodexLane(local-compaction reconcile + nudge caps)isCodexClientisCodexHostisCodexClientisCodexHost/responses/compactgateisCodexClientisCodexHost!isCodexClient!isCodexHost!isCodexClient!isCodexHostisCodexClientisCodexHostx-bili-pluginmarkerisCodexClientcodexAlignedWindowisCodexClientBehavior changes (old → new)
Only requests carrying BOTH an explicit
x-bili-pluginmarker AND a codex-shaped User-Agent change behavior (today: pi over strict codex relays):limit × 0.9→limit(full window bar; the nudge-side growth-fold cap lifts with it).compaction_triggerspecial dispatch,/responses/compactinterception: no longer apply to the declared non-codex host (its trigger items take the ordinary path).acp_retrieve) and image-rescale: ARMED again where previously disarmed — the disarm reason (codex host rejects bili-injected tools, fix: image_full 死循环(#3266)——codex lane 上 restore 通道结构性不可用:按宿主门控 + 提示/回执列出可恢复 ref #3270) does not hold for plugin hosts, which register bili's tools natively.codexAlignedWindow): UNCHANGED.Headerless clients (genuine codex CLI, all other clients): byte-identical behavior — no marker means the UA fallback path, which is the old code. Wire shape of preflight summary payloads: unchanged (still UA-driven; #2733 strict relays keep accepting them — covered by the extended e2e).
Open item (owner decision, NOT changed here)
codexAlignedWindow(src/codex-models.ts) still gates on the raw UA: a declared pi host with a codex UA still gets its effective window aligned against codex's model table when it stamps no context-window header. Left as-is deliberately: the issue author scoped it out ("native model window … not changed as the solution") and tests/codex-window-align.test.ts pins the current contract under #321 PR-E1 (declared marker + codex UA → clamp). If the owner wants declared-host windows to skip codex-table alignment too, it is a one-line swap toisCodexHost+ updating those five e2e expectations — tracked here rather than filed separately (same mechanism family).Verification (local, targeted — full verdict is remote CI)
New suite
tests/issue3686-pi-codex-ua-host-policy.test.ts(7/7 green), including loopback e2e through a strict #2733-style relay at LIMIT=20_000 (bars 18_000/20_000, measured hermetic totals ≈19.7K genuine codex vs ≈18.2K declared pi):Adjacent targeted suites green: issue2733-preflight-codex-shape, codex-compact(-e2e), codex-window-align, codex-models, codex-live-window, lane-decisions-matrix, issue3272-ccr-codex-lane-gate, preflight-compress-responses, codex-local-compaction*, codex-turn-isolation*.
npm run typecheckclean,npm run buildOK.No kernel/ changes, no config-surface additions, no persistence-format or signed-reasoning changes. Human review required (identity/session-binding logic ⇒ auto-merge gate fails by design).