oficina / docs Public

Spec: the Team rung and the suite producer half (suite revision 10)

§8.2.1 records Paul's 2026-11-01 ruling "New docs Team, old private": a
documents.visibility column, team for new documents, private for existing
ones and for the sample library, readable by every admitted member and
writable only as before. §8.2.2 is how Docs serves suite revision 10
(commit 12848f8, "Hold private too, check per person"): the revision
counter, the suite_feed log, S1/S2/S3 as Docs implements them,
DOCS_SUITE_CONSUMERS, what is plaintext and the gates. §14a cites revision
10 and §6.5 and records the module-path move as a follow-up.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 47b88d5846977612446e4df6c40231b60784aad7 parent 7d218bd
1 file changed, +152 −9
  • docs/superpowers/specs/2026-08-30-docs-design.md +152 −9
diff --git a/docs/superpowers/specs/2026-08-30-docs-design.md b/docs/superpowers/specs/2026-08-30-docs-design.md
index 28d8d7d..9c3a16e 100644
--- a/docs/superpowers/specs/2026-08-30-docs-design.md
+++ b/docs/superpowers/specs/2026-08-30-docs-design.md
@@ -594,18 +594,146 @@ ruling 2). A link does not move data — whoever holds it reads the document
here, on this instance — so it forbids nothing here.
**Within a team, Docs is one of several apps sharing one trust domain**
-(suite ruling 1). Same-team siblings may pull team-visible documents under
-the suite contract, and Docs serves S1, S2, S3 and S8 wherever sibling
-consumer tokens are in its platform config. That switch is independent of
-whether a home is present (suite §3): Docs serves a lone memoria with no
-home in the picture.
+(suite ruling 1). Same-team siblings may pull documents under the suite
+contract, and Docs serves S1, S2 and S3 wherever sibling consumer tokens are
+in its platform config (§8.2.2). S8 is not served yet (§14a). That switch is
+independent of whether a home is present (suite §3): Docs serves a lone
+memoria with no home in the picture.
**Only the team rung is team-visible** (suite ruling 15). A document that is
private, granted to named people, or reachable only by link is never
-team-visible, so no sibling may hold a copy of it — and §8.2's existing rule
-that a link share is *viewer or commenter, never editor* is the rule suite
-ruling 15 adopts suite-wide. It stays here as the original; the doctrine
-cites it rather than restating it.
+team-visible — and §8.2's existing rule that a link share is *viewer or
+commenter, never editor* is the rule suite ruling 15 adopts suite-wide. It
+stays here as the original; the doctrine cites it rather than restating it.
+
+> **Suite revision 10 (Paul, 2026-11-01, commit `12848f8`) changes what a
+> sibling may hold, not what the rung means.** This paragraph used to end
+> "so no sibling may hold a copy of it". Revision 10's notes at §4.2 and
+> §4.3 overrule that: a consumer holds every live document, and the rung
+> decides who may read one only through Docs' own read check, asked per
+> person through S2. §8.2.2 is how Docs serves that.
+
+### 8.2.1 The team rung (Paul, 2026-11-01)
+
+Paul's ruling, 2026-11-01, asked how Docs' sharing should default once a
+document could be shared with the whole team: **"New docs Team, old
+private."** A document created from now on is on the `team` rung unless its
+owner makes it private; a document that already existed stays private until
+its owner shares it. Suite revision 10's status block records the same
+ruling.
+
+- **The column.** `documents.visibility` is `private` or `team`
+ (migration `0009_suite.sql`, a CHECK holding the two values). The
+ migration's column default is `private`, which is what every existing row
+ gets. `Store.Create`/`CreateDraft` write `team` explicitly; nothing writes
+ the empty string.
+- **One exception: the sample library is private.** The six sample documents
+ `EnsurePerson` seeds (`Config.SampleDocuments`) are one person's welcome
+ content, and on the team rung every member's copies would sit in every
+ other member's list. `Seed` creates them `private`.
+- **Who reads a team document.** Every admitted *member*, and only for
+ reading. Lone shape: an address on `$DOCS_ALLOWED_ADDRESSES`
+ (`allowlist.configured`) — a guest admitted only by a grant is not a
+ member and gets nothing from the rung. Team mode: a person whose roster
+ standing is `Member` under a current lease. `NotMember` gets nothing;
+ `Unknown` gets nothing from the rung, exactly as it gets nothing from
+ ownership, and a list built under it is partial as before.
+- **Editing is unchanged.** The owner and writer grants edit; the team rung
+ never writes, never shares and never publishes. Links and grants do what
+ they did.
+- **One predicate.** The rung is a third clause of `Store.permissionScope`
+ (`team_access.go`) for `permissionRead` only, so `GetFor`, `ListFor`,
+ the export routes, the stream, the update log and S2 all read it from the
+ same place. It never reads `links`.
+- **The control.** The share page carries a "Who on your team can read it"
+ section: one plain form, the direction in a hidden field (the shape the
+ public link already uses), owner- and member-only like granting, and a
+ 303 back. No script. The list marks a team document someone else owns
+ "Shared with the team".
+
+### 8.2.2 Serving the suite contract (suite revision 10)
+
+Docs implements `server.Producer` from `amadan.net/oficina/suite/server`
+(suite §6.5, read at commit `12848f8`) and mounts `server.Handler`. The
+package owns the bearer check, the wire shapes, the S2 decode and cap and
+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
+(`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.
+
+**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
+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
+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
+supersedes them. `item_id` is the document's sqid; `gone` is true only on
+a deletion's row.
+
+**S2.** The asker is mapped to the actor Docs keys on in its current shape:
+`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
+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.
+Then, for each pair: a deleted or unknown id is `NOT_VISIBLE`; a document
+the actor may not read through `permissionScope` is `NOT_VISIBLE`, or
+`UNKNOWN` when team standing is `Unknown`; a readable one is `VISIBLE` at
+the current revision, `STALE` below it, and `UNKNOWN` above it or at a
+revision below 1. A Home subject with no Docs principal yet still reads the
+team rung by standing alone, since its first sign-in would. Nothing is
+cached: every call reads the roster lease and the database afresh.
+
+**S3.** The current revision only; anything else is
+`suite.ErrNotAvailable`, as is a deleted or unknown id. The body is plain
+UTF-8: the title, a blank line, then `Store.Text`. An untitled document is
+its text alone. The revision is read again after the text is replayed and a
+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`.
+
+**`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
+mints. Unset or empty: no consumers, and `/suite/*` is the 404 every
+unknown path gets. Malformed: `New` refuses to start.
+
+**Where it is mounted.** On the outer `ServeMux` beside the chi router, as
+exactly `GET /suite/s1`, `POST /suite/s2` and `GET /suite/s3/{item}`. So it
+sits outside the session and admission groups and outside `homeCSRF`, which
+memoria's `POST /suite/s2` would fail (it sends only `Authorization`, no
+`Origin` and no `Sec-Fetch-Site`). Every other path, `/suite/` prefix
+included, still goes through the router and its CSRF check.
+
+**What is plaintext.** S3's body leaves Docs as plaintext to a
+bearer-authenticated consumer: the content sealing (`content_cipher.go`)
+protects bytes at rest, and S3 is a read of them like the editor's.
+`suite_feed` holds ids, revisions and times only; `visibility` and
+`revision` are metadata beside the `title` column that was already
+plaintext. Nothing here logs a title or text.
+
+**Gates.** `conformance.Run` from `amadan.net/oficina/suite/conformance`
+runs in `go test ./...` against the real producer over a team-mode store
+seeded with `fixtures/custody.json`'s world. Docs' own tests hold the team
+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.
---
@@ -1143,6 +1271,21 @@ Docs does **not** restate any of them. Where this spec previously did — the
five-call contract in §9.1, the instance boundary in §8.2, the egress reason
in §11.2 — the restatement has been replaced by a citation.
+**Suite revision 10, commit `12848f8` (2026-11-01), consumed for the producer
+half.** Paul's ruling that day, **"Hold private too, check per person"**,
+widens custody to every live item; the revision's notes at §4.2 and §4.3 and
+its new §6.5 (the producer package) are what §8.2.2 implements. Docs cites
+them by number and does not restate them. Where rulings 3 and 14 above
+speak of custody as team-visible items, revision 10's §4.2 note governs.
+The doctrine is under review at that commit and may change in small ways;
+§8.2.2 is re-read against whatever lands.
+
+**Docs imports the contract module under its old path.** Suite §10 says Docs
+moves from `github.com/carlosframework/docs` to `amadan.net/oficina/docs`
+before it imports the contract. Importing works without the move — `go get
+amadan.net/oficina/suite@12848f8` resolves through the hub — so the move
+stays a follow-up of its own rather than riding this change.
+
**Not yet consumed**, because they need work this spec has not specified:
the hand-off (suite §7.1), which needs a receipt route, pending state and a
confirmation step on the create endpoint; and S8 write-as-self (suite §7.2),