Repository navigation
[PR] fix(storage): do not serve migrated block placeholders as content snapshots - #6943
mariopasquali wants to merge 7 commits into
Conversation
…pshots
Full-mode import stores { one: null, full: { text: block.summary, count: 0 } } for blocks whose legacy record had no snapshot, so every block row has a view. Readers took that row as the snapshot: after migration, decompress returned the block summary as the block's content instead of collecting the live messages. Readers now go through blockContentSnapshot(), which treats the placeholder like a missing entry.
ranxianglei
left a comment
There was a problem hiding this comment.
Reviewed locally on head 0858098 — verified, approving.
Verification performed
- Placeholder shape confirmed at the writer:
completeBlockContents(src/storage/ingest.ts:519–530) stores exactly{ one: null, full: { text: b.summary, count: 0 } }, so the predicate inblockContentSnapshotmatches it exactly. Thesummary === undefinededge (placeholder{ count: 0 }with notext) is also caught —undefined === undefined— good. - Reproduced the master failure:
tests/storage-block-content-placeholder.test.tsrun against master fails with the claimed symptom ("SQLite load must not serve the block summary as its content") and passes on this head. 3/3 new tests pass here. - Read-path coverage: every remaining raw
blockContents.get(call is a fork copy-on-write site (src/plugin.ts:1807/1813 fork endpoint, src/fork-adoption.ts:252) that intentionally copies the row verbatim into the child — correct as-is; the user-facing readers are all on the helper now. - Adjacent suites: 64/64 (decompress-empty-range, derived-fork-block-inheritance, dsh-fork-adopt, export-block-summaries, export-jsonl-ccr-originals, export-jsonl-content, e2e-export-handoff).
tsc --noEmitclean (fresh build on this head),check:unused-exportsclean (12 waived), architecture-docs guard green.
Non-blocking note (pre-existing, out of scope): the fork guard at src/plugin.ts:1807 accepts a placeholder (non-empty summary text) as "original content available". Harmless today because the fork copies the prefix messages themselves, but if fork semantics ever require true originals for fully-historical blocks, that guard should use the same placeholder test.
Nice find with the real-store numbers (333 blocks / 86 sessions affected).
(ai: qwen3.8-27b)
…able (review fix for ranxianglei#6943) - storage-block-content-placeholder: drop debug console.log residue; assert the reloaded row is actually the completeBlockContents placeholder shape (and the legacy load has no snapshot), so the test fails loudly if the import ever stops emitting the placeholder instead of silently passing. - migrate-block-placeholder: add the two missing negative rows to the blockContentSnapshot truth table (summary-text + real count kept; real one-view + zero full count kept) — the guard must not fire on any real snapshot shape.
(ai: opencode/vllm-qwen-qwen3.8-27b) Duplicate screening: not a duplicate — no open or closed issue/PR covers the block-placeholder / blockContents-migration defect (mirror search + open [PR] row list; only this PR touches the seam). ReviewDirection & root cause — correct. No-collision proof (the correctness crux) — verified. A real snapshot can never have the placeholder shape. The only real-snapshot writer is Reader coverage — complete. All 9 content-serving sites route through the helper: decompress-shared.ts:221 (resolveDecompress) and :594 (resolveDerivedDecompress), export.ts:67/199/245/395, external-summary-compress.ts:88, web/sessions-data.ts:1732/1886. Untouched sites verified safe: plugin.ts:1778/1784 and fork-adoption.ts:252-253 are copy-on-fork write paths (carrying the placeholder through is correct), and the search_context original-text corpus (decompress-shared.ts Behavior changes (flagged per policy):
Test validity — real, and now tightened. I verified the fail-on-master / pass-on-head claim locally on both trees: on master the e2e test fails the parity assertion (migrated returns the summary) and the unit file fails at import; on the PR head all 3 pass. Two hygiene gaps fixed directly on the PR branch (commit
Both files re-run green (3/3) after the edits. CI & base: my push re-triggered CI (28 checks at read time, 0 failed, 22 pending). The branch is 43 commits behind master, but master touched none of the PR's 5 source files since the branch point — clean rebase, no conflict expected (GitHub: mergeable, state=behind). Verdict: mergeable, once CI is green on head 结构化八问
收工判定:可合并(待 head |
(ai: opencode/vllm-qwen-qwen3.8-27b) CI status update on head |
…ns {3,5,11,14}
The probe anchor PROXY_TOOL_AT=6 was calibrated on 2026-10-31 for ranxianglei#4521
(schedule {4,6,8,9}). The nudge scheduling has shifted again — nudge now
lands at {3,5,11,14}. Re-calibrate the anchor to the next nudge-carrying
request pair (5 → tool round, 6 → fold round). The fold/proxy-tool-round
mechanics under test are unchanged.
Closes: master-red on test (windows-latest, 22, 3) and (ubuntu-latest, 22, 1).
…ic wire shape The probe's hardcoded request-index anchors (PROXY_TOOL_AT/FOLD_AT) broke every time the nudge gate's schedule shifted. The last recalibration (245ecb1) was measured on a direct local run (timestamps ON by default since ranxianglei#4313), but CI runs the suite preload pin BILI_MESSAGE_TIMESTAMPS="0" (timestamps OFF) — a different wire shape, a different schedule (no nudge at index 5) — so it passed locally and failed on every CI shard. Root-cause fix instead of another anchor whack-a-mole: - Arm the fold on the first request carrying the ephemeral nudge with >=11 tagged refs; fold on the re-request after the acp_status round. The probe now materializes the ranxianglei#2929 scenario wherever the schedule places it. - Pin compress.messageTimestamps:false so the probe's wire shape is hermetic regardless of how the suite is launched (matches the CI preload pin). Supersedes the 245ecb1 recalibration. Verified: passes with and without the preload pin, same deterministic schedule (nudge at inputs[7], fold at inputs[8]).
(ai: vllm-qwen/qwen3.8-27b) This run: all 3 red test shards were an inherited failure from master — fixed by merging the sentinel's Diagnosis (all verified live this run, not from memory):
Action:
七问
判定: 修复完成 —— 新 head |
(ai: claude-opus-5-5)
When a legacy JSON session has a folded block but no saved snapshot for it, a full-mode import stores a placeholder so every block row has a view:
{ one: null, full: { text: block.summary, count: 0 } }(completeBlockContentsinsrc/storage/ingest.ts). After a restart, the session reads that row back. Readers then treat it as a real snapshot.What a user sees: before migration,
decompressof such a block rebuilds the content from the live messages. After migration it returns[Block b1 content — 0 item(s)]followed by the block summary. The summary is shown as if it were the original content.This change adds
blockContentSnapshot()insrc/session.ts. It returnsundefinedfor the placeholder shape (one === null,full.count === 0,full.text === block.summary). The readers insrc/decompress-shared.ts,src/export.ts,src/web/sessions-data.tsandsrc/external-summary-compress.tsnow use it. The placeholder is then handled like a missing entry: decompress collects from the live messages, and the web view says "no snapshot". The write side and the schema do not change.Real data: in a migrated copy of our store (8,299 sessions, 921 with blocks, 38,052 blocks), 333 blocks (214 active) in 86 sessions have the placeholder shape.
Tests:
tests/storage-block-content-placeholder.test.ts: legacy session → full-mode import → reopen → decompress. It fails on master and passes with this change.tests/migrate-block-placeholder.test.ts: reader cases. It fails on master and passes with this change.tsc,check:unused-exportsandtools/check-architecture-docs.mjspass.tests/issue4612-gc-online-guard.test.tswas stopped by our time limit: on our disk it is slow, not hanging (see CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599).