Repository navigation
[PR] feat(fastpath): v6 render-snapshot plane — steady turns skip the full-view scan (#5664) - #5689
Conversation
pf_render / pf_render_log / pf_render_ckpt sidecar tables for the #5664 outbound-row snapshot plane. Rows are the per-rendered-ordinal OUTBOUND bytes previously emitted (prefix-reuse source of truth); the log journals append/cast/recast deltas; every checkpoint carries an S4 sha256 checksum and physically absorbs the log (fold rule: ckpt absolute values then post-ckpt appends). Log continuation starts from max(MAX(ls_seq), ckpt_ls_seq) so entries never fall behind their own checkpoint watermark. Cascade delete rides deleteSession like pf_*. MySQL/network backends degrade soft (null/empty) exactly like the pf_* identity plane.
…5664) Steady-state engaged v6 turns used to re-run the full n-core pipeline (reconcile/fold/detect over stored rows, processTurn over the whole frozen view, estimate/probe over all n rows) even though only the new tail changed. This lane caches what egress already emitted (station 2, committed at finalize on every engaged turn) and, when a conservative gate is fully green, replays ONLY the last W cores plus the new window cores through the kernel (probe-verified byte-identical tail output), splices the cached prefix rows back in without re-serialization, and feeds incremental estimate bases (budget.inputEstBaseTokens) instead of re-scanning n rows. Any red gate condition, failed window verify, or commit failure falls back to the untouched legacy full path for that turn; client-side compaction shrinks the captured row list and forces a recast+checkpoint at finalize (owner-decided compaction semantics). Caps mismatch (model/strategy/maxDim/toolArmed/multimodal) or S4 checksum failure kills the mirror loud and falls back. New rollout cohort watermarkV6Render nested inside watermarkV6MsgId, default 0%.
…dy tail-only rows (#5664) Review pass on the self-authored lane surfaced four state-maintenance bugs on the green path plus a class of test-blind spots; all fixed here with regression pins: 1. steady capture appended the FULL row list (production shape), not just this turn's new rows: the pos column shifted forward every green round, doubling the table on disk and in the mirror; only the per-round recast churn (masking an audit stall) kept the byte equation green. Capture now sends committedTail.slice(F) — exactly the appended suffix. 2. Cumulative estCum/textCum/imgCum re-counted the F frozen window rows every green round (linear ledger drift ⇒ shrinking max_tokens clamp and polluted k calibration over long sessions). Sums and the image-reserve delta now cover only this turn's new elements; legacy rounds still carry absolute totals. 3. The audit obligation was consumed only by cast/recast: after N green rounds tick%N===0 stayed true forever and the lane dead-locked back to full legacy until an unrelated caps flip. Any legacy full-capture round now zeroes the tick (it IS the audit). 4. Hygiene from the same pass: identity faults rethrow through the window- pass catch instead of retry-passing; CCR content-store adoption no longer defers past fast rounds (dangling refs); splice shallow-clones mirror rows so downstream cannot alias-mutate next round's verify baseline; NUL-bearing rows refuse persistence loudly-once (node:sqlite truncates bound strings at \0 silently) and hydrate parse failures log error instead of failing soft-silent. Test tier extended: per-round render-table↔identity-ledger alignment pin, two-audit-wave fast-round threshold (catches the stall), submitted-volume and cumulative-sum algebra pins, session-cascade wipe of the three render tables, and a second-sidecar-open 12→12 migration idempotency no-op.
Review round 1(已完成并修复,fix commit
|
…review hygiene) rows-misaligned pins rows.length === maxPos+1 before F is computed, so F <= maxPos+1 and 'maxPos < F-1' can never hold. Behaviorally inert; no test referenced the reason string.
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复——本线程即上游 PR #5689 的评审线程;检索 open/closed issue/PR,无针对同一机制(#5664 render-snapshot plane)的并行评审或修复条目;堆叠链 #5643→#5652→#5664 各层机制不同、无重叠。 标签: 评审结论:独立通读全量 diff(切缝 / gate / budget / 存储 / 测试),对第 1 轮修复清单逐条复核—— 八问:
本轮补交 commit(独立标注,已推 PR 分支,head
CI 状态说明:本 PR base 是堆叠分支 P3 留尾清单:接受(teardown 挂 clearWatermarkV6Render、LRU 驱逐 sessionSids 残留、RenderCaps 缺版本维度、facade try/catch——均内存有界卫生项;RenderCaps 缺版本维度的最坏代价 = 升级后一次浪费的快轮,verify 自愈)。 判定:代码质量达标,红路径等价性有证据,绿路径状态 bug 已修并钉住,配置面已补齐。建议待 #5652 合入、全量 CI 转绿后按堆叠流程合并。 |
|
(ai: sglang-gpu0/qwen3.8-27b) Review 结论:ready-to-merge(按 §7.4 需人类合并——含持久化 schema v12、新 rollout 键,且为 feat 类) 对照 #5664 子项规格逐条核对:
本地验证(tsx 套件,串行跑):typecheck clean;tests/issue5664-render-snapshot.test.ts 6/6;tests/fastpath-v6-msgid.test.ts 14/14;tests/fastpath-v6-tail-window.test.ts 3/3;tests/lane-decisions-matrix.test.ts 99/99;tests/storage-unified.test.ts 17/17。 CI 说明:本 head 上跑的是 CORE matrix(#3295 三层 CI 对非 master 目标 PR 的正常形状:8 gate 绿 + 9 个 env-gated e2e skipped),与 base 分支形状一致;FULL matrix 要等 rebase 到 master 后才跑(前置 #5652 先合并——stacking 依赖已正确:本 PR base = #5652 head a3d7bab)。 两点备注:
小问题已直接在分支修掉:src/persist.ts 注释声称 pfRenderCommit 「does NOT swallow silently」,实现实际 try/catch 返回 null(fail-soft 行为与 pfCommitTurn 一致,只有措辞失实)——commit 3f07c86 把注释对齐实际行为。 |
(ai: vllm-qwen/qwen3.8-27b) 第二轮两条备注都处理完了,另外的两个新 commit 已本地核实: 新 commit 核实(head 现为
备注 2(hydrate 后审计边界):同意并记录在案——重启后 auditTick=0 ⇒ 最长 N 个绿轮无计划性端到端复验;但每轮 verifyRenderWindow 仍把出站尾窗与存储行逐字节比对,任何出站可见的分歧一轮内即被抓住,计划审计是其上的第二道防线。有界、可接受。 备注 1(config surface 一节):已补齐——PR 正文追加了「## Config surface」节(措辞按第二评审草稿,带「review round 2 添加、owner 可裁定措辞」标注,原文逐字保留):① 八问(本轮增量):
CI:head 移至 判定:合并前最后一处缺口(config surface 节)已补齐,ready-to-merge 评估维持不变——§7.4 需人类合并(schema v12 持久化变更 + 新 rollout 键 + feat 类),PR 链接:#5689 |
…; structural divergence kills the lane permanently (owner ruling 2026-11-05, #5664) Recast (rewriting covered ordinals / deleting excess rows) existed as the plane's only self-heal path. The owner ruled it must not happen in ANY scenario (fold, caps flip, audit-caught drift, corruption death). This commit removes it from every layer instead of patching its call sites: - diffRowLists verdict 'recast' -> 'diverged'; the diverged branch now calls killRenderPlane(): the sid joins a permanent deadSids set, a kind='dead' entry is persisted into pf_render_log WITHOUT a checkpoint (nothing absorbs it), and the session rides the legacy full path from here on — bytes stay correct, the cache simply never serves again. - killRenderPlane is the ONLY mutation besides append/cast-once: S4 checksum mismatch, row gaps, log-fold disagreement, caps-unresolvable hydration states all KILL durably instead of returning null-and-retry; the arm cast refuses over any pre-existing non-empty table. - pfRenderCommit drops its deletes parameter end-to-end (store/shadow/persist) — covered ordinals can never be rewritten. - gate grows the durable reason 'lane-dead'; prepare-openai skips the capture build+commit entirely once the reason is lane-dead so dead sessions stop paying an O(full history) stringify per turn. - tests: golden A/B re-pinned (death lands at turn 14 caps flip, table freezes at 13 rows, restart hydrates straight to lane-dead — no re-arm); new pins: structural-divergence kill (immutable rows, loud log, persisted dead verdict, gate positive + re-capture refused negative per #3617) and death-persists-across-restart. Consequence (accepted by the ruling): once a session's outbound bytes ever diverge from its cached rows — most concretely after ANY compression fold re-shapes them — that session loses the render fastpath permanently. Fastpath lifetime = up to first divergence, never after.
|
(ai: sglang-gpu0/qwen3.8-27b) 已按裁定关死重铸 — commit 49ba14d(owner 裁定 2026-11-05:所有会触发重铸的场景都不允许重铸,需要关死) 改动把"重铸"从每一层整个移除,而不是在调用点打补丁:
本地证据:typecheck 干净;issue5664-render-snapshot 8/8、fastpath-v6-msgid 14/14、fastpath-v6-tail-window 3/3、lane-decisions-matrix 99/99、storage-unified 17/17(另 1 个环境门跳过)。 代价(裁定接受的后果,写明供合并前确认):会话一旦出站字节与其缓存行发生任何偏差——最典型的是第一次压缩折叠后(折叠块以 mid-stream user 消息重渲染,出站必然变字节),或其宿主改写/截断历史、切换模型导致 caps 翻转——该会话的渲染快路径永久失效。快路径寿命 = 首次结构事件之前。新会话/新 sid 不受影响,照常享受铸造→稳态增益。合并前提不变:需先合 #5652(本 PR 叠在其上);§7.4 要求人类合并(schema v12 持久化变更 + 新 rollout 键)。 |
…d of failing the request (#5664, review round 3) The no-recast sealing (49ba14d) added a store.pfRenderRows pre-existing check to the arm branch, but SessionStore.pfRenderRows has no local try/catch and station 2 runs OUTSIDE prepare-openai's try block — a transient SELECT failure would have propagated out of prepareOpenai and failed the whole model request, an availability regression vs the old fail-soft arm path. A thrown read carries no divergence evidence, so it defers the arm to the next round (warn + op none) instead of killing the plane or crashing the caller. Test pins both directions: flaky-read round fails soft AND the next healthy round arms normally (transient != death).
(ai: vllm-qwen/qwen3.8-27b) 关死重铸的改动( 对
本评审发现并已修复的缺陷( 两条记录在案的非阻塞观察(P3,不动):① 每个重新 hydrate 已死 sid 的进程会再补写一条重复 dead 记录(幂等再确认,界于重启次数内,会话级联删除时清掉);② 代价条款确认(裁定接受的后果,按你的要求写明):快路径寿命 = 首次结构事件之前(典型为第一次压缩折叠——折叠块以 mid-stream user 消息重渲染,出站必然变字节;以及宿主改写/截断历史、caps 翻转改变字节)。死后会话字节恒正确(纯 legacy),新会话/新 sid 不受影响。与「字节安全来自停止而非修复」的不变量一致,确认接受。 八问:
CI:head 现为 |
…nothing mapped is ever cached (#5643 §5 ruling, #5664) Owner ruling on #5643 (2026-11-05, canonical flow): the only plane boundary that can never be altered by model/maxDim/toolArmed/voice/harden/serialize is the post-kernel-rewrite generic core form. Rebuild the plane around it: - RenderCaps drops model/maxDim/toolArmed — they are per-turn mapping inputs, not snapshot validity (caps now: v, strategy, droppable, multimodal). - Station 3 green round: verify this round's rewritten window cores against the stored suffix at the core-form boundary; the full core sequence (cached prefix ++ window output) then passes through the FULL mapping chain fresh this turn (rescale/harden/coreToOpenai/voice/serialize all run with this turn's inputs). Within-family model switches ride through with zero events — they re-map next turn by construction. - Captures (steady tail, legacy full, fallback) store core strings, never mapped wire bytes. Tripwire semantics unchanged (one-turn legacy fallback, no recast, durable kill on divergence); sums/audit/death machinery untouched. - Tests: golden A/B rewritten to the core regime with a shape pin asserting every stored row carries core identity fields (id/contentType) and no wire bytes are persisted.
…dentity lane, ranxianglei#5754 image-shed cap, ranxianglei#5689 render-snapshot plane
…ed cap, render-snapshot plane Upstream 2919794..ce8f92e (57 commits) lands three large planes: - ranxianglei#5652 fastpath-v6 identity lane (c295f90 storage layer, d55a50c composite identity, 9c1fb86 full-list wire, da6885d fixed tail window, plus the review follow-ups) - ranxianglei#5754 image-shed 64-item cap (6aed3b8) - ranxianglei#5689 render-snapshot plane (acca4db schema v12, 6d3ca30 O(1) steady turns, 49ba14d seal-shut probe) - ranxianglei#5721 witnessed rebase supplement Overlap with this lane was four files. src/plugin.ts auto-merged (upstream touches the handoff-reply import at :31 and handlePluginTool at :2337; this lane owns the strip entry points at :22 / :61 / :2640..:4554). The two CONFIGURATION files are generated and were regenerated from the seed. One real conflict, in tests/issue4666-migration-dedup.test.ts line 158: upstream re-swept the sqlite user_version pin to the literal 13, this lane had already derived it. Kept the derived form -- that is the whole point of the earlier sweep, and the literal is what goes stale on the next bump. That conflict resolution exposed a latent bug of mine. 3eb22b1 ("pin the mysql lock lane to the CURRENT schema version") derived the mysql stamp assertions from STORAGE_SCHEMA_VERSION as well. When it was written both numbers were 9; ranxianglei#5652/ranxianglei#5689 have since pushed the sqlite unified store to 13 while the MySQL backend stayed at 11, because the v12 identity plane and the v13 render-snapshot plane are sqlite-only. The mysql-contract lane therefore asserted "13" against a migrator that correctly stamps "11". Fixed by exporting MYSQL_SCHEMA_VERSION from src/storage/mysql.ts and pointing the four mysql-side assertions at it; the sqlite assertions keep deriving from STORAGE_SCHEMA_VERSION. Verified String(MYSQL_SCHEMA_VERSION) is "11", i.e. byte-identical to the literal upstream asserts. Verification on the merge tree: issue5175 58/0, tag-echo 79/0, issue2190-degen-close 32/0, golden-storage-render 5/0, storage-engine-proofs 12/0, native-compact-terminal 1/0, plugin-passthrough-tag-strip-chat 20/0, issue4666-migration-dedup 2/0 (the three mysql cases skip without BILI_MYSQL_TEST_DSN; no local MySQL or docker socket in this sandbox). tsc --noEmit clean, all four gates exit 0, generated docs byte-identical.
#5664 — fastpath v6 render snapshot:出站渲染平面(按 #5643 §5 规范流转顺序重建)
设计基准:#5643 补充裁定(owner,2026-11-05)§「规范流转顺序」——所有平面每轮走固定链:
本平面(station 2/3)是这条链上第一个允许驻留的缓存点。本分支已按该裁定重写:行内只驻留「内核改写后的通用核形态」(CoreMessage),映射层之后一个字节都不缓存。
这个平面缓存什么、不缓存什么
缓存(pf_render 表,每 sid 一张,append-only):每个存活元素一行的改写后通用核形态 JSON + 累计账本(est/text/img)。这是链上唯一能经受住模型/maxDim/toolArmed/voice/harden/序列化全部变化的边界——它们统统发生在行右侧的映射层里,逐轮用当轮输入重跑。
不缓存:映射后 wire 字节、序列化结果、任何目标协议形态。推论:族内切模型下一轮天然过一遍映射层,身份平面不需要为它设任何事件;RenderCaps 因此收缩为 {v, strategy, droppable, multimodal}(strategy/droppable/multimodal 改变的是改写输出本身)。
防错机制(全部 fail-soft,宁可整轮回退不猜)
合同与证据
出站字节 ≡ legacy 全量管线出站字节,逐字节(tests/issue5664-render-snapshot.test.ts 三阶段黄金 A/B:17 回合语料、arm→fast wave→audit 翻转→caps 分歧死锁→重启水合,外加稳态行数/校验和/账本代数钉)。新增形状钉:每一行的存储体必须携带核心身份字段(id/contentType)——wire 字节进不了表。
升级边界(诚实声明)
v12 三表未合入 master,按裁定零迁移成本:若未来存在存过旧语义(wire 行)数据的实例,其首次 legacy 捕获会因分歧判死——fail-soft 方向正确(宁死不错),且 rollout 默认关闭、未合入前不存在该存量。
灰度与开关
BILI_ROLLOUT_WATERMARK_V6_RENDER(rollout 百分比,默认 0)叠在 v6 msgid 车道之上;两车道互不干扰(身份平面先行,渲染平面消费其 pf_rows.core_json 窗口水合)。Closes #5664
Round 4 — witnessed rebase: the snapshot evolves with compression (#5643 补充裁定, commit
4ecde0a95)The no-recast regime sealed in round 2 made the plane unable to survive its first compress — the exact failure mode owner ruled out on #5643 ("快照必须随压缩演进"). Round 4 replaces fold-dead with a structural-witness rebase:
activeBlocksSignature, sorted multiset of active block id+generation) costs exactly one red round when the layout moves, then re-synchronizes. Folded sessions keep serving fast while their layout is stable.pfRenderCommit replaceAll), writes a fresh S4-checksummed checkpoint carrying the post-event signature, resets the audit tick. Storage bounded by live elements (compaction shrinks the table). Witness sources are server-side evidence only: block-signature move around this turn's kernel pass, dsh native-compaction detector ([bug] DSH 桌面端 0.1.188:宿主原生压缩落地摧毁折叠基底 → 同一区间永久不可锚定、compress 连片失败并熔断(compaction-basic auto:false 仍无效) #2432), fold-usage consumed pre→post, gate-observed move.