Skip to content

[PR] fix(invariants): bind separator exemptions to producer-owned wire items - #5478

Merged
ranxianglei merged 10 commits into
ranxianglei:masterfrom
Maziar123:fix/invariant-provenance
Nov 9, 2026
Merged

ranxianglei merged 10 commits into
ranxianglei:masterfrom
Maziar123:fix/invariant-provenance

Conversation

@Maziar123

@Maziar123 Maziar123 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4388 for the producer-separator false positive and the answered-compress pairing gap covered here. Other ordering incidents remain separately tracked.

Supersedes #4442 if the owner selects this provenance-based approach. The two separator exemptions are mutually exclusive and must not both be merged; the owner retains that choice.

Problem

The invariant judge needs to distinguish a producer-inserted Responses turn separator from client-owned content with identical prose. It also must not treat an already-answered compress call as genuinely pending when its outbound result disappears.

Change

The host Responses producer mints the canonical rawResponsesItem carrier. One linear identity walk of the final codec output binds its owned indexes to the existing serialized body. The judge maps those indexes through its actual-wire decode; no second codec render, text/prefix whitelist, per-item serialization or quadratic search. Replaced, missing or rewritten carriers/bodies fail closed. Client-identical prose alone never acquires ownership.

Complete outbound compress pairs remain clean; an answered baseline call that loses its result is reported; genuinely pending calls and original client orphans keep their exemptions. All real callers migrate to the single producer API; no server compatibility re-export.

When producer ownership is unknown, exact byte equality is checked before the narrow separator exclusion. Unchanged client lookalikes are therefore preserved rather than reported as dropped; changed or deleted lookalikes and pairing findings remain armed. Moving this equality check before the scan-cap break also performs one additional equality probe at the former boundary. An exact match there is now retained instead of reported as lost; this does not relax producer ownership.

Verification

At fd4466cb2f, seven actual-wire suites passed 118/118 tests; typecheck, file-size, unused-export, test-import-graph and diff checks passed. Maintainer review subsequently reported 119/119 across eight focused suites and successful CI at that head. Positive and negative cases include real producer → serialize → fresh parse → judge, altered/missing carrier and client-lookalike controls, pairing, ordering and compact endpoint behavior. This evidence does not replace checks on a future rebased head.

Related work and limits

Host-only change: no kernel planner edit or persistence schema change. Related #4388 incidents outside this PR's two covered defects remain separate. Kernel investigation #5455 is also separate: current guarded public-planner controls did not produce an asymmetric answered pair, historical reachability remains unproved, and explicit human owner approval is still absent. No kernel implementation or historical-causation claim is made.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重: 与在途修复 PR 无重复立项,但与 #4442 构成竞争关系——同一症状(judge 把 bili 自己插入的 Responses 轮次分隔符误判为「客户端塞进历史中间的内容」),机制不同:#4442 按精确文案豁免,本 PR 按生产者对象身份绑定(identity-in/index-out)。两者若先后都合入,#4442 的文案豁免会重新打开本 PR 要关掉的口子(客户端亲手敲的相同文案会被再次豁免),所以必须二选一。建议以本 PR supersede #4442(身份绑定严格强于文案匹配)。保留哪个由 owner 拍板,agent 不代关。另:正文引用了 #4388/#5455 作背景但没有 Closes/Fixes 链接,合并前需补(见发现 ③)。

标签: bug / codex / scope/wiring / p3(advisory judge 准确性缺陷,codex Responses 车道,无可用性影响)

