oficina / docs Public

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

Plain git — no account needed to clone.

Download

Download this file

1# Delegated Docs access
2
3This branch adds `docs_list`, `docs_get`, `docs_create` and `docs_update` to the shared Oficina
4connection. The same operation contracts serve the Oficina CLI, Paseo, ChatGPT
5and Claude through the connection service. They require a configured Home
6identity link to an existing local account and current document permission.
7Addressless Home-only people retain browser access but are not supported by this
8initial agent adapter.
9
10Set `DOCS_AGENT_ISSUER` to the connection service HTTPS origin and
11`DOCS_AGENT_TEAM` to the instance team. Both are required together with the
12existing Home configuration. In team mode the team must match its provisioned
13binding. The verifier expects this app's exact origin plus `/api/v1` as audience
14and the configured Home issuer as identity authority. Browser login and native
15routes retain their existing guards.
16
17Export deployment contracts with `go run ./cmd/docs-contract`. The protected
18endpoints are `GET /api/v1/operations` and
19`POST /api/v1/operations/{name}`. App credentials come from the connection
20service; cookies and personal browser sessions do not authenticate this API.
21
22Create requires activated content sealing and a nonzero canonical UUID
23`client_id`. Supply a title and up to 200 literal paragraph/heading blocks, with
24128 KiB of text total. Paragraphs have `type: paragraph` and `text`; headings
25have `type: heading`, `text` and `level` from 1 to 6. Reuse the UUID only to retry
26the identical initial content. A successful response contains the document ID,
27URL and current body revision; read content separately with `docs_get`.
28
29Get returns text and ProseMirror JSON from the same replay, with a decimal
30`body_revision` string. Responses are capped at 1 MiB. List uses 20 items by
31default, up to 100, and returns an opaque `next_cursor`.
32
33Update requires `docs:write` and current document write permission. Pass
34`{team,id,client_id,expected_revision,edits}`: copy `expected_revision` exactly
35from the last get's `body_revision`. Each edit is
36`{index,delete_count,blocks}`, using zero-based positions in `content.content`.
37Use 1–32 nonoverlapping edits in descending index order, all referring to that
38original body. Insert/delete at most 200 blocks and insert at most 128 KiB of
39literal paragraph/heading text. Other structures keep their positions and must
40remain untouched; this operation refuses to flatten them. Keep at least one
41block, using an empty paragraph if needed.
42
43The edit response is `{id,url,revision}`, where `revision` is the originally
44applied body sequence even on retries. Retry the exact request with the same
45UUID after an interrupted response; later browser edits are never overwritten
46by a retry. A new stale edit returns 409 with no changes: read again and submit
47fresh edits with a new UUID. Title-only changes do not change the body revision.
48Editing pending/incompletely received CRDT history is refused until its missing
49updates arrive. Sharing, export, comments, title edits and deletion remain
50outside these delegated operations.
51
52The receipt marker binds the Home key, Home issuer, connection issuer and team.
53Changing any requires an explicit operator migration; never erase receipt state
54to make retries appear new. Enabling access does not activate or convert legacy
55content storage. All content writes use the existing sealed collaborative core.
56
57See the reviewed design in
58[the agent access spec](superpowers/specs/2026-10-25-agent-access.md). This branch
59is not a claim of deployment or live client certification.
60
61October 30 compatibility: this branch includes main's one-way adoption of
62Docs links into `home_identity_links`. Use the normal boot migration; never
63restore the retired tables or deploy the October 25 binary over a migrated
64store. Agent admission, writer checks and response chunks use the shared keyed
65binding resolver. Completed retries repeat final authority checks. In team mode,
66`docs_list` returns 503 while standing is Unknown because its schema has no
67partial-result indicator; `docs_get` can still read an explicit share.
68