Skip to content

[PR] kernel: sign the leading functionCall of a rebuilt Google model content (fold-split parallel batch → sticky 400) - #6888

Open
mameikagou wants to merge 6 commits into
ranxianglei:masterfrom
mameikagou:2026-11-16_google-unsigned-leading-call
Open

mameikagou wants to merge 6 commits into
ranxianglei:masterfrom
mameikagou:2026-11-16_google-unsigned-leading-call

Conversation

@mameikagou

Copy link
Copy Markdown

Fixes #6887

kernel-change: coreToGoogle (kernel/src/wire/google.ts) is the only place that rebuilds Gemini model contents after a fold. The unsigned leading functionCall is produced there, so the guard has to live there too. It is a mechanical wire-shape bug: the regression tests below reproduce it, and the root cause is reported in #6887.

Not a model-facing text change. No config surface change. The root package.json version is untouched.

Problem

Gemini 3+ requires the first functionCall part of each model content to carry a thoughtSignature. Parallel siblings never carry one. Sometimes a fold covers the signed head of a parallel batch while a protected sibling survives. coreToGoogle then rebuilds a model content that leads with the unsigned sibling. Every later request 400s (Function call is missing a thought_signature in functionCall parts), including retries and cold-loads. The production evidence is in #6887 (0.1.214, agy + gemini-4-carbon-high).

#6103 (shipped in 0.1.214) fixed a different producer, a stripped proxy compress call. This PR fixes the fold-split shape.

