oficina / base Public

Spec and plan: answer Fable's review (B1-B6 and nits)

Human

Prompt

Fable reviewed both plans: CHANGES REQUESTED. Fix every should-fix (E1-E5, B1-B6), take the cheap nits; delete route for unsent uploads with Remove freeing the slot; a never-seen primary means no attachments; frame the tool result as data and add the live witness; allow-list downloads; paste the text and attach nothing; the PDF chip line; cite AGENTS.md line 49 against line 89.

From this commit's own message. The prompt ledger has no entries for it — which is what a squashed, rebased or amended commit looks like, and what every commit looks like in a repo without a ledger.

Summary

Refused files keep Ask ready (D5); Remove and a pagehide beacon delete unsent uploads (D6); Base allow-lists download types (D7); a paste with words attaches nothing (D8); upload slot before body with a read deadline and a client queue of two; PDF chip line; can_attach; cache, failure and accessibility nits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev bdc24d2d019ef27a9e81560cac25e0034dce1dfb parent bc1e4de
2 files changed, +486 −299
  • docs/superpowers/plans/2026-11-26-ask-attachments-slice1.md +398 −255
  • docs/superpowers/specs/2026-11-26-ask-attachments-design.md +88 −44

CI passed — run details

CI log
=== build ===
CGO_ENABLED=0 go build ./...
=== vet ===
go vet ./...
=== fmt-check ===
=== staticcheck ===
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 ./...
=== govulncheck ===
go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 ./...
No vulnerabilities found.
=== gitleaks ===
2:09PM INF Unknown SCM platform. Use --platform to include links in findings. host=amadan.net
2:09PM INF 1 commits scanned.
2:09PM INF scanned ~2535386 bytes (2.54 MB) in 240ms
2:09PM INF no leaks found
=== budget ===
go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget size
budget size: 22 directories within budget
=== script-test ===
scripts/prepare-apps_test.sh
ok   releases lookup failure stops before ship
ok   app owned elsewhere stops the script
ok   apps listing failure stops before create
ok   ambiguous release dir is refused
ok   explicit version resolves the ambiguity
ok   releases match is exact, not substring
ok   shipped version is only promoted, existing app not created
ok   fresh account creates, ships, promotes to edge, enables
ok   failing promote stops the script
ok   ship is retried while uploads are rate limited
all passed
hack/fonts_test.sh
fonts_test: ok
=== test ===
go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -count=1 ./...

receipt: test step 6.798s against a 60s target (the gate's other steps are not in this figure)
receipt: 16 packages ran, 0 cached, 6 without tests, 0 failed
receipt: slow package 6.023s amadan.net/oficina/base/internal/webtest
receipt: slow package 1.206s amadan.net/oficina/base/internal/issuer
receipt: slow package 589ms amadan.net/oficina/base/internal/operations
receipt: slow package 180ms amadan.net/oficina/base/internal/consumer
receipt: slow package 164ms amadan.net/oficina/base/internal/web
receipt: slow test 1.51s amadan.net/oficina/base/internal/webtest TestHomeDoesNotWaitOnAStalledSnapshot
receipt: slow test 1.07s amadan.net/oficina/base/internal/webtest TestAskZoneIsToldOnce
receipt: slow test 960ms amadan.net/oficina/base/internal/issuer TestAuthorizeSignsForInstalledApp
receipt: slow test 510ms amadan.net/oficina/base/internal/operations TestOperationsRefusals
receipt: slow test 220ms amadan.net/oficina/base/internal/webtest TestAskZoneAgainOnANewConnection
=== native ===
strings: copy review's strings.json is not here (git-ignored); its comparison skipped
strings: 119 in the catalog, 116 used
worktree-lib_test: ok
diff --git a/docs/superpowers/plans/2026-11-26-ask-attachments-slice1.md b/docs/superpowers/plans/2026-11-26-ask-attachments-slice1.md
index f6c6bb7..642e011 100644
--- a/docs/superpowers/plans/2026-11-26-ask-attachments-slice1.md
+++ b/docs/superpowers/plans/2026-11-26-ask-attachments-slice1.md
@@ -2,15 +2,19 @@
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
-**Goal:** On the web, the person attaches files to a message in Ask: with
-the paperclip, by pasting or by dropping. They see each file upload as a
+**Goal:** On the web, the person attaches files to a message in Ask, with
+the paperclip, by pasting or by dropping. They watch each file upload as a
chip, and send. Their files show in the thread as thumbnails and pills, and
the Assistant reads them.
-**Spec:** `docs/superpowers/specs/2026-11-26-ask-attachments-design.md`
-(rulings R1 to R8, decisions D1 to D4, sections 2.1 and 3). Equipo's half:
-`oficina/equipo` `docs/superpowers/specs/2026-11-26-assistant-attachments-design.md`
-and its plan of the same name as this one.
+**Spec:** `docs/superpowers/specs/2026-11-26-ask-attachments-design.md`:
+rulings R1 to R8, decisions D1 to D8, and sections 2.1 and 3. Equipo's
+half is `oficina/equipo`
+`docs/superpowers/specs/2026-11-26-assistant-attachments-design.md`, with a
+plan of the same name as this one.
+
+**Review:** this revision answers Fable's plan review of 2026-11-26: B1 to
+B6, and the cheap nits.
**Branch:** `design/ask-attachments` holds the spec and this plan. Build on
`feat/ask-attachments`, from `origin/main` (`0a6e8bc` when this was
@@ -18,288 +22,418 @@ written).
**Order between the repos:**
-- Equipo's slice 1 ships to production first.
-- This branch can be built and tested at any time against the fake
- (`internal/equipo/equipotest`), which learns Equipo's new contract in
- Task 1.
-- It merges and deploys only once production Equipo answers `attachments`
- in the Assistant's snapshot (Task 11).
-- The paperclip shows only when that field is true (D3). An older Equipo
- never sends the field, so Base offers nothing until it does.
-
-**Gates for every task:** a failing test first, observed failing for the
-right reason. Then:
-
-- `make test` (or the one package with `-run`, through the Make
- toolchain, `GOTOOLCHAIN=go1.26.11`);
-- `make vet fmt-check staticcheck budget`;
-- the browser tasks also run `make browser` with `RASTRILLO_CHROME` set
- (Chromium path: see memory "Base review gates"), at least
- `-run 'TestAsk'`.
-
-`make ci` and the full `make browser` run before hand-over (Task 10).
+- **Equipo first.** Equipo's slice 1 ships to production first.
+- **Building here.** This branch can be built and tested at any time
+ against the fake (`internal/equipo/equipotest`), which learns Equipo's
+ new contract in Task 1.
+- **Merging here.** It merges and deploys only once production Equipo
+ answers `can_attach` in the Assistant's snapshot (Task 12).
+- **The paperclip waits too.** It shows only when `can_attach` is true
+ (D3). An older Equipo never sends the field, so Base offers nothing until
+ it does.
+
+**Gates for every task:**
+
+- Write a failing test first, and watch it fail for the right reason.
+- Then run `make test`, or the one package with `-run` through the Make
+ toolchain (`GOTOOLCHAIN=go1.26.11`).
+- Then run `make vet fmt-check staticcheck budget`.
+- The browser tasks also run `make browser` with `RASTRILLO_CHROME` set,
+ at least `-run 'TestAsk'`. See memory "Base review gates" for the
+ Chromium path.
+- `make ci` and the full `make browser` run before hand-over (Task 11).
## Plan decisions
-- **P1. Base keeps no bytes (R1).**
- - Uploads are read into memory up to 10 MiB plus 1 byte, because
- Equipo's `ReadUpload` wants a known length. They go on with
- `Content-Length`, and nothing is written to disk.
- - At most 4 uploads run at once for the whole process (a semaphore).
- The fifth waits up to 10 s, then gets `503` with `Retry-After: 2`.
- - Downloads stream through `io.Copy` and are never buffered.
+- **P1. Base keeps no bytes (R1), and its bounds hold** (Fable B3).
+ - **The order.** `askUpload` first checks the declared `Content-Length`
+ (over 10 MiB is `413` at once). Then it takes a slot from a
+ process-wide semaphore of 4. Only then does it read the body.
+ - **The read.** It reads under `http.ResponseController.SetReadDeadline`
+ of 60 s, into memory, to at most 10 MiB plus 1 byte. A stalled body
+ fails at the deadline and gives its slot back. Peak memory is about
+ 4 × 10 MiB.
+ - **Waiting.** A request that waits more than 10 s for a slot is `503`
+ with `Retry-After: 2`.
+ - **The page.** `ask-attach.js` uploads two files at a time, and retries
+ a `503` after `Retry-After` by itself, up to 5 times.
+ - **Sending on.** The body goes to Equipo with `Content-Length`, because
+ Equipo's `ReadUpload` wants a known length. Nothing is written to disk.
+ - **Downloads** stream through `io.Copy`, and are never buffered.
- **P2. New client calls, not `call`.** `call` caps answers at 4 MiB and
- times out after 20 s. `Upload` gets 60 s, and `OpenAttachment` returns
- the `*http.Response` for the handler to stream. It is bounded by the
- request's context and by a 60 s header timeout.
-- **P3. Base sets its own headers on downloads.** It keeps Equipo's
- `Content-Type` and `Content-Disposition`, which are already sniffed and
- inline only for images. It always adds:
- - `X-Content-Type-Options: nosniff`;
- - `Content-Security-Policy: default-src 'none'; img-src 'self'; style-src 'unsafe-inline'; sandbox`;
- - `Cache-Control: private, max-age=3600`.
+ times out after 20 s.
+ - `Upload` gets 60 s, and sends **no** `Idempotency-Key`: Equipo's upload
+ takes none (Fable nit).
+ - `OpenAttachment` returns the `*http.Response` for the handler to
+ stream. It is bounded by the request's context and a 60 s header
+ timeout.
+ - `DeleteAttachment` treats `204` and `404` as done.
+- **P3. Base decides the download headers (D7, Fable B4).**
+ - **Inline.** Only `image/png`, `image/jpeg`, `image/webp` and
+ `image/gif`.
+ - **Download.** The other five types (PDF, text, Markdown, CSV, JSON).
+ Text types get `; charset=utf-8`.
+ - **Anything else** is `application/octet-stream`, as a download.
+ - **The name.** `Content-Disposition` is built by Base from the name
+ Equipo gives, with `mime.FormatMediaType`. Equipo's own header is never
+ used.
+ - **Always.**
+ - `X-Content-Type-Options: nosniff`.
+ - `Content-Security-Policy: default-src 'none'; img-src 'self'; style-src 'unsafe-inline'; sandbox`.
+ - **Caching.** Previews are `Cache-Control: private, max-age=3600` with
+ `Vary: Cookie`. Originals are `Cache-Control: no-store`.
+ - **`/preview`** answers only for the four image types; anything else is
+ `404`.
+ - **Failures.**
+ - Equipo's error bodies never come through.
+ - A `401` drops the link, as `askDone` does, and answers `404`.
+ - A `5xx` or a timeout answers `502` with an empty body.
- **P4. Thumbnails come from Base's origin,** at
`/ask/attachments/{id}/preview`, so the page CSP (`img-src 'self' data:`)
- needs no change. A chip shows its thumbnail once the upload answers.
- Until then it shows a file mark, never a `blob:` URL, which the CSP
- would refuse.
+ is unchanged. A chip shows its thumbnail once the upload answers. Until
+ then it shows a file mark, never a `blob:` URL, which the CSP would
+ refuse.
- **P5. The attach script is its own module,**
- `internal/look/static/ask-attach.js`. It is imported by `ask.js`, so
- `ask.js` (2,160 lines) only grows by the hooks. It follows Equipo's
- `chat-attach.js`: XHR for upload progress, one upload per file at once,
- and the server's word final.
-- **P6. The no-script page shows files but can't attach (R4).**
+ `internal/look/static/ask-attach.js`, imported by `ask.js`.
+ - `ask.js` (2,160 lines) grows only by the hooks.
+ - It follows Equipo's `chat-attach.js`: XHR for progress, and the
+ server's word is final.
+- **P6. The no-script page shows files but can't attach them (R4).**
- `chat.html` draws thumbnails as links to the full image, and pills as
- download links. The paperclip and chips exist only when the script
- adds them.
- - `POST /ask/messages` with `attachments` works without script too, but
- nothing without script sends it.
-- **P7. Equipo IDs only.** A client never sees an Equipo URL. Message
- JSON carries `attachments` (`id`, `kind`, `name`, `media_type`, `size`,
- `width`, `height`), and each client builds `/ask/attachments/{id}`.
- `/ask/attachments/{id}` checks that the ID looks like `at_[a-z0-9]{8,60}`
- before calling Equipo.
+ download links.
+ - The paperclip and the chips exist only when the script adds them.
+- **P7. Equipo IDs only.** A client never sees an Equipo URL.
+ - Message JSON carries `attachments` (`id`, `kind`, `name`,
+ `media_type`, `size`, `width`, `height`), and each client builds
+ `/ask/attachments/{id}`.
+ - IDs must match `at_[a-z0-9]{8,60}` before Equipo is called.
- **P8. Text may be empty with files.**
- `askSend` accepts an empty `text` when at least one `attachments` is
present.
- - `ask.js`'s submit drops its `field.value.trim()` early return in that
- case, and the textarea loses `required` once script runs. It stays
- `required` without script.
-- **P9. The native apps keep working, with no attach UI (slice 2).** They
- decode `attachments` and show a person bubble's files as one plain line
- of names under the text, so a files-only message is never an empty
- bubble.
+ - `ask.js`'s submit skips its `field.value.trim()` early return in that
+ case.
+ - The textarea loses `required` once script runs. It keeps `required`
+ without script.
+- **P9. The installed native apps get a names line before the web ships.**
+ - They decode `attachments` and show a person bubble's files as one
+ plain line of names under the text, so a files-only message is never
+ an empty bubble.
+ - That build is released before or with the web (Task 12; Fable nit).
+- **P10. Refused files never take Ask down (D5, Fable B1 and B2).**
+ - **Runner can't take files.** A send with files refused by Equipo's
+ `409 attachments_unavailable`, or `409 runner_too_old`, answers
+ `409 {"state":"ready","files":"unavailable"}`.
+ - The page keeps Ask ready, sets `can_attach` false (the paperclip
+ goes), keeps the chips, and marks them with the "can't be read right
+ now" line.
+ - The words stay in the field. Sending again without the chips works.
+ - **Stale upload.** Equipo's `422` on a send with files (an upload
+ expired, or already sent) answers `422 {"state":"ready","files":"stale"}`.
+ The page marks every chip "attach it again", and Remove clears them.
+ - **Words alone.** A send with no files keeps today's mapping.
+- **P11. Remove frees the upload (D6, Fable B6).**
+ - Remove calls `DELETE /ask/attachments/{id}` once the upload has an ID.
+ A Remove during the upload aborts the XHR, then deletes if an ID came
+ back.
+ - On `pagehide`, `navigator.sendBeacon` posts the unsent IDs to
+ `POST /ask/attachments/discard`. Base deletes each as best it can, and
+ always answers `204`.
+ - Chips don't survive a reload.
+- **P12. Paste (D8, Fable B5).** On `paste`:
+ - **With words.** If `clipboardData` holds `text/plain` or `text/html`
+ with any non-space text, the existing text path runs (`pasteMarkdown`
+ or plain), and nothing is attached.
+ - **Files only.** Only when `clipboardData.files` is non-empty and there
+ is no text are the files attached, and the default is prevented.
+- **P13. The flag is `can_attach`** (Fable nit), in Equipo's snapshot and
+ in `/ask/state`. Each message's list is `attachments`.
## File map
| File | Change |
|---|---|
-| `internal/equipo/chat.go` | `Attachment`; `Message.Attachments`; `Snapshot.Attachments`; `Send(…, files)`; `Upload`; `OpenAttachment` |
+| `internal/equipo/chat.go` | `Attachment`; `Message.Attachments`; `Snapshot.CanAttach`; `Send(…, files)`; `Upload`; `OpenAttachment`; `DeleteAttachment`; `ErrAttachmentsUnavailable` |
| `internal/equipo/equipo_test.go` | the client's new calls |
-| `internal/equipo/equipotest/chat.go` | the fake: uploads, reads, send with files, the snapshot flag, `FilesReady(bool)` |
-| `internal/web/ask.go` | routes; `askView.Files`; `/ask/state` `attachments` |
-| `internal/web/ask_files.go` | new: `askUpload`, `askAttachment` |
-| `internal/web/ask_relay.go` | `askBearer` split (no form parse for raw bodies); `askSend` with files; `project()` keeps files; turn reasons |
-| `internal/web/templates/partials/chat.html` | the files row in person bubbles; the paperclip slot; data words for the script |
-| `internal/look/static/ask.js` | hooks: send with files, files-only submit, files in `addMessage` |
-| `internal/look/static/ask-attach.js` | new: paperclip, picker, paste, drop, chips, progress, refusals, viewer |
+| `internal/equipo/equipotest/chat.go` | the fake: upload, read, delete, send with files, `can_attach`, `FilesReady(bool)`, `HoldNextUpload`, `ExpireUploads`, `ServeHostile(type, disposition)` |
+| `internal/web/ask.go` | routes; `askView.CanAttach`; `/ask/state` `can_attach`; status words for turn reasons |
+| `internal/web/ask_files.go` | new: `askUpload`, `askAttachment`, `askDiscard`, `askDeleteAttachment`; the slot semaphore |
+| `internal/web/ask_relay.go` | split `askBearer` so a raw body is never parsed as a form; `askSend` with files (P10); `project()` keeps files |
+| `internal/web/templates/partials/chat.html` | the files row in person bubbles; the composer's `data-*` words |
+| `internal/look/static/ask.js` | hooks: send with files, the files-only submit, files in `addMessage`, P10 answers, the paste hand-off (P12) |
+| `internal/look/static/ask-attach.js` | new: paperclip, picker, paste, drop, chips, progress, queue of two, retry, Remove, beacon, viewer, announcements |
| `internal/look/static/app.css` | chips, drop outline, files row, viewer sheet; light and dark |
| `internal/webtest/ask_files_test.go` | new |
| `internal/web/relay_internal_test.go` | `project()` keeps files |
| `internal/browsertest/attach_test.go` | new |
-| `internal/browsertest/testdata/attach/` | `note.md`, `shot.png`, `big.bin` (made at run time, not committed), `photo.heic` header |
-| `docs/api/base-native-v1.md` | `/ask/state` and message `attachments`; the two new routes |
+| `internal/browsertest/testdata/attach/` | `note.md` and `shot.png`; big and HEIC files made at run time |
+| `docs/api/base-native-v1.md` | `can_attach`, message `attachments`, the routes |
| `internal/webtest/ask_native_contract_test.go` | pins the new fields |
| `native/apple/Sources/BaseKit/API/Models.swift`, `Ask/Thread.swift` | decode `attachments`; the names line (P9) |
-| `docs/copy-pending.md` | Review 10 rows |
+| `docs/copy-pending.md` | the next free review number (13 at the time of writing): the strings |
## Task 1: the Equipo client and its fake learn files
- [ ] **Test first** (`internal/equipo/equipo_test.go`, against
`equipotest`):
- - `Upload` sends the bytes, `Content-Type`, an RFC 5987
- `Content-Disposition`, the bearer and an `Idempotency-Key`, and
+ - **`Upload`** sends the bytes, `Content-Type`, an RFC 5987
+ `Content-Disposition` and the bearer, and no `Idempotency-Key`. It
returns the `Attachment`.
- - It maps `413 attachment_too_large`, `415 attachment_type`,
- `415 attachment_heic`, `413 attachment_pixels` and
- `409 attachment_limit` to an `*Error` with that `Code`.
- - `Send` with two IDs posts `attachments` in order. With none it posts
- no `attachments` key, so the body is byte-identical to today's.
- - `OpenAttachment(…, preview)` returns the response unread, with the
- status and headers. A 404 is `ErrNotFound`.
- - A snapshot with `"attachments": true` decodes into
- `Snapshot.Attachments`, and messages decode their `attachments`.
-- [ ] Implement in `chat.go`. Add a `do` helper beside `call` for raw
- bodies and streamed answers. Leave `call` as it is.
-- [ ] Fake (`equipotest/chat.go`):
- - `POST /api/v1/attachments`: per bearer, sniffs PNG and text, and
- refuses over 10 MiB, `image/heic` and a sixth unsent file.
- - `GET /api/v1/attachments/{id}[/preview]`: per bearer, 404 for another
- person's file.
- - `send` accepts `attachments`: they must be the bearer's and unsent,
- there may be at most 5, and empty text is fine with files. It checks
- the key replay against the files too. It refuses with
- `409 runner_too_old` when `FilesReady(false)`.
- - `snapshot` says `attachments` from `FilesReady`, false by default.
- - `HoldNextUpload()` holds one upload, as `HoldNextSnapshot` holds a
- snapshot.
- - The message and events carry the files.
-- [ ] Gate: `make test`, `vet`, `fmt-check`, `staticcheck`.
-
-## Task 2: `POST /ask/attachments`
+ - **Refusals.** It maps `413 attachment_too_large`,
+ `415 attachment_type`, `415 attachment_heic`, `413 attachment_pixels`
+ and `409 attachment_limit` to an `*Error` with that `Code`.
+ - **`Send`** with two IDs posts `attachments` in order. With none, the
+ body is byte-identical to today's. A `409 attachments_unavailable` is
+ `ErrAttachmentsUnavailable`.
+ - **`OpenAttachment(…, preview)`** returns the response unread. A `404`
+ is `ErrNotFound`.
+ - **`DeleteAttachment`.** `204` and `404` are nil, and `409` is an
+ `*Error`.
+ - **Decoding.** `"can_attach": true` decodes into `Snapshot.CanAttach`,
+ and messages decode their `attachments`.
+- [ ] **Implement** in `chat.go`, with a `do` helper beside `call` for raw
+ bodies and streamed answers. `call` is unchanged.
+- [ ] **The fake** (`equipotest/chat.go`):
+ - **`POST /api/v1/attachments`** works per bearer. It sniffs PNG and
+ text, and refuses over 10 MiB, `image/heic`, and the 21st unsent file.
+ - **`GET /api/v1/attachments/{id}[/preview]`** works per bearer: another
+ person's file is `404`. `ServeHostile` makes it answer a set type and
+ disposition (`text/html` inline, `image/svg+xml`).
+ - **`DELETE /api/v1/attachments/{id}`.** Your own unsent upload is
+ `204`; a sent one is `409 attachment_sent`; an unknown one is `404`.
+ - **Send** accepts `attachments`: yours and unsent, at most 5, with empty
+ text allowed when there are files. A replayed key is checked against
+ the files too.
+ - `FilesReady(false)` refuses files with
+ `409 attachments_unavailable`.
+ - `ExpireUploads()` makes the next send with files `422`.
+ - **The snapshot** says `can_attach` from `FilesReady`, false by default.
+ - **Messages and events** carry the files.
+ - **`HoldNextUpload()`** holds one upload, as `HoldNextSnapshot` does.
+- [ ] **Gate:** `make test vet fmt-check staticcheck`.
+
+## Task 2: `POST /ask/attachments` (P1)
- [ ] **Test first** (`internal/webtest/ask_files_test.go`):
- - A member's upload reaches the fake with their bearer, name and type.
- The answer is `201` with the attachment JSON and `Cache-Control:
- no-store`.
- - 10 MiB plus 1 byte is `413 {"code":"attachment_too_large"}`, and the
- fake sees no call.
- - Each Equipo refusal passes through as `code`, with Equipo's status.
- - Each Ask state that isn't ready gives `409 {"state": …}`, as the other
- writes do: not connected, reconnect, no runner.
- - A cross-site `Origin` is refused by CSRF.
- - Signed out, a JSON request is `401` and a page request a redirect.
- - With the fake held, a fifth concurrent upload waits, then gets `503`
- with `Retry-After`.
- - A `401` from Equipo drops the link, as `askDone` does.
-- [ ] Implement `ask_files.go`. Split `askBearer` into the state check and
- the form parse, so a raw body is never parsed as a form. Mount the route
- in `askRoutes`.
-- [ ] Gate: `make test`.
-
-## Task 3: `GET /ask/attachments/{id}` and `/preview`
+ - **A member's upload** reaches the fake with their bearer, name and
+ type. The answer is `201` with the JSON and `Cache-Control: no-store`.
+ - **Too big.** A declared length over 10 MiB is `413` before the body is
+ read. So is a body over 10 MiB sent with no length. The fake sees no
+ call in either case.
+ - **Equipo's refusals** come back as `code`, with Equipo's status.
+ - **Not ready.** Each Ask state that isn't ready is `409 {"state": …}`,
+ as for the other writes.
+ - **Other refusals.**
+ - A cross-site `Origin` is refused by CSRF.
+ - Signed out, JSON gets `401`.
+ - A `401` from Equipo drops the link.
+ - **A stalled body** (Fable B3): send headers and half a body, then
+ stop. Within the read deadline (set short in the test), the request
+ fails and its slot is free. Then four more uploads all succeed.
+ - **Busy.** With 4 uploads held in the fake, a fifth waits, then gets
+ `503` and `Retry-After`.
+ - **The slot comes first.** A test hook records the slot count when the
+ body read starts. It is never above 4 with 8 clients sending at once.
+- [ ] **Implement:**
+ - write `ask_files.go`;
+ - split `askBearer` into the state check and the form parse;
+ - mount the route in `askRoutes`.
+- [ ] **Gate:** `make test`.
+
+## Task 3: `GET /ask/attachments/{id}` and `/preview` (P3)
+
+- [ ] **Test first:**
+ - **Inline images.** A PNG streams `inline` with P3's headers. A preview
+ has `max-age=3600` and `Vary: Cookie`, and an original has `no-store`.
+ - **Downloads.** A CSV is an `attachment`, with `text/csv;
+ charset=utf-8`.
+ - **Hostile upstream** (Fable B4):
+ - Equipo answering `text/html` with `inline` is served as a
+ download;
+ - `image/svg+xml` is served as an `application/octet-stream`
+ download;
+ - `/preview` for either is `404`.
+ - **Streaming.** A 9 MiB file streams to the end from a fake that writes
+ slowly, and the test reads as it comes.
+ - **`404`, with no Equipo call:** another member's ID, and an ID that
+ doesn't match `at_[a-z0-9]{8,60}`.
+ - **`404`, never a redirect:** when Ask isn't connected.
+ - **Upstream failures:**
+ - a `401` drops the link and answers `404`;
+ - a `500`, or a timeout, answers `502` with an empty body;
+ - Equipo's error body never comes through.
+ - **`HEAD`** works.
+- [ ] **Implement:** `askAttachment(preview bool)` in `ask_files.go`.
+- [ ] **Gate:** `make test`.
+
+## Task 4: Remove and discard (P11, Fable B6)
- [ ] **Test first:**
- - An image streams with Equipo's type, `inline`, and the P3 headers.
- A text file is an `attachment` download.
- - A 9 MiB file streams to the end. The test reads the body as it comes,
- and Base never holds it all (checked with a fake that writes slowly).
- - Another member's ID is `404`, and so is an ID not matching
- `at_[a-z0-9]{8,60}`, with no Equipo call.
- - Not connected is `404`, never a redirect inside an `<img>`.
- - `HEAD` works.
-- [ ] Implement `askAttachment(preview bool)` in `ask_files.go`.
-- [ ] Gate: `make test`.
-
-## Task 4: sending with files
+ - **Remove.** `DELETE /ask/attachments/{id}` relays with the bearer and
+ answers `204`. Equipo's `404` is `204` too. Equipo's
+ `409 attachment_sent` is `409`.
+ - **The slot is free.** After 20 uploads and one Remove, a 21st upload
+ passes.
+ - **Discard.** `POST /ask/attachments/discard` takes up to 5 `id`
+ fields, deletes each, and answers `204` even when some fail. A
+ malformed ID is skipped.
+ - **CSRF** refuses a cross-site discard. A same-origin beacon (with
+ `Sec-Fetch-Site: same-origin`) passes.
+- [ ] **Implement:** `askDeleteAttachment` and `askDiscard`.
+- [ ] **Gate:** `make test`.
+
+## Task 5: sending with files (P8, P10, Fable B1 and B2)
- [ ] **Test first** (`ask_files_test.go`, and `TestAskFormsCarryKeys` and
`TestAskSendRelaysWithBearer` extended):
- - Form `text` plus two `attachments` fields relay in order.
- - `attachments` alone, with empty `text`, sends.
- - Six are `422`, as are a malformed ID and an empty message with no
- files.
- - `409 runner_too_old` from Equipo gives the `oldrunner` state, as
- today.
- - A plain text send is unchanged (the fake sees no `attachments` key).
-- [ ] Implement in `askSend`.
-- [ ] Gate: `make test`.
-
-## Task 5: state, events and the capability
+ - **What sends.** `text` and two `attachments` relay in order.
+ `attachments` with empty `text` sends.
+ - **Base's own `422`s:** six files, a malformed ID, and an empty message
+ with no files.
+ - **`FilesReady(false)`.** A send with files is
+ `409 {"state":"ready","files":"unavailable"}`. Nothing in the link
+ changes, and the page's state stays `ready`. A words-only send right
+ after it is `201`.
+ - **`ExpireUploads()`.** A send with files is
+ `422 {"state":"ready","files":"stale"}`.
+ - **Words only, refused.** Equipo's `409 runner_too_old` is still the
+ `oldrunner` state, as today.
+ - **Plain text** is unchanged: the fake sees no `attachments` key.
+- [ ] **Implement** in `askSend`. When files were sent, map
+ `ErrAttachmentsUnavailable`, `ErrRunnerTooOld` and Equipo's `422`
+ before `askDone`.
+- [ ] **Gate:** `make test`.
+
+## Task 6: state, events and `can_attach`
- [ ] **Test first:**
- - `relay_internal_test.go`: a `message` event's `attachments` survive
- `project()`, with only P7's fields. An `equipo` URL in an extra field
- never comes through.
- - `webtest`: `/ask/state` carries messages' `attachments`, and
- `"attachments": true` only when the fake says so.
+ - **`relay_internal_test.go`.** A `message` event's `attachments`
+ survive `project()`, with only P7's fields. An Equipo URL in an extra
+ field never comes through.
+ - **`webtest`.** `/ask/state` carries messages' `attachments`, and
+ `"can_attach": true` only when the fake says so.
`TestAskEventsRelay` carries a message with files.
- - The native contract test pins the new fields and routes.
-- [ ] Implement in `chat.go` (types), `ask.go` (`askView.Files`, the state
- JSON) and `ask_relay.go` (`project()`).
-- [ ] Write it into `docs/api/base-native-v1.md`.
-- [ ] Gate: `make test`.
-
-## Task 6: files in the thread, drawn by the server
-
-- [ ] **Test first** (`webtest`, scripts off):
- - A person message with an image and a CSV draws a files row: an
- `<a href="/ask/attachments/{id}">` around
- `<img src="/ask/attachments/{id}/preview" alt="{name}" width height>`,
- and a pill `<a href="/ask/attachments/{id}" download>` with the name
- and the size in the member's locale ("1.2 MB", "820 KB").
- - A files-only message draws no empty text paragraph.
- - The page says no word "Equipo" (`TestAskNamesNoEquipo` still passes).
- - The page CSP is unchanged.
-- [ ] Implement in `chat.html`, with a size helper in the template funcs,
- and add the CSS in `app.css` (light and dark).
-- [ ] Gate: `make test`.
-
-## Task 7: the composer, with script
+ - **The native contract test** pins the new fields and routes.
+- [ ] **Implement** in `chat.go` (the types), `ask.go` (`askView.CanAttach`
+ and the state JSON) and `ask_relay.go` (`project()`).
+- [ ] **Document** it in `docs/api/base-native-v1.md`.
+- [ ] **Gate:** `make test`.
+
+## Task 7: files in the thread, drawn by the server
+
+- [ ] **Test first** (`webtest`, scripts off). A person message with an
+ image and a CSV draws a files row:
+ - **The image.** An `<a href="/ask/attachments/{id}">` around
+ `<img src="/ask/attachments/{id}/preview" alt="{name}" width height>`.
+ - **The CSV.** A pill `<a href="/ask/attachments/{id}" download>` with
+ the name and the size in the member's locale ("1.2 MB", "820 KB").
+ - **Files only.** A files-only message draws no empty text paragraph.
+ - **No Equipo.** `TestAskNamesNoEquipo` still passes.
+ - **The CSP** is unchanged.
+- [ ] **Implement** in `chat.html`, with a size helper in the template funcs
+ (rastrillo locales), and the CSS in `app.css` (light and dark).
+- [ ] **Gate:** `make test`.
+
+## Task 8: the composer, with script
- [ ] **Test first, browser** (`internal/browsertest/attach_test.go`, with
`askBase`, `openPanel` and `FilesReady(true)`):
- **The paperclip.** It shows in the panel and on the Ask page. With
- `FilesReady(false)` it isn't there, and neither drop nor paste
- attaches.
+ `FilesReady(false)` it doesn't, and drop and paste attach nothing.
- **The picker.** Setting two files on the hidden input through CDP
- (`DOM.setFileInputFiles`) makes two chips, each reaching "done". The
- image chip then shows its thumbnail from `/ask/attachments/…/preview`.
- - **Paste.** A `ClipboardEvent` whose `DataTransfer` holds a PNG `File`
- attaches it, and the field's text is unchanged. A paste of HTML only
- still goes through `pasteMarkdown`: the paste tests pass unchanged.
- - **Drop.** A `DragEvent` sequence (`dragenter`, `dragover`, `drop`)
- with a `File` attaches it. The drop outline shows during the drag and
- goes after.
- - **Progress and Remove.** With the fake holding the upload
- (`HoldNextUpload`), the chip shows the uploading word and a progress
- ring with `aria-valuenow`. Remove takes the chip away, and the upload
- is never sent with the message.
- - **Refusals.**
- - A file over 10 MiB is refused on the chip with no request.
- - A sixth file is refused on the chip.
- - A `.heic` is refused on the chip with no request.
- - Equipo's `415 attachment_type` shows its words on the chip.
- - **Send.**
- - With chips still uploading, Send waits, then sends once with the
- IDs in chip order.
- - Files with no text send.
- - The chips clear on success. On a failure they stay, with the
- existing "That didn't send. Try again."
+ (`DOM.setFileInputFiles`) makes two chips that reach "done". The image
+ chip then shows its thumbnail from `/ask/attachments/…/preview`.
+ - **A PDF.** Its chip shows "Ask can't read PDFs yet" (D4), and it still
+ sends.
+ - **Paste** (P12, Fable B5):
+ - a `DataTransfer` holding only a PNG `File` attaches it, and the field
+ is unchanged;
+ - one holding a PNG **and** `text/html` with a table pastes the table
+ as Markdown and attaches nothing;
+ - one holding a PNG and `text/plain` pastes the text and attaches
+ nothing;
+ - the existing paste tests pass unchanged.
+ - **Drop.** `dragenter`, `dragover` and `drop` with a `File` attach it.
+ The outline shows during the drag and goes after.
+ - **Progress and Remove** (P11):
+ - with `HoldNextUpload`, the chip shows the uploading word and a
+ progress ring with `aria-valuenow`;
+ - Remove during the upload aborts it;
+ - Remove after it sends `DELETE` (seen in the fake);
+ - a removed file is never sent.
+ - **The queue** (Fable B3). Five files from one page reach the fake at
+ most two at a time, and all five finish. A fake `503` with
+ `Retry-After: 1` on the third is retried by itself and succeeds.
+ - **Refusals:**
+ - over 10 MiB, a sixth file, and a `.heic` are refused on the chip with
+ no request;
+ - `415 attachment_type` shows its words on the chip.
+ - **Send:**
+ - with chips uploading, Send waits, then sends once with the IDs in
+ chip order;
+ - files with no text send;
+ - the chips clear on success;
+ - a network failure keeps them, with "That didn't send. Try again."
+ - **Send refused** (P10, Fable B1 and B2):
+ - with `FilesReady` turned false after the paperclip showed, the send
+ gives the "can't be read right now" line on the chips; the paperclip
+ goes; Ask is not in its "needs an update" state; and Send after
+ Remove sends the words;
+ - with `ExpireUploads()`, the chips say "attach it again".
+ - **Beacon.** On `pagehide` with two unsent chips, the fake sees both
+ deleted.
- **The thread.** The sent message shows thumbnails and pills from the
- `message` event, as the server draws them. Clicking a thumbnail opens
- the viewer sheet: the full image, Close, and Escape to close.
+ `message` event, drawn like the server's.
+ - **The viewer.**
+ - Clicking a thumbnail opens the sheet with focus on Close.
+ - Escape closes it and focus returns to the thumbnail.
+ - Tab stays inside while it is open.
+ - **Announcements.** The live region says when an upload finishes and
+ when one is refused.
- **The CSP.** The console shows no CSP violation through the whole test
- (`harness` console capture).
- - **Mobile width.** The chips scroll sideways and the paperclip keeps a
+ (the harness captures the console).
+ - **Mobile width.** The chips scroll sideways, and the paperclip has a
44 px target. Take a screenshot to `BASE_BROWSER_ARTIFACTS`.
-- [ ] Implement `ask-attach.js` and the `ask.js` hooks:
- - `post()` appends `attachments`, so the key's signature includes them.
- - The files-only submit (P8).
- - `addMessage` draws the files row, sharing the server's markup.
+- [ ] **Implement:**
+ - write `ask-attach.js`;
+ - add the `ask.js` hooks: `post()` appends `attachments`, so the key's
+ signature includes them; the files-only submit; P10's answers; the
+ paste hand-off; `addMessage` drawing the files row with the server's
+ markup.
- The words come from `data-*` attributes on the composer, written by
- `chat.html`, so the strings live in the template, as the review
- expects.
-- [ ] Gate: `make test` and `make browser` (`-run 'TestAsk'`).
+ `chat.html`.
+- [ ] **Gate:** `make test` and `make browser` (`-run 'TestAsk'`).
-## Task 8: turn failures in words
+## Task 9: turn failures in words (Fable B1)
-- [ ] **Test first** (browser and webtest): a failed turn with reason
- `attachment_unavailable` shows its line in the status. So does
- `runner_storage_full`. Any other reason keeps "That didn't get an
- answer. Try again."
-- [ ] Implement in `ask.js` `setTurn` and in the no-script status line in
- `ask.go`.
-- [ ] Gate: `make test` and `make browser` (`-run 'TestAsk'`).
+- [ ] **Test first** (browser and webtest):
+ - A failed turn with reason `attachment_unavailable`,
+ `runner_storage_full` or `runner_too_old` shows its own line in the
+ status. Without script, the status line shows it too.
+ - Any other reason keeps "That didn't get an answer. Try again."
+- [ ] **Implement** in `ask.js` `setTurn`, and in the no-script status line
+ in `ask.go`.
+- [ ] **Gate:** `make test` and `make browser` (`-run 'TestAsk'`).
-## Task 9: the native apps show files as a line (P9)
+## Task 10: the native apps show files as a line (P9)
- [ ] **Test first** (BaseKit tests):
- - A message JSON with `attachments` decodes.
+ - A message JSON with `attachments` decodes, and so does one with an
+ unknown `kind`.
- A person bubble with files and text shows the names line under the
- text, and a files-only one shows only the names.
- - An unknown `kind` still decodes.
-- [ ] Implement in `Models.swift` and `Thread.swift`. Add the one string,
- the names line's accessibility label, to `Localizable.xcstrings`.
-- [ ] Gate: `make native-check`.
+ text. A files-only bubble shows only the names.
+- [ ] **Implement** in `Models.swift` and `Thread.swift`. Add the names
+ line's accessibility label to `Localizable.xcstrings`.
+- [ ] **Gate:** `make native-check`.
-## Task 10: copy review, gates, hand-over
+## Task 11: copy review, gates, hand-over
-- [ ] Add Review 10's rows to `docs/copy-pending.md` and run the
- copy-review skill (`paulca/agent-skills` `copy-review`,
- `serve.sh`) for Luna's review. Check `result.json` before running it
- again. Draft strings follow. They reuse Equipo's approved words where
- they fit, and never name Equipo:
+- [ ] **Copy review.** Add the rows to `docs/copy-pending.md` under the
+ next free review number (13 at the time of writing; check again). Run
+ the copy-review skill (`paulca/agent-skills` `copy-review`, `serve.sh`)
+ for Luna's review, and check `result.json` before running it again.
+ These are drafts. They reuse Equipo's approved words where they fit, and
+ never name Equipo. Equipo's two new strings (its plan, P6) go in the same
+ review.
| Where | Text |
|---|---|
@@ -309,44 +443,53 @@ right reason. Then:
| Chip, Remove (label) | Remove {name} |
| Chip, failed | Couldn't upload. Try again. |
| Chip, sixth file | At most 5 files in one message. |
+ | Chip, PDF (D4) | Ask can't read PDFs yet. |
+ | Chip, files refused at send (P10) | Files can't be read right now. Remove them to send your message. |
+ | Chip, stale (P10) | This file has expired. Attach it again. |
| Refusal, too large | That file is over 10 MB. |
| Refusal, type | Ask takes images (PNG, JPEG, WebP, GIF) and text, Markdown, CSV, JSON and PDF files. |
| Refusal, HEIC | HEIC photos can't be read yet. Share it as a JPEG and try again. |
| Refusal, pixels | That image is too large: at most 12,000 pixels on a side and 40 megapixels. |
| Refusal, too many waiting | Too many files are waiting to send. Send or remove some first. |
- | Refusal, busy (503) | Too many uploads at once. Try again in a moment. |
+ | Refusal, busy (after retries) | Too many uploads at once. Try again in a moment. |
+ | Announcement, uploaded | {name} attached |
+ | Announcement, refused | {name} not attached: {reason} |
| Thread, files row (label) | Attached files |
| Thread, pill (label) | {name}, {size}. Download |
| Viewer, Close | Close (approved) |
| Turn failed, file missing | A file didn't arrive whole. Attach it again. |
| Turn failed, no room | There's no room left for these files. Try fewer or smaller ones. |
+ | Turn failed, runner too old | Files can't be read right now. Send it again without them. |
| Native, names line (label) | Attached: {names} |
-- [ ] Run `make ci`, and the full `make browser` with
+- [ ] **Gates.** Run `make ci`, and the full `make browser` with
`BASE_BROWSER_ARTIFACTS`. Put the outputs in the report. Known failures
on main are listed in memory "Base review gates".
-- [ ] Get an independent review (Fable, else Codex Astra, with a
- self-contained prompt). Fix what it finds and push.
-
-## Task 11 (controller): merge and deploy, after Equipo
-
-- [ ] Wait for Equipo's Task 13: production Equipo is live, and Paul's
- snapshot says `attachments: true`.
-- [ ] Get Paul's approval of Review 10, then merge `feat/ask-attachments`
- to `main` on the hub.
-- [ ] Deploy Base (the usual `make release` and carlos deploy). Then
- `curl /api/version` and restart if needed (memory "Calls gates report
- false green").
-- [ ] Check it live, as Paul:
- - Attach a screenshot and a `.md` and ask about both. Ask about the
- `.md` again two messages later.
- - Paste an image.
- - Open the thumbnail.
- - Check that the console shows no CSP errors.
-- [ ] Tell Paul.
+- [ ] **Review.** Get an independent review (Fable, else Codex Astra, with a
+ self-contained prompt). Fix what it finds, and push.
+
+## Task 12 (controller): merge and deploy, after Equipo
+
+- [ ] **Wait for Equipo.** Equipo's Task 14 is done: production Equipo is
+ live, and Paul's snapshot says `can_attach: true`.
+- [ ] **Merge.** Paul approves the copy review. Then merge
+ `feat/ask-attachments` to `main` on the hub.
+- [ ] **Native first.** Release the native build with Task 10 (Mac Sparkle
+ and TestFlight) before or with the web deploy (P9).
+- [ ] **Deploy Base:** the usual `make release` and carlos deploy. Then
+ `curl /api/version`, and restart if it is needed (memory "Calls gates
+ report false green").
+- [ ] **Check it live, as Paul:**
+ - attach a screenshot and a `.md`, and ask about both;
+ - two messages later, ask about the `.md` again;
+ - paste an image, and paste a table from Numbers;
+ - remove a chip;
+ - open the thumbnail;
+ - check that the console shows no CSP errors.
+- [ ] **Tell Paul.**
## Not in this plan
- The native attach UI (slice 2), and reading PDFs (slice 3).
-- Files for jobs (R6), removing a file (R2), sealing the bytes (R8), and
- files into Oficina apps (R7).
+- Files for jobs (R6), removing a sent file (R2), sealing the bytes (R8),
+ and files into Oficina apps (R7).
diff --git a/docs/superpowers/specs/2026-11-26-ask-attachments-design.md b/docs/superpowers/specs/2026-11-26-ask-attachments-design.md
index 1ab0ebc..1aedef6 100644
--- a/docs/superpowers/specs/2026-11-26-ask-attachments-design.md
+++ b/docs/superpowers/specs/2026-11-26-ask-attachments-design.md
@@ -1,7 +1,8 @@
# Files in Ask
-Status: approved by Paul on 2026-11-26, with every recommendation. Read
-against Base main `0a6e8bc` and Equipo main `478e0055`.
+Status: approved by Paul on 2026-11-26, with every recommendation. Revised
+after Fable's plan review of 2026-11-26 (B1 to B6, Equipo's E1, and the
+nits). Read against Base main `0a6e8bc` and Equipo main `478e0055`.
Paul's ruling (2026-11-26): "Definitely want to attach files in Ask and the
assistant read them if necessary."
@@ -42,8 +43,12 @@ Design decisions that follow from these:
|---|---|---|
| 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. |
| 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. |
-| D3 | **Equipo ships first. Base shows the paperclip only when Equipo says the person's runner can take files** (the snapshot's `attachments`). | A Base that offers files and then fails at send. |
-| D4 | **PDFs are accepted in slice 1,** and the Assistant says it can't read them yet. Slice 3 reads them. | Leaving PDFs out of the picker. That needs Base-side type checks and words that slice 3 throws away. |
+| 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. |
+| 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. |
+| 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. |
+| 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. |
+| 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. |
+| D8 | **A paste with words pastes the words** (Fable B5). Files are attached only when the clipboard holds files and no text. 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. |
## 1. What exists today
@@ -145,21 +150,32 @@ Design decisions that follow from these:
- **Drop and paste.**
- Files dropped on the composer are attached. An outline shows while
something is dragged over it.
- - A pasted image (a screenshot) or a copied file is attached.
- - A rich-text paste stays Markdown, as now (`ask.js:1676`).
+ - A pasted image (a screenshot) or a copied file is attached, but only
+ when the clipboard holds no text (D8).
+ - A paste with words pastes the words, and a rich-text paste stays
+ Markdown, as now (`ask.js:1676`).
- **Chips.** Each file gets a chip above the text field: a file mark, its
name and size, a progress ring while it uploads, and Remove.
- - Each file uploads at once.
+ - Files upload two at a time, in order. A busy answer is retried by
+ itself.
- Once an image is up, its chip shows the thumbnail Base serves.
- - A refusal shows on the chip in words.
+ - A refusal shows on the chip in words, and so does a PDF's "can't read
+ yet" line (D4).
+ - Remove deletes the upload in Equipo too (D6).
+ - A phone photo over 40 megapixels (48 MP cameras) is refused until
+ slice 2 resizes on the device. On the web, share it as a smaller
+ image.
- **Sending.** Send waits for the uploads to finish. Text may be empty when
- a file is attached. A sixth file is refused at the chip.
+ a file is attached. A sixth file is refused at the chip. If the files
+ are refused at send, the chips say why and the words can still go (D5).
- **In the thread.** The person's bubble shows a row of thumbnails, then
file pills (a mark, the name and the size), then the text.
- A thumbnail opens full size in a sheet.
- A pill downloads the file.
- Both come from Base. Without script the thumbnails and pills still show,
and a thumbnail opens the image itself.
+ - The viewer takes focus and gives it back on Close. Finished and refused
+ uploads are announced.
### 2.2 Mac and iPhone (slice 2)
@@ -176,51 +192,78 @@ Design decisions that follow from these:
## 3. Base's changes (slice 1)
-- **Upload:** `POST /ask/attachments`, with the raw body, `Content-Type` and
- `Content-Disposition`.
- - The body is held to 10 MiB plus 1 byte, and a body over 10 MiB is
- refused before Equipo is called.
- - Base relays it to Equipo's `POST /api/v1/attachments` with the person's
- bearer, at most 4 at a time, with a 60 s limit.
- - It answers with Equipo's JSON (`id`, `kind`, `name`, `media_type`,
- `size`, `width`, `height`).
- - Equipo's refusals (`attachment_too_large`, `_type`, `_heic`, `_pixels`,
- `_limit`) come back as `code`, and Base has words for each.
- - It makes the same session and state checks as every Ask write.
-- **Read:** `GET /ask/attachments/{id}` and `/{id}/preview` stream
- Equipo's answer through, with the person's bearer. They never go through
- `call`.
- - Base keeps Equipo's `Content-Type` and `Content-Disposition`.
- - Base sets its own `nosniff`, sandbox CSP and `Cache-Control: private`.
+- **Upload:** `POST /ask/attachments`, with the raw body, `Content-Type`
+ and `Content-Disposition`.
+ - **A slot first.** It takes one of 4 process-wide slots before it reads
+ the body. It then reads under a 60 s read deadline, to at most 10 MiB
+ plus 1 byte. A body over 10 MiB is refused before Equipo is called, and
+ a stalled body loses its slot when the deadline passes.
+ - **Waiting.** A request that waits more than 10 s for a slot gets `503`
+ with `Retry-After`. The page retries by itself.
+ - **The relay.** It goes to Equipo's `POST /api/v1/attachments` with the
+ person's bearer and a 60 s limit, and answers with Equipo's JSON (`id`,
+ `kind`, `name`, `media_type`, `size`, `width`, `height`).
+ - **Refusals.** Equipo's refusals (`attachment_too_large`, `_type`,
+ `_heic`, `_pixels`, `_limit`) come back as `code`, and Base has words
+ for each.
+ - **Checks.** It makes the same session and state checks as every Ask
+ write.
+- **Remove:** `DELETE /ask/attachments/{id}` relays Equipo's delete of an
+ unsent upload. A `404` counts as done.
+ `POST /ask/attachments/discard` takes the page's unsent IDs from a beacon
+ when the page goes away, and deletes them as best it can.
+- **Read:** `GET /ask/attachments/{id}` and `/{id}/preview` stream from
+ Equipo with the person's bearer, never through `call`.
+ - **What Base allows (D7).** Only `image/png`, `image/jpeg`, `image/webp`
+ and `image/gif` are inline. The other five types are `attachment`, and
+ anything else is `application/octet-stream` as `attachment`. `/preview`
+ serves images only.
+ - **Headers.** Base always sets `nosniff` and a sandbox CSP.
+ - **Caching.** Previews are `Cache-Control: private, max-age=3600` with
+ `Vary: Cookie`. Originals are `no-store`.
+ - **Failures.** Equipo's error body never comes through.
+ - A `401` drops the link and answers `404`.
+ - A `5xx` or a timeout answers `502` with no body.
+ - An `<img>` then shows its `alt`.
- **Send:** `POST /ask/messages` takes up to 5 `attachments` fields.
`Client.Send` sends them, and text may be empty when there are any.
+ - **Runner can't take files.** Equipo's `409 attachments_unavailable` (or
+ `runner_too_old`) on a send with files answers `409` with
+ `files: "unavailable"` and leaves Ask ready (D5).
+ - **Stale upload.** Equipo's `422` on a send with files answers `422`
+ with `files: "stale"`.
- **State and events.**
- `equipo.Message` gains `Attachments`, and `project()` and `/ask/state`
keep it. No Equipo URL ever reaches a client: each builds
`/ask/attachments/{id}`.
- - `/ask/state` gains `attachments` (true or false), from Equipo's
- snapshot.
-- **Turn failures.** A failed turn's `attachment_unavailable` and
- `runner_storage_full` reasons get their own words in the status line.
+ - `/ask/state` gains `can_attach`, from Equipo's snapshot.
+- **Turn failures.** A failed turn's `attachment_unavailable`,
+ `runner_storage_full` and `runner_too_old` reasons get their own words in
+ the status line.
+- **The native apps** show a person's files as a line of names until slice
+ 2. That build ships before or with the web release, so no installed app
+ draws an empty bubble.
- **Copy review** of every new string, before release. Base never names
Equipo (Review 8).
## 4. Equipo's changes (slice 1, ships first)
-In short. The Equipo spec has the detail.
+In short; the Equipo spec has the detail.
-- **E1.** The Assistant's send route accepts `attachments`.
- - A send with files to a runner older than the new protocol is
- `409 runner_too_old`, and nothing is stored.
- - The snapshot says `attachments: true` when the person's runner can take
- them.
-- **E2.** A `read_attachment` tool. It reads text by line, shows an image
- again, and says a PDF can't be read yet.
-- **E3.** Each later turn lists the person's files from the last 14 days in
- this conversation. The tool reads them from the runner's copy, and says so
- when a file has gone (R3).
-- **E4.** A hand-off from a turn with files goes ahead without them. The
- Assistant is told to say the job can't see them (R6).
+- **E1. The send takes files.** The Assistant's send route accepts
+ `attachments`. Files need the person's primary runner to be seen on the
+ new protocol; otherwise the answer is `409 attachments_unavailable`, with
+ nothing stored. The snapshot says `can_attach`.
+- **E2. Deleting unsent uploads.** `DELETE /api/v1/attachments/{id}`
+ deletes an unsent upload.
+- **E3. `read_attachment`.** The tool reads text by line, inside a frame
+ that says it is data and not instructions. It shows an image again, and
+ says a PDF can't be read yet.
+- **E4. Files across the conversation.** Each later turn lists the person's
+ files from up to 14 days of this conversation. The tool reads them from
+ the runner's copy, and says so when a file has gone (R3).
+- **E5. Hand-offs.** A hand-off from a turn with files goes ahead without
+ them. The Assistant is told to say the job can't see them (R6).
## 5. Privacy, retention and deletion
@@ -238,8 +281,9 @@ In short. The Equipo spec has the detail.
- Sent files: as long as the message, in Equipo, not sealed (R8).
- Runner copies: 14 days.
- Base: none.
-- **Deletion:** none in slice 1 (R2). When a member is removed from Base,
- nothing of theirs is left in Base.
+- **Deletion:** a sent file stays (R2). An unsent upload is deleted on
+ Remove, when the page goes away (as best it can), or after 24 hours (D6).
+ When a member is removed from Base, nothing of theirs is left in Base.
## 6. Slices