Fichas spec §6: build against suite revision 11 at 91affa1
Cites the revision-11 doctrine (status block, §6 S1 row, §6.5, §6.6, §11 gates 3 and 5) at 91affa1; the cursor reset replaces the 503 and the manual reset; revisions redrawn against the whole log; no-store and what sits in front of Handler; CheckProducer and the named revisions in the gates and §6.7; doc-owner-left's withdrawal noted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+113
−43
docs/superpowers/specs/2026-09-19-fichas-design.md+113 −43
CI passed — run details
diff --git a/docs/superpowers/specs/2026-09-19-fichas-design.md b/docs/superpowers/specs/2026-09-19-fichas-design.md| index bd02e05..d66e99b 100644 |
| --- a/docs/superpowers/specs/2026-09-19-fichas-design.md |
| +++ b/docs/superpowers/specs/2026-09-19-fichas-design.md |
| @@ -345,6 +345,23 @@ follows is only what is particular to Fichas. Built on branch |
| `feat/suite-producer`, which sits on `feat/contract-demo` — the build that |
| is live — and not on `main`, which has no code. |
| +**Amended 2026-11-02 (this session, adopting revision 11).** Fichas now |
| +builds against suite doctrine **revision 11**, pinned at |
| +`amadan.net/oficina/suite` commit **`91affa1`** (suite `main`; Fable 5.1 |
| +APPROVE on 640d058, squashed to 91affa1): its status block, §6's S1 row, |
| +§6.5 (the producer half, `Handler` the only mount, |
| +`conformance.RunProducer`/`CheckProducer`, no-store on every response), |
| +§6.6 (revisions and cursors survive a restore; `CURSOR_RESET`), and §11 |
| +gates 3 and 5. Cited, not restated. What changed in Fichas for it: an |
| +unrecognised cursor is `server.ErrCursorReset`, not a 503 (§6.2); a new |
| +revision is redrawn against every revision the card's log holds, not only |
| +the current one (§6.2); the conformance test drives the producer through |
| +`server.Handler` via `CheckProducer` and asks at the fixture's named |
| +revisions (§6.6, §6.7). Gate 5 (a removed member) is Fichas' admission |
| +list: a removed address is `NOT_VISIBLE` on the next S2 call |
| +(`TestSuiteRuleIsNeverCached`); Fichas has no grants or ownership for it to |
| +keep, so §14's open question has nothing to act on here. |
| + |
| **S9 (reach) depends on an unresolved ruling — see §10.** |
| ### 6.1 Paul's ruling, and why it costs Fichas nothing new |
| @@ -398,8 +415,20 @@ else: |
| lower id. |
| - **Every request checks the cursor's nonce.** The event at the cursor's |
| id must still exist, be a card event, and carry that nonce. Otherwise |
| - the feed fails, which §6.5 turns into a 503 — loud, never a page. A |
| - cursor that is not in the canonical form fails the same way. |
| + the feed returns `server.ErrCursorReset`, which the package answers |
| + `409 {"code":"CURSOR_RESET"}` (doctrine §6.6, revision 11) — never a |
| + page, and since revision 11 never a 503 either, which stalled the |
| + consumer for ever. A cursor that is not in the canonical form, names an |
| + event ahead of the log, or one another log issued is reset the same way. |
| + Fichas expires and compacts nothing (the log is append-only, §5), so an |
| + expired cursor cannot arise; were events ever pruned, a cursor naming a |
| + pruned one would find no event and be reset. A failed *read* of the |
| + cursor's event stays an error, a 503 the consumer retries: a database |
| + that did not answer has not said the cursor is wrong. |
| +- **The stamp is the per-event nonce**, drawn at random for each event and |
| + written with it — the first of the two shapes doctrine §6.6 makes |
| + normative — so a restored log holds only the stamps of the events it |
| + has. |
| **item_id is `"<card id>.<card nonce>"`** — both parts canonical positive |
| decimals, so one card has exactly one id on the wire (`"042.…"`, `"+42.…"` |
| @@ -425,7 +454,8 @@ with `created_at`; on a clock that is frozen, or set back to where it |
| stood at the backup, a recreated card gets that too. A random nonce it |
| gets again only with negligible probability (2^-63 per draw): the old |
| item id is `NOT_VISIBLE` in S2 and refused in S3, and the event at the old |
| -cursor carries another nonce (or is gone), so S1 is a 503. |
| +cursor carries another nonce (or is gone), so S1 answers the reset |
| +(revision 11; a 503 under revision 10). |
| **Revisions are random, and their order is the log's (amended 2026-11-01, |
| this session, as Docs did).** The nonces leave one case: a card that |
| @@ -437,8 +467,14 @@ clock does too: frozen, or behind by less than the backup's age, and |
| `max(previous + 1, now)` is a counter again; and a backup from before a |
| clock scheme still holds the counter's small values. So **every revision |
| Fichas issues — creation and every change — is a fresh random positive |
| -int63** from crypto/rand (store.go `nextRevision`), redrawn in the |
| -vanishing case that it equals the card's current one (and when it is 0). |
| +int63** from crypto/rand (store.go `nextRevision`), redrawn when it is 0 |
| +and, for a change to an existing card, while it equals **any revision the |
| +card's log holds** — the current one or any before it (store.go |
| +`freshRevision`, doctrine §6.6's L4, revision 11; revision 10's Fichas |
| +checked only the current one). The check reads the card's own card-kind |
| +events inside the write's transaction; a failed read fails the write, and |
| +a source that yields nothing fresh in eight draws fails it loudly rather |
| +than spinning. A new card has no log to collide with. |
| A reissue has negligible probability — 2^-63 per draw — so memoria's held |
| revision after a restore is `UNKNOWN` (the restored log never issued it) |
| and S3 refuses it: not `VISIBLE` for different text, whatever the clock |
| @@ -476,11 +512,13 @@ equality. |
| 0005 only fills nonces that were 0, and its triggers refuse any later |
| change. |
| -**The reset is kept.** A restore still rewrites the feed, so S1 still |
| -answers the consumer's cursor with a 503 (the cursor's nonce). On that |
| -503: **reset the consumer** — discard every item it holds from this |
| -instance and its cursor, and re-read from `""` — so held copies that S2 |
| -now answers `UNKNOWN` are replaced rather than withheld for ever. |
| +**The reset is the contract's now (revision 11).** A restore still |
| +rewrites the feed, so S1 answers the consumer's old cursor with the reset: |
| +`409 {"code":"CURSOR_RESET"}`. What the consumer then does — hide every |
| +item it holds from this instance, re-read from `""`, retire what the |
| +re-read does not list, at most one reset per re-read — is doctrine §6.6's |
| +consumer half, binding on memoria, and replaces the manual reset revision |
| +10's 503 needed. |
| ### 6.3 S2 — admission, keyed on the address |
| @@ -544,6 +582,16 @@ FICHAS_SUITE_CONSUMERS=[{"consumer_id":"memoria","tokens":[{"epoch":1,"sha256":" |
| Unset or empty: no consumers, and **the routes do not exist** — `/suite/` |
| falls through to the app like any unknown path. Malformed: boot is refused. |
| +**Every suite response is `Cache-Control: no-store`, `Vary: Authorization`** |
| +(doctrine §6.5, revision 11) — set by `server.Handler` on each 200, each |
| +refusal, the reset, the 401 and the mux's own 404 and 405. What sits in |
| +front of `Handler` in production is rastrillo's panic recovery and its |
| +`securityHeaders` (CSP, nosniff, X-Frame-Options, Referrer-Policy, set |
| +before the handler runs; nothing about caching), then `App`'s outer |
| +`ServeMux`; no Fichas middleware wraps `/suite/`. The harness covers |
| +`Handler` only, so `fichastest.TestEverySuiteResponseIsNoStore` checks the |
| +two headers through `rastrillo.Handler` around `App` as `main` builds it. |
| + |
| `server.Handler` is mounted on the outer `ServeMux` at `/suite/`: outside |
| the session group, and outside the chi router whose app-wide |
| `csrf.Protect(cfg.Origin)` would refuse memoria's `POST /suite/s2`, which |
| @@ -554,27 +602,36 @@ every other route keeps the check. |
| ### 6.6 Gates |
| -- **Conformance.** `conformance.CheckAs(h, suite.SubjectAddress)` — the |
| - harness's entry point for an address-keyed app — runs in `make ci` |
| - against `server.Routes` over the real producer and a real database, |
| - through a test-only naming adapter: the fixture's item ids map to the |
| - card ids seeded for them (and feed rows map back) (one Customer card per case, its name the case's |
| - `s3_body` (the deleted case deleted). Random revisions cannot be edited |
| - into the fixture's small numbers, so each card's two events and its row |
| - are then set directly: its current revision R, and a history event at |
| - R − 1, so "one behind" is in its log (`STALE`) and "one ahead" is not |
| - (`UNKNOWN`). |
| - `CheckAs` sends the fixture's asker and stranger as addresses with their |
| - values unchanged; `pers_ana` is put on the owners list and `pers_bo` is |
| - not. The harness also asks under `person_ref`, which Fichas must answer |
| - `UNKNOWN`, follows S1 to its tip, and asks S3 one revision either side. |
| - The adapter renames ids; it decides nothing. |
| +- **Conformance.** `conformance.CheckProducer(p, suite.SubjectAddress)` — |
| + revision 11's entry point for an app on `suite/server`, which mounts the |
| + producer through `server.Handler` behind a token it mints and requires |
| + the 401 without it — runs in `make ci` over the real producer and a real |
| + database, through a test-only naming adapter: the fixture's item ids map |
| + to the card ids seeded for them (and feed rows map back). One Customer |
| + card per case, its name the case's `s3_body` (the deleted case deleted). |
| + Random revisions cannot be edited into the fixture's numbers, so each |
| + card's two events and its row are then set directly: the first event at |
| + the case's `prior_revision`, the last and the row at its `revision` — the |
| + fixture's names, never computed — so the prior revision is in its log |
| + (`STALE`) and the case's `unknown_revision` is not (`UNKNOWN`). |
| + `CheckProducer` sends the fixture's asker and stranger as addresses with |
| + their values unchanged; `pers_ana` is put on the owners list and `pers_bo` |
| + is not. The harness also asks under `person_ref`, which Fichas must answer |
| + `UNKNOWN`; asks S2 about an id Fichas does not know (`NOT_VISIBLE`); |
| + follows S1 to its tip and asks it from a cursor no log issued (the |
| + reset); refuses S3 at the other two revisions, with no, a malformed or a |
| + zero revision, and on POST; and holds every response to no-store and |
| + `Vary: Authorization`. The adapter renames ids; it decides nothing. No |
| + test calls the deprecated `server.Routes`. |
| The test asserts the failures are **exactly** the twelve listed in §6.7 |
| - — no more, no fewer — so a fixture change on the suite branch fails |
| + — no more, no fewer — in the harness's own words at `91affa1`, and pins |
| + the fixture's nine case ids, so a fixture change on the suite side fails |
| loudly here rather than being absorbed. |
| - **Fichas-native tests** (`suite_test.go`, `fichastest/suite_test.go`): |
| S1 paging, tip, `gone` on delete, the revision bump on update and on an |
| - entry, malformed and future cursors; every S2 branch above; S3 |
| + entry, malformed, future and restored cursors reset (and a failed cursor |
| + read a 503, not a reset); a new revision fresh against the card's whole |
| + log; every S2 branch above; S3 |
| current-only and the text shape; the CSRF exemption is exactly |
| `/suite/`; no consumers, no routes; a configured consumer and no token is |
| a 401; a malformed `FICHAS_SUITE_CONSUMERS` refuses boot. Every guard |
| @@ -585,8 +642,8 @@ every other route keeps the check. |
| Evidence for the suite, where its AGENTS.md says fixtures are corrected by |
| the second implementation. Not changed there from here. |
| -The fixture (`fixtures/custody.json` at `c38e3ad` (suite main; the reviewed branch tip 983114a plus polish)) describes a world with |
| -a sharing ladder. Fichas has none: |
| +The fixture (`fixtures/custody.json` at `91affa1`, revision 11: nine |
| +cases) describes a world with a sharing ladder. Fichas has none: |
| | Case | Fixture state | Fichas | Result | |
| |---|---|---|---| |
| @@ -594,22 +651,32 @@ a sharing ladder. Fichas has none: |
| | `doc-deleted` | deleted | a gone card | passes | |
| | `doc-private` | private, the asker owns it | no private state; every member sees it | passes, **by coincidence**: VISIBLE because every member sees every card, not because of ownership | |
| | `doc-granted` | granted to the asker | no grants | passes, **by coincidence**, as above | |
| -| `doc-guest` | granted to a guest only | no guests, no grants | **fails** S2 for the asker at the current revision (VISIBLE), one behind (STALE) and one ahead (UNKNOWN); the fixture wants NOT_VISIBLE at all three | |
| +| `doc-guest` | granted to a guest only | no guests, no grants | **fails** S2 for the asker at the current revision (VISIBLE), at the case's prior revision (STALE) and at its never-issued revision (UNKNOWN); the fixture wants NOT_VISIBLE at all three | |
| | `doc-link` | private to someone else, link-shared | no private state, no links | **fails**, as above | |
| | `doc-was-team` | moved from team to private | no private state | **fails**, as above | |
| | `doc-link-added-late` | private, link added later | no private state, no links | **fails**, as above | |
| +Revision 11 proposed a tenth case, `doc-owner-left` (private, owned by a |
| +member who has lost team standing, `NOT_VISIBLE` to everybody); it was |
| +withdrawn at `91affa1` pending Paul's ruling (doctrine §14). Were it |
| +restored, Fichas could not express it either — a card's owner is |
| +provenance, and every admitted person reads every card — and the test's |
| +pinned case list would fail first. |
| + |
| One more gap, not a failure because the test's adapter bridges it (a |
| second, the fixture's suite-shape-only askers, was closed upstream at |
| -`c38e3ad` (suite main; the reviewed branch tip 983114a plus polish) by `CheckAs`): |
| +`c38e3ad` by `CheckAs`, which `CheckProducer` runs): |
| - **Item ids are names, not an app's ids.** `doc-team` is not a card id; |
| an app whose ids it allocates itself cannot seed them as given. |
| -S3 (current and superseded revisions) and S1 (every live item at its |
| -current revision, the deleted one gone, paged to the tip) pass in full, as |
| -do every stranger question and every `person_ref` question. The twelve failures — four cases, three revisions each |
| -— are not bugs to fix in Fichas: |
| +S3 (current, prior and never-issued revisions, and the malformed-revision |
| +and POST refusals), S1 (every live item at its current revision, the |
| +deleted one gone, paged to the tip; the never-issued cursor reset), the |
| +unknown-id questions, the 401 and the no-store headers pass in full, as do |
| +every stranger question and every `person_ref` question. The twelve |
| +failures — four cases, three revisions each — are not bugs to fix in |
| +Fichas: |
| bending the producer to refuse cards that every member can open in the app |
| would make memoria hide what Fichas shows. |
| @@ -747,14 +814,14 @@ sealed or sealed+print only. |
| for consistent whole-database restores and forward-only migrations |
| (§6.2): a card recreated after a restore passes as one memoria holds |
| only with negligible probability (the item id's random nonce); a feed |
| - position rewritten by a restore is a 503, not a silent continuation (the |
| - cursor's nonce); and a card edited after the restore reissues a |
| - revision memoria holds only with probability 2^-63 per draw (random |
| - revisions, ordered by the log). The reset is |
| - manual today: on a Fichas S1 503 after a restore, discard everything |
| - memoria holds from this instance plus its cursor, and re-read from `""`. |
| - Open for Paul: whether memoria should do that by itself on a persistent |
| - S1 503. |
| + position rewritten by a restore is reset, not a silent continuation (the |
| + cursor's nonce); and a card edited after the restore cannot reissue a |
| + revision its restored log holds, and reissues one memoria holds only |
| + with probability 2^-63 per draw (random revisions, ordered by the log). |
| + *Amended 2026-11-02:* the reset is no longer manual. Revision 11 answered |
| + the question this item left open for Paul: S1 answers the cursor |
| + `409 {"code":"CURSOR_RESET"}` and the consumer starts over by itself |
| + (doctrine §6.6). |
| - **A field rename and memoria's copy** (§6.4). Renaming a field moves no |
| card's revision, so memoria keeps the old label in its copy of each card |
| until that card next changes. Bumping every card of the type on a rename |
| @@ -788,6 +855,9 @@ In order, and small: |
| from the events table, S2 as admission, S3 as the card's text, mounted |
| only when `FICHAS_SUITE_CONSUMERS` is set. Conformance runs in CI with |
| the inexpressible cases asserted (§6.7). Not deployed, not merged. |
| + **Moved to revision 11 at `91affa1` on 2026-11-02** (branch |
| + `feat/suite-r11`, from `main`): the cursor reset, the log-wide revision |
| + redraw, `CheckProducer` (§6 intro). |
| 5. The derived summary, with citations (§7). |
| References and reach (§9) wait on §10's ruling. **Reshaping by sentence is |