Change

  • signLeadingFunctionCall(parts, { model, signing }), called from flushModel. It acts only when all of these hold:
  • When it acts, it stamps the documented bypass value skip_thought_signature_validator on that first functionCall and leaves every other part as-is.
  • Existing signature bytes are never rewritten (KDD release v0.1.3 #10). Siblings stay untouched. Unsigned histories and intact signed batches stay byte-identical, so the pins in kernel/tests/issue3939-wire-byte-stability.test.ts are unchanged and still pass.
  • kernel/package.json version 0.0.198 → 0.0.199.
  • Wire ledger WC-026 added (tests/wire-contract-fakes.ts): the fake Google upstream now rejects a signing conversation whose model content leads with an unsigned call. A gate test (positive plus two negatives) and a live-enforcement probe are in tests/wire-contract.test.ts.

Tests

  • kernel/tests/wire-google.test.ts:
    • the fold-split repro (a parallel batch whose signed head is folded away, plus a later signed turn that stays SIG-LATER);
    • an intact signed batch round-trips byte-identical;
    • an unsigned history is unchanged;
    • a Gemini 3+ target with no signature left;
    • a truth-table unit test covering Claude, Gemini 2.5, a signed head, a signed thought and no call.
  • The three new behaviour tests fail on master and pass with the fix.
  • npm --prefix kernel test passes.
  • Targeted bili Google suites pass: 151 passed, 0 failed, 2 skipped (e2e gates). The suites are adapter-google, e2e-google-compress, gemini-inline-media, google-*, issue1204/2407/2658/3158/5390, launcher-gemini-family, plugin-passthrough-progress-frame-google, preflight-google-summary, verif-wire-google-rebuild-stability, wire-contract, wire-contract-golden.
  • npm run typecheck is clean. The full-suite verdict comes from CI on this head.

Alternative considered

Keep folds from splitting one model content's parallel batch, by moving the boundary or protecting the head. That is a unit-projection change (KDD #12), which is larger and needs owner design. The wire-level guard covers every producer of this shape, including this one and future ones. A projection-level rule could still be added on top.

…nt (ranxianglei#6887)

A fold that covers the signed head of a parallel functionCall batch but
keeps a protected sibling made coreToGoogle emit a model content led by an
unsigned call; Gemini 3+ 400s every later request. When no part of the
rebuilt model content is signed and the target needs signatures, stamp the
documented bypass value on the first functionCall. Signed parts, siblings,
unsigned histories and Claude-family targets stay byte-identical.

Adds wire-contract ledger WC-026.
@ranxianglei ranxianglei changed the title kernel: sign the leading functionCall of a rebuilt Google model content (fold-split parallel batch → sticky 400) [PR] kernel: sign the leading functionCall of a rebuilt Google model content (fold-split parallel batch → sticky 400) Nov 16, 2026
The kernel version bump to 0.0.199 (PR ranxianglei#6888) left kernel/package-lock.json
stale at 0.0.198, failing the lock-sync check. Regenerated with
'npm install --package-lock-only'; the only drift is the two version lines.

Co-authored-by: e_work-daemon[bot] <198958989+ework-daemon[bot]@users.noreply.github.com>
@ranxianglei ranxianglei added bug Something isn't working p2 scope/kernel gemini labels Nov 16, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

Duplicate screening: not a duplicate. The fold-split producer (a parallel batch whose signed head is folded away while a protected sibling survives) is a distinct mechanism from #6103 (shipped in 0.1.214), which fixed a different producer — a stripped proxy compress call. No other open issue/PR targets this wire shape.

Review

Direction (highest priority): Correct. The bug is a wire-shape defect in coreToGoogle (kernel/src/wire/google.ts) — the only place that rebuilds Gemini model contents after a fold. When a fold covers the signed head of a parallel batch, the rebuilt content leads with an unsigned sibling, and Gemini 3+ 400s on every later request (sticky across retries and cold-loads). Fixing it at the wire rebuild (the producer) is the right layer — it covers every producer of this shape, including future ones. The alternative (a projection-level rule, KDD #12) is larger and needs owner design; the wire-level guard is the right scope for this fix.

Code: The guard signLeadingFunctionCall is conservative and correct:

  • It acts ONLY when the target needs signatures (the conversation carries any signature OR the model matches gemini-(3+)), NO part of the rebuilt content is already signed, the target is not Claude-family (Compatibility update for calling Claude APIs via Antigravity *cough cough* #5390), and the content has a functionCall.
  • It stamps the documented bypass skip_thought_signature_validator on the leading functionCall and leaves every other part as-is.
  • Existing signature bytes are never rewritten (KDD release v0.1.3 #10). Siblings stay untouched.
  • It strictly turns a 400 into a 200; it never turns a 200 into a 400.

Regression: I reviewed the existing behaviors the touched paths carry:

  • Unsigned histories stay byte-identical (no signature present → no bypass added).
  • Intact signed batches stay byte-identical (a part is already signed → the guard returns early).
  • Claude-family is skipped (Compatibility update for calling Claude APIs via Antigravity *cough cough* #5390).
  • Verified locally: kernel/tests/wire-google.test.ts 23/23 pass (fold-split repro, intact batch, unsigned history, Gemini 3+ target, truth table); kernel/tests/issue3939-wire-byte-stability.test.ts 20/20 pass (byte-stability preserved).
  • One narrow edge case (non-blocker): the conversation-level signing flag can flip when a fold removes the last signed message, so a non-thinking unsigned batch in a non-gemini-3+-named conversation could get a bypass in one request and not the next (a one-time prefix-cache break). Very narrow — the primary gate is the model-match, so it is rare.

Tests: Real tests, not tautologies. The three new behaviour tests fail on master and pass with the fix. The fold-split repro is a genuine regression test (a parallel batch whose signed head is folded away, plus a later signed turn that stays SIG-LATER). The WC-026 wire-ledger entry (tests/wire-contract-fakes.ts) plus the gate test (positive + two negatives, tests/wire-contract.test.ts) follow the ledger-only-grows discipline (#1304); the ledger row carries a live enforcement clause.

Diff cleanliness: Clean. 5 files, 182+/2-. Every line relates to the fix. The kernel version bump 0.0.198 → 0.0.199 is CI-enforced (Kernel Boundary rule 2). No unrelated changes, no whitespace churn.

CI fix I pushed: The only CI failure on the original head was lock-sync — kernel/package-lock.json was stale at 0.0.198 after the version bump to 0.0.199. I regenerated it (npm install --package-lock-only); the only drift was the two version lines. Pushed as commit 5bb11470f3 to the PR branch. On the original head all test shards passed; CI is now re-running on the fixed head.

结构化八问

  1. 是什么问题:Gemini 3+ 要求每条 model content 的第一个 functionCall part 携带 thoughtSignature(并行兄弟 part 从不携带)。fold 之后,coreToGoogle 可能重建出一条以未签名兄弟 part 打头的 model content(当并行批次的签名头被 fold 覆盖、而受保护的兄弟存活时)。之后每个请求都 400(Function call is missing a thought_signature in functionCall parts),且跨重试与冷加载都是粘性的。

  2. 什么原因导致的:coreToGoogle(kernel/src/wire/google.ts)是 fold 之后重建 Gemini model content 的唯一位置。当 fold 覆盖并行批次的签名头时,重建后的 content 以未签名的兄弟 part 打头,而重建逻辑没有给打头的 functionCall 签名,于是 wire 形状违反了 Gemini 3+ 的要求。

  3. 影响范围与严重程度:仅影响 Gemini 3+(Google 车道)的会话,且仅当 fold 拆分了并行批次(签名头被 fold、受保护兄弟存活)时触发。触发后会话被彻底卡死(每个请求 400,粘性)。触发面窄,但一旦命中影响严重(会话不可用)。

  4. 怎么修复的:新增 signLeadingFunctionCall(parts, {model, signing}),从 flushModel 调用。仅当以下条件全部满足时生效:目标需要签名(会话携带任意签名 或 模型匹配 gemini-(3+))、重建的 content 中没有任何 part 已签名、目标不是 Claude 家族(Compatibility update for calling Claude APIs via Antigravity *cough cough* #5390)、content 含 functionCall。生效时给打头的 functionCall 盖上文档化的 bypass 值 skip_thought_signature_validator,其余 part 原样保留。已有签名字节从不改写(KDD release v0.1.3 #10)。

  5. 是否有回归问题:审了触碰路径承担的既有行为——未签名历史保持字节不变(无签名、不加 bypass);完整签名批次保持字节不变(已有 part 签名 → guard 提前返回);Claude 家族被跳过(Compatibility update for calling Claude APIs via Antigravity *cough cough* #5390)。本地验证:kernel/tests/wire-google.test.ts 23/23 通过、kernel/tests/issue3939-wire-byte-stability.test.ts 20/20 通过(字节稳定性保持)。改动严格地把 400 变成 200,绝不会把 200 变成 400。未发现回归。一个窄边界(非阻塞):会话级 signing 标志在 fold 移除最后一条带签名消息时可能翻转,使非 thinking 的未签名批次在非 gemini-3+ 命名的会话中一个请求有 bypass、下一个没有(一次性前缀缓存断裂)。非常窄——主门是模型匹配,故罕见。

  6. 是否破坏缓存:bypass 值是文档化的 wire 常量,不是缓存键,不影响前缀缓存。字节稳定性测试确认完整批次不变。无缓存影响。

  7. 是否改了设计方向:没有。修复是 kernel 里的 wire 级 guard,覆盖该形状的所有生产者(含未来的)。替代方案(projection 级规则,KDD refactor: reapOrphanBlocks should live in acp-kernel, not the proxy #12)更大且需 owner 设计;wire 级 guard 是本次修复的正确范围。

  8. 是否引入了新的配置:没有。无新配置、env 或默认值。

判定:可合。 修复方向正确、代码保守、测试真实、diff 干净;lock-sync 已修(5bb11470f3),CI 在修复后的 head 上重跑中。已按 PR 自身 diff 打标签:bug / p2 / scope/kernel / gemini。

… CI fix)

The root package-lock.json tracks the in-repo kernel via
"acp-kernel": "file:./kernel"; its kernel entry was stale at 0.0.198
after the version bump to 0.0.199 (PR ranxianglei#6888). The lock-sync check also
regens the root lockfile, so this line must move too.

Co-authored-by: e_work-daemon[bot] <198958989+ework-daemon[bot]@users.noreply.github.com>
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

CI update on the fixed head (08c7e92357):

  • lock-sync now passes — it took fixing BOTH lockfiles, not just the kernel one:
    • kernel/package-lock.json version 0.0.198 → 0.0.199 (commit 5bb11470f3)
    • root package-lock.json kernel entry 0.0.198 → 0.0.199 (commit 08c7e92357) — the root lockfile tracks the in-repo kernel via "acp-kernel": "file:./kernel", so its kernel entry has to move too. The lock-sync job regens both, so both had to be in step.
  • Final tally: 37 success, 14 skipped, 1 failure — test (windows-latest, 22, 2).
  • That single failure is a flaky Windows socket-teardown timeout, not a PR regression:
    • Failing test: abort x proxy-openai-sse: client abort mid-stream destroys the upstream request (tests/wire-exit-matrix.test.ts), error upstream socket(s) must be destroyed after the client abort (closed=0), duration 22063 ms (a timeout).
    • The sibling abort tests in the same file (proxy-anthropic-sse, proxy-responses-sse, proxy-json) pass in <200 ms — the mechanism works; only the openai-sse socket teardown timed out on this Windows run.
    • The PR touches only Google wire signing (kernel/src/wire/google.ts) plus the two lockfiles; it does not touch the OpenAI SSE abort path. All 10 other test shards — including every Ubuntu shard — pass.
  • I attempted to re-run the failed job, but the token lacks permission (HTTP 403). Please re-run test (windows-latest, 22, 2) from the GitHub UI to confirm it's green on retry.

Verdict unchanged: mergeable. The PR's own changes are verified (kernel wire-google 23/23, issue3939-wire-byte-stability 20/20, wire-contract in the passing shards); the only PR-caused CI failure (lock-sync) is now fixed. The remaining red is an unrelated Windows flake.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

CI fixed — PR is fully green on new head 485bf78a5b (auto-fix attempt 1/6, done).

What I did this run:

  1. Re-verified live state first (mirror cache): test (windows-latest, 22, 2) still failing on head 08c7e92357; all other 10 test shards + static gates green.
  2. Fetched the failing job log (job 133132480934): exactly ONE test failed — tests/wire-exit-matrix.test.ts "abort x proxy-openai-sse: client abort mid-stream destroys the upstream request", error upstream socket(s) must be destroyed after the client abort (closed=0), duration 22 s (sibling abort cells: ~80–430 ms) — the classic slow-runner timeout signature.
  3. Checked CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 (CI master control): master e0d63bf8c8 is GREEN (0 failed, confirmed by multiple sweeps). Floor 1431 (2026-11-16 03:28Z) records this exact same signature (same shard, same closed=0) as a known inherited flake on PR [PR] fix(omp): arm the direct-send window guard so a proxy outage cannot egress an oversized history (#5032) #5077, with the fix living on origin/ci-fixes head 297709ef5 — "abortAfterFirstByte now waits for a ready predicate (up.requests() >= 1) before destroying the client socket — the 400 ms fallback used to fire before the proxy forwarded on slow runners, leaving requests=0 / closed=0".
  4. Verified the PR branch (fork mameikagou/billion-context, based on green master e0d63bf8c8) did NOT contain that fix, and that the PR's own diff (kernel Google-wire signing, +45/-1 in kernel/src/wire/google.ts + tests) touches nothing in the failing path.
  5. Merged origin/ci-fixes into the PR branch (clean merge; only the three flake-fix test files came in), ran the targeted suite locally: wire-exit-matrix 8/8 pass, then pushed new head 485bf78a5b to the fork branch (fetch-first, no concurrent changes found, non-force push).
  6. Re-verified the re-run: main CI run 43819854255 on 485bf78a5b completed / success (07:02:56Z) — including the previously red test (windows-latest, 22, 2) shard; all other workflows (E2E lanes, ci-image, PR Build Artifact, kernel-guard, gate) green/skipped.
  7. Posted the status + conclusion lines to CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 per CI-coordination policy.

八问

  1. 是什么问题:PR [PR] kernel: sign the leading functionCall of a rebuilt Google model content (fold-split parallel batch → sticky 400) #6888 的 CI 中 test (windows-latest, 22, 2) 分片红——wire-exit-matrix 的 abort 用例断言「客户端中止后上游 socket 必须被销毁」失败(closed=0)。
  2. 什么原因导致的:不是本 PR 代码的问题,是已知的慢 runner flake——abortAfterFirstByte 销毁客户端 socket 前只等 400 ms 兜底,慢 runner 上代理还没转发请求兜底就先触发,导致 requests=0 / closed=0。修复早已在 origin/ci-fixes(297709ef5,改为等 ready 谓词 up.requests() >= 1),本 PR 分支(基于 e0d63bf8c8)不含该修复。
  3. 影响范围与严重程度:仅 CI 信号(该分片误红),无用户侧影响;不修则该分片每次跑到此用例都可能随机红、阻塞合并。
  4. 怎么修复的:按 CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 既定处置(floor 1431 对 PR [PR] fix(omp): arm the direct-send window guard so a proxy outage cannot egress an oversized history (#5032) #5077 同签名先例)把 origin/ci-fixes 合入 PR 分支,本地定向跑 wire-exit-matrix 8/8 绿后推送,CI 重跑验证。
  5. 是否有回归问题:无——合入的 diff 只动 3 个测试文件(wire-exit-matrix / storage-durability / issue4612-gc-online-guard 的 flake/slow 修复),不碰任何 src/ 生产代码,不动 PR 自身的 kernel 改动;高危模式逐项过(无语义漂移、无阈值/时序/输出格式变化)。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:没有。
  8. 是否引入了新的配置:没有。

判定:PR #6888 CI 全绿(head 485bf78a5b),auto-fix 收工,等待人审/合并。

ci-check added 2 commits November 19, 2026 01:56
…discipline)

Merging origin/master into this branch made the PR's original 0.0.198->0.0.199 bump invisible: master independently bumped the kernel to 0.0.199 (commits 497efc7, 4ccccab), so the diff vs master showed kernel/src changes with no version delta and kernel-guard Rule 2 failed. Re-bump to 0.0.200 restores the required version delta for the PR's kernel change (kernel/src/wire/google.ts). Lockfiles synced via npm install --package-lock-only.
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

Merge conflict resolved + red CI fixed. PR is now fully green and mergeable.

What I did this run:

  1. Resolved the merge conflict. The PR was mergeable_state: dirty because master had advanced past the PR's base. I merged origin/master (a446a3c) into the PR branch — a clean merge, zero file conflicts (the "dirty" was a stale-base position, not a real textual conflict). Merge commit ecba80f8c7.

  2. Fixed the red CI (kernel-guard). After pushing the merge, CI failed on exactly one job — kernel-guard, Rule 2 (version discipline): "kernel/ source changed without bumping the version in kernel/package.json."

    • Root cause: master independently bumped the kernel 0.0.198 → 0.0.199 (commits 497efc7e31, 4ccccab15f) — the same version this PR had already bumped to for its own kernel/src/wire/google.ts change. After merging master, the PR's diff vs master showed kernel source changes but no version delta (both sides at 0.0.199), so the guard failed.
    • Fix: bumped the kernel version 0.0.199 → 0.0.200 and synced the lockfiles (kernel/package.json, kernel/package-lock.json ×2, root package-lock.json ×1). Commit 69f5b4f0b7. This is a pure version-number change — no code or behavior change.
  3. Verified locally before pushing: lock-sync clean (root + kernel, via npm install --package-lock-only), kernel-guard Rule 2 logic passes (SRC_CHANGED=1, BUMPED=1), npm run typecheck clean, kernel suite 1645/1645, wire-contract + google-complete-frame 49/49.

  4. Result: all 12 CI workflows success on head 69f5b4f0b7 (main CI + all E2E + build artifact). PR is mergeable: True, mergeable_state: blocked (awaiting human review/merge — not a conflict).


八问(中文结论)

  1. 是什么问题:PR 与基线分支冲突(mergeable_state: dirty),解决冲突后 CI 又因 kernel-guard 版本纪律红掉。
  2. 什么原因导致的:① 冲突是 master 前进了、PR 基线过期(非真实文本冲突);② kernel-guard 红是因为 master 独立把 kernel 版本从 0.0.198 提到了 0.0.199(与 PR 自己 bump 到的版本相同),合并 master 后 PR 相对 master 的 diff 里有 kernel 源码改动却没有版本差,触发「源码改了但没 bump 版本」。
  3. 影响范围与严重程度:仅本 PR 的 CI/合并状态,无用户侧影响。严重度 = CI 阻断(PR 无法合并),不是产品缺陷。
  4. 怎么修复的:把 origin/master 合进 PR 分支(干净合并、零文件冲突);再把 kernel 版本 0.0.199→0.0.200 并同步 lockfile,恢复 kernel-guard 要求的版本差。纯版本号改动,不动代码行为。
  5. 是否有回归问题:无。版本 bump 是纯数字变更;合入的 master 变更本身已发布/已测。本地 typecheck 干净、kernel 1645/1645、wire-contract 49/49;CI 12 条工作流全绿。双侧都改的文件(版本文件 + 3 个 flake-fix 测试文件)均为同向收敛,无语义冲突。
  6. 是否破坏缓存:不涉及。未触碰缓存/重试/增量游标/去重逻辑。
  7. 是否改了设计方向:不涉及。无架构/边界/数据流变更。
  8. 是否引入了新的配置:不涉及。无新 env/config/默认值。

判定:本 PR 的合并冲突与红 CI 均已修复,CI 全绿、可合并,等待人工 review/merge。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[ework] CI fix verified green ✓

1 similar comment
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[ework] CI fix verified green ✓

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants