Skip to content

[PR] feat: wire google lane into snapshot render (#3764) - #3770

Merged
ranxianglei merged 1 commit into
masterfrom
2026-10-19_snapshot-render-google-lane
Oct 19, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-10-19_snapshot-render-google-lane

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Wires the google lane into the #3759 snapshot-render feature, closing the gap left as a v1 non-goal and now orphaned after #3752 closed.

What / why

prepareGoogle now consumes maybeSnapshotView(session, msgs, …) for its two consumers (effectiveTokenCount + core.processTurn), exactly mirroring the openai/anthropic/responses prepares landed in #3759. reconcileFoldCoverage keeps observing the client view, same as those lanes.

Before this change the google lane rode the legacy path: a google session's fold overlay stayed anchored to the client-resent bytes, so the #3752/#3751 id-churn family existed intact on the google lane, and the BILI_ROLLOUT_SNAPSHOT_RENDER switch had no effect on google sessions (the engine entry point wasn't in this prepare at all).

Only two consumers switch here, not three: the google wire deliberately has no reasoning-drop (#651 — Gemini validates thoughtSignature on replayed parts, and dropping a thought part takes its signature with it → 400). This divergence is documented in the prepare.

The engine is wire-agnostic (it eats core BiliMessage); zero engine changes were needed. The one projection seam worth noting: the synthetic acp_summary_<blockId> anchor is a mid-stream system core, and coreToGoogle rides non-assistant cores onto the user side (Gemini has no system role inside contents) — so the anchor renders without needing systemToUser.

Tests

Adds google variants to tests/snapshot-render.test.ts, driven over the native Gemini wire (streamGenerateContent?alt=sse):

  1. D-on steady state — anchor rendered once, covered rows suppressed, live tail present, prefix through the summary byte-stable, metadata.snapshotRenderTurns latch counting.
  2. D-on identity-seed upgrade — flip the id salt via the existing __setMessageIdSaltForTests("upgrade-v2") seam; prefix stays byte-identical across the 0.1.200 → 0.1.201 upgrade (#3658 identity change) mass-unfolds persisted sessions incl. Anthropic lane; downgrade re-churns #3752 re-mint, block survives, no destroy verdict.
  3. D-off control — legacy path still churns on the same scenario (documents the bug this lane fixes), no D latch.

Prefix stability is asserted on the joined text sliced through the summary rather than element-wise, because coreToGoogle merges same-side runs (the anchor can share a contents entry with the live tail).

Local: npm run typecheck clean; tests/snapshot-render.test.ts + tests/e2e-google-compress.test.ts = 14/14 pass (the real e2e-google-compress regression suite confirms the prepare change doesn't disturb existing google compression). Full-suite verdict comes from CI on the pushed head.

Behavior change (flagged)

Rollout-gated behind the existing BILI_ROLLOUT_SNAPSHOT_RENDER; default-off ⇒ no behavior change until enabled. When enabled, google sessions' outbound prefix renders from the unified transcript (server-authoritative, fold-time ids) instead of re-deriving identity from client bytes — identical semantics to the three lanes already shipped. No new config surface (reuses the existing rollout gate; no config field added).

Scope gates

  • Single-module scoped (src/server/prepare-google.ts + its test). No kernel/ change, no config schema change, no version bump.
  • Not auto-merge: when enabled this changes the outbound wire bytes for google sessions (a message-shape change), which §7.4 routes to human review.

Closes #3764

@ranxianglei ranxianglei changed the title feat: wire google lane into snapshot render (#3764) [PR] feat: wire google lane into snapshot render (#3764) Oct 19, 2026
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-19_snapshot-render-google-lane (3d7a069)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.4469-pr.3770.46a7f89

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr3770.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重:不重复。 检索了 open+closed 的 issue 与 PR:无其他 snapshot-render / google 车道相关条目在途。本 PR 与 #3756(设计)→ #3759(openai/anthropic/responses 三车道实现,已合并)→ #3764(缺陷报告:google 车道缺位)是上下游关系,不是重复立项;本 PR 即 #3764 的修复交付物,无并列的重复修复。

标签:bug · gemini · scope/wiring · p2(#3764 缺陷类补全;客户端为 Gemini native wire;改动面在协议接入层 prepare-google.ts;rollout 默认关、当前无线上影响,但启用后 google 整条 wire 才获得其他三车道的 #3752 保护 → p2)。

审核进行中,先报状态:

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

总判定:代码通过审查;合并被一个与本项目无关的 CI 红阻塞(该红是 #3759 引入的 master 既有问题,已跟踪于 #3771、修复 PR #3774 在途)。建议:#3774 落地(并覆盖 google 车道,见下)→ 本 PR rebase → 全量矩阵转绿后合并。功能有 rollout 门控(默认关),不紧急。

八问:

  1. 是什么问题:google(Gemini)车道被漏在 snapshot render 特性之外——google 会话的折叠覆盖层仍锚定客户端回传字节,0.1.200 → 0.1.201 upgrade (#3658 identity change) mass-unfolds persisted sessions incl. Anthropic lane; downgrade re-churns #3752/Image message ids re-mint whenever an earlier image leaves the visible tail (membership-based ClusterCounter suffix) — prefix-cache breaks per fold, feeds #3748 storage growth #3751 那族 id 重铸导致的 mass-unfold 风险在 google 车道上完整存在,且 rollout 开关对 google 会话完全无效。
  2. 什么原因导致的:prepare-google.ts 从未调用 maybeSnapshotView,引擎入口在这个 prepare 里根本不存在——不是配置漏接,是接入点缺失。
  3. 影响范围与严重程度:所有 google 会话(启用 rollout 前的现状);严重度=特定条件下有问题(id churn 发生时折叠对账失败→mass unfold)。rollout 默认关,当前无线上影响;本 PR 合入+启用后 google 与其他三车道语义一致。
  4. 怎么修复的:把 maybeSnapshotView 接进恰好两个消费点(effectiveTokenCount + core.processTurn),位置与 openai/anthropic/responses 三车道逐点镜像;reconcileFoldCoverage 等其余路径保持观察客户端视图;reasoning-drop 有意缺席(Protected-message exemption inflates the incompressible context floor: per-compression reasoning is never reclaimable (~83.5% of measured residual) #651 thoughtSignature);零引擎改动。投影接缝(合成 acp_summary_<blockId> system core 经 coreToGoogle 落到 user 侧)已对照内核源码核实(kernel/src/wire/google.ts:345 注释明确支持该行为)。
  5. 是否有回归问题:生产代码无回归——逐项清点过:D-off 默认路径下 maybeSnapshotView 原样返回客户端数组(引擎源码核实 + D-off 对照测试钉住);prepare 内其余全部消费者(dsh compact 检测 / fold 对账 / drift 检测 / deriveTitle / history-rewrite 检测 / compaction archive / orphan reap / snapshotMessages)保持客户端视图不变;Protected-message exemption inflates the incompressible context floor: per-compression reasoning is never reclaimable (~83.5% of measured residual) #651 不变式保持;其他三车道零触碰。typecheck 干净,本地定向 14/14(snapshot-render + e2e-google-compress 全套)。但必须报告:本 PR 的 CI 全量矩阵红了(12 腿中 6 红),独立归因后确认非本 PR 所致:纯 master(a8853fe,不含本 PR 任何代码)同样失败(run 39191418594,同一组测试同一断言)——[PR] Snapshot rendering: proxy lane outbound prefix rendered from server-side canonical history; existing sessions immune to | 快照渲染:proxy 车道出站前缀从服务端正史渲染,存量会话对内核升级免疫(#3756) #3759 把一组从未在 CI 真正跑绿的测试带进了 master(其合前"绿"是一次 skip 空矩阵的假绿),现已由 CI red: snapshot-render D-lane tests fail non-deterministically ('D observability latch counted turns') while passing locally — #3759 merged with unverified-in-CI tests #3771 跟踪、[PR] fix: make snapshot-render D-lane test deterministic and surface degrade reason (#3771) #3774 修复(根因:测试用固定 60ms sleep 等 sidecar 写入,CI CPU 饥饿下静默退化成 legacy 路径,只有 latch 断言暴露)。本 PR 新增的 2 个 google D-on 测试因继承同一 harness 模式在 CI 同签名失败,本地通过。
  6. 是否破坏缓存:否。特性方向是让出站前缀更稳(D-on 下跨 id 重铸字节稳定,测试钉住);缓存/重试/增量游标失效策略不受影响;D-off 字节级不变。
  7. 是否改了设计方向:否。纯扩展 [PR] Snapshot rendering: proxy lane outbound prefix rendered from server-side canonical history; existing sessions immune to | 快照渲染:proxy 车道出站前缀从服务端正史渲染,存量会话对内核升级免疫(#3756) #3759 已确立的模式到第 4 条车道,无架构/边界/数据流转向。
  8. 是否引入了新的配置:否。复用既有 BILI_ROLLOUT_SNAPSHOT_RENDER rollout 门(默认 off),未新增任何 config/env 字段。

行为变更披露(按规范):启用 BILI_ROLLOUT_SNAPSHOT_RENDER 后,google 会话的出站前缀从「按客户端回传字节推导身份」切换为「服务端统一 transcript 渲染(fold-time id)」——与已上线三车道语义一致;默认关 ⇒ 启用前零行为变化。

交叉事项(均已处置):

收工判定:代码质量达标(单模块、parity 正确、测试有牙、无回归、无新配置面),review 侧放行;合并等待 #3774 覆盖 turnGoogle 并落地 + 本 PR rebase 后矩阵转绿。

prepareGoogle now consumes maybeSnapshotView for effectiveTokenCount and
core.processTurn (reconcileFoldCoverage keeps observing the client view),
mirroring the openai/anthropic/responses lanes landed in #3759. Reasoning-drop
is deliberately absent on this wire (#651: Gemini validates thoughtSignature),
so only two consumers switch, not three.

Adds google variants to tests/snapshot-render.test.ts driven over the native
Gemini wire: steady-state prefix byte-stable, seed-upgrade prefix byte-identical
across the #3752 identity re-mint (via __setMessageIdSaltForTests), and the
D-off control showing the legacy path still churns. Rollout-gated behind
BILI_ROLLOUT_SNAPSHOT_RENDER and default-off, so no behavior change until enabled.
@ranxianglei
ranxianglei force-pushed the 2026-10-19_snapshot-render-google-lane branch from 322502e to 3d7a069 Compare October 19, 2026 05:12
@ranxianglei
ranxianglei merged commit 2b40342 into master Oct 19, 2026
32 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.597-master.2b40342 (rolling master tag).

npm install -g billion-context@0.0.597-master.2b40342  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

ranxianglei pushed a commit that referenced this pull request Oct 19, 2026
#3772)

A `labeled` event for any non-ci:full label starts a run whose gate/plan
job immediately decides skip, but it shared the per-ref concurrency group
of in-flight real runs with cancel-in-progress=true — so the vacuous
skip-run cancelled the real matrix mid-flight and then recorded success
with an empty matrix (false green + 40+ cancelled runs per label burst;
#3770 repro).

Append a `-skip` suffix to the concurrency group for exactly those
trigger-time events (pull_request + labeled + label != ci:full — the same
predicate each gate/plan job already uses), so skip-runs can never cancel
in-flight runs; they finish in ~20s as a harmless trace. ci:full labeled
runs stay in the base group and still supersede in-flight core runs
(#3295); schedule/dispatch/push events are unaffected (suffix is '').

All 13 workflows with a labeled trigger AND a cancel-in-progress group:
ci.yml, ci-image.yml, ci-e2e.yml, ci-registry.yml, ci-zcode-real.yml,
ci-e2e-dsh.yml, ci-e2e-dsh-native.yml, ci-e2e-codex-persona.yml,
ci-e2e-native.yml, ci-e2e-native-opencode.yml, ci-e2e-pi-ws.yml,
ci-windows-codex.yml, ci-e2e-fake.yml. ci-theorem.yml excluded: no
concurrency block, nothing to cancel there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ci:full Run the FULL CI matrix (all e2e lanes + 12-leg test matrix) on this PR gemini p2 scope/wiring

Projects

None yet

1 participant