oficina / home Public

Clone
git clone https://amadan.net/oficina/home

Plain git — no account needed to clone.

Download

Download this file

πŸ€– Team members: the Team page, and roster mode in every app

Status: APPROVED (design), 2026-10-27. Drafted by Claude Opus 5.5 for Paul. Reviewed by Claude Fable 5.1 (claude-fable-5-1), 2026-10-27, discussion 92, APPROVED (design, round 3) at 93f8209, after rounds 1 and 2 (CHANGES REQUIRED). Not approved by that verdict and gated separately: the shared handoff change (ConsumerConfig.StartPath) before the Team page; each slice (Team page, resolve, each app's roster port) β€” whole-code review, CI green, verified canary (amendment status, items 1 and 3). Part A implemented on branch team-page (base 82d9388) by Claude Opus 5.5, 2026-10-28; its deviations are Β§11. Slice A (Team page, resolve, addedat, membershipnames) reviewed by Claude Fable 5.1 (claude-fable-5-1), 2026-10-28, discussion 95, APPROVED at 1388016; non-blocking notes 1–7 applied before the squash, 8–10 recorded. Not deployed: the verified canary and production resolve keys come first. Base: Home origin/main e2ec1ab; Docs d867db1, Sheets af8deeb, Slides ebbb08f, Calendar 00d8e3d, Calls (repo oficina/meet, cmd/calls) 47afcb9, Memoria 521ae24. Paul's rulings, 2026-10-27, applied here: owner-chosen member names, sealed, refusing @; unnamed members show role plus a short ref; every member of a team sees its member list, only owners write; no "you've been added" mail from Home (owners tell people); port order Sheets, Slides, Memoria, Calendar, Calls. Implements spec ruling 23, Β§10 (memberships "written only at the directory origin, by a team owner, behind a fresh-assertion step-up"), Β§14's step-up row, and gate 21. Companions: team-provisioning-amendment.md (seeds the first owner) and team-provisioning-app.md.

---

1. Scope

Part A: a Team page on https://oficina.works that shows a team's members to every member of that team and lets an owner add, remove, promote, demote and name them. Part B: the follow-on β€” roster team mode in Sheets, Slides, Calendar, Calls and Memoria, which only Docs has today. Until Part B lands for an app, that app ignores the Team page and keeps admitting by its own allowlist.

2. The page

  • Route: GET /team?team=<sqid> (ruling 22: team views carry ?team=). Linked from the springboard's account menu as "Team" when the signed-in person is on the selected team.
  • Signed out: an anonymous GET /team?team=<sqid> follows the chooser (docs_chooser.go:142-154): 303 to /auth/start?return_to=… with the query preserved (spec Β§5.6), so a shared team link survives sign-in.
  • Who sees it: a directory session whose subject has a memberships row (owner or member) for that team. Everyone else signed in β€” a guest, a member of another team, a stranger, an unknown or malformed sqid β€” gets the same 404 as an unknown route (gate 4's pattern). The page's own answers are never 403; csrf.Protect and the host check, which run before the handler, keep their own codes.
  • Who writes: owners only. A member sees no write controls, and a member's POST to any write route gets the same 404 (gate 21).
  • Reading needs a session; writing needs a fresh one (round 1, blocker 4; round 2, blocker 2). The directory gains a second handoff.Consumer on the same Store, same ConsumerID (directory), with RequireFreshAuth: true, at its own start path /auth/fresh/start; Callback and Finish stay shared because they are store-level and the fresh requirement rides the pending row's path prefix. The existing consumer at /auth/start stays ordinary (RequireFreshAuth is per consumer, handoff/http.go:139-141). This cannot be mounted on today's handoff: Start calls c.guard(w, r, http.MethodGet, StartPath) and guard 404s when r.URL.Path != path (handoff/http.go:70-80, :107), with StartPath a package constant and no path field in ConsumerConfig. So it needs a reviewed change to the shared handoff module: ConsumerConfig.StartPath, defaulting to the constant, used by Start's guard. Sequencing: that change, its tests and its review land first; the Team page and the directory operator confirm page (amendment Β§4) both depend on it and come after. The fresh consumer asks the issuer for max_age=300 and enforces the five-minute window itself on finish. Every Team-page POST checks the directory session's auth_time is within 300 s and not in the future; if not, it renders the existing continuation page to /auth/fresh/start?return_to=%2Fteam%3Fteam%3D<sqid>, and the person repeats the action on return. The submitted change is not retained across the step-up (the chooser's expired-session rule). The same fresh consumer fronts the operator confirm page (amendment Β§4). noscript_test.go's route list gains /team, /team/add, /team/resolved, /team/confirm, the role/name/remove POSTs and /auth/fresh/start.
  • Inherited gap, stated: fresh-assertion.md's open rastrillo item applies. The fresh consumer's max_age=300 makes the issuer refuse a Keymail session with no reported gesture; but a directory session minted by ordinary SSO from such a session inside the last 300 s carries auth_time = At and passes a directory-side freshness check. The page inherits that gap until rastrillo lets an assertion carry an absent auth_time, exactly as Docs linking does. Writes that arrive through /auth/fresh/start are not affected. Recovery codes: a recovery-code sign-in mints AuthTime: now (passkey.go:28-39) and no method claim rides the assertion, so a fresh exchange from such a session passes here. For the Team page that is accepted β€” recovery is a current credential. The directory operator confirm page inherits the same two gaps; the credential confirm page is where Paul's method is visible and refused (amendment Β§4 step 3).
  • Scriptless. Every action is a plain form POST with CSRF; estilo's busy.js is the only script, already on Home's closed list.
  • Shape (estilo, Calma door rules β€” sky only on the team header):
 Owner's view
 Oficina β–Ύ Lagged                                        [account β–Ύ]
 ───────────────────────────────────────────────────────────────────
 Team                                                    [Add person]
   Till          Owner     added 27 Oct     [Make member] [Remove] [Name]
   You           Owner     added 27 Oct     [Make member] [Name]
   Member …k7q   Member    added 28 Oct     [Make owner] [Remove] [Name]
 Changes reach every app in this team within a minute.

 Member's view: the same list, no buttons, and
 "Only owners can change who is on this team."

3. Rules every write keeps

  1. Owner only, re-checked inside the write transaction (the page render is not authority).
  2. Never zero owners. Removing or demoting the last owner refuses with fixed copy. Without this a team's roster becomes unwritable and the only exit is the operator seed (Β§5.2's "operator reset in all but name").
  3. One membership row per (team, person). Adding an existing member refuses with "already on this team"; role changes use their own button.
  4. Epoch bumps come from the existing memberships_epoch_* triggers; no second increment. Instances see a change within the roster lease (refresh due 30 s, hard expiry 60 s β€” roster-contract.md).
  5. added_at (round 1, blocker 5): memberships gains a nullable added_at (integer day, coarsened per Β§3.3), written by directory.seed-team for the first owner β€” its INSERT INTO memberships(team_id,person_ref,role) (directory.go:254) changes to write it, part of "verbs wrapped" β€” and by /team/confirm; pre-migration rows hold NULL and show no date. Additive migration directorydata/migrations/0002_membership_added_at.sql; gate 2's static half reads it.
  6. Bounds: 500 members per team (well inside the roster's 10,000 and 100-per-page limits; a number with a reason: a team page, not a directory). 30 writes per owner per hour.
  7. Call 2 still cannot write memberships, and nothing here changes that.

4. Adding someone by email

The problem. The owner knows an address. The roster keys on a person ref. Turning one into the other needs the pepper, which only the credential role holds (ruling 4), and home-operator-seed.md rules that "the directory cannot request address resolution over HTTP." The directory must also never see the address at all β€” it is the origin that renders account-authored strings and holds the roster.

The design: the browser carries the owner to the credential origin, which resolves and signs. The address is typed on id.oficina.works, never on oficina.works.

  1. Directory, POST /team/add (owner, fresh). Stores an add-intent row: hash of a random 32-byte intent id, team id, requester person ref, chosen role, sealed optional display name (Β§5), expiry 10 minutes. 303s (via the continuation page) to https://id.oficina.works/resolve?consumer=directory&intent=<id>.
  2. Credential, GET /resolve. Requires a complete credential session. Renders fixed copy only β€” "Enter the email address of the person to add" β€” no team name, label or sqid on the page (origin separation, gate 5). The intent id rides a sealed __Host- cookie, as /authorize does.
  3. Credential, POST /resolve. Normalizes and blind-indexes with the sign-in helper; finds the person, or mints a person stub as spec Β§6 describes for a never-signed-in guest, using the helper that exists, findOrMintPersonOn (links.go:156) β€” call 2, which Β§6 names, is not implemented. Rate limited: 20 per subject per hour, plus the existing per-IP budget. Signs a member-resolution receipt: {v, purpose:"member-resolve", iss, aud:<directory>, requester:<session sub>, intent, person_ref, iat, exp ≀ 120 s, jti} with a new dedicated P-256 key (private half HOME_RESOLVE_KEY on the credential role only) under context oficina/home/member-resolve/v1. The directory pins the public half as HOME_RESOLVE_PUBLIC_KEY β€” a fourth pinned key beside HOME_ASSERTION_KEYS, the operator key and the roster keys β€” and it joins NewDirectory's key-inequality set. Auto-POSTs it to the directory with the existing handoff page (static script, Continue button with script off). The address is dropped. The response never says whether the person already existed.
  4. Directory, POST /team/resolved. Verifies the receipt (key, context, aud, expiry, single-use jti in its own store), loads the intent by hash, and requires requester = intent requester = current directory session subject. Like the assertion callback it does not write here: it stores the verified result in the sealed inbox and 303s to GET /team/confirm.
  5. Directory, POST /team/confirm (same-origin, CSRF, still fresh): re-checks owner, writes (team, person_ref, role) and the sealed name in one transaction, deletes the intent. Done.

Telling the person: Home sends nothing (Paul, 2026-10-27). The owner tells them; the confirm page says so: "Let them know β€” they sign in at oficina.works." Rejected: a fixed "you've been added" mail from the credential role.

What this costs the one rule. Nothing new at rest: the address is transient on the credential role, as on every sign-in; the directory holds a person ref, as it does for every member. Gate 2 gains a fifth path (resolve) that receives an address and must leave none readable, WAL included.

5. What the page shows β€” RULED 2026-10-27 by Paul

Owner-chosen display names, sealed at rest; a member without one shows role plus a short ref ("Member …k7q"). Rejected, recorded so they are not re-proposed: refs only (unusable past a few people); a name each person sets for themselves suite-wide (a new per-person preference, Β§8 keeps that set small); addresses pulled from the team's instances and rendered in RAM (grows Home, and Home-only members have no address in any instance); an address kept by Home (forbidden by the one rule).

Storage. membership_names(team_id, person_ref, sealed_name, updated_at day) in the directory DB, FK to memberships with ON DELETE CASCADE, sealed with the existing ID-bound helper under a new purpose (directory.member-name/v1/<team id>/<person ref>). 1–64 UTF-8 bytes; any value containing @ is refused with a field hint saying why, so a name is not quietly an address. A determined owner can still type "till at lagged dot biz"; it is sealed, so it is not readable at rest β€” the rule's test. Set when adding (optional) or later via [Name]; owners only; deleted with the membership row. Names never ride an assertion, call 8, a log or an error string.

Spec text this changes: Β§3.2's "Sealed" list gains "member display names"; Β§10's data-model list gains membership_names and memberships.added_at; the README's published list says owners can name members. Gate 2's static half reads the membership_names migration (directorydata/migrations/0003_membership_names.sql) and asserts the name column is a sealed BLOB.

5a. Every member sees the list β€” RULED 2026-10-27 by Paul

Checked against the rules:

  • The one rule (no readable address at rest, retains nothing from an instance): untouched. The list is rendered from the roster and the sealed names β€” Home's own records, not instance content β€” and nothing is added at rest beyond Β§5's sealed column.
  • Β§2.2's "only to that person" / "no operator view" governs content an instance hands Home; the roster is not that. The closest honest analogue is applied anyway: the list is rendered per request, only to a person who is on that team, and never to anyone else β€” no operator view, no cross-team view, no export, no API. A guest, a member of another team or Paul as operator gets 404 like any stranger.
  • Never cross a team: the query is keyed on the requested team and the viewer's own membership in it; gate 4 tests the cross-team case.
  • Never a support console: no path renders another team's list.

The privacy cost, stated plainly: every member learns who else is on the team, who the owners are, when each was added, and the name an owner chose for each person β€” including names the named person never saw or agreed to. An owner's private note used as a name ("Till – contractor, leaving March") is published to the whole team. The field hint says so: "Everyone on this team sees this name." Before this ruling only owners learned the roster from Home; members could already infer much of it from shared items in the instances, but not owner status or names.

6. Gates

  • Gate 21 β€” every write requires a fresh assertion (auth_time 301 s refuses; future refuses); call 2 cannot write memberships or names; a write naming a team the caller does not own answers the same 404 as an unknown team; a member (non-owner) can GET the list but gets 404 on every POST, and the page renders no write control for them.
  • Gate 4 β€” a member of Acme opening /team?team=<beta> gets 404; a guest of acme.docs (no roster row) gets 404 on Acme's list.
  • Gate 2 β€” resolve path extended; names containing @ are refused, and canary names appear only as ciphertext in the file, WAL and SHM.
  • Gate 5 β€” /resolve renders no account-authored string (scan with a canary team name and member name present in the directory).
  • Gate 9 β€” no address, member name, team name or person ref fragment in logs.
  • Step-up route β€” a stale-session POST renders the continuation to /auth/fresh/start; an assertion through it with auth_time 301 s old is refused at finish; the ordinary /auth/start consumer is unchanged. Anonymous GET /team?team=<sqid> 303s to /auth/start with the query preserved.
  • added_at β€” seed and confirm write a day value; pre-migration rows render no date; gate 2's static half covers both new migrations.
  • Last-owner β€” remove/demote the sole owner refuses; with two owners, either may leave.
  • Cross-origin β€” receipt replay, wrong aud, wrong requester (another owner's session), expired intent, a receipt for team A confirmed into team B, and a directory-only attacker (no credential session) all fail.

7. Part B β€” roster mode in the other five apps

What Docs already does (internal/docs/team_config.go, team_access.go, teamstate): DOCS_TEAM_ID, _DIRECTORY_ORIGIN, _PROVISIONING_BASE64, _OPERATOR_KEYS_BASE64, _ROSTER_TOKEN (all or none, and only with DOCS_HOME_*); a verified provisioning record; the home/roster cache; tri-state admission (Member / NotMember / Unknown); grant-only query mode when not a member; lease re-check before every commit and stream event; a fingerprint marker that refuses to boot back into allowlist mode. Each port copies that shape with <APP>_TEAM_* names and the same five variables. Shared code to extract first: a small home/teammode helper (config parse, record verification, admission middleware, fingerprint marker) so five apps do not re-implement Docs' team_config.go. (Built after the Sheets port, per Fable's sequencing on oficina/sheets #52: teammode-package.md.) Then per app:

| App | Admission today | Port work beyond the shared helper | Hard part | |---|---|---|---| | Sheets | SHEETS_OWNERS (everyone is co-owner) | Member = the team rung; grant-only mode for any per-sheet sharing; close live edit channels at lease expiry | None special | | Slides | SLIDES_ALLOWED_ADDRESSES | As Sheets. Team instances ship without uploads (no object storage on the account); when storage arrives, cap presigned GETs at the lease ceiling (60 s) | Asset URLs outliving removal, later | | Calendar | CALENDAR_ALLOWED_ADDRESSES | Published .ics feed tokens stay capability links (like Docs public links) and need an owner revoke; reminders need an address | Home-only members have no address in the instance β€” reminders need an in-app "email for reminders" the instance stores (ruling 5 allows instances to) | | Calls | CALLS_ALLOWED_ADDRESSES | Check standing at room join and on every signaling reconnect; close the signaling socket at lease expiry | Native Mac/iOS clients assume one host; they need a team-host picker and Home sign-in | | Memoria | MEMORIA_OWNERS | Grant-only mode applies to search results and the AI answer's sources; sibling calls already bind to MEMORIA_TEAM hosts | AI stays off unless the team owner asks and Paul agrees (see team-provisioning-app.md Β§5) |

Order β€” RULED 2026-10-27 by Paul: Sheets, Slides, Memoria, Calendar, Calls. Calls last because of native clients and live media.

Until an app is ported, its lagged instance runs Home sign-in plus its own allowlist holding only the owner's address (Track 1). Alta registers it as a credential consumer so Home sign-in works, but leaves its directory team_instances row pending: roster-contract.md forbids marking an instance live in the chooser before TeamMode passes its gates. Adding someone on the Team page therefore does nothing in that app until it is ported; Alta's per-instance allowlist edit (Paul only, retyping the address β€” Alta keeps none after a team is live) is the stopgap.

Acceptance per port: Docs' existing roster test list (two teams, removal within 60 s under failing refresh, grant-only vs owner shortcut, stream closure, fingerprint lock-in), plus a readiness probe GET /api/team returning only {team_mode, consumer, roster:"ok"|"stale"|"unknown"} for Alta's activation evidence. Full app CI, top-model review, verified canary.

8. Not in this design

Guests (unchanged: instance grants, kind = guest); per-team 2FA floor (Β§14); ownership transfer as its own verb (promote + leave covers it); invitations that wait for acceptance (membership is immediate; standing does nothing until the person signs in); suite-wide sign-out.

9. Still open

Nothing for Paul in this file; all four questions were ruled on 2026-10-27 (names, no mail, members read, port order). Round-2 review is owed on Β§2 and Β§5.

10. Round-1 findings: disposition

Blocker 4 (no route to start a step-up; "no 403 anywhere") β†’ Β§2: a second handoff.Consumer with RequireFreshAuth at /auth/fresh/start, named in the noscript route list; anonymous GET follows the chooser; 403 claim narrowed to the page's own answers. Blocker 5 (no added_at) β†’ Β§3 rule 5, Β§5 spec-text list. Notes: findOrMintPersonOn cited (Β§4 step 3); freshness gap inherited and stated (Β§2); HOME_RESOLVE_PUBLIC_KEY pinned and in the inequality set (Β§4 step 3); membership_names in Β§10 and gate 2 (Β§5); Calls repo named (status). Round 2: blocker 2 (fresh consumer not mountable) β†’ Β§2: reviewed handoff change (ConsumerConfig.StartPath), guard cited, sequenced first; recovery-code acceptance stated and cross-referenced; added_at nullable and the seed INSERT change (Β§3); the stopgap allowlist edit retypes the address (Β§7). None declined.

11. Part A as built (branch team-page): deviations and notes

Recorded in the same branch as the code, for the whole-code review. None changes a ruling; each is a choice the text left open or could not make.

  1. The migrations are their own set, oficina_directory_team (directorydata/team_migrations/migrations/0001_membership_added_at.sql, 0002_membership_names.sql, 0003_member_add.sql), applied by Runtime.ServingSchema, not files 0002/0003 in the frozen oficina_directory set β€” the shape round 4 (#94) ruled for the operator endpoint's tables, so the compatibility, admission and legacy profiles do not move. Because 0001 alters a frozen table, the legacy diagnostic now replays the whole serving schema beside the frozen one; an exact serving memberships stands in for the frozen one, any other change is still a mismatch. The native command refuses such a database, as it already does one carrying the operator set.
  2. added_at is written by seed-team over the operator endpoint only ("verbs wrapped"); the native command's path keeps its three-column INSERT, because its schema has no such column.
  3. The resolve key's inequality set: on the directory it is checked against HOME_ASSERTION_KEYS and the roster key at load, and added to the operator endpoint's distinct-key set (Alta's key, the owner-seed public key, the provisioning key, the roster keys) β€” the set NewDirectory's keys come from β€” rather than as a new NewDirectory parameter. On the credential role it is likewise kept apart from the assertion key and that role's operator keys.
  4. Both resolve keys are optional. Without them the page lists and edits members and offers no Add person; /team/add, /team/resolved, /team/confirm and /resolve answer 404.
  5. The account menu links "Team" once per directory team the person is on (at most eight; "Team: <name>" when several). The springboard's selected team is a HOME_DASHBOARD_TEAMS grouping, not a directory sqid, so "the selected team" has nothing to map to. It costs one indexed read per signed-in directory page.
  6. One live add per owner (team_add_intents.requester is unique); a newer add replaces the older.
  7. /team/resolved also requires the browser's intent cookie (__Host-oficina-team-add, set by /team/add) to equal the receipt's intent, beside the receipt's, the intent's and the session's subject. The jti is recorded inside the resolving transaction.
  8. A stale GET /team/confirm redirects to /auth/fresh/start back to /team/confirm, keeping the server-held intent (ten minutes); a stale confirm POST gets the continuation page to the same. Nothing was in the form to keep or lose, and the confirm POST still needs a fresh session. Every other stale write returns to /team?team=<sqid> and is not kept.
  9. The receipt: base64url(JSON payload) "." base64url(signature), the design's fields, ≀ 2 KiB; iat may lead the directory's clock by 5 s (two processes, perhaps two hosts); exp is strict.
  10. The 30-writes budget counts every owner POST, /team/add and /team/confirm included; in memory, per process, like sign-in's.
  11. Small things: the short ref is four characters ("Member …k7qz"); the sole owner is drawn no Make member or Remove; the @ refusal also covers the fullwidth and small commercial at; the page is plain under the bar (AGENTS.md: the sky goes on the door, the team home's header and the front page β€” "sky only on the team header" read as the team home's).
  12. Spec text: Β§3.2's sealed and plaintext lists and Β§10's data model are updated. There is no README in this repository to carry "owners can name members"; Β§3.2 carries it.
  13. "Call 2 cannot write memberships or names" β€” call 2 is not built, so gate 21's clause is a source scan: no production file but directorydata/members.go and internal/operator/directory.go writes either table.

The inherited freshness gap (Β§2) is recorded where the gap lives, fresh-assertion.md's open rastrillo item, and on teamFresh.

Not in Part A: the roster ports (Β§7, Part B); the verified canary on deployed previews; production HOME_RESOLVE_KEY/HOME_RESOLVE_PUBLIC_KEY.