oficina / base Public

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

Plain git — no account needed to clone.

Download

Download this file

1# Files in Ask
2
3Status: approved by Paul on 2026-11-26, with every recommendation. Revised
4after Fable's plan review of 2026-11-26 (B1 to B6, Equipo's E1, and the
5nits). Read against Base main `0a6e8bc` and Equipo main `478e0055`.
6
7Paul's ruling (2026-11-26): "Definitely want to attach files in Ask and the
8assistant read them if necessary."
9
10Equipo owns the Assistant's half: `oficina/equipo`, branch
11`design/assistant-attachments`, spec
12`docs/superpowers/specs/2026-11-26-assistant-attachments-design.md`. The slice 1
13plans are `docs/superpowers/plans/2026-11-26-ask-attachments-slice1.md` in each
14repo.
15
16**The short version.** Equipo already has the whole attachment pipeline for
17its own conversation (the Coordinator's): upload, type sniffing, limits,
18relay to the runner, and images shown to the model. Its runner even stages
19files for Assistant turns. The one thing that refuses them is the Assistant's
20send route. So Ask uses Equipo's attachments as they are. Base stores no
21bytes: it relays uploads and reads with the person's own bearer, as it
22already relays every other Ask call. No new store, and no CARLOS bucket for
23Base.
24
25## Decisions
26
27Paul ruled on 2026-11-26, approving every recommendation of the draft:
28
29| # | Ruling |
30|---|---|
31| R1 | **Equipo holds the bytes, and Base keeps no copy.** Base relays uploads and reads with the person's bearer, and caches nothing on the server. |
32| R2 | **A sent file can be removed, but later, not in slice 1.** Nothing in the suite deletes a message yet either. |
33| R3 | **The Assistant can read a file for 14 days,** while the runner holds it. After that it says the file has gone and asks the person to attach it again. There is no machinery to send it to the runner again. |
34| R4 | **No attaching without script in slice 1.** The paperclip shows only with script. The rest of Ask works without script as now, and that includes seeing files in the thread. |
35| R5 | **Native copies Equipo's attachment code into BaseKit now.** It moves into the shared kit when a third app needs it. |
36| R6 | **A job sees the files the person attached,** in a later slice. Until then the hand-off goes ahead without them, and the Assistant says the job can't see them. |
37| R7 | **Putting a file into an Oficina app through `use` waits.** It needs each app's operations to take a file, which is its own spec. |
38| R8 | **Encrypting Equipo's attachment bytes is a follow-up.** It doesn't block slice 1. |
39
40Design decisions that follow from these:
41
42| # | Decision | Rejected |
43|---|---|---|
44| D1 | **Equipo's limits and types, unchanged:** 10 MiB a file, 5 a message, and nine types. | Bigger limits for Ask. The relay frames and the runner's quota are sized for these. |
45| D2 | **The runner reads the files,** on Paul's own machines, through the frames that exist. Equipo gives the Assistant a `read_attachment` tool. | Base extracting text and sending it as words. That puts the bytes through Base and loses the "data, not instructions" framing. |
46| D3 | **Equipo ships first. Base shows the paperclip only when Equipo says the person's runner can take files** (the snapshot's `can_attach`). A runner never seen counts as one that can't. | A Base that offers files and then fails at send. |
47| D4 | **PDFs are accepted in slice 1.** A PDF's chip says "Ask can't read PDFs yet" before sending, and the Assistant says so too. Slice 3 reads them and drops the line. | Leaving PDFs out of the picker. That needs Base-side type checks and words that slice 3 throws away. |
48| D5 | **Refused files never take Ask down** (Fable B1, B2). When a send with files is refused because the runner can't take them, Ask stays ready: the paperclip goes, and the chips say why. A stale upload, refused at send, is marked "attach it again" on its chip. Words always still send. | Showing the whole chat's "needs an update" state for a file. |
49| D6 | **Remove frees the upload** (Fable E1, B6). Equipo gains a delete for unsent uploads, and Base calls it on Remove. Chips don't survive a reload: when the page goes away, Base asks Equipo, as best it can, to delete what was never sent. The 24-hour drop catches the rest. | Evicting the oldest unsent upload. That silently drops a file the person may still mean to send from another tab. |
50| D7 | **Base decides what is shown inline, not Equipo** (Fable B4). Only PNG, JPEG, WebP and GIF are served inline. Everything else is a download, and any type outside the nine is `application/octet-stream`. | Passing Equipo's headers through on Base's origin, where the session lives. |
51| D8 | **A paste with words pastes the words** (Fable B5, B8). Files are attached only when the clipboard holds no words beyond the files' own names (plan P12). Word, Excel, Pages and Numbers put a picture of the selection beside its text, and a table pasted from Excel stays a table. | Attaching every image on the clipboard. |
52
53## 1. What exists today
54
55### 1.1 Equipo
56
57- **The Assistant refuses files.** The API doc says it "takes words only, so
58 a message with `attachments` is `422 invalid_input`"
59 (`docs/api/equipo-v1.md:157`).
60 - The refusal is in `LaneStore.Send`
61 (`internal/equipo/chat/lane.go:51`), which also passes no files to
62 `sendOrigin` (`lane.go:69`).
63 - Job threads refuse the same way (`jobs.go:135-137`).
64 - Attachments were a non-goal of the Assistant's first slice
65 (`2026-11-12-equipo-assistant-design.md:27`).
66- **The Coordinator's conversation takes files.** Each file is uploaded
67 with `POST /api/v1/attachments`: the bytes as the body, the type in
68 `Content-Type`, the name in `Content-Disposition`. Its ID then goes in the
69 message's `attachments` (`equipo-v1.md:97-99`, `chat/http.go:78-80`).
70 These routes take the person bearer Base already holds.
71- **Limits** (`internal/attach/attach.go:20-94`):
72 - 10 MiB a file, and 5 a message.
73 - Images at most 12,000 px a side and 40 MP.
74 - PNG, JPEG, WebP, GIF, PDF, plain text, Markdown, CSV and JSON. The type
75 is sniffed from the bytes.
76 - HEIC is refused (`attachment_heic`), and an image's location is
77 stripped.
78 - Unsent uploads are kept 24 hours, at most 20 a person
79 (`chat/attachments.go:27-31`).
80- **Storage.** The bytes are in Equipo's SQLite (`chat_attachment_data`,
81 `chat/attachments.go:35-62`). They are not sealed, and a sent file is
82 never deleted.
83- **Reading a file.** `GET /api/v1/attachments/{id}` and `/preview` check
84 that the file is the person's. They answer with `nosniff` and a sandbox
85 CSP. Images are served inline, and anything else as a download
86 (`attachments_http.go:86-110`).
87- **Messages carry their files** in snapshots and events. Both go through
88 `withFiles` (`store.go:271-276`, `1016-1027`), so Assistant messages will
89 too, once files can be linked to them.
90- **How a runner gets the bytes.**
91 - `relayFiles` queues each file as 128 KiB `attachment` frames before the
92 message frame. Each chunk is read from SQLite only as it is sent
93 (`store.go:389-390`, `attachments.go:240-291`).
94 - The runner checks each file and keeps it read-only for 14 days, under a
95 500 MB quota a person (`runner/thin/files.go:25-82`).
96 - An Assistant turn links its files into its own desk
97 (`assistant.go:142-166`).
98- **What the model sees today.**
99 - Images go in with the message, scaled to 1568 px (`claude.go:745`,
100 `codex.go:193-202`).
101 - Text files are meant to be read with `read_file`
102 (`bridge.go:160-166`, `504-536`).
103 - PDFs "cannot be read here yet" (`claude.go:722`).
104- **Three gaps for the Assistant.**
105 - It has no `read_file` (`runner/provider/actions.go:184-186`).
106 - Nothing reads PDFs.
107 - A file is seen in its own turn only.
108
109### 1.2 Base
110
111- **Web.** The composer is a plain form that posts `text` and `key` to
112 `POST /ask/messages` (`templates/partials/chat.html:61`). `ask.js` sends
113 the same form as `fetch` with JSON accepted (`ask.js:1614-1626`).
114- **Native.** `AskModel.send()` posts the same form
115 (`AskModel.swift:292`, `API/Client.swift:52-53`).
116- **Server.** `askSend` bounds the form at 64 KiB and calls
117 `equipo.Client.Send` with `{"text","idempotency_key"}`
118 (`internal/web/ask_relay.go:118-135`, `internal/equipo/chat.go:298-303`).
119- **The client.** `call` handles JSON only, reads at most 4 MiB of an
120 answer, and times out after 20 s (`equipo.go:107-144`).
121- **Messages lose their files on the way.** `equipo.Message` has no
122 attachments field (`chat.go:32-38`), and `project()` keeps only that
123 shape (`ask_relay.go:442-466`).
124- **Images must come from Base's own origin.** The CSP is
125 `img-src 'self' data:` (`internal/web/oficina.go:107`), so a `blob:` URL
126 is refused as well.
127
128### 1.3 Other Oficina apps
129
130- **Where the bytes go.** Slides (`internal/slides/assets.go:75-82`,
131 20 MiB) and Mapa (`2026-11-17-mapa-images.md`, 10 MiB) put them in the
132 app's own CARLOS bucket, through rastrillo `blobs`
133 (`blobs/s3.go:60-75`).
134- **How readers fetch them.** Only through the app, which checks scope.
135 Presigned URLs failed against `img-src 'self'`, and the bucket has no CORS
136 rule.
137- **Sealing.** Mapa and Docs seal the bytes; Slides does not.
138- **Base needs none of this.** Equipo is the store here (R1).
139
140## 2. What the person sees
141
142### 2.1 Web (the Ask page and the docked panel)
143
144- **The paperclip.** It sits in the composer's actions, left of Send. It
145 shows only with script and only when the snapshot says `attachments`.
146 - It opens a file picker: several files, with `accept` listing the nine
147 types.
148 - On an iPhone, Safari then offers the photo library and the camera, and
149 hands a photo over as JPEG.
150- **Drop and paste.**
151 - Files dropped on the composer are attached. An outline shows while
152 something is dragged over it.
153 - A pasted image (a screenshot) or a copied file is attached, but only
154 when the clipboard holds no words beyond the files' own names (D8).
155 - A paste with words pastes the words, and a rich-text paste stays
156 Markdown, as now (`ask.js:1676`).
157- **Chips.** Each file gets a chip above the text field: a file mark, its
158 name and size, a progress ring while it uploads, and Remove.
159 - Files upload two at a time, in order. A busy answer is retried by
160 itself.
161 - Once an image is up, its chip shows the thumbnail Base serves.
162 - A refusal shows on the chip in words, and so does a PDF's "can't read
163 yet" line (D4).
164 - Remove deletes the upload in Equipo too (D6).
165 - A phone photo over 40 megapixels (48 MP cameras) is refused until
166 slice 2 resizes on the device. On the web, share it as a smaller
167 image.
168- **Sending.** Send waits for the uploads to finish. Text may be empty when
169 a file is attached. A sixth file is refused at the chip. If the files
170 are refused at send, the chips say why and the words can still go (D5).
171- **In the thread.** The person's bubble shows a row of thumbnails, then
172 file pills (a mark, the name and the size), then the text.
173 - A thumbnail opens full size in a sheet.
174 - A pill downloads the file.
175 - Both come from Base. Without script the thumbnails and pills still show,
176 and a thumbnail opens the image itself.
177 - The viewer takes focus and gives it back on Close. Finished and refused
178 uploads are announced.
179
180### 2.2 Mac and iPhone (slice 2)
181
182- The Mac gets a paperclip in `Composer`. Files can be dropped on the
183 composer or the window, or pasted with ⌘V.
184- The iPhone gets a `+` with Photos, Camera and Files.
185- Both get the same chips, as Equipo's `EquipoKit/Attachments` draws them
186 (R5).
187 - HEIC, TIFF and anything over 2560 px becomes JPEG on the device.
188- Bubbles show thumbnails and pills. A tap opens Quick Look on the Mac, or a
189 preview with Share on the iPhone.
190- Until slice 2, the apps show a person's files in the thread as a plain
191 line of names, so no bubble is ever empty.
192
193## 3. Base's changes (slice 1)
194
195- **Upload:** `POST /ask/attachments`, with the raw body, `Content-Type`
196 and `Content-Disposition`.
197 - **A slot first.** It takes one of 4 process-wide slots before it reads
198 the body. It then reads under a 60 s read deadline, to at most 10 MiB
199 plus 1 byte. A body over 10 MiB is refused before Equipo is called, and
200 a stalled body loses its slot when the deadline passes.
201 - **Waiting.** A request that waits more than 10 s for a slot gets `503`
202 with `Retry-After`. The page retries by itself.
203 - **The relay.** It goes to Equipo's `POST /api/v1/attachments` with the
204 person's bearer and a 60 s limit, and answers with Equipo's JSON (`id`,
205 `kind`, `name`, `media_type`, `size`, `width`, `height`).
206 - **Refusals.** Equipo's refusals (`attachment_too_large`, `_type`,
207 `_heic`, `_pixels`, `_limit`) come back as `code`, and Base has words
208 for each.
209 - **Checks.** It makes the same session and state checks as every Ask
210 write.
211- **Remove:** `DELETE /ask/attachments/{id}` relays Equipo's delete of an
212 unsent upload. A `404` counts as done.
213 `POST /ask/attachments/discard` takes the page's unsent IDs from a beacon
214 when the page goes away, and deletes them as best it can.
215- **Read:** `GET /ask/attachments/{id}` and `/{id}/preview` stream from
216 Equipo with the person's bearer, never through `call`.
217 - **What Base allows (D7).** Only `image/png`, `image/jpeg`, `image/webp`
218 and `image/gif` are inline. The other five types are `attachment`, and
219 anything else is `application/octet-stream` as `attachment`. `/preview`
220 serves images only.
221 - **Headers.** Base always sets `nosniff` and a sandbox CSP.
222 - **Caching.** Previews are `Cache-Control: private, max-age=3600` with
223 `Vary: Cookie`. Originals are `no-store`.
224 - **Failures.** Equipo's error body never comes through.
225 - A `401` drops the link and answers `404`.
226 - A `5xx` or a timeout answers `502` with no body.
227 - An `<img>` then shows its `alt`.
228- **Send:** `POST /ask/messages` takes up to 5 `attachments` fields.
229 `Client.Send` sends them, and text may be empty when there are any.
230 - **Runner can't take files.** Equipo's `409 attachments_unavailable` (or
231 `runner_too_old`) on a send with files answers `409` with
232 `files: "unavailable"` and leaves Ask ready (D5).
233 - **Stale upload.** Equipo's `422` on a send with files answers `422`
234 with `files: "stale"`.
235- **State and events.**
236 - `equipo.Message` gains `Attachments`, and `project()` and `/ask/state`
237 keep it. No Equipo URL ever reaches a client: each builds
238 `/ask/attachments/{id}`.
239 - `/ask/state` gains `can_attach`, from Equipo's snapshot.
240- **Turn failures.** A failed turn's `attachment_unavailable`,
241 `runner_storage_full` and `runner_too_old` reasons get their own words in
242 the status line.
243- **The native apps** show a person's files as a line of names until slice
244 2. That build ships before or with the web release, so no installed app
245 draws an empty bubble.
246- **Copy review** of every new string, before release. Base never names
247 Equipo (Review 8).
248
249## 4. Equipo's changes (slice 1, ships first)
250
251In short; the Equipo spec has the detail.
252
253- **E1. The send takes files.** The Assistant's send route accepts
254 `attachments`. Files need the person's primary runner to be seen on the
255 new protocol; otherwise the answer is `409 attachments_unavailable`, with
256 nothing stored. The snapshot says `can_attach`.
257- **E2. Deleting unsent uploads.** `DELETE /api/v1/attachments/{id}`
258 deletes an unsent upload.
259- **E3. `read_attachment`.** The tool reads text by line, inside a frame
260 that says it is data and not instructions. It shows an image again, and
261 says a PDF can't be read yet.
262- **E4. Files across the conversation.** Each later turn lists the person's
263 files from up to 14 days of this conversation. The tool reads them from
264 the runner's copy, and says so when a file has gone (R3).
265- **E5. Hand-offs.** A hand-off from a turn with files goes ahead without
266 them. The Assistant is told to say the job can't see them (R6).
267
268## 5. Privacy, retention and deletion
269
270- **Who can read the bytes:**
271 - the person, through Base, which checks the session and uses that
272 person's bearer;
273 - Equipo, which checks `person` on every read;
274 - the person's own runner, which gets only their files, on their own desk.
275 - Nobody else. Base stores and caches nothing on the server.
276- **What reaches a model provider.** The runner sends images, and the text
277 the model reads, to the model the runner uses (Claude or Codex under
278 Paul's plans). It already does this for the Coordinator.
279- **Retention:**
280 - Unsent uploads: 24 hours in Equipo.
281 - Sent files: as long as the message, in Equipo, not sealed (R8).
282 - Runner copies: 14 days.
283 - Base: none.
284- **Deletion:** a sent file stays (R2). An unsent upload is deleted on
285 Remove, when the page goes away (as best it can), or after 24 hours (D6).
286 When a member is removed from Base, nothing of theirs is left in Base.
287
288## 6. Slices
289
2901. **Web, and Equipo's half.** Equipo E1 to E4. In Base: the relay, the
291 send, state and events, the thread, the composer, the browser tests and
292 copy review. Equipo ships first (D3).
2932. **Mac and iPhone** (R5).
2943. **PDFs** (Equipo). The text by page, and a scanned PDF's first pages as
295 images.
2964. **Later:**
297 - files for jobs (R6);
298 - removing a file (R2);
299 - sealing the bytes in Equipo (R8);
300 - files into Oficina apps (R7).
301