oficina / equipo Public

Plan: the Assistant reads files, slice 1

Human

Prompt

Write the slice 1 implementation plan, task by task with tests first, with exact files and gates; include runner compatibility and the production rollout (docs-t1 staged upgrade with staging-thin.py, then upgrade-thin.sh, and updating the runners).

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

Task-by-task plan: protocol 32, the Assistant's send with files, the snapshot flag, earlier files, fencing older runners, hand-offs, read_attachment, headless and staging witnesses, and the staged rollout.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 6c15e4292e710b45dc52e4d9e49ca1906890e10d parent 60c721c
1 file changed, +322 −0
  • docs/superpowers/plans/2026-11-26-ask-attachments-slice1.md +322 −0

CI cancelled — superseded by a newer push — run details

CI log
=== prepare ===
ci-box: machine: aarch64, 32 CPUs, 62 GiB memory, kernel 7.0.0-1017-aws
ci-box: python 3.12.3; Docker version 29.1.3, build 29.1.3-0ubuntu3~24.04.2
ci-box: user namespaces allowed: 233151
ci-box: cgroup: cgroup2fs
ci-box: disk /home/ci/work/repos/oficina__equipo/wt/design__assistant-attachments: Type  Size Avail | ext4   96G   85G
ci-box: disk /home/ci/.cache/equipo-ci-box: Type  Size Avail | ext4   96G   85G
ci-box: bwrap: fetched and verified in 0.3s
ci-box: claude: fetched and verified in 1.3s
ci-box: codex: fetched and verified in 3.6s
ci-box: codex-code-mode-host: fetched and verified in 1.5s
ci-box: libwrap: fetched and verified in 0.3s
ci-box: socat: fetched and verified in 0.4s
npm warn deprecated node-domexception@1.0.0: Use your platform's native DOMException instead
ci-box: image pulled in 9.9s
ci-box: pi: installed and verified in 7.2s
ci-box: opencode: installed and verified in 2.3s
ci-box: chromium 156.0.8078.79-1~deb13u1: 76 packages fetched, verified and unpacked in 9.3s
ci-box: clone deepened in 3.6s
ci-box: file times set from content: 3114 files, 200 directories
ci-box: ready in 17.1s
=== copy ===
EQUIPO_RELEASE_COPY_CHECK=1 CGO_ENABLED=0 go test ./internal/equipotest -run '^TestReleaseCopyReviewed$' -count=1
ok  	amadan.net/oficina/equipo/internal/equipotest	0.141s
=== compile ===
go build ./...
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py compile
+ go build -tags testbuild ./...
  1.2s
+ go list -export -test -tags testbuild -f  ./...
  0.6s
+ go list -export -test -tags browser,testbuild -f  ./internal/equipo ./internal/headless ./internal/idtest ./internal/plan3test ./internal/thintest
  0.3s
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -version

