Repository navigation
fix(affinity): project responses/google wire renders into the neutral identity domain (#2791) - #2839
Conversation
… identity domain (#2791) blockText() only knew text|thinking|redacted_thinking content types, so a responses-wire render (input_text/output_text blocks) hashed to canon-JSON blobs instead of turns: openai==responses identity equality was FALSE while openai==google was TRUE. resolve()/chainFingerprint hash neutralTurns(raw wire input) (src/prefix-affinity.ts:553, :923) with no pre-conversion, so any responses-wire client (codex /v1/responses proxy mode, dsh openai-responses) forked a pfa-* session on a cross-wire model switch — the #2791 silent-fold-loss class. Also align the merge boundaries: gemini splits commentary and function call across contents[] items while openai merges across messages — model items now merge into the pending assistant run (mirroring the openai block-list branch); responses function_call sibling items merge into a pending run when one exists; google functionResponse unwraps its transport wrapper ({output:}/{result:}/{content:} single-key-string conventions). Tests: - unit: all four wire renders (openai/anthropic/responses/google) project to IDENTICAL neutral turns; mid-session switch onto responses AND google wires resolves via:"prefix" with the same sessionId in both directions. - proxy e2e: cross-wire switch onto the responses and google lanes keeps the session AND its fold (pfas===1, carrier attached, no re-fold) — red green proven against the pre-fix src (pfa fork fails the test). - real-client pi e2e: openai→responses switch (fakeresp provider on the openai-responses API) keeps conv/session/fold; the anthropic-switch test gains the reverse (anthropic→openai) leg. Note: responses sessions' neutral hashes shift (text-turn canon fix + merge boundaries) — a live responses-wire anonymous session will miss prefix-resolve ONCE on upgrade and re-fold, same migration class as the hv1→hv2 bridge, smaller population.
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3142-pr.2839.15a321cThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2839.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 收到。这是 #2791/#2812/#2819 的 gap-scan 后续 PR(responses/google wire 的 neutral identity 投影 bug)。开始按 PR review 规范审查: 计划
初判后给结构化八问结论。 |
[bot] 🏷 Review 完成 — 结论:可合(mergeable)。以下为结构化八问。 验证证据(先放硬证据)
八问1. 是什么问题:#2791 建立的 wire-neutral identity 投影对 responses/google 两条 wire 不完整——responses 文本轮被投影成 canon-JSON blob 而非纯文本、两侧 assistant run 的合并边界不一致,导致同一会话换协议重放时哈希对不上,prefix-resolve 落空,fork 出 2. 什么原因导致的:根因在投影函数本身(生产者层):① 3. 影响范围与严重程度:触发条件明确——匿名(无身份头)会话 + 会话中切协议:codex 4. 怎么修复的:补全 5. 是否有回归问题:未发现无意回归。逐项清点触碰路径的既有行为:openai/anthropic 投影逐字节不变(新分支只响应 responses 专属 type 名与 google parts 形状;65/65 定向绿佐证);hv1/hv2 域种子分离("v2"/"v2i\0" vs raw)保证升级后旧条目不可能跨域误配,只会按披露机制一次性失配后重新 mint;400 no-identity 路径、上游转发字节、持久化格式、kernel 均未触碰;#1115/#629 反收养纪律未被削弱(byte-exact 阶梯 + user-word 锚点原样)。有意行为变更(已披露类):responses/google 匿名会话的 neutral 哈希整体平移 → 升级后每个受影响活跃会话 miss 一次 prefix-resolve、mint 新链、re-fold(与 #2812 hv1→hv2 桥同类)。 6. 是否破坏缓存:不影响上游 prefix-cache 机制本身;本修复恰恰移除一个缓存归零源(fork→re-fold)。升级期一次性 re-fold 是已披露成本。 7. 是否改了设计方向:没有转向——把 #2791/#2807/#2812 的 neutral-domain 设计延伸到剩余两条 wire 家族,架构、边界、数据流不变。 8. 是否引入了新的配置:无。(测试里用到的 其他
判定:可合。 唯一建议动作:修正 PR 正文中 google 平移人口的措辞(可选但建议),然后直接 merge。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.295-master.011bf5e # this exact build
npm install -g billion-context@master # always the newest merged build
|
Follow-up to #2791 / #2812 / #2819 (gap scan asked for in #2791 discussion): scanning the remaining protocol matrix surfaced a REAL bug, not just a gap.
The bug
blockText()insrc/affinity-neutral.tsonly handledtext | thinking | redacted_thinkingcontent types. A responses-wire render (input_text/output_textblocks — the OpenAI Responses API shape used by codex/v1/responsesproxy mode and dshopenai-responses) projected each turn to a canon-JSON blob instead of its text:resolve()andchainFingerprinthashneutralTurns()over the RAW wire input (src/prefix-affinity.ts:553, :923) with no pre-conversion. So a responses-wire client that switches protocol mid-session (or any cross-wire continuation) missed prefix-resolve and forked apfa-*session — the exact #2791 silent-fold-loss class: fold ledger orphaned, history re-arrived unfolded, upstream re-folded from scratch, cache reset.Red-green: stashing the
src/affinity-neutral.tshunk fails the new proxy e2e withgot pfa-da71ba97cbee4154, pfa-f61ed9a2914da1ba.The fix (
src/affinity-neutral.ts)blockText(): acceptinput_text/output_text.contents[]items while openai merges across messages — model-role items now merge into the pending assistant run (mirror of the openai block-list branch).function_callsibling items merge into a pending assistant run when one exists (codex splits commentary message + function_call items).functionResponse: unwrap transport wrappers ({output:}/{result:}/{content:}single-key-string conventions) before canon.Coverage matrix (this PR's additions)
pfas===1)fakerespprovider, openai-responses API)Real-client notes: the pi plugin normalizes messages before resolve, so the pi lane is behavioral coverage (conv/session/fold/persistence across the switch), while the proxy-level test is the regression catcher for the projection itself (it fails on the pre-fix src).
Upgrade note
Responses: effectively ALL anonymous responses-wire sessions shift — every text-bearing turn (canon fix) plus the function_call merge boundaries.
Google: not just split renders — the merge also shifts the COMMON single-item shape (one model
contents[]item carrying[text, functionCall]parts), and thefunctionResponseunwrap shifts every tool result whose response is a string or single-key-string object. Net: effectively all tool-using anonymous google sessions.Per affected ACTIVE session crossing the upgrade boundary: one prefix-resolve miss → mint a new chain → one re-fold. No history loss (the client holds it); self-heals after the first fold round. Same migration class as the hv1→hv2 bridge (#2812). openai/anthropic projections are byte-identical pre/post (pinned by the existing hash tests), and plugin-headered clients (dsh/pi/codex-overlay) don't key on the hash at all. The single-key unwrap deliberately drops the wrapper key name (
{output:"x"}≡{result:"x"}); a cross-convention collision requires a whole-chain match — acceptable heuristic, documented in the code comment.Test plan
npx tsc --noEmitcleanACP_TEST_E2E_NATIVE=1): cross-protocol switch + new openai→responses test, green twice consecutively; red-green at proxy layer