结构化八问

  1. 是什么问题:出站不变量 judge(advisory,从不挡请求)的两个盲区:①压缩后 bili 在 Responses wire 上插入自己的轮次分隔符,judge 每个折叠回合都把它误报成「客户端内容 mid-insertion」(Compression breaks Responses assistant history ordering, causing repeated invalid_assistant_history 400s #564/[Bug][Responses] acp_turn_sep 合成分隔符进入持久压缩覆盖集合,导致重复历史漂移误报 #2627 假阳性);②客户端已拿到应答的 compress 调用在配对检查里被按工具名整体豁免,它的结果若在出站丢失,没人上报([Bug][claude] 0.1.207: subagent requests fail with 400 "tool_use ids were found without tool_result blocks" right after a fold in the parent session #4862 漏检)。
  2. 什么原因导致的:①序列化后分隔符与任何同文案 user message 字节相同,内部 id 到不了 wire——内容层面无法识别所有权,旧代码里也没有所有权信息的来源;②「按名字豁免」混淆了两种状态:「进行中」(kernel hideConsumedCompressCalls 拥有其结果,出站没结果合理)与「已回答」(本应成对,结果消失 = bili 拆了对)。
  3. 影响范围与严重程度:仅 advisory(log/面板诊断面),不挡请求、不改 wire。①污染 codex/Responses 车道所有折叠回合的诊断准确性(假阳性噪音);②让真实的半配对损坏一直漏到上游 400 才暴露。p3。
  4. 怎么修复的:①身份契约四步:producer 铸造规范载体对象挂到 marker core 的 rawResponsesItem 侧车 → kernel codec 按引用原样输出该对象(已核实 coreToResponses 单 user-run 分支与 patchResponsesInput 新核插入两条路径都走引用)→ 最终数组一次线性对象身份扫描把 index 绑到 claim → claim 绑定到既有序列化 body 字符串;judge 复用同一次实际 wire 解码,经 codec 打的 wireIndex 戳把 owned index 映射到 core,只豁免这些位置。每一步 fail-closed(body 字节不符/载体被替换/缺失 → 退回原判定),客户端相同文案结构上拿不到豁免。②豁免从「工具名」收窄为「进行中 id 集」(entry 侧无同 id 应答才算进行中)。
  5. 是否有回归问题:既有行为逐项清点——分隔符插入逻辑相对 server.ts 原版是逐字搬迁(插哪些 marker 不变);非 Responses wire 与无分隔符回合 manifest 为 undefined → legacy 路径逐字节一致(空 provenance ⇒ 零豁免);非 compress 配对路径与 公告:release v0.1.193 修复dsh 切模型导致上下文暴涨问题,修复fork问题,修复claude codex dsh等自动压缩导致会话破坏问题 . 另外修复几十个bug. 我本地场景有限,未必都测全,麻烦大家小场景先测试下是否有问题.任何问题及时反馈. #2821 量守卫未动;shed 改写过的轮次不向 judge 传数组(防 stale-index 误豁免);全部调用方(prepare/relay/loop/compact/测试)已迁移到新返回形状。本地 typecheck 干净、五个定向套件 88/88 绿、unused-export 与 test-import-graph 门禁干净、CI(dd34c7b)39 success / 16 skipped / 0 failed。⚠️ 但见发现 ①:分支基线落后 master([Feature][experimental] After compression, relocate the compress call pair to its own fold point (weak-attention models | [Feature][experimental] After compression, relocate the compress call pair to its own fold point (weak-attention models | [Feature… #5470 合入前),rebase 前本条只对旧基线成立。
  6. 是否破坏缓存:否。body 仍照常构建一次,manifest 只是 O(n) 引用扫描,不重新序列化、不改出站任何字节,前缀缓存不受影响。
  7. 是否改了设计方向:没有转向。这是 Compression breaks Responses assistant history ordering, causing repeated invalid_assistant_history 400s #564/[Bug][Responses] acp_turn_sep 合成分隔符进入持久压缩覆盖集合,导致重复历史漂移误报 #2627 的正路落地:用 provenance 取代文案/前缀白名单;新文件 src/server/responses-ordering.ts 是搬迁函数的自然归宿。遗留一个 owner 决策点:与本 PR 和 [PR] fix: exempt Responses turn separators from the outbound-invariant judge #4442 的关系处置(建议 Supersedes)。
  8. 是否引入新配置:无(无 env、无 config key、无默认值变化)。

行为变更披露(强制项)

  • judge ①:旧 = 每个折叠 Responses 回合对 producer 分隔符报 N 条 mid-insertion 假阳性(N=插入数)→ 新 = provenance 成立时这些位置豁免;客户端自己敲的同文案仍照旧被判(该情形行为未变)。
  • judge ②:旧 = 所有 compress 调用按名字整体豁免配对检查 → 新 = 仅「进行中」(entry 侧无应答)豁免;「已回答但结果出站丢失」新增 unpaired-tool-call finding。属检测能力有意加强,不是放松。

发现(合并前需处理)

① 须 rebase 当前 master:分支基线 c78ecb4 早于 #5470(compress-at-fold-point)合入;#5470 恰在本 PR 改动的 relay.ts refreshFolded 排序修复调用处(~L2177)插入了 relocateCompressCarriers,直接文本冲突;server.ts 导入区也可能冲突。交互语义良性(slots 跟随 repair 作用的数组,manifest 晚绑定到最终数组+body),但必须在 rebase 后的 head 上由 CI 验证。
② 与 #4442 的关系需写明:建议正文加 "Supersedes #4442",由 owner 决定关闭 #4442(agent 不代关)。
③ 缺 issue 链接:§7.4 要求 Fixes #N——本 PR 收口哪个 issue(#4388 症状①?还是单独立项?)需补充。
④ 热点文件提示(非本 PR 瑕疵):#5279/#4410/#5093/#4023 也在改 src/invariant-judge.ts,先合者会让后合者 rebase,调度时留意顺序。

测试有效性

正负成对齐全:真实 producer→serialize→fresh parse→judge 全链、载体替换/丢失/body 单字节改动(fail-closed)、client look-alike 对照(不得获得豁免)、配对三态(进行中/已回答/宿主孤儿)、compact endpoint、round-2 连续性。断言钉住具体 violation kind 及其缺席,有牙,非恒真。

判定

代码质量过外部提交严标准(命名/死代码/重复/错误处理/魔法值/风格逐项过;注释讲 why 且与事实相符)。暂 hold:rebase 当前 master 并 CI 绿、补 Closes 链接与 #4442 关系声明后即可合;未发现需要重构的缺陷。

@ranxianglei ranxianglei added bug Something isn't working codex p3 scope/wiring labels Nov 1, 2026
@Maziar123

Maziar123 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Follow-up at fd4466cb:

  • When producer ownership is unknown, both separator fidelity scans now compare exact client content before applying the narrow separator exclusion. Unchanged client lookalikes are no longer reported as dropped; changed or deleted lookalikes and I3 pairing findings remain armed. Exact equality proves fidelity, never producer ownership.
  • The canonical separator literal, carrier predicates, and core-index mapping now live in src/server/responses-separator.ts; responses-ordering.ts is back below the 400-line limit without removing substantive documentation.

Verification: seven actual-wire suites passed 118/118 tests; typecheck, file-size, and diff checks passed. The pre-fix replay failed the three unchanged-lookalike regressions. No kernel planning or cropping behavior changed.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

第二轮审核(fd4466c)。查重结论沿用首轮(与 #4442 竞争关系不变,待 owner 拍板)。结论先行:两处修复成立、全部验证通过,代码侧 HOLD 条件已清;剩 PR 正文两项元数据(Closes 链接、#4442 关系声明)+ owner 对 #4442/#5478 二选一的裁决。

结构化八问(本轮增量)

  1. 是什么问题:归属未知(opaque 改写销毁了生产者证明)时,两条保真扫描在字节比较之前就把分隔符形元素跳过——客户端若恰好自己发过同文案且未被改动,会被误报为 dropped/rewritten(假阳性)。
  2. 什么原因导致的:原实现把「无法证明是 bili 写的」当成「这个元素可以忽略」;但逐字节相等本身是保真证据(客户端元素还在),与归属判定无关,必须先测。
  3. 影响范围与严重程度:advisory 诊断面;只影响「归属未知 + 客户端恰含同文案」的回合(原假阳性 → 现正确干净)。被改写/被删除的仿冒项、非分隔符注入项、I3 工具配对保持报警,均有测试钉住。
  4. 怎么修复的:两条扫描把 exact-equality 提到 unknown 归属跳过之前,跳过只作用于「未匹配且分隔符形」的元素;另把规范字面量/载体谓词/core 索引映射抽到 src/server/responses-separator.ts(41 行),responses-ordering.ts 回到 395 行(<400 上限)。
  5. 是否有回归问题:逐项清点——provenance 豁免路径不变(proven marker 有无 unknown flag 都豁免;空/缺失集永不豁免,负测试钉住);I3 配对、冻结前缀、render-tail 语义未动;抽取后无陈旧导入(所有消费者指向新模块,grep 核实);本地 8 套件 119/119 绿,typecheck/unused-export/test-import-graph 全净,CI(fd4466c)39 success / 16 skipped / 0 failed。⚠️ 有一处应披露的微行为变化(见下)。
  6. 是否破坏缓存:否(纯判定层顺序调整 + 模块抽取,wire 零字节变化)。
  7. 是否改了设计方向:没有;本轮反而收紧了认识论边界——「相等证明保真、绝不证明归属」写进了代码注释与 JudgeOptions 文档,与首轮的 provenance 契约一致。
  8. 是否引入新配置:无。

行为变更披露(建议作者补进 PR 正文)

两条扫描里 stableEqual(e,x) 从 scanned > cap break 之后移到了之前:效果是每个 entry 元素在旧循环会 break 的边界格上多做一次相等探测,且无条件适用(含无分隔符的 legacy 回合)。方向安全(字节相同的元素越界一格从「报丢失」变「匹配上」,与 judge 既有的按字节认身份原则一致),但严格说把扫描窗扩了一格,PR 描述里应披露一句。

验证细节

剩余项(非代码)

① PR 正文仍缺 Fixes #N(§7.4 硬性要求)——本 PR 收口哪个 issue?
② 仍未写明与 #4442 的关系(建议 "Supersedes #4442");且需 owner 裁决二选一:两者若先后都合入,#4442 的纯文案豁免会重新打开本 PR 关掉的口子(客户端同文案被再次豁免),合入顺序有实质意义。

判定

代码侧通过(外部提交严标准继续达标:命名/死代码/重复/错误处理逐项过,注释与事实相符,抽取干净)。补上 ①② 并等 owner 对 #4442 拍板即可合;cap 边界微变化不拦合并,但须披露。

@Maziar123

Maziar123 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Updated the PR body with the scoped Fixes #4388 link, the Supersedes #4442 relationship and mutual-exclusion constraint, and the one-cell scan-boundary behavior disclosure requested in review. No code changed. The owner still needs to choose between this provenance approach and #4442.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

第三轮审核(仅正文更新,head 仍为 fd4466c,无代码变化)。三处正文修改已逐字核实到位:① Fixes #4388(带范围限定句「for the producer-separator false positive and the answered-compress pairing gap covered here」);② Supersedes #4442 if the owner selects this provenance-based approach. The two separator exemptions are mutually exclusive and must not both be merged;③ 一格边界披露「one additional equality probe at the former boundary… does not relax producer ownership」。第二轮的全部验证结论与 CI 绿(39 success / 16 skipped / 0 failed)对该 head 继续有效。

结构化八问(本轮增量)

  1. 是什么问题:本轮无新代码问题;核实作者对上一轮三项要求的落实。
  2. 什么原因导致的:不涉及。
  3. 影响范围与严重程度:不涉及(正文-only)。
  4. 怎么修复的:不涉及。
  5. 是否有回归问题:出现一个新的机械性阻塞——master 自 PR 合入点(ec24a19)之后前进了约 60 个提交(v0.1.212 已发版、kernel 0.0.178、多车道合入),PR 当前 mergeable_state=dirty;文件级比对显示两侧重叠的只有 CHANGELOG.md(双方都在 Unreleased 顶部加了条目),无任何代码文件冲突。窗口内的 kernel 变更未触碰本 PR 依赖的两条机制(Responses codec 按引用输出载体、wireIndex 戳),风险低,但按 §7.2 以同步后 head 的 CI 为准——正文自己也写了「This evidence does not replace checks on a future rebased head」。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及。
  8. 是否引入新配置:不涉及。

剩余动作(各归其位)

① 作者(分支在 fork,我推不了):把 origin/master 合并进 PR 分支(加一个 merge commit 即可,勿 rebase 重写历史),CHANGELOG 冲突保留双方条目,push,等同步后 head 的 CI 绿。
② owner 裁决:#4442 与本 PR 二选一(正文已正确声明互斥并保留选择权)。
③ owner 知会(非阻塞):#4388 是多症状用户报告(I2 mid-history-rewrite、I1 mid-insertion、reasoning-pair-violated、NO known output ceiling 告警等);本 PR 只收口其中分隔符误报与配对缺口,但 Fixes #4388 会在合并时自动关闭整个 issue。若其余症状尚未单独立项,建议合并前先拆出或改由 owner 事后处置,避免未修部分被静默关掉。

判定

代码侧维持第二轮结论:通过。本轮未发现新问题;待 ① 同步+CI 绿、② owner 拍板后即可合。

…i#5478 conflict)

Union of the two divergent edits in the compat-role rewrite path: keep ranxianglei#5478's object-graph/string split for the carrier binding, and retain master's Kiro judgeRoleRestore capture in BOTH success branches (graph and string) so Kiro turns carrying a separator manifest still get the invariant-judge role restore. CHANGELOG keeps both sides' entries.
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

本轮动作:PR #5478 与 master 的合并冲突已解决并推回贡献者分支(Maziar123:fix/invariant-provenance,fast-forward,sha 6b443339a),保留了贡献者的全部原始提交与署名。共 2 处冲突,均按「两边意图并置」处理,未丢弃任一侧逻辑。

结构化八问:

  1. 是什么问题:外部贡献者 PR [PR] fix(invariants): bind separator exemptions to producer-owned wire items #5478 与 master 合并冲突(mergeable_state=dirty),CI 被卡无法推进。
  2. 什么原因导致的:PR 基线(fad9805b)之后 master 又合入了 Kiro CLI 车道改动;它与本 PR 都改了 src/server/relay.ts 同一处「compat 角色改写」——本 PR 把这段拆成「对象图路径 + 字符串兜底」两支,master 在同一段新增 Kiro 的 judgeRoleRestore(记录 bili 自己注入角色的改写点,供 invariant 判定器还原);另一处是双方各自往 CHANGELOG [Unreleased]/Fixed 顶部加条目。
  3. 影响范围与严重程度:仅阻断该 PR 自身的合并推进,不涉及任何已发布行为;属阻断性(卡在 dirty),非产品缺陷。
  4. 怎么修复的:用 merge(非 rebase,保作者署名)把 master 并入。CHANGELOG 两边条目都保留;relay.ts 保留本 PR 的双分支结构,并把 master 的 judgeRoleRestore 捕获同时放进 graph 分支与 string 分支的成功块——因为带分隔符 manifest 的 Kiro 回合走的是 graph 分支,若只补 string 支会让这类回合丢失角色还原(相对 master 反而是回归)。已核实 commitGraph() 只改 wireBody、不改 body,故两支都能安全地把原始 body 交给 builtinRoleRestorePoints。
  5. 是否有回归问题:① 本 PR 的分隔符归属绑定(graph/string 拆分、string 改写即 invalidateSeparatorOwnership)完整保留;② Kiro judgeRoleRestore 现在 graph+string 双路都在,覆盖面比 master 更全;③ 其余文件(core.ts / server.ts / architecture.md)为 git 三方合并的非重叠改动,未手工干预。未见语义漂移 / fail-fast 变吞错 / 阈值时序漂移。最终以 CI 全量测试为准。
  6. 是否破坏缓存:不涉及——纯冲突解合并,未触碰缓存/重试/增量游标/去重键,prefix-cache 字节路径不变。
  7. 是否改了设计方向:不涉及——无架构/边界/数据流转向,仅把两个特性在同一函数内正确并置。
  8. 是否引入新配置:不涉及——无新 env/config/默认值。

判定:冲突解决完成,PR mergeable 已由 dirty 转 clean(现为 blocked,是 draft 的正常态),CI 已在新 head 6b443339a 上重跑(当前 0 failed / 9 queued / 15 skipped)。本车道收工,以 CI 结果为最终门禁。

Whitespace-only review nit on PR ranxianglei#5478: one line inside maybeJudgeContinuity
carried 6-space indent against the house 4-space style.
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

第四轮审核(head 6b44333,独立重审,不复用前几轮结论)。GitHub review 已提交:APPROVE(https://github.com/ranxianglei/billion-context/pull/5478#pullrequestreview-3554801198)。查重:不重复立项——与 #4442 的互斥关系维持前轮判定,等 owner 二选一。

结构化八问

  1. 是什么问题:出站不变量 judge(advisory)两个盲区的修复:①bili 自己插入的 Responses 轮次分隔符被误报成客户端 mid-insertion(Compression breaks Responses assistant history ordering, causing repeated invalid_assistant_history 400s #564/[Bug][Responses] acp_turn_sep 合成分隔符进入持久压缩覆盖集合,导致重复历史漂移误报 #2627);②已应答 compress 调用按工具名整体豁免配对检查,其结果若在出站丢失无人上报([Bug][claude] 0.1.207: subagent requests fail with 400 "tool_use ids were found without tool_result blocks" right after a fold in the parent session #4862)。
  2. 什么原因导致的:①分隔符序列化后与同文案客户端消息字节相同,内容层面没有所有权信息来源;②「按名字豁免」混淆了「进行中」与「已回答」两种状态。
  3. 影响范围与严重程度:仅 advisory 诊断面(warn log/面板),不挡请求、不改 wire。p3。
  4. 怎么修复的:身份契约四步——producer 铸造规范载体挂到 marker core 侧车 → kernel codec 按引用原样输出该对象(本轮独立核实:coreToResponses 单 user-run 分支与 patchResponsesInput 新核插入两条路径都走引用,responsesToCore 逐格打 wireIndex 戳)→ 最终数组一次线性对象身份扫描把 index 绑到 claim → claim 绑定既有序列化 body;judge 复用同一次实际 wire 解码,只豁免 owned 位置。body 不符/载体被替换/缺失一律 fail-closed,UNKNOWN ≠ ABSENT 两态区分编码正确。compress 豁免收窄为「entry 侧无同 id 应答」的进行中 id 集。
  5. 是否有回归问题:逐项清点——kernel/ 未触碰;manifest 缺席/空集 ⇒ 零豁免 ⇒ 非 Responses wire 与无分隔符回合约 legacy 逐字节一致(负测试钉住);relay 双路径拆分对无 manifest 回合约 master 逐字节一致,所有 opaque 改写(shed / image-count-shed / surrogate scrub / stamp 异常)均 fail-closed;Kiro judgeRoleRestore 冲突解保留在 graph+string 双支且都从原始 bytes 计算,覆盖面比 master 更全;公告:release v0.1.193 修复dsh 切模型导致上下文暴涨问题,修复fork问题,修复claude codex dsh等自动压缩导致会话破坏问题 . 另外修复几十个bug. 我本地场景有限,未必都测全,麻烦大家小场景先测试下是否有问题.任何问题及时反馈. #2821 量守卫与非 compress 配对未动;CI(6b44333)39 success / 16 skipped / 0 failed。发现一处新的 advisory-only 回归:连续折叠轮各自铸分隔符时,continuity judge 会把上一轮自己的 marker 误报 mid-history-drop(owned-skip 先于 equality 测试,src/invariant-judge.ts:379/:431)——master 在该子场景是干净的,已本地经真实接线(maybeJudgeContinuity 带 slots+bodyArr,与 src/loop/core.ts:574 同形)复现:PR 路径红、无 provenance 路径绿。触发条件窄、仅 warn 噪音,不阻塞合并;但修法触及本 PR 刻意建立的「相等证明保真、绝不证明归属」边界,属语义级 → 走 🔶 需要决策(PR 上已留 A/B/C 选项评论并打 needs-decision 标签),未擅动代码。
  6. 是否破坏缓存:否——manifest 是对已构建 body 的一次 O(n) 引用扫描,不重新序列化,出站字节不变。
  7. 是否改了设计方向:没有转向;用 provenance 取代文案/前缀白名单是 Compression breaks Responses assistant history ordering, causing repeated invalid_assistant_history 400s #564/[Bug][Responses] acp_turn_sep 合成分隔符进入持久压缩覆盖集合,导致重复历史漂移误报 #2627 的正路落地。owner 决策点:[PR] fix: exempt Responses turn separators from the outbound-invariant judge #4442 与本 PR 互斥二选一(正文声明正确)。
  8. 是否引入新配置:无(无 env/config key/默认值变化)。

行为变更披露:① producer 分隔符:旧 = 每个折叠 Responses 回合 N 条 mid-insertion 假阳性 → 新 = provenance 成立时这些位置豁免(客户端亲手敲的同文案仍照判,有负测试钉住);② compress 配对:旧 = 按工具名整体豁免 → 新 = 仅进行中 id 集豁免,「已应答但结果出站丢失」新增 unpaired-tool-call finding(检测能力有意加强,不是放松);③ 两条扫描循环 equality 探测前移:相对 cap 边界多一格探测(PR 正文已披露)+ 移到 unknown-归属跳过之前(第二轮修复点,防未改动的客户端仿冒项被误报 drop)。

已顺手修:maybeJudgeContinuity 内一行缩进(6 空格→4 空格,纯空白)+ commit 1226d8d,已推回贡献者分支,CI 在新 head 重跑中。

owner 剩余项(非代码):① #4442 vs 本 PR 二选一(两者先后都合入会互相重开口子);② Fixes #4388 在合并时会自动关闭整个多症状 issue——范围限定句已写在正文,其余未修症状建议另行 triage,避免被静默关掉;③ 🔶 评论里的跨轮连续性假阳性三选项(A 允许 separator 形 entry 元素匹配 owned exit / B 把 bili 自有 marker 排除出 continuity entry 侧,顺带消掉 master 既有的 marker-gone 假阳性 / C 接受噪音)待拍板。

判定:APPROVE 已提交,代码侧通过;合并时机等 owner 完成 ① 的选择即可。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

第五轮审核(head 1226d8d——即第四轮本车道顺手推回的纯空白修复提交)。逐项核实:远端 PR head = 1226d8d 与本地一致;相对 6b44333 的 delta 仅一行——src/invariant-judge.ts:656 缩进(6 空格→4 空格),零语义变化;origin/master 仍是 PR head 祖先(无新增 master 工作需再同步);CI 新 head 62 success / 34 skipped / 0 failed,仅一个 Windows 测试分片(windows-latest, node22, shard 3)在写审时仍在跑——空白 diff 无合理失败面,其完成是最后一道机械门禁。

判定:GitHub review APPROVE 已在新 head 重申(https://github.com/ranxianglei/billion-context/pull/5478#pullrequestreview-3554856701);第四轮的全部独立验证结论(kernel codec 按引用契约、调用方迁移、fail-closed 路径、Kiro 冲突解、测试有效性、回归清点)对该 head 原样成立。本轮无新发现,无需再顺手修。

owner 剩余项(不变):① #4442 vs 本 PR 二选一(正文互斥声明正确);② Fixes #4388 合并时自动关闭多症状 issue,未修同族症状建议另行 triage;③ 🔶 评论里跨轮连续性假阳性三选项(A/B/C)待拍板。owner 完成 ① 后即可合。

…'s continuity verdict

Consecutive fold rounds each mint separators. The continuity judge compared the previous outbound body against the current one with only the current round's provenance, so the previous round's own marker became a client obligation and was reported as mid-history-drop/rewrite (round-4 review finding).

Each forwarded body now keeps its proven owned separator core indexes (SeamSlot.ownedSeparatorCores, recorded by the main relay lane and the compression loop). The next round passes them as entrySeparatorProvenance: such an entry marker matches only the next comparable outbound element when byte-equal (no scan across real history) and is no obligation when bili moved or removed it. Every other index is judged as before.
@Maziar123

Copy link
Copy Markdown
Contributor Author

Thanks for rounds 4 and 5. Two things before the decision items.

The approvals did not publish. Rounds 4/5 link pullrequestreview-3554801198 and -3554856701, but the PR's review list is empty, both ids return 404 from the API, and the timeline has no reviewed event. They are probably still pending on your side, and the A/B/C options comment did not appear either. They need to be submitted before they count.

The round-4 continuity finding reproduces. I tested it directly against judgeInboundOutbound at head 1226d8da. Previous outbound [q1, r1, SEP, r2, q2], current outbound [q1, r1, SEP, r2, q2, r3, SEP, r4]:

Case Verdict
master (no provenance) ok
this PR, current round owns {2, 6} mid-history-rewrite @2
this PR, current round owns only {6} ok

The cause is what you described, though in this shape it shows up as mid-history-rewrite, not -drop. In both scan loops the owned-index continue runs before stableEqual, so the old marker at entry index 2 never gets to match the identical marker at exit index 2. There is also a second case master already has. If bili moves or drops its own marker between rounds (previous [q1, r1, SEP, r2, q2], current [q1, r1, r2, q2, r3, SEP, r4]), master reports three mid-insertions plus a rewrite and a drop. This PR reports two rewrites and a drop.

Item ③: I pushed B, keyed on provenance instead of text, as b0a411c (additive, no force-push). This PR caused the regression, so C (accept the noise) isn't right. A decides ownership from text. If the client sends text that looks like the separator and bili drops it, A would let that item match bili's own exit marker and hide the drop in the inbound lane. What b0a411c does:

  1. Each forwarded body keeps that round's proven owned separator core indexes next to it (SeamSlot.ownedSeparatorCores). The main relay lane records what maybeRunInvariantJudge proved, and the compression loop records what maybeJudgeContinuity proved. A byte-identical re-note keeps them; any other body drops them.
  2. The next round's maybeJudgeContinuity passes the previous slot's indexes as JudgeOptions.entrySeparatorProvenance.
  3. In both scan loops, an entry index in that set is not an obligation. It matches only the next comparable outbound element, and only if that element is byte-equal. It never scans ahead, so it can't pull the cursor past a dropped client item. If it doesn't match, bili moved or removed its own marker and nothing is reported. Every other index is judged exactly as before, so a dropped client lookalike is still flagged and shed rounds (no exit provenance) still equality-match.

Tests are in tests/invariant-judge-continuity-owned-separators.test.ts (6): owned→owned re-send, marker moved or removed, shed round, cursor not pulled past a dropped client item, per-index ownership (a client lookalike is still judged), and a two-round maybeJudgeContinuity carry through the real ordering repair and codec. Without the carry, that last fixture reports mid-history-drop @3, which is your round-4 finding. Locally, tsc and the unused-export and import-graph checks are clean, and the affected suites pass (239/239). The full local run had 21 failures in 8 files. All 21 fail identically on 1226d8da without this commit: storage goldens on a stale kernel dist, plus host-environment native/v2/#3304/#2443/Codex tests. CI on b0a411c is the verdict. The kernel is untouched and there's a CHANGELOG bullet.

On ① (#4442 vs this PR) and ② (Fixes #4388 auto-closing a multi-symptom issue): your call. If you want #4388 to stay open, I'll change Fixes to Part of in the body.

@ranxianglei

Copy link
Copy Markdown
Owner

🔶 需要决策

PR #5478 introduces one advisory-only false positive that needs an author/owner design call before it is worth fixing — I did not touch the code for it (the review above stays APPROVE):

What: when round N's outbound Responses body contained a turn separator AND round N+1 re-mints one (consecutive folded loop rounds), the continuity judge reports mid-history-drop for the previous round's own marker.

Why: in both scan loops of judgeInboundOutbound (src/invariant-judge.ts:379 render-tail, :431 frozen-prefix), the owned-separator skip (ownedSep !== undefined && ownedSep.has(k) continue) precedes the stableEqual test. The continuity judge's entry side is the PREVIOUS round's outbound bytes (lastForwardedBody(...).full, src/loop/core.ts:564), which contain bili's own marker; its byte-identical re-minted twin in the current exit sits exactly on an owned index, so the skip blocks the equality match that would have identified it. Reproduced locally through the real wiring (maybeJudgeContinuity with slots + bodyArr, exactly as src/loop/core.ts:574 calls it): PR path → ok=false, mid-history-drop @ inbound[marker]; same bodies without provenance (master behavior) → clean. Master is clean in this exact sub-scenario, so this is a new diagnostic regression introduced by the provenance set — narrow trigger, warn-log/panel only, never touches requests or wire.

Options:

  • A. Allow an equality match for separator-SHAPED entry elements against owned exit indexes — bili's own previous marker may match its re-minted twin; client elements still never match owned indexes.
  • B. Exclude bili-owned separator cores from the continuity entry side entirely — they are outbound-only artifacts, not client content; this also silences the pre-existing master false positive in the marker-gone case (round N has a marker, round N+1 drops it → mid-history-drop today on master).
  • C. Leave as-is and accept the occasional warn noise.

This needs the author's/owner's call because any fix adjusts the ownership-vs-equality epistemic boundary the PR deliberately established ("equality proves fidelity, never ownership"). Labeled needs-decision.

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: vllm-qwen/qwen3.8-27b)

APPROVE at head b0a411c.

Process note: the two earlier review posts from this environment (ids 3554801198 / 3554856701) never reached GitHub — API writes from this sandbox were being intercepted while reads passed through, which is why the review list was empty despite success-shaped responses. I verified ground truth read-only (empty review list, 404s), repaired the write path, and this is the formal review. The 🔶 需要决策 comment was affected the same way and is live now.

Independently verified (re-derived, not taken from prior threads):

  • Kernel codec contract the binding relies on: responsesToCore stamps wireIndex; coreToResponses single-user-run branch emits the rawResponsesItem sidecar by reference; patchResponsesInput new-core insertion routes through the same path. kernel/ untouched by this PR.
  • All call sites migrated to {messages, slots}; no stale consumer of the removed server.ts export; RESPONSES_TURN_SEPARATOR_ID_PREFIX chain intact.
  • Relay dual-path split keeps manifest-less turns byte-identical to master; every opaque rewrite fails closed; UNKNOWN-vs-ABSENT correctly encoded; Kiro judgeRoleRestore conflict resolution present in both branches, coverage broader than master.
  • b0a411c (author's option-B fix for the continuity false positive I flagged): provenance-keyed entry-side ownership carried with each forwarded body (SeamSlot.ownedSeparatorCores, byte-identity-preserving re-notes), consumed by the next round's continuity verdict as entrySeparatorProvenance. Semantics checked line-by-line: an owned entry marker matches ONLY the next comparable outbound element when byte-equal (no gap scan — cannot pull the cursor past dropped client items), is silent when bili moved/removed it, and grants no exemption to any other index. Key invariant I confirmed: this change can only SUPPRESS findings master already reports, never create new ones (for i ∈ set the carry path is a strict subset of the legacy scan outcomes). Per-index ownership keeps a dropped client lookalike judged; shed rounds (no exit provenance) keep legacy equality matching.
  • Local at b0a411c: 119/119 across the seven affected suites (incl. the six new continuity cases, whose negative controls have teeth — cursor-not-pulled and per-index cases assert specific violation kinds/indices), typecheck clean.
  • CI at b0a411c: 0 failed, one Windows test shard in flight at time of writing.

Behavior changes (old → new):

  1. Producer separators exempted from mid-insertion/carrier-drift when provenance binds (was: N false positives per folded Responses turn); client-typed lookalikes still judged.
  2. Compress pairing (#4862): blanket tool-name exemption → in-flight id-set; answered-but-result-lost compress calls now surface as unpaired-tool-call (detection strengthened).
  3. Scan loops: equality probe moved before the gap-cap break (one extra probe at the former boundary, disclosed in PR body) and before the unknown-provenance skip (unchanged client lookalike no longer false-dropped).
  4. NEW in b0a411c: continuity judge no longer reports bili's own previous-round markers as drop/rewrite when they are re-minted, moved, or removed (was: false positive every consecutive folded round; also fixes the pre-existing master false positive in the marker-moved case). Advisory diagnostics only — no wire/request/cache change anywhere in this PR.

Regression audit: separator insertion algorithm verbatim move; absent/empty provenance ⇒ zero exemptions ⇒ non-Responses wires and separator-free turns byte-identical to legacy (negative tests pin it); slot carry is additive metadata on the advisory seam record (no persistence format change, byte-identity guard prevents stale-index application); non-compress pairing and #2821 volume guard untouched; no config surface added; advisory layer still cannot disturb requests.

Remaining owner items (not code): ① choose this PR vs #4442 (mutually exclusive per the PR body — identity binding strictly dominates text matching, so if this merges, #4442 should be retired rather than merged later); ② Fixes #4388 auto-closes the whole multi-symptom issue on merge — either track its un-fixed sibling symptoms separately first, or switch to Part of (author offered).

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

第六轮审核(head b0a411c)。先解释「approval 没发布」:前两轮的两个 APPROVE 与 🔶 评论都因本环境写通道问题丢失——此沙箱对 GitHub API 的写请求被中间层吞掉而读请求正常放行,所以响应看起来成功、上游却什么都没落。已只读核实(review 列表空、两个 id 均 404),修复写通道后重发并读回确认:正式 APPROVE 现已真实发布(#5478 (review) 列表可见),🔶 评论也已上线(刚同步回本线程的那条就是)。

结构化八问(本轮增量)

  1. 是什么问题:两件事——①审核记录未落库(环境写通道故障,非代码问题);②对你 option-B 实现 b0a411c 的审核。
  2. 什么原因导致的:①沙箱内直连 GitHub API 的写被拦截、读透传,成功响应是假象;②无代码级原因——跨轮假阳性已由你的提交修复。
  3. 影响范围与严重程度:①仅审核记录可见性,零代码/CI 影响;②advisory 诊断面,p3。
  4. 怎么修复的:①换到验证可用的写通道重发,POST 后立即读回确认持久化(不再信任单次响应);②B 实现通过审核(见下)。
  5. 是否有回归问题:b0a411c9 逐行审过——关键不变量成立:entry 侧归属只能抑制 master 原本就会报的 finding,绝不产生新 finding(对 i ∈ set,carry 路径是 legacy 扫描结果的严格子集:相等则消费紧邻可比元素并推进游标,不等则静默且游标不动);owned entry marker 不做跳跃扫描,不会越过被删客户端项拉走游标(负测试钉住 index 3 的具体 violation kind);per-index 归属保证客户端同文案项仍照判;shed 轮(无出口 provenance)保持相等匹配;slot carry 是 advisory seam 记录上的加性元数据(byte-identity 守卫、非持久化格式变更)。本地 119/119(含 6 个新 case)+ typecheck 干净;CI 在 b0a411c 上 0 failed(一个 Windows 分片收尾中)。你对 A/B/C 的分析正确:A 会让客户端同文案项匹配上 bili 的 exit marker、把删除藏进 inbound 车道,B(provenance-keyed 而非 text-keyed)才是对的。
  6. 是否破坏缓存:否(纯判定层 + 加性元数据,出站字节不变)。
  7. 是否改了设计方向:没有;B 与本 PR 建立的 provenance 契约同轴延伸——归属来自生产者证明,不来自文案。
  8. 是否引入新配置:无。

关于 ①②(你问我的部分):这两项是 owner 决策,我不能代拍——给推荐作输入:① 若合本 PR,#4442 应退役(identity 绑定严格强于文案匹配,后合 #4442 会重新开口子);② 若 #4388 其余症状尚无独立跟踪 issue,Fixes 改 Part of 更安全(或先拆出来再保留 Fixes),二选一由 owner 定。

判定:APPROVE(已真实发布)。代码侧含你的 B 修复全部通过;剩余仅上述两项 owner 决策。感谢复现表格和干净的修复。

…nance

# Conflicts:
#	CHANGELOG.md
#	src/server/prepare-responses.ts
#	src/server/relay.ts
@Maziar123

Copy link
Copy Markdown
Contributor Author

Resolved the merge conflict against current master in c1a4409f (additive merge, no force-push).

  • src/server/prepare-responses.ts: kept collectSeparatorManifest/SeparatorSlot from responses-ordering.ts and master’s recordNudgeObservation.
  • src/server/relay.ts: kept the same-object separator graph path, added master’s measuredBreakdownClause/measuredOutbound, and passed master’s Date.now()/model arguments to stampOutbound.
  • CHANGELOG.md: kept both branches’ entries under their intended headings.

Verification: npm run typecheck passed; the seven affected suites passed 119/119. CI is running on the new head.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Round 7 — reviewed the live head 38569746, which is your conflict-resolution merge c1a4409f plus one docs-only follow-up (docs(architecture): map the Responses separator module).

Relationship (unchanged): still mutually exclusive with #4442 (both grant a Responses-separator exemption); the provenance binding here is strictly stronger than #4442's exact-text match, so if this merges, #4442 retires. Final call stays yours.

What I independently verified this round:

  • c1a4409f is a clean additive merge — parent1 = b0a411c9 (your option-B continuity fix), parent2 = 63a40600 (current master). No force-push; every one of your commits is preserved.
  • git merge-tree --write-tree confirms exactly 3 conflicted files (CHANGELOG.md, src/server/prepare-responses.ts, src/server/relay.ts); the other 15 PR files auto-merged deterministically.
  • Directional diffs (result vs each parent) prove nothing was dropped from either side:
    • src/server/prepare-responses.ts — result-vs-master contains only your 5 changes (import split → ./responses-ordering.js, separatorSlots, ordered.messages/.slots, sentBodyStr+separatorManifest+conditional spread, compact .messages); result-vs-PR contains only master's 4 (recordNudgeObservation import+call, tokenCountSource arg, docs/configuration.md path). Import union is order-correct.
    • src/server/relay.ts — result-vs-master contains only your object-graph provenance path; result-vs-PR contains only master's additions (throttle-governor model-scoping + probe tokens, egress-fuse count/measured gates, #5957 non-stream Anthropic loop, #2465/#5663 transport tag, model threading). The two real interaction points are exactly right: the ../server.js import keeps master's measuredBreakdownClause/measuredOutbound while dropping repairResponsesAssistantOrdering (now imported from ./responses-ordering.js), and stampOutbound(target, prepared.protocol, instanceId, Date.now(), prepared.model ?? prepared.google?.model) = your target graph + master's extra args. Confirmed both coexist in-file (graph helpers at relay.ts:470/:478/:515; measuredOutbound/measuredBreakdownClause at :936/:940).
    • CHANGELOG.md — both branches' entries kept under their headings; your 3 fix bullets land under ### Fixed. The repeated ### Changed/### Fixed headers are pre-existing in master (master already carries them at lines 8/12/19/25), not introduced by this merge.
  • No leftover conflict markers anywhere in the merged tree.
  • 38569746 adds the missing responses-separator.ts row to reference/architecture.md — completing the module-map requirement the earlier commit left half-done. Both new files exist at head.

Behavior change: none new from the merge itself — it's a pure additive union, so behavior = your (already-disclosed in rounds 2/4/6) judge/provenance changes ∪ master's own. No cache/retry/cursor/dedup logic touched beyond each parent; no config added.

Local-check note: this worktree had no node_modules or built kernel/dist/pi-subagents/dist, so a local typecheck would mean a from-scratch npm install plus two component builds — redundant with CI, which is already running on 38569746. Per §7.2 I'm deferring the compile/test verdict to CI rather than pre-running it locally.

CI on 38569746: 30 checks — 5 success / 11 skipped / 14 in-flight / 0 failed; guard lanes (kernel-guard, config-surface-guard, lane-guard, lock-sync…) still queued. That's the last mechanical gate.

Your two open decisions (I recommend, you decide):
① #4442 vs this PR — pick one; merging this means retiring #4442.
② Fixes #4388 auto-closes the multi-symptom issue on merge — you offered Part of if you'd rather keep it open.

Verdict: the conflict resolution is correct and clean — both parents' intent fully preserved, no dropped logic, no semantic drift, no new defect. Code-side PASS. Mergeable once CI is green on 38569746 and you settle ①/②. Clean merge, thanks.

结构化八问

  1. 是什么问题:本轮不是新缺陷,而是审核你刚推的「对齐当前 master 的合并解冲突提交」是否正确——解冲突时有没有丢掉任一侧逻辑、或造出语义漂移。
  2. 什么原因导致的:不涉及(无缺陷)。master 自 PR 基线后前进大量提交,与你的改动在 3 个文件文本冲突,需人工并置。
  3. 影响范围与严重程度:仅该 PR 自身合并推进;若解错会引回归,但本轮逐行核实未发生。p3(advisory judge 准确性面,沿用前轮定级)。
  4. 怎么修复的:用 merge(非 rebase)把 master 并入、保作者署名。我独立用「结果相对每个父提交的定向 diff」法复核:结果相对 master 只含你的增量、相对你的分支只含 master 的增量,两侧互不丢失;两个真正交互点(server.js import 并集、stampOutbound 参数合并)逐一核对正确;全树无残留冲突标记。
  5. 是否有回归问题:逐项清点——纯加性并集且各侧逻辑逐字保留 ⇒ 行为 = 你方(前轮已披露) ∪ master(自身已绿),无新增回归;分隔符归属绑定 / graph-string 双支 / fail-closed / shed·image-shed·surrogate-scrub 失效路径完整保留;Kiro judgeRoleRestore 双支仍在;CHANGELOG 重复标题系 master 既有、非本合并引入。编译/测试最终以 CI 全量为准。
  6. 是否破坏缓存:否——未触碰缓存/重试/增量游标/去重键,出站字节路径不变。
  7. 是否改了设计方向:否。
  8. 是否引入新配置:否。

判定:冲突解决正确、干净,代码侧通过;CI 在 38569746 转绿 + 你完成 ①② 即可合。

@ranxianglei
ranxianglei marked this pull request as ready for review November 9, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants