feat(cojson): signature mismatch recovery with session conflict preservation#3522
Draft
gdorsi wants to merge 8 commits into
Draft
feat(cojson): signature mismatch recovery with session conflict preservation#3522gdorsi wants to merge 8 commits into
gdorsi wants to merge 8 commits into
Conversation
Introduce ConflictSessionID type and isConflictSessionID/toConflictSessionID helpers, following the existing pattern of ActiveSessionID/DeleteSessionID. Conflict sessions are derived from active sessions by appending "!" and will be used to store divergent transactions during crash recovery.
Introduces recoveryTestHelpers.ts with five shared helpers for signature mismatch recovery test layers: setupRecoveryActors, createSharedTaskMap, crashAfterServerAckBeforeLocalPersist, expectTaskFields, and waitForRecovery.
Replace anonymous key/value pairs (a, b, c, d; server1, server2; only-on-server) in the three recovery integration tests with realistic task map fields (title, priority, status, assignee, archived, owner, due) and add ASCII topology docblocks explaining the crash scenario and expected state. Introduce shared helpers from recoveryTestHelpers.ts for actor setup, crash simulation, field assertions, and condition polling. Keep the first two protocol-level tests (SignatureMismatch detection and dedup) unchanged. Also fix crashAfterServerAckBeforeLocalPersist to wait for peer sync only (not storage sync) when storage writes are intentionally blocked, preventing a hang when the storage waitForSync promise never resolves. Note: the "jazzCloud ahead by more transactions" test requires the client session to be longer than the server's to trigger the SignatureMismatch error path; the test makes three post-crash edits to satisfy this constraint.
…ion recovery stories Adds three integration tests to the signature mismatch recovery suite: - bob convergence after observing stale state pre-recovery - fresh charlie load after recovery sees only repaired history - recovery preserves unrelated sessions from a second agent session
Add two tests to the replaceSessionContent core invariants suite: - verify isDeleted remains true and delete session is preserved after replaceSessionContent on a deleted coValue - verify newContentSince(undefined) emits tombstone content after deleted recovery
Add recovery module that detects signature mismatches from the server, replaces the divergent session with authoritative content, and preserves divergent local edits via conflict sessions. Implementation: - recovery/index.ts: orchestrates mismatch recovery flow - replaceSessionContent on CoValueCore: rebuilds VerifiedState - replaceSessionHistory on storage: durable session replacement - SignatureMismatch error handling in sync layer Test coverage across three layers: - Integration (L1): 9 end-to-end recovery stories - Core invariants (L2): 5 focused replaceSessionContent tests - Storage queue (L3): 4 async queue ordering tests Includes test.fails cases documenting known design gaps: deleted-value tombstone propagation and crash-during-queue-replacement.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
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.
Summary
replaceSessionContenton CoValueCore andreplaceSessionHistoryon both sync and async storage layerstest.failscases: deleted-value tombstone propagation and crash-during-queue-replacementTest plan
test.failscases correctly document known design gaps