From 87843548712d519a75d453f484b6dc0e01b26c95 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 25 Sep 2026 23:20:22 +0900 Subject: [PATCH] docs(features): state that local-draft ids are never reused (09-08) Revisions restart at 1 after a delete, so a reused draft id lets a stale tab overwrite a new draft. The sample now states the fresh-id premise the port's revision contract requires, and when tombstones are needed instead. Co-Authored-By: Claude Opus 5.5 --- .../local-draft-feature/application/local-draft-api.ts | 1 + src/features/local-draft-feature/domain/local-draft.ts | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/features/local-draft-feature/application/local-draft-api.ts b/src/features/local-draft-feature/application/local-draft-api.ts index b7778de6..3b384b63 100644 --- a/src/features/local-draft-feature/application/local-draft-api.ts +++ b/src/features/local-draft-feature/application/local-draft-api.ts @@ -10,6 +10,7 @@ export type LocalDraftRecord = Readonly<{ export type SaveLocalDraftCommand = Readonly<{ draft: LocalDraft; + /** Only unambiguous while draft ids are never reused (see LocalDraft.draftId). */ expectedRevision: number | null; idempotencyKey: string; }>; diff --git a/src/features/local-draft-feature/domain/local-draft.ts b/src/features/local-draft-feature/domain/local-draft.ts index 877fe12b..8e023ee2 100644 --- a/src/features/local-draft-feature/domain/local-draft.ts +++ b/src/features/local-draft-feature/domain/local-draft.ts @@ -1,4 +1,14 @@ export type LocalDraft = Readonly<{ + /** + * 09-08. One id per draft, never reused after the draft is removed. The + * repository deletes without a tombstone and a recreated record starts again + * at revision 1, so a tab still holding revision N of the removed draft + * could compare-and-swap over a new draft that reused its id (the capability + * port's revision contract says so: IndexedDbWriteReceipt.revision in + * src/application/ports/browser-file-storage/indexeddb-port.ts). A fresh id + * per draft (for example crypto.randomUUID()) makes that stale save a + * CONFLICT; a product that must reuse ids needs tombstones instead. + */ draftId: string; title: string; body: string;