fix(server): extend persister quiesce fence to snapshot writes — merge, don't clobber (CWD-4) - #324
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With
OPENBOOK_SERVER_PERSIST=1, a stale client whole-snapshotPUT /api/pages/:id(pure LWW) could clobber a newer server checkpoint — the persister's quiesce/reseed freeze protocol existed but only the version-restore route used it (PVH-8). Board: CWD-4 (epic OB-76).Solution
The persister now owns a reusable quiesce→write→finalize boundary with intent discrimination: restores keep overwrite semantics (drop + reseed +
relay.forget, now correctly ordered via anafterWritehook); client snapshot PUTs merge — the snapshot's Yjs update is applied to the retained canonical doc and checkpointed as the CRDT union, so neither the stale client's op nor the server's merged state is ever lost (review probe: durable end-state strictly better than base, which silently dropped the PUT's op). Same-page writes serialize; cross-page writes don't; freezes are refcounted so a concurrent DELETE can't strip another writer's guard; shutdown drains in-flight fences; cold pages (no live session) skip the machinery entirely. Merge checkpoints preserve per-block authorship (OB-170). Persist-off path byte-identical.Key files:
packages/server/src/collabPersist.ts,app.ts. New deps: none.Before / After
No visual change — server persistence semantics (flag-gated; OPENBOOK_SERVER_PERSIST off in prod today).
PUT {"name":"x"}(no data)Test procedure
Review verification (Quinn, two full rounds with probes): two-client durability probe base vs branch (union convergence), refcount probed four ways, serialization event-order probe, restore parity.
Operational notes
None today (flag off in prod). This closes the double-writer that blocked enabling server persistence; the real-Postgres interleaving proof (checkpoint-in-flight vs PUT) is specced for the CWD-11 harness as a follow-up test. Known accepted gap: relay view is a safe superset of durable until the next checkpoint (pre-existing T1 asymmetry, unchanged).
Verify: green (full
pnpm verify). Reviews cleared: code (Quinn — round 1 BLOCKER [durability inversion] fixed and re-verified by probe; round 2 N1-N3 + nits applied, all pre-endorsed).🤖 Generated with Claude Code
https://claude.ai/code/session_018RUicirLRuuZvjJN13N6yN