Spec: Fichas serves the suite contract under revision 10 (§6, §12.4)
Paul, 2026-11-01, suite revision 10: "Hold private too, check per person". Cites suite 12848f8 (status block, §4.2/§4.3 notes, §6.5) rather than restating it. For Fichas, where every admitted person sees every card: S1 is the events table (card events, gone = deleted), S2 is admission keyed on the address (lone shape), S3 is the card's text at its current revision. FICHAS_SUITE_CONSUMERS, mounting outside the CSRF check at exactly /suite/, the gates, and the fixture cases Fichas cannot represent (§6.7). Two open items added to §10.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+204
−4
docs/superpowers/specs/2026-09-19-fichas-design.md+204 −4
diff --git a/docs/superpowers/specs/2026-09-19-fichas-design.md b/docs/superpowers/specs/2026-09-19-fichas-design.md| index b67204e..76ed7eb 100644 |
| --- a/docs/superpowers/specs/2026-09-19-fichas-design.md |
| +++ b/docs/superpowers/specs/2026-09-19-fichas-design.md |
| @@ -333,9 +333,196 @@ only importer today and is a pure consumer. **Fichas would be the first |
| server**, with memoria as the waiting consumer — a real end-to-end exercise |
| of the contract, and the first-server design tax, both. |
| -S1 is §5's table. S2 answers per asker, intersected with custody. S3 is |
| -person-less and custody-scoped. **S9 (reach) depends on an unresolved |
| -ruling — see §10.** |
| +**Amended 2026-11-01 (this session, implementing the ruling below).** The |
| +contract this section builds against is suite doctrine **revision 10** at |
| +`amadan.net/oficina/suite` commit `12848f8` (branch `feat/server-half`, |
| +under review): its status block, the revision-10 notes at §4.2 and §4.3, |
| +and §6.5, the producer half `amadan.net/oficina/suite/server`. What they |
| +say is cited, not restated (suite AGENTS.md: "cite, never restate"). What |
| +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. |
| + |
| +**S9 (reach) depends on an unresolved ruling — see §10.** |
| + |
| +### 6.1 Paul's ruling, and why it costs Fichas nothing new |
| + |
| +Paul, 2026-11-01, suite revision 10: **"Hold private too, check per |
| +person"** — a consumer (memoria) holds every live item, and S2 rules on each |
| +one per person, per request, never cached. |
| + |
| +Fichas has no sharing ladder. Every admitted person already sees every card |
| +that is not gone: `Card.OwnerID` is provenance, not authority (models.go, |
| +and §9 — one instance per team, and the team shares its cards). So the |
| +ruling reads, for Fichas: |
| + |
| +- **S1** lists every card. `gone` means deleted, because deletion is the |
| + only way a card leaves anybody's view. |
| +- **S3** serves the text of any card that is not gone, at its current |
| + revision. |
| +- **S2** is "is this asker admitted to this Fichas instance", for a card |
| + that is not gone. |
| + |
| +The revision-9 sentence this replaces — "S2 answers per asker, intersected |
| +with custody. S3 is person-less and custody-scoped" — is withdrawn with the |
| +intersection (doctrine §4.3's revision-10 note). |
| + |
| +### 6.2 S1 is §5's events table |
| + |
| +§5 says the events table *is* S1, and the producer reads it and nothing |
| +else: |
| + |
| +- **Rows** are the `events` rows with `object_kind = card`, in id order |
| + after the cursor: `created`, `updated`, `deleted`, `entry_added`, and the |
| + catalogue's field-kind upgrade. An entry landing consumes a card revision |
| + and is logged on the card (`entry_added`, store.go `AddEntry`), so the |
| + entry's own `created` row (`object_kind = entry`, no revision) is skipped |
| + — the card row beside it already carries the bump. Type and field events |
| + are not items. |
| +- **A row is** `(card id, events.revision, events.kind = deleted, |
| + events.created_at)`: the card's revision *after* that event, whether it |
| + made the card gone, and when. All four are plaintext already under §4.1 |
| + case 1 and §4.2; serving S1 unseals nothing, and no row carries a title, |
| + a value, an owner or an actor. |
| +- **History is replayed, not collapsed.** A card edited three times since |
| + the cursor yields three rows; the consumer keeps the last. |
| +- **The cursor** is the decimal id of the last row returned. `""` is the |
| + beginning. At the tip the page is `rows: []` and the same cursor — except |
| + that `""` at an empty log answers `"0"`, because the contract refuses an |
| + empty cursor, and the next poll gets `"0"` back. `events.id` is |
| + `AUTOINCREMENT` and SQLite has one writer, so ids are committed in order |
| + and never reused: a cursor can never step past a row that commits later |
| + with a lower id. |
| +- **A cursor Fichas could not have issued is an error, never a page.** One |
| + that is not a canonical non-negative decimal, or that is ahead of the |
| + log's highest id (the database restored from an older backup), makes the |
| + feed fail, which §6.5 turns into a 503. An empty page there would stall |
| + the consumer silently on a log that has gone backwards; a 503 is loud. |
| + Whether it should instead re-announce from the beginning is §10's. |
| + |
| +**item_id is the card id as a canonical decimal string** — `"42"`, never |
| +`"042"` or `"+42"`, so one card has exactly one id on the wire. It is |
| +structural (§4.1 case 2), never content; `cards.id` is `AUTOINCREMENT` and |
| +cards are never deleted as rows (`DeleteCard` marks them gone), so an id is |
| +never reused for a different card. It tells the consumer roughly how many |
| +cards were ever made, which a consumer that holds every card knows anyway. |
| + |
| +### 6.3 S2 — admission, keyed on the address |
| + |
| +Fichas boots only in the lone shape (`FICHAS_SHAPE=suite` refuses to boot, |
| +config.go `ErrSuiteNotBuilt`), so it keys its members on a lowercased |
| +address, and an asker is a subject of kind `address` (doctrine §3). Per |
| +pair, in order: |
| + |
| +| Asker / item | Answer | |
| +|---|---| |
| +| kind `person_ref` — a kind Fichas does not key on | `UNKNOWN`, every pair | |
| +| `address`, not admitted (`Admit`: the `FICHAS_OWNERS` list, the one predicate sign-in and every session already run) | `NOT_VISIBLE`, every pair | |
| +| admitted; card gone, unknown, or an id that is not a canonical card id | `NOT_VISIBLE` | |
| +| admitted; asked revision = current | `VISIBLE` | |
| +| admitted; 1 ≤ asked revision < current | `STALE` | |
| +| admitted; asked revision > current, or < 1 (a revision the log never issued) | `UNKNOWN` | |
| + |
| +Nothing is cached: admission and every card's revision are read per call. |
| + |
| +### 6.4 S3 — the card as plain text |
| + |
| +Current revision only; anything else — gone, unknown id, a revision that |
| +is not current — is `suite.ErrNotAvailable`, which §6.5's package answers |
| +with its one empty 404. The revision is checked before the card is read and |
| +again after, so an edit that lands mid-read is refused rather than served |
| +under the old number. |
| + |
| +The body, lines joined by `\n` with no trailing newline: |
| + |
| +``` |
| +<the card's title> |
| +<Label>: <value> each other field with a value, in field order |
| + (blank line) |
| +<entry type label> each entry, newest first |
| +<Label>: <value> each of its fields with a value |
| +``` |
| + |
| +Values are as stored (a date is `2026-10-02`); labels and values are |
| +unsealed in memory for the response and nowhere else. A card with only a |
| +title is exactly its title. |
| + |
| +**A field rename does not move a card's revision** (§3: field definitions |
| +version on their own), so a consumer's copy keeps the old label until that |
| +card next changes. §10. |
| + |
| +### 6.5 Configuration and mounting |
| + |
| +`FICHAS_SUITE_CONSUMERS`, in the format doctrine §6.5 fixes, read by |
| +`server.ConsumersFromEnv(os.Getenv, "fichas")` inside `LoadConfig`: |
| + |
| +``` |
| +FICHAS_SUITE_CONSUMERS=[{"consumer_id":"memoria","tokens":[{"epoch":1,"sha256":"<64 hex>"}]}] |
| +``` |
| + |
| +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. |
| + |
| +`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 |
| +carries only `Authorization` — no `Origin`, no `Sec-Fetch-Site`. The CSRF |
| +check has nothing to protect there: the credential is a bearer header, |
| +which a cross-site form cannot attach. **Exactly `/suite/` is exempt**; |
| +every other route keeps the check. |
| + |
| +### 6.6 Gates |
| + |
| +- **Conformance.** `conformance.Check` 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 (one Customer card per case, its name the case's |
| + `s3_body`, edited up to the case's revision; the deleted case deleted), |
| + and its `person_ref` askers map to an admitted address (`asker`) and a |
| + non-admitted one (`stranger`). The adapter renames; it decides nothing. |
| + The test asserts the failures are **exactly** the eight listed in §6.7 |
| + — no more, no fewer — so a fixture change on the suite branch 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 |
| + 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 |
| + mutation-tested, recorded in the test's comment. |
| + |
| +### 6.7 What Fichas cannot represent from the custody fixture |
| + |
| +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 `12848f8`) describes a world with a |
| +sharing ladder. Fichas has none: |
| + |
| +| Case | Fixture state | Fichas | Result | |
| +|---|---|---|---| |
| +| `doc-team`, `doc-team-link` | team rung (± a link) | every card | passes | |
| +| `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 current (VISIBLE, wants NOT_VISIBLE) and behind (STALE, wants NOT_VISIBLE) | |
| +| `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 | |
| + |
| +Two more gaps, neither a failure because the adapter bridges them: |
| + |
| +- **The asker is suite-shape only.** Both fixture subjects are `person_ref`. |
| + A lone-shape producer keys on `address` and must answer `UNKNOWN` to a |
| + `person_ref`, so run unadapted every S2 check fails. A fixture with an |
| + `address` twin of each subject would let a lone producer run it as |
| + shipped. |
| +- **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 and S1 pass in full. The four failures 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. |
| ## 7. The derived summary |
| @@ -466,6 +653,14 @@ sealed or sealed+print only. |
| retention one, and TensorX's zero-retention posture does not answer it |
| (`memoria/ZDR-TREAT-AS-LOCAL.md` §6). Not a blocker at one user; a |
| blocker at the second team. |
| +- **S1 after a restore from backup** (§6.2). A consumer's cursor ahead of |
| + the log is a 503 today — loud, and stuck until someone resets the |
| + consumer. Re-announcing from the beginning would heal itself but replays |
| + every card's history. Open for Paul; added 2026-11-01. |
| +- **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 |
| + would fix it at the cost of a log row per card. Open; added 2026-11-01. |
| - **Whether fichas embeds at all**, or is keyword-only in memoria. Paul, |
| 2026-09-19: no preference. Decide when there is content; keyword-only is |
| the cheaper default and §10's egress ruling points that way. |
| @@ -489,7 +684,12 @@ In order, and small: |
| Call Log. No type designer. |
| 3. Capture from Calls (§8). |
| 4. The S1/S2/S3 server half and the conformance harness in CI (§6), so |
| - memoria indexes fichas like a Doc. |
| + memoria indexes fichas like a Doc. **Built 2026-11-01** on |
| + `feat/suite-producer` (over `feat/contract-demo`) against suite |
| + revision 10 at `12848f8`, under Paul's ruling of that day (§6.1): S1 |
| + 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. |
| 5. The derived summary, with citations (§7). |
| References and reach (§9) wait on §10's ruling. **Reshaping by sentence is |