Repository navigation
[PR] fix: egress diff occurrence-aware — collision-pair deletion no longer ghosts or mismatches (follow-up on #7849) - #7851
Conversation
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 查重: 不重复 — this thread's PR (#7851 upstream) is the only PR targeting the egress-diff gap; the related open row #7850 (upstream #7849) is the stacked BASE PR (egress row addressing msgid→rid), a different thread, not a parallel fix for the same defect. No other open [PR] row touches 标签: Live status (verified just now): PR #7851 is open, head Reviewing the diff now; full review conclusion (8-question form) to follow. |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) PR #7851 审核结论(8 问)1. 是什么问题 2. 什么原因导致的 3. 影响范围与严重程度 4. 怎么修复的 5. 是否有回归问题 6. 是否破坏缓存 7. 是否改了设计方向 8. 是否引入了新的配置 代码与测试核查(本地实测)
CI 状态(live 核查) 收工判定 (一个非阻塞观察,不立项:300-iter property 测试用随机 msgid,碰撞概率≈0,实际不覆盖碰撞路径——碰撞路径由 3 个定向 case 覆盖,足够;若日后想把 property 也扩到碰撞场景可再议。) |
… longer ghosts or mismatches (follow-up on #7849) diffEgressView keyed its spine on msgid (first-wins). When the host minted a collision pair (two rows, same msgid, distinct rids) and a fold/delete removed one, the spine Set marked BOTH rows "spine", so the D-run never fired (the deleted row stayed live — a ghost) and the U wrote the survivor's bytes onto the first row's rid (content mismatch). The diff's contract "replay reproduces next exactly" was violated with no runtime invariant to catch it. The spine now matches each next row to a SPECIFIC prev occurrence: prefer the occurrence whose bytes agree (the survivor keeps its own rid — a pure -D), else the first occurrence after the pointer (msgid-only, so a content edit still emits a U). No-collision views have one occurrence per msgid, so the match is identical to the old first-wins key there (no behavior change). Regression tests: the two repro cases (delete-first / delete-second of a collision pair) plus a survivor-content-edit case, each asserting the exact ops and the replay identity.
1dbce58 to
7904d44
Compare
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.1334-master.af8ed2a # this exact build
npm install -g billion-context@master # always the newest merged build
|
…end default From the #7738 egress-plane review — four storage/session bugs plus the pluginDeltaResend default. Each is self-contained; B2 is the main one. B2 (pin deadlock): tryIncrementalPin anchored the client's id list by POSITION (ledgerEl[T-L+j]). After a fold, pi resends the FULL id list (L) which is longer than the folded server view (T), so the pin failed ("incremental list longer than the view"), degraded the new rows to h_ content ids, and — a host id can never equal an h_ id — deadlocked forever on "reanchor next turn". Replaced the egress path with an ID-anchored pin (tryEgressPin) that anchors by element identity (list index vs ledger element rank, offset d = j - p), absorbs the fold's rank shift, and classifies every turn shape in one pass: - full (d=0) / incremental / tail (d<0): restamp the aligned prefix with the ledger's canonical host ids, take the new increment from the tail; - zero overlap (REANCHOR_NOW): every declared id is a fresh increment — no 400, no h_ (the #7851 occurrence-aware diff rebuilds the ledger next turn); - fold-summary ranks stay content-derived (the client can never echo them). It NEVER returns null in egress mode (no h_ degradation). The legacy (non-egress) positional path is unchanged — issue5874 pins its null-degrade contract. B3 (title lag): the egress identity row was upserted before deriveTitle ran, so a session's first-turn title was never written (NULL for single-turn sessions, one-turn lag otherwise). Re-upsert the identity row after the title is derived (buildEgressIdentityInput). B4/B5 (7-table session list empty): webSummaryRows ran `WITH bl AS (SELECT ... FROM blocks)`, but a 7-table (egress) instance does NOT create the legacy `blocks` table → the query threw "no such table: blocks" → the whole list crashed to the disk walk, where egress sessions (no JSON files) are missing → the panel showed 0 sessions. Guard on legacyTablesPresent: query the sessions table alone and count egress_state rows so a single-turn egress session isn't filtered as an empty stub (isEmptyStub checks hasEgress). pluginDeltaResend default OFF -> ON (owner ruling 2026-11-28): the server must be ready to handle the delta arm (direct-append) alongside the full / incremental / tail / non-intersecting shapes. Inert until a shim claims delta (x-bili-pf-delta: 1); roll back with BILI_ROLLOUT_PLUGIN_DELTA_RESEND=0. Tests: c6 Test D updated for the never-null pin + Path A element-granular ledger, Test E (post-fold full-list resend anchors) added; crosslane-wire-pin stale Path A assertions fixed; new tests/egress-7table-session-list.test.ts (B4 repro). tsc clean; egress/pin/web suites green (c6 5/5, egress-record 9/9, issue5874 43/43, crosslane 1/1, egress-7table 1/1, egress-authority-ladder 7/7, egress-fork-host-e2e 11/11, egress-invariants-7773 1/1). Scoped out (follow-up, see PR description): B1 — record the model answer at end-of-turn so the FINAL turn's answer isn't lost if the conversation ends before pi resends it. It needs a response-stream tee in relay.ts + a recordEgressTurn append; kept out of this PR to leave the hot serve path untouched.
Follow-up on #7849 (the msgid→rid egress addressing migration). #7849 moved the egress PERSISTENCE layer to self-dispatched rids, but left the DIFF engine (
diffEgressView) still matching on msgid (first-wins). This PR completes the migration on the diff side.The gap
When the host mints a collision pair (two rows, same msgid, distinct rids) and a fold/delete removes one of the pair, the diff cannot express the deletion — the spine
Set<msgid>marks BOTH rows "spine", so:ops=[](no-D), the deleted row stays live (a ghost);U{rid=first, bytes=second}, writing the survivor's bytes onto the first row's rid (content mismatch + ghost).The diff's contract "replay reproduces next exactly" is violated, with no runtime invariant to catch it.
The fix
The spine now matches each
nextrow to a specificprevoccurrence instead of a msgid: prefer the occurrence whose bytes agree (the survivor keeps its own rid — a pure-D, no spuriousU), else the first occurrence after the pointer (msgid-only, so a content edit still emits aU). No-collision views have one occurrence per msgid, so the match is identical to the old first-wins key there — no behavior change for the common case.Tests
Three regression tests in
tests/egress-state.test.ts: the two repro cases (delete-first / delete-second of a collision pair) plus a survivor-content-edit case, each asserting the exact ops and the replay identity. The existing pinned diff cases (tail / nudge / fold / content-edit / num-lifecycle / move / 300-iter property) all still pass unchanged.Scope
Single-module fix (
src/storage/egress-state.ts),fix:only, regression tests added. Stacked on #7849 (the egress state table only exists on that branch). Severity p2 — the egress plane is default-off/unreleased and the collision requires the host to mint a wrong id; this closes the gap before GA.