Specify delegated Slides operations and atomic creation
1 file changed,
+35
−0
docs/superpowers/specs/2026-10-25-agent-access.md+35 −0
diff --git a/docs/superpowers/specs/2026-10-25-agent-access.md b/docs/superpowers/specs/2026-10-25-agent-access.md| new file mode 100644 |
| index 0000000..9cc0c83 |
| --- /dev/null |
| +++ b/docs/superpowers/specs/2026-10-25-agent-access.md |
| @@ -0,0 +1,35 @@ |
| +# Delegated Oficina access for Slides |
| + |
| +Status: proposed implementation specification. User requested one browser grant across Oficina and all four first clients: CLI, Paseo, ChatGPT, Claude. This is the named MCP consumer that activates design §7.3. Transport is the temporary shared `amadan.net/oficina/agent-access.git` module at 8ed8ba8, with migration to Rastrillo after its matching capabilities ship. Existing drive API remains supported. |
| + |
| +## Initial contract |
| + |
| +Disabled unless SLIDES_AGENT_ISSUER and SLIDES_AGENT_TEAM are both set. Require a valid configured Home bridge and exact canonical HTTPS origins, with separate identity and delegation issuers. Validate before schema/storage changes. App audience is its origin plus `/api/v1`. Construct NewRemoteVerifier(delegation issuer, audience, Home issuer); introspection must return identity_issuer exactly equal to configured Home issuer, refusing missing or different namespaces. Bearer-only `/api/v1/operations` discovery and `/api/v1/operations/{name}` POST routes mount outside browser CSRF, alongside the existing drive router. No session/token creation or implicit Home linking. |
| + |
| +Three descriptors feed identical API, CLI and MCP contracts, all requiring the configured team: |
| + |
| +- `slides_list_decks`, slides:read: bounded metadata, 20 default / 100 maximum, descending internal numeric ID encoded as a canonical decimal string cursor. SQL uses existing visibleDecks owner/team/explicit-grant seam before LIMIT. Public deck identifiers remain exact ten-character sqids. Return only sqid/title/theme/revision (decimal string) and next_cursor; no eager core opens. |
| +- `slides_get_deck`, slides:read: exact sqid; current visibility; one replay at the selected row's seq returns the raw h.JSON canonical block-tree view (not a deck.Deck remarshal, which can truncate fractional z), including speaker notes, with sqid and decimal-string revision. No second document representation or lossy conversion. Whole result at most 1 MiB; oversize is an explicit failure. |
| +- `slides_create_deck`, slides:write: nonzero canonical UUID client_id, title at most 512 UTF-8 bytes, optional existing theme (default paper), 1–50 typed slides. Each slide has heading/body_markdown/notes_markdown, combined text at most 128 KiB. Build existing `set_meta`, `add_slide`, `add_block`, and `set_notes` ops with server-minted IDs, title-body template. Existing core parses Markdown; its shape check must pass before storage. New decks are private, owned by current local user. Return bounded sqid/url/revision only; no invitations/sharing/export/presentation effects. |
| + |
| +Strict Unicode and duplicate/unknown-field checks precede ordinary decoding. Shared schema validation remains authoritative for field types/bounds; bounded request and response at 1 MiB. Public machine errors use stable shared codes and no storage/credential details. Existing browser/drive behavior and content storage policy are preserved. |
| + |
| +## Identity, storage and atomic retry |
| + |
| +Resolve the exact Home issuer/subject through the existing bridge to a currently admitted existing local User. Never infer the local account from subject/email and never create one. Capture stable user ID and email and original Subject/Client/Grant. Reverify the original bearer against the original verifier, required scope/team, and all three fields after obtaining the SQLite writer and immediately before every commit, including completed retries. Inside transactions use the transaction's connection to re-read the Home link and local user/current admission; do not call a second DB connection while holding the writer. |
| + |
| +Add separate additive agent migrations for singleton authority marker, creation receipts and connection attribution. Home DEK-derived keyed fingerprints bind marker to the key and exact identity issuer, delegation issuer and team. The first marker can be established only with BOTH receipt and attribution tables empty; otherwise refuse explicitly. Check it at startup and as the transaction's first write. Changing key/namespace must refuse instead of silently starting a new retry namespace. |
| + |
| +Creation coordinate fingerprints both issuers, subject, client, team and canonical UUID; normalized typed payload (trimmed nonempty title, defaulted theme, exact ordered slide strings, never minted IDs) has its own fingerprint. Attribution fingerprints both issuers/subject/client/team/local-user ID, stores encrypted client label under the Home DEK, and uses `connection:<fingerprint>` in the existing DeckUpdate actor column. Bind ciphertext purpose to that immutable coordinate; extend actorLabels with a batched connection lookup before numeric actor parsing, recover the client label plus operator and existing agentMark for browser history attribution. No fake person or old agent token. No content/credentials in central logs or receipts. |
| + |
| +Factor the domain persistence body of applyOps into a transaction-local helper. It retains the existing optimistic seq check and DeckUpdate insertion and performs no publish or snapshot. Existing applyOps wraps it and retains postcommit view/publish/snapshot behavior. Similarly factor createDeckRow onto a supplied DB transaction, preserving sqid retries and private defaults. The new adapter's single transaction reserves writer/marker, checks authority, claims/re-reads receipt, creates row, applies the canonical op batch, explicitly runs BOTH h.Check and h.JSON plus deck.Parse before commit, writes sealed attribution and receipt, then final authority check. A failed step rolls back metadata/log/receipt/attribution together. Return sufficient parsed view/seq state from creation so postcommit parsing cannot turn a committed create into failure; preserve existing applyOps wrapper behavior for its established callers. Discard mutated handles after rollback. Publish seq and optional snapshot only after successful commit. New create response is already bounded, so a large deck read cannot turn a committed create into a failed retry. |
| + |
| +Completed receipt must match payload, still reference an existing currently visible deck, and never apply content again; deletion yields 404 and browser edits survive. Six concurrent identical first requests must converge to one deck/update/receipt. Restart must use durable receipts with the same binding. |
| + |
| +## Read emission and tests |
| + |
| +Track every returned deck and recheck original bearer, fresh Home/local identity and current visibleDecks access immediately before response headers and each at-most-64-KiB write. Use bounded verification/write deadlines and abort partial HTTP responses on loss of authority. This is shared across discovery/list/get/create responses. No response is emitted from Registry.HTTP directly. |
| + |
| +Meaningful tests use real Home link fixtures, real core replay and actual HTTP transports: disabled/partial configuration; wrong team/scope/identity namespace; private/team/granted visibility before pagination; exact large IDs; strict invalid Unicode and unknown fields; bounded create/input/output; atomic rollback at update/receipt/final authority stages; reserved-writer revocation; changed principal/local link/admission; startup and live marker tampering; independent old receipt/attribution adoption refusal; fresh restart, concurrent create, preserved subsequent browser edits and deleted retry; actual chunked response revocation. A real HTTPS grant-service/CLI/MCP fixture discovers and creates/reads/retries a deck and refuses after logout. Mutation evidence must distinguish each critical boundary from a later check masking its absence. |
| + |
| +Run the full `.amadan/ci.d/10-gate`, focused race checks, source review and remote CI before merge. No deployed or four-host certification is claimed until real tests run there. Follow-on semantic edits, assets, export/presentation/sharing require separate contract work against existing domain seams. |