Spec §8.2.2: revisions and cursors a restore cannot reissue; S2 rechecks standing
From Astra's review of feat/suite-producer at a6eeeb5 (2026-11-01). The revision is max(previous + 1, now in unix microseconds); the S1 cursor is "<id>.<stamp>" checked every request, and a cursor Docs did not issue is an error (the earlier "answered from the beginning" is withdrawn). States what is protected, and that after a restore memoria must drop everything held from Docs and its cursor. S2 asks team standing again after its reads.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+43
−10
docs/superpowers/specs/2026-08-30-docs-design.md+43 −10
diff --git a/docs/superpowers/specs/2026-08-30-docs-design.md b/docs/superpowers/specs/2026-08-30-docs-design.md| index 1558dde..72d936d 100644 |
| --- a/docs/superpowers/specs/2026-08-30-docs-design.md |
| +++ b/docs/superpowers/specs/2026-08-30-docs-design.md |
| @@ -663,23 +663,32 @@ S3's one refusal; what follows is only the part Docs owes. Custody is every |
| live document, per revision 10's §4.2 and §4.3 notes, which are cited and |
| not restated. |
| -**The revision counter.** `documents.revision` starts at 1 and goes up by |
| -one, in the same writer transaction as the change, on every applied update |
| +**The revision counter.** `documents.revision` moves, in the same writer |
| +transaction as the change, on creation and on every applied update |
| (`ApplyUpdate`), rename, visibility change and deletion. `doc_updates.seq` |
| alone misses renames, and a rename changes S3's bytes. A grant, a revoke or |
| -a link changes who may read, which S2 asks live, so none of them bumps it. |
| +a link changes who may read, which S2 asks live, so none of them moves it. |
| +Each new value is **max(previous + 1, now in unix microseconds)** — strictly |
| +increasing, still an integer under 2^53 — never simply previous + 1. Rows |
| +that existed before migration 0009 start at 1 and jump to the clock on |
| +their first change. |
| **The feed log.** `suite_feed (id AUTOINCREMENT, document_id, revision, |
| -gone, touched_at)` is append-only and written in the same transaction as |
| -each bump, creation included. Migration `0009` writes one row per live |
| +gone, touched_at, stamp)` is append-only and written in the same |
| +transaction as each bump, creation included; a change whose feed row cannot |
| +be written does not commit. `stamp` is the row's creation in unix |
| +nanoseconds, written once. Migration `0009` writes one row per live |
| document that existed before it, so a consumer's first poll sees the whole |
| library. *Live* is `deleted_at IS NULL AND owner_id > 0`: the orphans |
| `0002_owners.sql` made are readable by nobody and are not fed. |
| **S1.** Pages the log by `id`, 256 rows (`server.FeedPageLimit`). The cursor |
| -is the last row's id in decimal; `""` is the beginning, and a cursor that |
| -does not parse is answered from the beginning (a re-announce is always |
| -safe). At the tip Docs returns the cursor it was given and no rows. Every |
| +is `"<id>.<stamp>"` of the last row served, in canonical decimals; `""` and |
| +`"0"` are the beginning. The stamp is checked against the row on every |
| +request, and a cursor whose row is gone or carries another stamp — or any |
| +cursor Docs did not issue — is an error, which the suite package answers |
| +503: never a page, never a guess at a position. At the tip Docs returns the |
| +cursor it was given and no rows. Every |
| row is emitted, so a document edited ten times since the last poll appears |
| ten times; the earlier rows name revisions that are no longer current, S3 |
| answers them 404, and the consumer counts them missing until the last row |
| @@ -690,7 +699,13 @@ a deletion's row. |
| `address` in lone shape (grants and admission key on it; the person row is |
| looked up and never created), `person_ref` in team mode (the Home subject, |
| through connect's link and then the Home-only principal, exactly as a |
| -signed-in request resolves it, and the roster standing for that subject). An |
| +signed-in request resolves it, and the roster standing for that subject). |
| +In team mode standing is asked again **after** the reads, from the |
| +request's latched access: if it is no longer `Member` the readable set is |
| +read again without the membership clauses, so the team rung and ownership |
| +answer `UNKNOWN` (or `NOT_VISIBLE` for a `NotMember`) and only an |
| +independent address grant stays `VISIBLE`. A lease that runs out mid-call |
| +can neither hide a document silently nor authorise one. An |
| asker of the other kind answers `UNKNOWN` for every pair. In lone shape an |
| address that would not pass the front door (`allowlist.allows`: a configured |
| member, or a holder of a live grant) is refused like any other stranger. |
| @@ -710,6 +725,21 @@ change answers `ErrNotAvailable`, so a body is never labelled with a |
| revision it does not match. S3 carries no person, so it does not consult |
| `permissionScope`. |
| +**Restore from a backup (Astra's review, 2026-11-01).** What is protected: |
| +a revision or a feed position issued before a restore is never issued again |
| +after it. Counting revisions up from the restored value reissued them for |
| +different content — a private draft backed up, renamed to confidential |
| +text and held by memoria, restored and shared with the team, answered S2 |
| +`VISIBLE` for a teammate against the confidential copy — and AUTOINCREMENT |
| +reissued feed ids, so memoria's cursor met a tip that said nothing had |
| +changed. With the clock as the revision's floor every copy memoria holds |
| +from before the restore is `STALE` or `UNKNOWN`, withheld loudly; with the |
| +stamp, memoria's cursor is a 503. That 503 is the signal, not something to |
| +retry past: **after a restore memoria must drop everything it holds from |
| +Docs and its Docs cursor, and re-read from `""`.** The protection assumes |
| +the clock does not run backwards across the restore by more than the time |
| +between the backup and the restore. |
| + |
| **`DOCS_SUITE_CONSUMERS`.** `server.EnvSuffix`'s variable, strict JSON: |
| `[{"consumer_id":"memoria","tokens":[{"epoch":1,"sha256":"<64 hex>"}]}]`, |
| one or two tokens per consumer, each the SHA-256 of a token the operator |
| @@ -739,7 +769,10 @@ team mode, with the asker on the roster and the stranger off it. Docs' own tests |
| default and the migrated private rows, the rung for a member and not a |
| non-member, S1 paging, the tip, `gone` and every bump, every S2 branch, S3's |
| current-only rule, the CSRF exemption being exactly the three routes, no |
| -consumers meaning no routes, and the 401. |
| +consumers meaning no routes, and the 401; and, from Astra's review, the |
| +restore sequence above with a real SQLite backup, a lease running out |
| +before and after S2's reads, a change whose feed row cannot be written not |
| +committing, and a lone-shape guest answered 404 by every sharing route. |
| --- |