Skip to content

[PR] fix: egress judge render-lane tail-fidelity (snapshot-render I2 false positive) - #4243

Closed
ranxianglei wants to merge 1 commit into
masterfrom
2026-10-22_i2-render-lane-tail-fidelity
Closed

ranxianglei wants to merge 1 commit into
masterfrom
2026-10-22_i2-render-lane-tail-fidelity

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

问题

快照渲染(BILI_ROLLOUT_SNAPSHOT_RENDER,引擎 #3759/#3756)开启的会话上,出站判官(#3944/#3939)误报 I2 mid-history-rewrite @0 — inbound[0] ... absent from outbound frozen prefix。

判官拿入站原始字节逐位对照出站前缀。渲染车道有意把被折叠块覆盖的入站区域替换成服务端渲染视图(正史行 + 摘要锚),所以「入站[0] 从出站前缀消失」是引擎定义行为,不是重写事故。

根因

judgeInboundOutbound 的 I2 冻结前缀模型假设:出站前缀 == 入站前缀(字节稳定)+ 折叠追加 carrier。渲染轮破坏了这个假设:出站布局是 [服务端正史行][摘要 carrier][客户端尾部],而入站是 [覆盖区][客户端尾部]。覆盖区的入站消息被服务端行替换 → 与出站前缀对不上 → 误报。

修法

让判官感知渲染车道的尾部边界,而不是关掉 I2:

  • maybeSnapshotView(src/server/snapshot-render.ts)在 live 成功路径把客户端尾部起点 clientJoin 记到 session.metadata["snapshotRenderTailStart"];函数入口先无条件清除该键,保证「存在 ⟺ 本轮渲染了 live 视图」——所有 early-return / degrade / shadow 路径都不设它,此时出站就是原始客户端字节,走 legacy。
  • relay.ts 判官调用点读取该边界并传入 maybeRunInvariantJudge({ renderTailStart })。
  • 判官(src/invariant-judge.ts)新增 render-lane tail-fidelity 模式:只校验 entry[renderTailStart..](客户端逐字尾部)按序出现在出站里;服务端渲染前缀豁免于冻结前缀规则。I2 对尾部保持武装——尾部真被改 / 丢 / 乱序仍会红。跨轮前缀稳定性归 seamLcp/shadow(出站 vs 上轮出站),职责不重叠、覆盖不丢。
  • legacy 全量入站-出站路径在字段缺省时逐字不变(非渲染车道零行为变化)。

行为变更(有意,需披露)

  • 旧:渲染轮判官对覆盖区误报 I2(假阳性红,日志噪音)。
  • 新:渲染轮判官只校验尾部,覆盖区豁免;真·尾部损坏仍红。
  • 原因:渲染引擎写错时仍需 I2 抓——靠「尾部保真 + 跨轮稳定性」两条线继续兜底,只是不再拿错基准去比对。非渲染车道完全不受影响。

测试

tests/invariant-judge.test.ts 新增 6 例:

  • POS bug-repro(无感知 = 红 / 带 renderTailStart = 绿,直接钉住本 issue 的假阳性);
  • NEG 控制 ×2:尾部被改写 / 被丢弃仍红(证明牙齿保留,不是关掉 I2);
  • POS 多尾部按序跨服务端前缀匹配;POS 空尾(全被覆盖)边界;
  • wiring:renderTailStart 经 maybeRunInvariantJudge 端到端生效。

本地定向验证:judge 32/32、snapshot 相关 5 套 27/27、typecheck、build(dist-import-annotations / dist-external OK)全绿。全量回归交 CI。

Closes #4241

On a session where snapshot render (BILI_ROLLOUT_SNAPSHOT_RENDER) served the
outbound prefix, the invariant judge compared raw inbound bytes against the
server-rendered view and false-positived I2 mid-history-rewrite on the
intentionally-replaced covered region.

Plumb the client-tail join index (clientJoin) out of maybeSnapshotView via
session.metadata["snapshotRenderTailStart"] into the judge. When set, I2
validates only entry[renderTailStart..] against the outbound (the rendered
prefix is exempt); I2 stays armed on the byte-intact live tail. The legacy
inbound-vs-outbound path is unchanged when the field is absent.
@ranxianglei ranxianglei changed the title fix: egress judge render-lane tail-fidelity (snapshot-render I2 false positive) [PR] fix: egress judge render-lane tail-fidelity (snapshot-render I2 false positive) Oct 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-22_i2-render-lane-tail-fidelity (74b2c00)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.5040-pr.4243.56b7765

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-pr4243.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

[bot] 🏷
(ai: vllm-qwen/qwen3.8-27b)

查重: 不重复。本 PR 对应 #4241(出站判官对快照渲染车道误报 I2 的原始 bug 报告),检索 open/closed issue 与 PR 无其他同机制条目;PR 以 Closes #4241 关联,无并列重复 PR。

标签: bug + scope/wiring + p3(判官误报属请求管道/出站校验面的日志噪音缺陷,无功能影响,非客户端车道问题)。

已取分支 2026-10-22_i2-render-lane-tail-fidelity @ 74b2c00(base master c87185a,单 commit,4 文件 +220/-50:src/invariant-judge.ts、src/server/relay.ts、src/server/snapshot-render.ts、tests/invariant-judge.test.ts)。正在做独立 review(方向/回归/代码/测试有效性),随后按八问给结论。

@ranxianglei

Copy link
Copy Markdown
Owner Author

(ai: zhipuai-lb/glm-5.3)

已并入合并列车 #4525(master 6d7c587,合并方式 merge commit,提交保留原作者署名)。本 PR 关单收尾;若列车中对应提交出问题,回滚点为 #4525 单提交 revert。

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

Labels

bug Something isn't working p3 scope/wiring

Projects

None yet

1 participant