amadan: job cancelled — a newer push superseded it
diff --git a/docs/superpowers/plans/2026-11-26-ask-attachments-slice1.md b/docs/superpowers/plans/2026-11-26-ask-attachments-slice1.md
new file mode 100644
index 00000000..1200a51e
--- /dev/null
+++ b/docs/superpowers/plans/2026-11-26-ask-attachments-slice1.md
@@ -0,0 +1,322 @@
+# The Assistant reads files, slice 1: Implementation Plan
+
+> **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:** The person attaches files in Base's Ask, and the Assistant reads
+them: in the turn they arrive and in later turns, for as long as the runner
+holds them (14 days).
+
+**Spec:** `docs/superpowers/specs/2026-11-26-assistant-attachments-design.md`
+(A1 to A5). Base's spec is binding for the rulings:
+`oficina/base` `docs/superpowers/specs/2026-11-26-ask-attachments-design.md`
+(R1 to R8).
+
+**Branch:** `design/assistant-attachments` holds the spec and this plan.
+Build on `feat/assistant-attachments`, from `origin/main` (`478e0055` when
+this was written).
+
+**Order between the repos:** this plan ships first, through to production.
+Base's slice 1 (its own plan, same file name) merges only once production
+Equipo answers `attachments` in `GET /api/v1/assistant/snapshot`.
+
+**Gates for every task:** a failing test first, observed failing for the
+right reason. Then:
+
+- `make test-lane LANE=<the package's lane>` for the touched packages;
+- `make vet fmt-check staticcheck budget` before each commit;
+- `make ci` before hand-over (Task 12).
+
+Never run bare `go test`: the pinned toolchain and lanes are in the Make
+targets. Record the commands and results in the controller report
+(AGENTS.md).
+
+## Plan decisions
+
+- **P1. Protocol 32.** It is one bump for all of A1 to A5: Assistant files,
+ `earlier`, and `read_attachment`. The runner's hello says 32, and the
+ instance gates on it.
+- **P2. `read_attachment` runs on the runner,** reading the coordinator's
+ uploads desk, where files live for 14 days. The Assistant's own desk keeps
+ only the running turn's staged files, as now. So the multi-turn window
+ needs no new staging or relay.
+- **P3. The tool reads only named files:** the turn's `attachments` plus its
+ `earlier`. The bridge keeps that set in the turn's facts (`turnFacts`).
+- **P4. Images in later turns** come back as an MCP image block. If Task 1
+ finds that an engine drops image blocks, that engine gets the text
+ fallback in the spec (A2).
+- **P5. The tool sets are pinned.** The `assist` action's pin
+ (`provider.AssistTools`, checked by `claude.ValidateInit`) and the fake
+ CLIs (`internal/fakeclaude`, `internal/fakecodex`) learn
+ `read_attachment` in the same task. Otherwise every Assistant session
+ fails to start.
+- **P6. No new person-facing copy in Equipo.** The model-facing texts live
+ in the runner (`bridge.go`'s constants). The API codes (`runner_too_old`,
+ `attachment_*`) and their `copy_key`s exist already. Base writes the
+ person's words.
+
+## File map
+
+| File | Change |
+|---|---|
+| `internal/wire/runners.go` | `Protocol32`, `ProtocolAssistantFiles`, `ProtocolCurrent`; `Encode` below 32 |
+| `internal/wire/frames.go` | `MessageCommand.Earlier []AttachmentRef` (`earlier`) |
+| `internal/wire/assistant.go` | `ToolReadAttachment`, `AssistTools`, `AssistantSnapshot.Attachments` |
+| `internal/wire/assistant_files_test.go` | new |
+| `internal/equipo/chat/lane.go` | `Send` takes files; `Snapshot.Attachments`; `fenceLanes` below 32 |
+| `internal/equipo/chat/store.go` | dispatch fills `Earlier` (Assistant person turns) |
+| `internal/equipo/chat/attachments.go` | `earlierFiles` query |
+| `internal/equipo/chat/handoff.go` | `files_left_behind`, the context line, the op description |
+| `internal/equipo/chat/assistant_files_test.go` | new |
+| `internal/runner/provider/actions.go` | `AssistTools` gains `read_attachment` |
+| `internal/runner/thin/assistant.go` | the tool in `assistTools`; `assistRule` moves on |
+| `internal/runner/thin/bridge.go` | `read_attachment`; the named-file set; the result can carry an image |
+| `internal/runner/thin/mcp.go` | writes an image content block |
+| `internal/runner/thin/claude.go`, `codex.go` | `attachmentNote` per lane; the earlier block |
+| `internal/runner/thin/engine.go`, `state.go`, `link.go` | `TurnInput.Earlier` through the runner |
+| `internal/runner/thin/assistant_files_test.go` | new |
+| `internal/fakeclaude/fake.go`, `internal/fakecodex/fake.go` | the tool in their pinned sets; a `tool:read_attachment:<path>` directive |
+| `internal/headless/assistant_attach_test.go` | new (CI, local) |
+| `internal/headless/scenarios_test.go` | the `assistant_attachments` staging scenario |
+| `internal/headless/live_attach_test.go` | an Assistant-lane variant (live, not CI) |
+| `docs/api/equipo-v1.md`, `docs/api/equipo-v1.openapi.json` | Talk to the Assistant |
+| `.rastrillo/budgets.txt` | measured again |
+
+## Task 1: check MCP image results on both engines (no product code)
+
+- [ ] In a scratch checkout under `$TMPDIR`, make the bridge answer one test
+ tool with an MCP `{"type":"image","data":…,"mimeType":"image/png"}`
+ block.
+- [ ] Run it through `TestLiveAttachment`'s harness once with the pinned
+ Claude CLI and once with the pinned Codex CLI. Ask the model what colour
+ the image is.
+- [ ] Record per engine in the controller report whether the model saw the
+ image. That fixes P4 for Task 8. Delete the scratch.
+
+## Task 2: protocol 32 on the wire
+
+- [ ] **Test first** (`internal/wire/assistant_files_test.go`):
+ - At 31, `Encode` refuses an Assistant-lane `MessageCommand` with
+ attachments (`ErrProtocol`).
+ - At 31 it drops `earlier` from a frame with no attachments.
+ - At 31 a Coordinator-lane and a job-lane `MessageCommand` with
+ attachments pass unchanged.
+ - At 32 every frame passes unchanged.
+ - `ProtocolCurrent == 32`.
+ - `AssistTools` holds `read_attachment`. `TeamUpdateTools` doesn't.
+ - The snapshot JSON carries `attachments`.
+- [ ] Implement in `runners.go`, `frames.go` and `assistant.go`. Add the
+ `Encode` doc paragraph's sentence for 32.
+- [ ] Extend `mixed_protocol_test.go`'s table with protocol 32, if it
+ enumerates protocols.
+- [ ] Gate: `make test-lane` for `internal/wire`.
+
+## Task 3: the Assistant's send takes files (A1)
+
+- [ ] **Test first** (`internal/equipo/chat/assistant_files_test.go`, with
+ `lane_test.go`'s helpers), with a primary on 32:
+ - Upload two files. Send them with text to the Assistant: `201`, and the
+ message carries both, in order.
+ - The snapshot's tail, `GET …/messages` and the `message` event all carry
+ them.
+ - Files with no text: `201`.
+ - The same key with the same files gives `200` and the same message. The
+ same key with other files is `idempotency_conflict`.
+ - Six files are `invalid`. So is another person's upload, and so is a
+ file already sent.
+ - `project_id` is still `invalid`. A card answer still takes words only.
+- [ ] **Test first, older runner:** a primary on 31 and a send with files
+ give `ErrRunnerTooOld`.
+ - No message or turn is stored, and both uploads are still unsent.
+ - The same send without files passes.
+- [ ] Implement in `LaneStore.Send`. Validate as `Store.Send` does, and use
+ `runnerAt(person, wire.ProtocolAssistantFiles)` when there are files.
+ Pass the files to `sendOrigin`.
+- [ ] Break it, and watch the tests fail: drop the protocol check, then the
+ `linkFiles` order. Then restore it.
+- [ ] Gate: `make test-lane` for `internal/equipo/chat`.
+
+## Task 4: the snapshot says whether files work (A1)
+
+- [ ] **Test first:** `attachments` is true with a primary on 32. It is
+ false on 31, false with no runner, and false with no primary session yet,
+ matching what `runnerAt` lets through.
+- [ ] **Test first, HTTP:** `GET /api/v1/assistant/snapshot` carries the
+ field. On 31, a `POST /api/v1/assistant/messages` with `attachments` is
+ `409 runner_too_old` with the usual body.
+- [ ] Implement in `LaneStore.Snapshot`.
+- [ ] Gate: `make test-lane` for `internal/equipo/chat`.
+
+## Task 5: `earlier` on the Assistant's frames (A3)
+
+- [ ] **Test first** (`assistant_files_test.go`, reading the queued
+ `message` command):
+ - Three earlier Assistant messages with files, one of them 15 days old:
+ `earlier` lists the two recent ones, newest first, without this turn's
+ files.
+ - Coordinator-lane files never appear.
+ - The list is capped at 20.
+ - A `team_update` turn and a Coordinator turn carry no `earlier`.
+- [ ] Implement `earlierFiles(person, lane, exclude, since)` in
+ `attachments.go`. Call it in dispatch (`store.go`, beside `relayFiles` at
+ `:390`) for `LaneAssistant` and `TurnPerson`. It uses the store's clock
+ and `keepFiles`' 14 days: add the constant `wire.RunnerKeepFiles` so the
+ two can't drift.
+- [ ] The frame-size loop (`store.go`, "the tail gives way first") counts
+ `earlier`, and drops it before the tail when the frame is too big.
+- [ ] Gate: `make test-lane` for `internal/equipo/chat`.
+
+## Task 6: older runners are fenced (A5)
+
+- [ ] **Test first:** a primary connects at 31 with two Assistant turns in
+ flight, one carrying files.
+ - The one with files fails `runner_too_old`, and its message command is
+ acked, so it is never sent.
+ - The other is untouched.
+ - At 32 both are untouched.
+ - A worker connecting at 31 changes nothing.
+- [ ] Implement in `fenceLanes`. Keep its early return for 32 and later.
+ Below 32, also select Assistant turns that have a linked file
+ (`EXISTS chat_attachments` on the turn's messages).
+- [ ] Gate: `make test-lane` for `internal/equipo/chat`.
+
+## Task 7: a hand-off with files goes ahead without them (A4)
+
+- [ ] **Test first** (`handoff_test.go`): `team_request` from an Assistant
+ turn whose message has two files.
+ - The result carries `files_left_behind: 2`.
+ - The job thread's message has no files.
+ - The hand-off's stored context ends with the instance's reference line.
+ - Without files there is no field and no line.
+ - A repeated call returns the same result.
+- [ ] Implement in `teamRequest`. Count the turn's linked files. Append the
+ line with `referenceText`, so it stays quoted reference. Update
+ `opTeamRequest`'s output schema and description.
+- [ ] Gate: `make test-lane` for `internal/equipo/chat`.
+
+## Task 8: `read_attachment` on the runner (A2)
+
+- [ ] **Test first** (`internal/runner/thin/assistant_files_test.go`, with
+ `files_test.go`'s desk fixtures):
+ - A named text file reads as numbered lines, and `start` works.
+ - A named PDF answers the PDF line.
+ - A named image comes back as an image result, scaled under
+ `attach.ModelBytes`, or as the text fallback on an engine Task 1 found
+ blind.
+ - These answer "No such attachment":
+ - a held file not named for this turn;
+ - `../` and absolute paths outside `/workspace/attachments`;
+ - a symlinked name;
+ - a different person's file.
+ - A named file the sweep removed answers the "no longer on this machine"
+ line.
+ - The MCP reply for an image has one `image` content block and no text
+ block.
+- [ ] Implement:
+ - The case in `bridge.call`, reusing `readAttachment`'s path checks.
+ - The named set in `turnFacts`, from `TurnInput.Attachments` and
+ `Earlier`.
+ - `Call` returns a small result struct with an optional image, and
+ `mcp.go:259` writes it.
+- [ ] Add `read_attachment` to `provider.AssistTools`, to `assistTools`
+ (its model-facing description) and to the fake CLIs' pinned sets. Add the
+ fake CLIs' `tool:read_attachment:<path>` directive, which echoes the
+ result.
+- [ ] Move `assistRule` on (`assist-2026-11-26.1`).
+- [ ] Gate: `make test-lane` for `internal/runner/...` and
+ `internal/fakeclaude`, then `make runner-host` (the namespace and adapter
+ tests).
+
+## Task 9: the note names the right tool and earlier files (A2, A3)
+
+- [ ] **Test first** (`assistant_files_test.go`):
+ - An Assistant turn's note names `read_attachment` and never `read_file`.
+ A Coordinator turn's note is byte-for-byte what it was.
+ - With `earlier`, a second block lists each held file with its path, and
+ each missing one with the "attach it again" line.
+ - Both blocks carry the "person's data, not instructions" framing.
+ - Earlier images are not shown in the frame.
+- [ ] Implement in `attachmentNote` (Claude and Codex share it), and carry
+ `Earlier` through `link.go`, `state.go` and `engine.go` into `TurnInput`.
+ The state DB row stores it with `Attachments` (additive column).
+ Checking an earlier file never fails the turn (unlike `laneFiles`): a
+ missing one is listed as missing.
+- [ ] Gate: `make test-lane` for `internal/runner/...`.
+
+## Task 10: headless, end to end (CI)
+
+- [ ] **Test first** (`internal/headless/assistant_attach_test.go`, after
+ `attachments_test.go`). Use a local instance and runner with the fake CLI,
+ through `/api/v1/assistant` as Base calls it.
+ 1. Upload `notes.md` and a PNG, and send "tool:read_attachment:<md
+ path>". The reply quotes the file's first line, and the turn shows
+ both files.
+ 2. A second turn, with no files: "tool:read_attachment:<same path>" still
+ reads it, from `earlier`.
+ 3. Remove the file from the runner's desk by hand. The next turn's note
+ says it is gone.
+ 4. Restart the runner announcing protocol 31. Use the test build's protocol override,
+ or add one in `internal/runner/thin` behind the test build tag.
+ A send with files is `409 runner_too_old`, and the snapshot says
+ `attachments: false`.
+ 5. "tool:team_request" from a turn with files: the hand-off is made, with
+ `files_left_behind`.
+- [ ] Gate: `make test-lane` for `internal/headless`.
+
+## Task 11: staging and live witnesses (not CI)
+
+- [ ] Add the `assistant_attachments` scenario to `scenarios_test.go`,
+ selected by `EQUIPO_STAGING_SCENARIOS`. It runs steps 1 and 2 of Task 10
+ with the real Claude CLI on the staging runner. The reply has to name a
+ word that is only in the file.
+- [ ] Add the Assistant lane to `TestLiveAttachment`
+ (`EQUIPO_ATTACH_LIVE=1`): one turn with an image and one later turn that
+ re-reads it, on each engine.
+
+## Task 12: docs, budgets, hand-over
+
+- [ ] `docs/api/equipo-v1.md` ("Talk to the Assistant"):
+ - Drop "takes words only".
+ - Document `attachments` on send (the same upload route, at most five,
+ text optional), the `409 runner_too_old` for files, and the snapshot's
+ `attachments`.
+ - Say that card answers and job threads take words only.
+ - Mirror it in `equipo-v1.openapi.json`.
+- [ ] Measure `.rastrillo/budgets.txt` again.
+- [ ] Run `make ci` and `make copy-release-check` (no copy should change),
+ and put both outputs in the controller report.
+- [ ] Get an independent review (Fable, else Codex Astra, with a
+ self-contained prompt). Fix what it finds, push and ask for the merge.
+
+## Task 13 (controller): release and rollout
+
+On docs-t1, after the merge to `main`. AGENTS.md allows an agent to run the
+upgrade with a green staging run and no waiver; tell Paul afterwards.
+
+- [ ] `make release` on the merge commit, and note the version.
+- [ ] Staging:
+ - `scripts/staging-thin.py build`, then `release` (idle check, runners,
+ then the instance).
+ - `scripts/staging-thin.py suite assistant_attachments,<the usual set>`.
+ - `make staged-check`.
+- [ ] Production:
+ - `scripts/upgrade-thin.sh <version>`, and read the plan.
+ - `scripts/upgrade-thin.sh <version> --execute`: preflight, backup, the
+ primary runner, the instance, verify.
+ - If verify fails, `scripts/upgrade-thin.sh rollback --execute`, and tell
+ Paul.
+- [ ] Check it live:
+ - `curl https://<equipo>/api/version` shows the version.
+ - Paul's snapshot through Base staging says `attachments: true`.
+ - The runner's hello says 32 in the instance log.
+- [ ] Worker runners (Paul's Mac `paulequipo`): run the install command
+ from `docs/mac-runner.md` again, so every runner speaks 32. This is
+ Paul's step if it needs his sign-in.
+- [ ] Tell Paul and Base's controller that Equipo is live with files. That
+ unblocks Base's slice 1.
+
+## Not in this plan
+
+- PDF text and page images (slice 3).
+- Files into job threads (R6), removing a file (R2), and sealing the bytes
+ (R8).
+- Native Base (Base's slice 2).