docs(sdk,server): durable-write contract — rev CAS, WriteError taxonomy, Idempotency-Key (CWD-1) - #321
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
The Concurrency & Write Durability epic (OB-76) needs one contract that CWD-2 (server CAS), CWD-5 (idempotency), CWD-6 (client chokepoint), CWD-7 (IndexedDB outbox) and CWD-10 (conflict UX) can build against without re-deriving semantics — today the SDK has no typed write errors, no version tokens, and idempotency covers 1 of ~25 write routes. Board: CWD-1.
Solution
docs/write-contract.md(normative spec) + exported TS types in@book.dev/sdk(+ server envelope aliases). No runtime behavior change — types ship unused until CWD-2/5/6 land. Key decisions (owner-ratified): opt-inexpectedRevCAS (legacy callers keep LWW);revnaming to avoid permanent collision with page version history; per-entity revs with T9 persister checkpoints incrementing; discriminated 409 conflict envelopes carrying permission-filtered current state;Idempotency-Keywith request fingerprinting, response-capture ledger, 7-day GC, and a server capability flag gating outbox auto-replay; stable-position ordering contract (implementation = CWD-12).Survived two adversarial review rounds (Quinn: 20 findings round 1, 12 round 2 — all resolved; four semantics calls escalated to owner and baked in).
Before / After
No visual change — docs + types only.
ErrorfromthrowIfNotOk; 1 typed case (401 getPage)WriteErrortaxonomy withretryable, spec'd per statusexpectedRev+ 409 conflict envelope contractIdempotency-Keyheader contract for all wave-1 routes + replay semanticspnpm --filter @book.dev/sdk build)Test procedure
Operational notes
None now (docs/types only). Downstream consequences are tracked per-issue on the board: CWD-2 carries the instance-config TOCTOU + null-semantics alignment criteria; CWD-12 owns the ordering migration (must preserve the ledger posting-order hash + numeric-position bundle import).
Verify: green (full
pnpm verify×2 on final tip). Reviews cleared: code (Quinn — 2 rounds, final 12 findings all pre-endorsed and applied; re-verify confirmed downstream may build unchanged).🤖 Generated with Claude Code
https://claude.ai/code/session_018RUicirLRuuZvjJN13N6yN