oficina / slides Public

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

Plain git — no account needed to clone.

Download

Download this file

1# Delegated Oficina access for Slides
2
3Status: 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.
4
5## Initial contract
6
7Disabled 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.
8
9Three descriptors feed identical API, CLI and MCP contracts, all requiring the configured team:
10
11- `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.
12- `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.
13- `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.
14
15Strict 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.
16
17## Identity, storage and atomic retry
18
19Resolve 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.
20
21Add 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.
22
23Creation 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.
24
25Factor 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.
26
27Completed 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.
28
29## Read emission and tests
30
31Track 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.
32
33Meaningful 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.
34
35Run 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.
36
37## Build reproducibility amendment
38
39The full gate discovered that unchanged Slides Rust source rebuilt under the pinned 1.98.0 compiler differs from the committed Wasm: Cargo crate identities and symbol/code ordering vary by checkout and host despite remapped diagnostic paths. Adopt the existing Docs canonical builder for both Slides modules: Linux amd64, fixed `/work` source and fixed Cargo/Rustup roots, pinned Rust Docker image (or the same fixed-root bubblewrap environment on Linux amd64). Preserve Rust source, lockfiles, ABI and semantic behavior; regenerate committed CRDT/PDF artifacts with those builders, then require the normal byte comparisons, Rust tests and JS/core parity. Native Rust lint/tests remain native. Canonical target caches are worktree-specific; source is mounted read-only and only dedicated build caches are writable. No weakened or skipped gate.
40
41Credits regeneration additionally recognizes only the preexisting fastrand 2.5.0 vendor patch at its exact path. A reviewed upstream-archive hash manifest verifies every vendored file (only the parsed normal wasm getrandom feature differs), rejects symlink escapes and all other source replacements, and feeds actual vendored license notices. Vendor files join the credit input inventory. No dependency source or lockfile changes.
42
43## Home roster compatibility (2026-10-30)
44
45Provisioned team mode uses one Home roster Access captured for the verified
46subject. Agent team configuration must match that binding before migrations.
47Only existing Home-linked accounts resolve; the browser's Home-only fallback
48is not used by this first delegated API. Retain the same Access through
49registry calls, identity checks, writer transaction/retry and response emission.
50Creation requires Member; an allowlist cannot grant team standing. Read queries
51preserve the app's current rule: own/team-rung decks require Member, while
52independent explicit grants survive NotMember or Unknown. Query on the caller's
53transaction and recheck Unknown after selection. Full lists refuse Unknown,
54even when explicit grants remain, because this contract has no partial-list
55indicator. Socket write deadlines cannot outlive the retained membership lease
56or a shorter caller deadline. Browser write guards and non-team behavior are
57preserved. GPT-6 Astra reviewed this compatibility plan and source; full local
58checks and deployed canary review remain separate evidence.
59