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