Repository navigation
OBJ-82 — Snapshot persistence to Postgres on cadence - #28
Merged
objectgyan merged 1 commit intoMay 17, 2026
Merged
objectgyan merged 1 commit into
objectgyan merged 1 commit into
Conversation
Adds document_yjs_snapshots table with EF Core entity, migration, and per-session snapshot timer (default 30s, configurable via Yjs:SnapshotIntervalSeconds). Last-client-disconnect triggers a final snapshot; new sessions hydrate from DB on first connect. Each snapshot cross-writes a document_versions row for auditability with dedup: skipped if StateAccumulator unchanged since last snapshot.
OBJ-82 M5.2 — Snapshot persistence to Postgres on cadence
Milestone: M5 · Wave: 2 SummaryPersist Y.Doc state vector + update log to Postgres every N seconds (configurable) and on last-client-disconnect. Hydrate on first reconnect. Feeds M4 versioning. Acceptance
Validation
Branch / PRBranch from |
objectgyan
added a commit
that referenced
this pull request
May 17, 2026
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.
Linear
Closes OBJ-82
Summary
Adds durable Y.js session persistence: a per-session timer writes
document_yjs_snapshotsrows every N seconds (default 30, configurable viaYjs:SnapshotIntervalSeconds). Last-client-disconnect triggers a final snapshot. New sessions hydrate from the most recent snapshot on first connect or cold-start reconnect. Each snapshot also creates adocument_versionsrow for auditability with dedup: skipped if no Y.js update since last snapshot.API / data changes
document_yjs_snapshots(id uuid pk, document_id uuid fk→documents, state_vector bytea, update_log bytea, updated_at timestamptz, tenant_id uuid)with indexes ondocument_idandtenant_id.AddDocumentYjsSnapshots(20260517142955).YjsSnapshotService— handles DB writes and hydration usingIServiceScopeFactoryfor scopedAppDbContextaccess.GET /api/collab/snapshots/{id}/count— returns{ count: int }for validation/diagnostic use.appsettings.json: newYjs:SnapshotIntervalSecondskey (default 30).YDocSession: addedHydrationTask,SnapshotTimer,HasUpdatesSinceLastSnapshot,SetStateAccumulator().YDocRegistry: injectsYjsSnapshotService; starts cadence timer per session; triggers final snapshot on last-disconnect; awaits hydration before sending sync-step2.YjsWebSocketHandler: awaitssession.HydrationTask(cap 5s) beforeSendSyncStep2Asyncso reconnecting clients receive persisted state.Plan: plans/projects/document-builder/plan.md (§ OBJ-82)
Contract: plans/projects/document-builder/tickets/api-contracts/OBJ-82-yjs-snapshot.md
Validation script: scripts/validate-obj-82.ps1 — exit 0
Outcome report: plans/projects/document-builder/tickets/validation-reports/OBJ-82-outcome.md — VERDICT: PASS
For QA
Yjs__SnapshotIntervalSeconds=3in environment, start API, connect a WS client to/ws/docs/{id}, send a sync-update, wait 5s,SELECT count(*) FROM document_yjs_snapshots WHERE document_id='{id}'→ > 0.GET /api/collab/snapshots/{id}/countreturns{ count: N }.document_versionsrow (dedup).Checklist