oficina / base Public

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

Plain git — no account needed to clone.

Download

Download this file

1# Base on the Mac and iPhone, slice 2 part 1: Implementation Plan
2
3> **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. Every task is tests first: write the failing test, see it fail, make it pass, then run the task's gate.
4
5**Revision 3** (2026-11-28). Revision 2 answered Fable's plan review
6(`.superpowers/sdd/2026-11-28-native-slice2/plan-review.md`): B1, S1 to
7S13, and the nits taken. Fable approved it, and revision 3 folds in the
8re-review's R1 to R3 and its six nits. "Review" at the end maps each
9finding to where it is answered.
10
11**Goal:** In the Mac and iPhone apps, a person opens Store and People
12natively instead of on the web, and folds the Apps section away (remembered
13for them on that device). They also attach files in Ask:
14- the paperclip or `+`, with Photos, Camera, Files and Paste;
15- paste and drop;
16- HEIC to JPEG on the device;
17- chips, files in the sent bubble, and Quick Look.
18
19**Spec:** `docs/superpowers/specs/2026-11-23-base-native-design.md` §7, approved by Paul on 2026-11-28 with every recommendation.
20- Part 1 is 7.4, 7.5 (Apps folding only) and 7.6.
21- The files design (`2026-11-26-ask-attachments-design.md`) binds too: R1, R3, R5, D1 to D8.
22- The mockups are `.superpowers/mockups/native-s2/` (git-ignored; `python3 build.py`), sections 3 and 4.
23
24**Not in part 1:** notifications (part 2), decisions on the cards (part 3), "Made with Base" and opening documents (part 4).
25
26**Architecture:**
27- **Base's server** gains five JSON routes beside the Store and People pages, using the same builders and owner checks behind the member gate. They land and deploy first, on their own branch: they add no words, so they don't wait for copy review. The files routes are already live (`07ec2ec`, `docs/api/base-native-v1.md` "Files").
28- **rastrillo/native** gains `NativeHTTP.upload`. Uploads need `Content-Disposition`, upload progress and their own timeout, and the kit has none of these: `responseDetails` takes a path, method, body and content type only (`bb989a7`). The change goes on its own kit branch with its own review. Base then repins and forwards `upload` through `SwappableTransport`, the transport its client actually uses (`BaseSession.swift:286-305`).
29- **The app (BaseKit)** gains:
30 - Store and People models and screens, shared by both platforms;
31 - the Apps fold;
32 - `BaseKit/Attachments/`, copied from Equipo (R5) and then adapted to Base's relay and rules.
33
34**Tech stack:** as slice 1.
35- **Server:** Go (`GOTOOLCHAIN=go1.26.11`, `CGO_ENABLED=0`), chi, rastrillo.
36- **Native:** Swift 6.2 / SwiftUI on macOS 26 and iOS 26, RastrilloApple, `PhotosUI`, `QuickLook` / `QuickLookUI`, `ImageIO`, `UniformTypeIdentifiers`.
37
38**Repositories and branches:**
39
40| Repo | Tasks | Branch | Lands |
41|---|---|---|---|
42| **Base** | 1 to 4 | `api/store-people` from `origin/main` | First. Deployed in Task 4, before any app change |
43| **rastrillo/native** | 5 | `upload` from `origin/main` | After its own Fable review |
44| **Base** | 6 to 21 | `native/slice2-part1` from `origin/main`, once `design/native-slice2` (this plan) and `api/store-people` have landed | After the review (Task 21) and Luna's copy review (Task 22) |
45| Controller | 22 | copy review (Luna, from 2026-12-02), land, release | |
46
47Part C starts with Spike M, and includes Task 16A only if the spike says
48so: 22 numbered tasks, one spike, and one conditional task.
49
50**Equipo** needs no change. The code it lends is copied from origin/main `8bd40ed1`. Its attachment files are unchanged at `57f370c5` (Fable).
51
52## Machine hygiene (every task)
53
54- **One heavy job at a time.** Before any `swift test`, `swift build`, `build-iphone.sh`, `snapshots.sh`, `check-native.sh` or Go test run, check:
55 ```
56 sysctl -n vm.loadavg; pgrep -fl 'xcodebuild|swift-(build|test)|xctest|go (test|build|vet)'
57 ```
58 Wait while the 1-minute load is over 20, or while two or more heavy jobs from other sessions are running.
59- **Cap the job's parallelism:** `go test -p 4`, `swift test -j 4`, `swift build -j 4`. Task 6 makes `check-native.sh` pass `-j 4` too.
60- **Give every heavy command a timeout in minutes.**
61- **Never run the whole Go suite or `make ci` locally.**
62- **Simulators:** reuse the "Rastrillo Snapshots" simulator that `snapshots.sh` uses. Never create one.
63
64## Gates
65
66| Gate | Command | When |
67|---|---|---|
68| **Go, narrow** | `GOTOOLCHAIN=go1.26.11 go test -p 4 -count=1 ./internal/web ./internal/webtest -run '<tests>'` (timeout 10 min) | Tasks 1 to 3 |
69| **Swift, narrow** | `swift test --package-path native/apple -j 4 --filter '<suites>'` (timeout 15 min). It compiles the package for macOS only | Every native task, while iterating and at its end |
70| **iPhone compile** | `native/scripts/build-iphone.sh simulator` (timeout 20 min) | Tasks that touch `#if os(iOS)` code: 10, 11, 14, 18, 19 |
71| **Native gate** | `native/scripts/check-native.sh` (timeout 40 min): the catalog, every BaseKit test, BaseMac, and the iPhone Simulator build | **Twice only:** after Task 12 (the big copy), and in Task 21 before asking for the merge |
72| **Screenshots** | `native/scripts/snapshots.sh compare mac`, then `iphone` (timeout 20 min each) | Tasks that change a picture: 9, 10, 11, 16A (if taken), 17, 18, 19, and once in Task 21. Use `record` only for pictures the task means to change, and review the contact sheets beside the mockups before committing them |
73| **Hub CI** | push, then `AMADAN_HOME=$HOME/.amadan-claude-agent amadan ci status oficina/base -branch <branch> -json` | After each push |
74
75**What hub CI proves (checked 2026-11-28 on `382e86c`).**
76- It runs `make ci`: build, vet, fmt, staticcheck, govulncheck, gitleaks, budget, script tests, and the whole Go suite.
77- Its native step is `check-native.sh --core-only`. Its log shows only "strings: … in the catalog" and "worktree-lib_test: ok".
78- So it checks the string catalog and nothing else native. **No Swift is compiled or tested on the hub.**
79- A green hub verdict proves the Go and the catalog. Swift is proven only by the local gates above, and each task's commit says which ran.
80
81## Plan decisions
82
83- **P1. Five JSON routes, from the pages' own builders** (spec 7.4, as amended).
84 - The routes:
85 - `GET /api/v1/store`
86 - `POST /api/v1/store/{app}/install`
87 - `POST /api/v1/store/{app}/uninstall`
88 - `GET /api/v1/people`
89 - `POST /api/v1/people`
90 - **Shared builders.** Task 1 moves the reading into `storeContent` and `peopleContent`, and the invite into `invitePerson`.
91 - **Writes** take JSON or no body. They need a member's session (the native one or the web cookie: the same gate) and pass Base's CSRF check, which the kit's `Origin` satisfies.
92- **P2. Answers.** Every answer is `Cache-Control: no-store`.
93
94 | Route | Answers |
95 |---|---|
96 | `GET /api/v1/store` | `200 {owner, rows}`; `503 {"code":"unavailable"}` when the installs can't be read |
97 | `POST …/install` | `202 {"store"}` with the app installing. An app already installing answers `202` and one already installed answers `200`; neither calls `Start`. When `Start` fails, the store is read again: if the row now shows installing (another request claimed it), `202` as it stands; otherwise `503 unavailable`, and nothing was claimed. `Start` fails only before its claim, so a row reading failed then is an earlier failure (Fable's code review, should-fix 1). Also `403 owner_only`, `404 unknown_app` |
98 | `POST …/uninstall` | `200 {"store"}`, also when already uninstalled; `409 {"code":"busy"}`; `403`; `404`; `503` |
99 | `GET /api/v1/people` | `200 {owner, people: [{id, initial, name, email, role}]}`. `role` is `owner`, `member` or `invited`, so there's no `joined`. `503` when members can't be read |
100 | `POST /api/v1/people` | `200 {"person"}`: the person invited, or already here. Also `422 {"code":"bad_email"}`; `502 {"code":"mail_failed"}` (invite again to retry); `403 owner_only`; `415` for a non-JSON body; `503` |
101
102- **P3. The app falls back to the web for an older server.** If a Store or People read answers `404`, the sidebar row opens the web page, as slice 1 does. With the server deployed first (Task 4) this is only a guard.
103- **P4. Store polling.**
104 - It polls every 2 s while a row is installing and the screen is showing.
105 - It stops when nothing is installing, or when the screen goes away.
106 - On an error it backs off: 2, 4, 8, then every 15 s.
107 - On `401` it stops, and the session handles it.
108- **P5. Folding is local.**
109 - `SidebarFolds` keys the Apps state in `UserDefaults.standard` on `base.fold.apps.<accountKey>`.
110 - `accountKey` is `sha256(origin + "\n" + account id)`, first 16 bytes, hex. The account id is the one the session holds (`BaseSession.account`), so the state is right before `/api/v1/me` loads, and offline.
111 - It starts open, and is never synced.
112- **P6. The kit's upload** (Task 5):
113 ```swift
114 func upload(_ path: String, body: Data, contentType: String, filename: String,
115 maxBytes: Int, progress: @escaping @Sendable (Double) -> Void) async throws -> NativeResponse
116 ```
117 - It is a `NativeTransport` requirement with **no default** (B1). A conformer that doesn't forward it fails to compile.
118 - It sends `Content-Length`; Base answers `411` without it.
119 - It sends `Content-Disposition: attachment; filename*=UTF-8''<percent-encoded>`, as Equipo does (`EquipoKit/API/Attachments.swift:21-22`).
120 - It sets `URLRequest.timeoutInterval = 90` on the upload only. The session's 30 s default stays for everything else. Base waits up to 10 s for a slot and 60 s for Equipo (S2).
121 - Progress comes from `didSendBodyData`, and only grows.
122 - `maxBytes` bounds the response body.
123 - It returns any status, with headers. `401` handling is the caller's (S1).
124- **P7. What's copied from Equipo, file by file** (from origin/main `8bd40ed1`; each copy starts with a line naming its source path and SHA):
125
126 | Equipo file | Base file | How |
127 |---|---|---|
128 | `native/share/Sources/EquipoShareCore/AttachmentFile.swift` | `Attachments/AttachmentFile.swift` | copied, then gains `convertedFrom` (the "from HEIC" line) and a size check before reading (Tasks 14, 16) |
129 | `native/share/Sources/EquipoShareCore/FileAttachment.swift` | `Attachments/FileAttachment.swift` | as it is |
130 | `EquipoKit/Attachments/AttachmentDraft.swift` | `Attachments/AttachmentDraft.swift` | copied, then Base's rules (Tasks 14, 15) |
131 | `EquipoKit/Attachments/AttachmentViews.swift` | `Attachments/AttachmentViews.swift` | copied. Its full-size preview is deleted in Task 19, where Quick Look replaces it |
132 | `EquipoKit/Attachments/PhoneAttachmentPicker.swift` | `Attachments/PhoneAttachmentPicker.swift` | copied without the screenshot rows (`RecentScreenshot` isn't copied) |
133 | `EquipoMac/AttachmentPromises.swift` | `Attachments/AttachmentPromises.swift` | as it is |
134 | `EquipoMac/MacComposer.swift` (only `accepts(_:)` and the pasteboard reading `onAttachments` does) | `Attachments/MacPasteboard.swift` | the reading only. `ComposerEditor`, the `NSTextView` subclass, isn't copied; Task 17 says why |
135 | `EquipoKit/Attachments/AttachmentsFixture.swift`, `EquipoMac/MacAttachmentsFixture.swift` | `Tests/BaseSnapshots/AttachmentFixtures.swift` | adapted: draft items and sent messages with images generated in code, no session, no network |
136 | Tests: `AttachmentTests`, `AttachmentReviewTests`, `MacAttachmentTests` | `Tests/BaseKitTests/` | copied |
137
138 - **Not copied on purpose:**
139 - `AttachmentFollowupTests` and `AttachmentHTTPTests`, which test Equipo's own transport;
140 - `RecentScreenshot.swift`, which needs Photos permission (spec 7.6);
141 - `ShareFixture.swift` and the share extension.
142 - Equipo's `Fixtures/attachments/large.webp` is copied. Larger fixtures are generated in tests, never committed.
143- **P8. Where Base differs from Equipo's native files code:**
144 1. **Remove deletes the upload** (`DELETE /ask/attachments/{id}`, D6). A `409 attachment_sent` means it went with a message: the chip just goes, with nothing shown or announced. Remove is disabled while a send is in flight.
145 2. **Two at a time, preparing and uploading.** One gate admits two files at once from preparing through to their upload's answer, in order (S8).
146 3. **Busy is retried three times.** A `503 busy` is retried after `max(Retry-After, 2 s / 4 s / 8 s)`. The ring restarts at 0 on each try. After the third, the chip shows "Too many uploads at once. Try again in a moment." with Retry (S9).
147 4. **Discard only when the session ends** (S6, S7).
148 - `BaseSession.end()` captures the old client before clearing it, and starts a best-effort `POST /ask/attachments/discard` (five ids a call), bounded at 2 s. It never holds up `end()`.
149 - `end()` covers the Sign out button, an account switch, a rejected session, and the kit's step change. When another Oficina app signed the ID out, the session is gone first and the discard fails silently.
150 - Nothing is discarded on background or quit. Equipo's 24-hour drop catches those and a killed app.
151 5. **Uploads survive the background.**
152 - On iPhone an upload in flight runs inside `beginBackgroundTask`, so it can finish.
153 - If its answer is lost, the chip shows Retry. A retry is a second upload, since the route takes no key, so the orphan may count against the 20 for a day. That is accepted.
154 6. **The paperclip and `+` show only while `can_attach`** (`AskSnapshot` gains it).
155 7. **D5.**
156 - `409 files:"unavailable"` on send keeps Ask ready, drops `can_attach`, and marks every chip with the web's words. The words can then be sent alone.
157 - `422 files:"stale"` marks the chips "This file has expired. Attach it again."
158 8. **D8:** text on the pasteboard beyond the files' own names is pasted as text (through `PasteMarkdown`, as now). Otherwise its images and files are attached.
159 9. **The refusal words are the web's** (copy review 13), keyed by code: `attachment_too_large`, `_type`, `_heic`, `_pixels`, `_limit`, `busy`.
160 - A plain-text `400`, which is Base's body deadline on a slow link, shows the web's "Couldn't upload. Try again." with Retry.
161- **P9. The cache** (spec 7.6 and 7.9, 12, as amended; S11):
162 - **Path:** `FileManager.urls(.cachesDirectory)/Attachments/<accountKey>/<attachment id>/<name>`.
163 - `accountKey` is P5's.
164 - `<attachment id>` is checked against `[A-Za-z0-9_-]{1,64}`.
165 - `<name>` is the server's name reduced to its last path component, with `/`, `\`, NUL, a leading `.` and `..` removed, and cut to at most 120 bytes of UTF-8 on a character boundary. Its extension is replaced with the media type's (`UTType(mimeType:).preferredFilenameExtension`; `bin` when unknown).
166 - **Protection:** each file `0600`, excluded from backup, and on iOS written with `NSFileProtectionComplete`.
167 - **One download per id at a time:** an actor holds the in-flight tasks, and a second tap awaits the first.
168 - **Dates:** at download, the file's modification date is set to the message's `created_at`, or to the download time when the message has none (`AskMessage.createdAt` is optional). The sweep removes anything dated more than 14 days ago.
169 - **Files open in Quick Look are skipped** (R3). The cache keeps the set of ids being previewed. A file the sweep skipped, and one already past its 14 days when it was opened, is removed when its preview closes.
170 - **The sweep** also removes the folders of accounts not signed in now. It runs at launch, on every scene going active, when the Mac window opens, and on a daily timer while the Mac app runs.
171 - **Cleared** on `end()` and when Ask is disconnected (`AskModel` sees `disconnected`).
172 - **Previews** go in a 64-item memory cache, bounded at 2 MiB each.
173 - **Privacy manifest:** the sweep reads file dates, so `PrivacyInfo.xcprivacy` gains `NSPrivacyAccessedAPICategoryFileTimestamp` with reason `C617.1`.
174- **P10. Camera, Photos and Files.**
175 - **Camera** needs `NSCameraUsageDescription` in `ios/project.yml`.
176 - **Photos** goes through `PhotosPicker` (`matching: .images`, which gives a Live Photo's still). Each item is loaded as a file through a `FileRepresentation` transferable, never as `Data`.
177 - The file's URL is valid only inside the importing closure, so it is staged there (Equipo's `stage`, into a private directory the draft owns).
178 - It is then prepared from the staged URL (`prepareFile`), with its size checked before anything is read into memory.
179 - **Files** goes through `fileImporter`.
180 - **On the Mac,** `fileImporter` takes the nine types plus HEIC, HEIF and TIFF.
181 - **Before reading:**
182 - a non-image file over 10 MiB is refused from its size alone;
183 - an image over 128 MiB is refused.
184 - **Names:** Camera and Photos items are named `Photo 1.jpg`, `Photo 2.jpg`, … in the order chosen, so "Remove Photo 2.jpg" says which one.
185- **P11. Strings.**
186 - Words the web already has keep the web's approved text, under native keys.
187 - New words are drafted with a `DRAFT 2026-11-28` comment and listed in `copy-review/slice2-part1.json` (main checkout, git-ignored) for Luna from 2026-12-02.
188 - The release waits for that review. Building and the internal TestFlight build don't.
189- **P12. Version numbers.**
190 - The mid-branch internal TestFlight build for the device check is **0.1.3 (4)**, for Paul only.
191 - The release is **0.1.3 (5)**, Mac and TestFlight.
192
193## File map
194
195```
196Base, api/store-people
197 internal/web/store.go people.go storeContent, peopleContent, invitePerson
198 internal/web/api_team.go NEW: the five handlers
199 internal/web/app.go the routes beside /api/v1/home
200 internal/web/team_internal_test.go NEW
201 internal/webtest/api_team_test.go NEW
202 docs/api/base-native-v1.md "Store" and "People"
203
204rastrillo/native, upload
205 Sources/RastrilloApple/NativeHTTP.swift NativeTransport.swift
206 Sources/RastrilloTestSupport/ScriptedTransport.swift
207 Tests/RastrilloAppleTests/NativeHTTPUploadTests.swift NEW
208 APPLE.md
209
210Base, native/slice2-part1 (native/apple/Sources/BaseKit unless shown)
211 Session/BaseSession.swift SwappableTransport.upload; end() discards and clears the cache
212 API/Client.swift API/Models.swift store, people, files, can_attach
213 Team/StoreModel StoreView PeopleModel PeopleView .swift NEW
214 Home/SidebarFolds.swift NEW; Home/BaseActions.swift
215 Mac/MacMainView.swift MacPane, the Apps fold, the drop target
216 Phone/PhoneAskScreen.swift AppsSheet: the fold, "Your team", NavigationStack
217 Attachments/ (P7's files, and NEW: AttachGate, AttachIntake, AttachmentCache, QuickLook)
218 Ask/Composer.swift Thread.swift AskModel.swift PasteMarkdown.swift
219 ../BaseMac/BaseMacApp.swift the Paste command (Task 17)
220 Resources/Localizable.xcstrings
221 native/ios/project.yml native/PrivacyInfo.xcprivacy native/scripts/check-native.sh (-j 4)
222 Tests/BaseKitTests/… Tests/BaseSnapshots/TeamSnapshots.swift AttachmentFixtures.swift AskSnapshots.swift
223```
224
225---
226
227## Part A: the server (branch `api/store-people`)
228
229### Task 1: Store and People builders, shared
230
231**Files:** `internal/web/store.go`, `people.go`, `team_internal_test.go` (new).
232
233- [ ] **Tests first:**
234 - **`storeContent`:** a row per catalogue entry, with its state and error, plus `owner` and `installing`. A failed read is an error.
235 - **`peopleContent`:** a row per member, with `initial`, `name`, `email` and `role`.
236 - **`invitePerson`:** returns `inviteOK` with the member, or `inviteBadEmail` or `inviteMailFailed`.
237 - It sends only until one invitation has been delivered.
238 - An address already here sends nothing and answers that member.
239- [ ] Move the reads out of `storePage` and `people`, and the write out of `invite`. The pages render the same.
240- [ ] **Gate:** `go test -p 4 -count=1 ./internal/web -run 'TestStoreContent|TestPeopleContent|TestInvitePerson'` and `./internal/webtest -run 'TestStore|TestPeople|TestInvite'`. The existing page tests pass unchanged.
241
242### Task 2: The reads
243
244**Files:** `internal/web/api_team.go` (new), `app.go`, `internal/webtest/api_team_test.go` (new), `docs/api/base-native-v1.md`.
245
246- [ ] **Tests first** (`newHomeApp`, `link`, `nativeSignIn`, `nativeGet` from `native_test.go`):
247 - **`TestAPIStore`:** P2's shape, `no-store`, `application/json`, in catalogue order.
248 - Installing, installed and failed rows, the failed one with its error.
249 - A member who isn't the owner gets `"owner": false`.
250 - A failing installs read gets `503 unavailable`.
251 - **`TestAPIPeople`:** the owner, a member and an invited address, with their roles, in the page's order. A web-cookie session gets the same answer (nit 4).
252 - **`TestAPITeamRefusesWithoutSession`:** `401 {"code":"unauthenticated"}` with no session, and for a removed member.
253 - **`TestAPIPeopleHasNoRemove`:** `DELETE /api/v1/people/<id>` is not 2xx (404 or 405), and the member is still there.
254- [ ] Implement both reads, and route them beside `/api/v1/home`.
255- [ ] **Docs:** "Store" and "People" in `base-native-v1.md`, from P2.
256- [ ] **Gate:** `go test -p 4 -count=1 ./internal/webtest -run 'TestAPIStore|TestAPIPeople|TestAPITeam'`.
257
258### Task 3: The writes
259
260**Files:** `internal/web/api_team.go`, `app.go`, `internal/webtest/api_team_test.go`, `docs/api/base-native-v1.md`.
261
262- [ ] **Tests first:**
263 - **`TestAPIStoreInstall`:**
264 - the owner gets `202` with the row installing, and `Start` is called once;
265 - an app already installing gets `202`, and one already installed gets `200`, with `Start` not called;
266 - a `Start` that fails while another request has claimed the install (the row reads installing) gets `202`;
267 - a `Start` that fails having claimed nothing gets `503`, a failed row's retry included;
268 - a member gets `403 owner_only`, and an unknown app `404 unknown_app`;
269 - no `Origin` gets `403` (CSRF).
270 - **`TestAPIStoreUninstall`:** `200`; `409 busy` (an installer answering `install.ErrBusy`); `200` when already uninstalled; `403`; `404`.
271 - **`TestAPIPeopleInvite`:**
272 - the owner gets `200 {"person"}`, sent once (`capturingMailer`);
273 - the same address again sends nothing, and gets `200` with that member;
274 - an address that isn't one gets `422 bad_email`;
275 - a failing mailer gets `502 mail_failed`, then a second invite sends;
276 - a member gets `403`;
277 - a form body gets `415`;
278 - a body over 4 KiB gets `413`.
279- [ ] Implement them.
280- [ ] **Docs:** P2's table.
281- [ ] **Gate:** `go test -p 4 -count=1 ./internal/webtest -run 'TestAPIStore|TestAPIPeople'`. Push, and read hub CI, which runs the whole Go suite.
282
283### Task 4: Land and deploy the server
284
285- [ ] Ask for a short review of `api/store-people` (Fable, or Codex Astra when Fable is limited) and answer it on the branch. Then land it on main through the hub, and read hub CI on main.
286- [ ] **Note the rollback SHA:** the release now live on `base.oficina.works` (`curl -sS -D - -o /dev/null https://base.oficina.works/api/version | grep -i x-carlos-version`). Write it in the branch handoff.
287- [ ] **Deploy** as the Base runbook does: account `bds`, app `base`, release and promote. Base was deployed this way on 2026-11-27, after its adoption into team oficina, as `07ec2ec`. Restart if the promote needs it, since "live" can mean the old process.
288- [ ] **Confirm:**
289 - `x-carlos-version` shows the new release;
290 - `curl -s https://base.oficina.works/api/v1/store` answers `401 {"code":"unauthenticated"}`, not `404`, which proves the route is there.
291- [ ] **The lagged team:** check whether it runs a Base (`carlos instances list --app base` on its account). This deploy is Paul's Base only. A lagged rollout waits for Paul.
292- [ ] **Rollback,** if needed: promote the noted SHA, then check `/api/version` again.
293
294## Part B: the kit (rastrillo/native, branch `upload`)
295
296### Task 5: `NativeHTTP.upload`
297
298**Files:** `Sources/RastrilloApple/NativeHTTP.swift`, `NativeTransport.swift`, `Sources/RastrilloTestSupport/ScriptedTransport.swift`, `Tests/RastrilloAppleTests/NativeHTTPUploadTests.swift` (new), `APPLE.md`.
299
300- [ ] **Tests first, in two kinds** (R1):
301 - **Against a small HTTP listener on `127.0.0.1`** (a test helper on `Network.framework`; `NativeHTTP.origin` allows `http` there). A `URLProtocol` stub never sees an upload task's body or `Content-Length`, and gets no `didSendBodyData`. These tests check:
302 - the body arrives whole, and `Content-Length` equals its size;
303 - progress only grows and ends at 1.0;
304 - a response the listener holds back still completes. The helper takes a hold time; the test uses 2 s, and Task 21 runs it once by hand at 45 s.
305 - **With a `URLProtocol` stub,** through a test seam: an internal `NativeHTTP` init that takes the `URLSessionConfiguration`, so the stub's protocol class can be set. These tests check:
306 - `POST` and `Content-Type`;
307 - `Content-Disposition` is `attachment; filename*=UTF-8''…`, with `é`, spaces, `"`, `/` and `;` percent-encoded;
308 - the request's `timeoutInterval` is 90, and a `responseDetails` request's is still the session default;
309 - `413`, `503` (with `Retry-After`) and `401` come back as a `NativeResponse` with their headers, never thrown;
310 - a response over `maxBytes` throws;
311 - cancelling the task cancels the upload.
312 - **`ScriptedTransport.upload`** records the filename and the body's size.
313- [ ] **Implement it** with a `URLSessionUploadTask` and a task delegate, reusing `makeRequest` and `BoundedBody`.
314 - It is a requirement with **no default** (B1).
315 - Every in-repo conformer forwards or implements it: `NativeHTTP`, `ScriptedTransport`, and any in the kit's tests.
316 - `APPLE.md` says that an app's own wrapping transport must forward it, naming Base's `SwappableTransport` as the example.
317- [ ] **Gate:** in rastrillo/native, `swift test -j 4 --filter NativeHTTPUploadTests`, then that repo's native gate once.
318- [ ] **Review:** ask Fable to review the `upload` branch (Codex Astra if Fable is limited), with this task and P6 as the brief. Answer every finding, then land it on rastrillo/native main and note the SHA.
319
320## Part C: the app (branch `native/slice2-part1`)
321
322### Spike M: Mac paste and drop, before anything else in Part C (R2)
323
324A short spike on a scratch branch, whose code is thrown away. It settles
325whether the Mac composer stays the SwiftUI field (Task 17 as written) or
326becomes Equipo's `NSTextView` editor first (Task 16A). Time box: half a
327day.
328
329- [ ] **Paste.** Try two ways, and keep the one that works:
330 - retarget the existing Edit ▸ Paste item: find it by action `paste:` in `NSApp.mainMenu` after launch, and again whenever SwiftUI rebuilds the menu. It keeps AppKit's localised titles (nit 2);
331 - `CommandGroup(replacing: .pasteboard)`, re-adding the standard items.
332
333 Prove, by hand, in the main window's Ask composer:
334 - a screenshot and a Finder file attach;
335 - text from Pages pastes as text;
336 - rich text still becomes Markdown;
337 - the menu panel's composer, Settings and the sign-in code field still paste plain text.
338- [ ] **Drop.** Narrow the field and its field editor to text drag types, re-applied on **every** focus gain, because the shared field editor re-registers its own types each time it's set up for a field.
339 - Prove, by hand: a Finder file dropped on the field, on the thread, and on the field after focus has left it and come back. Each attaches and inserts no path.
340- [ ] **Record the outcome** in the branch handoff and in this plan's Review, with what was seen.
341 - If both hold, Task 17 goes ahead as written, with the way chosen here.
342 - If either fails, Task 16A is taken before Task 17.
343
344### Task 6: Repin, and forward `upload` through `SwappableTransport`
345
346**Files:** `native/apple/Package.swift`, `native/ios/project.yml` (`RastrilloNative.revision`), `Session/BaseSession.swift`, `Tests/BaseKitTests/SessionTests.swift`, `native/scripts/check-native.sh`.
347
348- [ ] **Tests first:**
349 - `SwappableTransport.upload` reaches the current inner transport;
350 - after `swap(_:)`, the next upload reaches the new one;
351 - an upload started before a swap finishes on the transport it started on.
352- [ ] Bump the kit to Task 5's SHA, and add `SwappableTransport.upload`. Without it the package doesn't compile, which is the point.
353- [ ] `check-native.sh` passes `-j 4` to `swift test` and `swift build`.
354- [ ] **Gate:** `swift test --package-path native/apple -j 4 --filter BaseKitTests.SessionTests`, then `build-iphone.sh simulator`.
355
356### Task 7: The client for Store and People
357
358**Files:** `API/Models.swift`, `API/Client.swift`, `Tests/BaseKitTests/ClientTests.swift`, `Fixtures/store.json`, `Fixtures/people.json`.
359
360- [ ] **Tests first (`ScriptedTransport`):**
361 - `store()` and `people()` decode;
362 - `install(app:)` and `uninstall(app:)` post with `Origin`, and decode the store;
363 - `busy`, `owner_only`, `unknown_app` and `unavailable` map to `BaseAPIError` cases;
364 - `invite(email:)` posts JSON and decodes `{"person"}`; `bad_email` and `mail_failed` map;
365 - a `404` on a read maps to `.notOnThisBase` (P3);
366 - a `401` calls `rejected`.
367- [ ] Add `StoreData`, `StoreRow` (with `State`), `PeopleData`, `Person` (with `Role`), and the five calls.
368- [ ] **Gate:** `swift test … --filter BaseKitTests.ClientTests`.
369
370### Task 8: Store and People models
371
372**Files:** `Team/StoreModel.swift`, `Team/PeopleModel.swift`, `Tests/BaseKitTests/StoreModelTests.swift`, `PeopleModelTests.swift`.
373
374- [ ] **Tests first (a clock and client you control):**
375 - **`StoreModel`:**
376 - P4's polling, backoff and stop on `401`;
377 - `install` shows installing at once;
378 - `uninstall` confirms first (`pendingUninstall`);
379 - `busy` shows "This app is still installing. Try again in a moment.";
380 - a failed row shows its error, or "The install didn't finish.";
381 - a member sees no buttons;
382 - an `announcement` is produced only when a row changes to installed or failed, never on a poll that changes nothing.
383 - **`PeopleModel`:**
384 - it loads;
385 - `invite` trims and lowercases;
386 - each error has the web's words and is exposed as an announcement;
387 - success clears the field and reloads;
388 - Invite is busy while in flight (the 650 ms spinner rule).
389- [ ] Implement both as `@MainActor @Observable` classes.
390- [ ] **Gate:** `swift test … --filter 'BaseKitTests.StoreModelTests|BaseKitTests.PeopleModelTests'`.
391
392### Task 9: Store and People screens
393
394**Files:** `Team/StoreView.swift`, `Team/PeopleView.swift`, `Tests/BaseSnapshots/TeamSnapshots.swift` (new).
395
396- [ ] **Snapshots first,** as the mockups `mac-store`, `mac-people`, `phone-store` and `phone-people`:
397 - Store as the owner (installed, installing, failed) and as a member;
398 - People as the owner (invite field, an invited row) and as a member;
399 - the uninstall confirmation;
400 - Mac and iPhone, light and dark, iPhone also at AX3.
401- [ ] **Build them** from the look's parts.
402 - **Uninstall** confirms with the web's words.
403 - **VoiceOver:** each row is one element.
404 - An owner's installed row has a named action, "Uninstall", and a failed row has "Try again".
405 - Polling never moves focus.
406 - The model's announcements are posted (`AccessibilityNotification.Announcement`), as are the invite's errors (the web's `role="status"`).
407- [ ] **Gate:** `snapshots.sh record mac` and `record iphone` for the new pictures only. Review them beside the mockups, then `compare` both.
408
409### Task 10: Getting to Store and People
410
411**Files:** `Mac/MacMainView.swift`, `Phone/PhoneAskScreen.swift`, `Home/BaseActions.swift`, `Tests/BaseKitTests/AskViewTests.swift`, `OpenerTests.swift`.
412
413- [ ] **Tests first:**
414 - choosing `store` or `people` sets `MacPane.store` or `.people` and never calls `openURL`;
415 - when a read answered `.notOnThisBase`, the same choice opens the web page;
416 - `AppsSheet` lists "Your team": Store, and People with the count of people once `/api/v1/people` has loaded, and no count before;
417 - `settings` is unchanged.
418- [ ] **Mac:** `MacMainView` gains `@State var pane: MacPane`. The Ask Base, Store and People rows select it.
419- [ ] **iPhone:** `AppsSheet` wraps its content in a `NavigationStack`, and the "Your team" rows push the screens.
420- [ ] **Gate:** `swift test … --filter 'BaseKitTests.AskViewTests|BaseKitTests.OpenerTests'`, then `build-iphone.sh simulator`, then `snapshots.sh compare`. The main window and the apps sheet change, so record those after review.
421
422### Task 11: The Apps section folds
423
424**Files:** `Home/SidebarFolds.swift` (new), `Mac/MacMainView.swift`, `Phone/PhoneAskScreen.swift`, `Tests/BaseKitTests/SidebarFoldsTests.swift`, `BaseSnapshots/MacSnapshots.swift`, `AskSnapshots.swift`.
425
426- [ ] **Tests first:**
427 - it starts open;
428 - a new `SidebarFolds` for the same account remembers;
429 - another account, or another Base, has its own state;
430 - the key is P5's hash, with no address or origin in clear;
431 - it works with no `me` loaded.
432- [ ] **Build the heading** on both platforms: a button with a chevron, and the count when folded.
433 - **Mac keyboard:** Space toggles it; ← folds and → unfolds.
434 - **VoiceOver:** "Apps, expanded" or "Apps, collapsed".
435 - **Reduce Motion:** no chevron animation.
436- [ ] **Snapshots:** the Mac sidebar folded and open; the apps sheet folded, also at AX3.
437- [ ] **Gate:** `swift test … --filter BaseKitTests.SidebarFoldsTests`, `build-iphone.sh simulator`, then `snapshots.sh compare` after a reviewed record.
438
439### Task 12: Copy Equipo's files code into BaseKit (R5)
440
441**Files:** P7's table, and nothing else.
442
443- [ ] Copy each file in P7, with its provenance line.
444- [ ] **Make them compile and nothing more:**
445 - Base names;
446 - `BaseText` for strings;
447 - an `AttachmentClient` protocol in place of `EquipoClient`, with `upload`, `delete`, `data(id:preview:)` and `download(id:to:)`.
448 - Behaviour is unchanged.
449- [ ] **Run the copied tests.** Mark any that assert behaviour P8 changes with `// Base differs: Task 14` or `Task 15`, and skip them (`XCTSkip`) until then.
450- [ ] **Gate:** `swift test … --filter 'BaseKitTests.Attachment'`, then **`check-native.sh`** (the first of its two runs).
451
452### Task 13: The files client
453
454**Files:** `API/Client.swift`, `API/Models.swift`, `Tests/BaseKitTests/ClientTests.swift`, `Fixtures/attachment.json`.
455
456- [ ] **Tests first:**
457 - **`AskSnapshot.canAttach`** decodes `can_attach`, and is `false` when it's missing.
458 - **`upload`:**
459 - it goes through the transport's `upload` to `/ask/attachments`, and decodes `201`;
460 - each refusal maps to its code;
461 - `503 busy` carries `Retry-After`;
462 - a plain-text `400` maps to `.uploadFailed`;
463 - a `401 unauthenticated` calls `rejected` (S1).
464 - **`deleteAttachment`:** `204` and `404` are done; `409 attachment_sent` is `.alreadySent`.
465 - **`discard(ids:)`:** five per call.
466 - **`attachmentData(id, preview: true)`:** bounded at 2 MiB.
467 - **`downloadAttachment(id, to:)`:** uses the transport's `download`.
468 - **`send(text, key, attachments:)`:** repeats the field in order.
469 - **On send:** `409 files:"unavailable"` maps to `.filesUnavailable`, and `422 files:"stale"` to `.filesStale`. Neither changes the phase.
470- [ ] Implement these. `BaseClient` conforms to `AttachmentClient`.
471- [ ] **Gate:** `swift test … --filter BaseKitTests.ClientTests`.
472
473### Task 14: The draft's rules
474
475**Files:** `Attachments/AttachmentDraft.swift`, `Attachments/AttachGate.swift` (new), `Session/BaseSession.swift`, `Tests/BaseKitTests/AttachmentDraftTests.swift`, `SessionTests.swift`.
476
477- [ ] **Tests first (a scripted client and a clock):**
478 - **P8.1, Remove:**
479 - Remove deletes;
480 - `.alreadySent` drops the chip silently;
481 - Remove is disabled while sending.
482 - **P8.2, the gate:**
483 - with five files added at once, at most two are preparing or uploading at any moment, in order;
484 - a sixth file is refused at the chip.
485 - **P8.3, busy:**
486 - three retries with backoff;
487 - the ring restarts at 0;
488 - then the busy chip, with Retry.
489 - **P8.4, discard:**
490 - `end()` reads the unsent ids from the draft and captures the client **before** `ask?.dispose()` clears them. It then starts a discard bounded at 2 s, and returns at once;
491 - a discard that answers `401` is dropped silently;
492 - nothing is discarded on background.
493 - **P8.5, background:**
494 - an upload in flight is wrapped in a background task, behind a protocol the test fakes;
495 - the task's expiry handler cancels the upload and shows Retry;
496 - files still queued behind the gate wait for the foreground and don't fail;
497 - a lost answer shows Retry.
498 - **The PDF line:** a PDF chip says "Ask can't read PDFs yet."
499- [ ] Turn each `// Base differs: Task 14` test around. Add the iOS `UIApplication` conformer of the background-task protocol.
500- [ ] **Gate:** `swift test … --filter 'BaseKitTests.AttachmentDraftTests|BaseKitTests.SessionTests'`, then `build-iphone.sh simulator` (the conformer is iOS-only).
501
502### Task 15: Sending with files, and D5
503
504**Files:** `Ask/AskModel.swift`, `Attachments/AttachmentDraft.swift`, `Tests/BaseKitTests/AskModelTests.swift`.
505
506- [ ] **Tests first:**
507 - Send waits for every upload;
508 - the text may be empty with files;
509 - the sent message's files clear the chips;
510 - a failed send keeps them, and a resend reuses the key;
511 - with `can_attach` false there is no paperclip or `+`, and `add` refuses;
512 - **D5:** after `.filesUnavailable` Ask stays ready, and the words go alone with one tap; `.filesStale` marks the chips;
513 - switching accounts ends the old draft (Task 14's discard).
514- [ ] Implement these, and turn each `// Base differs: Task 15` test around.
515- [ ] **Gate:** `swift test … --filter 'BaseKitTests.AskModelTests|BaseKitTests.AttachmentDraftTests'`.
516
517### Task 16: Files prepared on the device
518
519**Files:** `Attachments/AttachmentFile.swift`, `Tests/BaseKitTests/AttachmentFileTests.swift`.
520
521- [ ] **Tests first.** Fixtures are generated in the test with `CGImageDestination` (a HEIC, a 7952×5304 JPEG, a TIFF, a 2000 px PNG with GPS); nothing large is committed.
522 - HEIC, HEIF and TIFF become JPEG, and `convertedFrom` says what from;
523 - over 2560 px is scaled down, keeping its aspect;
524 - **converted output** has no EXIF location (S10);
525 - a PNG or JPEG at or under 2560 px goes up byte for byte, since Equipo strips location on arrival;
526 - the 48 MP photo comes out under 10 MiB and 40 MP;
527 - a non-image over 10 MiB is refused from its size, without being read;
528 - an image over 128 MiB is refused;
529 - an unknown type gets the web's types line.
530- [ ] Wire it into the draft behind Task 14's gate, off the main actor.
531- [ ] **Gate:** `swift test … --filter BaseKitTests.AttachmentFileTests`.
532
533### Task 16A: The Mac composer becomes an `NSTextView` (only if Spike M failed)
534
535**Files:** `Ask/Composer.swift`, `Mac/MacComposerEditor.swift` (new, from Equipo's `ComposerEditor` in `EquipoMac/MacComposer.swift`, P7 amended), `Tests/BaseKitTests/ComposerTests.swift`, `BaseSnapshots/AskSnapshots.swift`.
536
537- [ ] **Tests first:** every behaviour `ComposerTests` pins today still holds on the new editor:
538 - Return sends, and Shift- or Option-Return starts a new line;
539 - marked text (an input method) is never sent half typed;
540 - undo and redo;
541 - a rich paste becomes Markdown;
542 - the placeholder;
543 - the focus ring.
544- [ ] Move `ComposerInput`'s Mac half (undo, IME, rich paste) into the editor. The iPhone half is unchanged.
545- [ ] **Gate:** `swift test … --filter BaseKitTests.ComposerTests`, then `snapshots.sh compare mac` (the composer must look the same).
546- [ ] **Its own review** (Fable, or Codex Astra) before Task 17 starts.
547
548### Task 17: Attaching on the Mac
549
550**Files:** `Attachments/AttachIntake.swift` (new), `Attachments/MacPasteboard.swift`, `AttachmentPromises.swift`, `Ask/Composer.swift`, `Mac/MacMainView.swift`, `../BaseMac/BaseMacApp.swift`, `Tests/BaseKitTests/MacAttachmentTests.swift`, `AttachIntakeTests.swift`, `BaseSnapshots/AskSnapshots.swift`.
551
552**Why not Equipo's editor.**
553- Equipo's Mac composer is `ComposerEditor`, an `NSTextView` subclass that overrides `paste(_:)` and the dragging methods.
554- Base's composer is a SwiftUI field whose window field editor it only observes (`ComposerInput`, `Composer.swift:103-135`), so there's nothing to subclass.
555- Base takes Paste and drops where they arrive instead.
556
557- [ ] **Tests first (platform-neutral):** `AttachIntake.decide(_ contents: PasteboardContents) -> .attach([Item]) | .text` implements D8:
558 - an image alone attaches;
559 - files alone attach;
560 - text with an image (Pages, Word, Excel) is text;
561 - text that is only the files' own names attaches;
562 - a file promise attaches.
563- [ ] **Paste: the menu's Paste,** the way Spike M chose: the retargeted existing item, or the replaced group.
564 - ⌘V arrives at it through the menu, as every key equivalent does.
565 - **Only the main window's Ask composer asks `AttachIntake`.** `ComposerInput` gains `attaches`, set by `MacMainView`'s composer alone. The menu panel's composer (which doesn't attach in part 1), Settings and the sign-in code field always get the plain `paste:`. `focused` alone can't tell the two composers apart. On `.attach` it attaches, and the field gets nothing.
566 - **Otherwise** it sends `NSText.paste(_:)` down the responder chain, setting `ComposerInput`'s `pasting` flag first. This is required: the rich-paste path detects Paste by the menu item's action being `paste:` (`Composer.swift:136-139`), which the command's item no longer has.
567 - **Test:** a rich paste through the new command still becomes Markdown (HTML on the pasteboard, Markdown in the field), and the menu panel's composer pastes text even with an image on the pasteboard.
568 - **Accepted:** Paste from the field's own context menu calls the field editor directly, bypassing the command, so an image pasted that way does nothing. The menu, ⌘V, drop and the paperclip all attach.
569- [ ] **Drop: on the pane.**
570 - The Ask pane takes `.onDrop(of: [.fileURL, .image, file promise types], isTargeted:)` and shows the outline (mockup `mac-drop`).
571 - So that a drag over the field reaches the pane and doesn't insert a path, `ComposerInput` registers the field and its field editor for text types only (`registerForDraggedTypes([.string])` after `unregisterDraggedTypes()`).
572 - It does this on **every focus gain**, not once in `start()`, because the window's shared field editor re-registers its own types each time.
573 - Plain text can still be dragged into the field.
574 - With Task 16A taken, the editor's own dragging overrides do this instead.
575- [ ] **The paperclip:** left of Send, only while `can_attach`. It opens `fileImporter` (multiple selection, P10's types).
576- [ ] **The menu panel's composer** doesn't attach in part 1. Drops there are refused quietly.
577- [ ] **Chips and accessibility:**
578 - chips above the field, wrapping, at most 196 pt tall, then scrolling;
579 - **keyboard:** Tab reaches each chip; Delete removes it; Return retries a failed one;
580 - **VoiceOver:**
581 - Remove and Retry are named actions;
582 - the ring has a value ("62 percent"), updated without announcing each step;
583 - "{name} attached" and "{name} not attached: {reason}" are announced (the web's words);
584 - **Reduce Motion:** the ring jumps rather than animates.
585- [ ] **Snapshots,** as `mac-attach` and `mac-drop`, light and dark.
586- [ ] **Gate:** `swift test … --filter 'BaseKitTests.AttachIntakeTests|BaseKitTests.MacAttachmentTests'`, then `snapshots.sh compare mac` after a reviewed record.
587
588### Task 18: Attaching on the iPhone
589
590**Files:** `Attachments/PhoneAttachmentPicker.swift`, `Attachments/AttachSources.swift` (new, platform-neutral), `Ask/Composer.swift` (`ComposerPaste`, `ComposerInput` on iOS), `Phone/PhoneAskScreen.swift`, `native/ios/project.yml`, `Tests/BaseKitTests/AttachSourcesTests.swift`, `BaseSnapshots/AskSnapshots.swift`.
591
592- [ ] **Tests first, on the platform-neutral `AttachSources`** (it holds the logic; the iOS views only call it):
593 - which sources the menu offers: Photos, Camera only when available (injected), Files, and Paste only when the pasteboard says it has images or files (`UIPasteboard.hasImages` / `hasURLs`, injected);
594 - how many more Photos may be chosen: `5 - chips`;
595 - the names (P10: `Photo 1.jpg`…);
596 - that the paste of an image through the field (`ComposerPaste`) attaches it and inserts nothing.
597- [ ] **The `+` menu:** Photos, Camera, Files and Paste, Equipo's four, with Equipo's labels as drafts for Base's review.
598 - Paste reads the pasteboard as Equipo's `paste()` does, so the system shows its paste prompt.
599- [ ] **The field takes a pasted image.**
600 - `ComposerInput` sets the `UITextView`'s `pasteConfiguration` to accept `public.image` as well as text.
601 - `ComposerPaste`'s transform hands image items to the draft (`setNoResult()`), and leaves text as now.
602- [ ] **The rest:**
603 - the chips are one line that scrolls sideways;
604 - `NSCameraUsageDescription` is added (DRAFT: "Base uses the camera to take a photo for Ask.");
605 - **VoiceOver,** as in Task 17.
606- [ ] **Snapshots,** as `phone-attach`: the menu open, chips with a "from HEIC" photo and one uploading, light and dark, and AX3.
607- [ ] **Gate:** `swift test … --filter BaseKitTests.AttachSourcesTests`, `build-iphone.sh simulator`, then `snapshots.sh compare iphone` after a reviewed record.
608- [ ] **On a device,** with internal TestFlight build **0.1.3 (4)** (DRAFT strings; Paul only):
609 - five 48 MP photos picked at once (S8);
610 - a Live Photo (its still);
611 - a ProRAW photo (the 2560 px path);
612 - Camera;
613 - Files;
614 - a pasted screenshot;
615 - background during an upload.
616
617 Note the results in the commit.
618
619### Task 19: Files in the thread, Quick Look, and the cache
620
621**Files:** `Ask/Thread.swift`, `Attachments/AttachmentViews.swift`, `Attachments/AttachmentCache.swift` (new), `Attachments/QuickLook.swift` (new), `Session/BaseSession.swift`, `Ask/AskModel.swift`, `BaseMac/BaseMacApp.swift`, `native/PrivacyInfo.xcprivacy`, `Tests/BaseKitTests/AttachmentCacheTests.swift`, `AskViewTests.swift`, `BaseSnapshots/AskSnapshots.swift`.
622
623- [ ] **Tests first:**
624 - **The bubble:** thumbnails (from `/preview`), then pills (mark, name, size), then the words. A lone image draws larger. A failed thumbnail shows its name.
625 - A thumbnail's label is "Image, {name}"; a pill's is "{name}, {size}"; both have the button trait.
626 - **The cache:** every P9 rule, each a test.
627 - The path, and sanitised names such as `../x.command` stored as `x.txt` for a `text/plain` file.
628 - `0600`, excluded from backup, and `.complete` (iOS, checked through an injected file-attributes protocol).
629 - One download per id.
630 - The message date as the file date (the download time without one), and the 14-day sweep.
631 - The sweep skips an id open in Quick Look, and removes an expired one when its preview closes.
632 - Other accounts' folders removed.
633 - Cleared on `end()` and on `disconnected`.
634 - The sweep's triggers, each injected.
635 - **Quick Look:**
636 - the Mac opens `QLPreviewPanel` on click, or Space on a selected file;
637 - the iPhone presents `QLPreviewController`, which has Share;
638 - focus returns to the thumbnail when it closes;
639 - a `404` shows "This file isn't available any more." (DRAFT).
640- [ ] Build it.
641 - Remove the names line, `FilesLine` (`Thread.swift:135-159`).
642 - Delete the copied full-size preview in `AttachmentViews.swift`.
643 - Add the privacy manifest's `C617.1`.
644- [ ] **Snapshots:** the bubble as `mac-quicklook` (the bubble only) and `phone-sent`, light and dark, and the iPhone at AX3.
645- [ ] **Gate:** `swift test … --filter 'BaseKitTests.AttachmentCacheTests|BaseKitTests.AskViewTests'`, `build-iphone.sh simulator`, then `snapshots.sh compare` after a reviewed record.
646
647### Task 20: Strings
648
649**Files:** `Resources/Localizable.xcstrings`; `copy-review/slice2-part1.json` (main checkout, git-ignored).
650
651- [ ] **Every string from Tasks 8 to 19 is in the catalog.** The web's approved words are reused verbatim: the Store and People pages, and `data-w-*` in `chat.html`.
652- [ ] **These are new, drafted** (`DRAFT 2026-11-28`) and listed for Luna with their context:
653 - "from HEIC";
654 - Photos, Camera, Files, Paste (Equipo's approved words, which Base reviews in its own voice);
655 - "Your team";
656 - "Apps, expanded" and "Apps, collapsed";
657 - "Image, {name}";
658 - "This file isn't available any more.";
659 - "Photo {n}";
660 - the camera's purpose string.
661- [ ] **Gate:** `python3 native/scripts/check-strings.py`.
662
663### Task 21: The branch's last checks
664
665- [ ] **`check-native.sh` once** (the second of its two runs), then `snapshots.sh compare` for both platforms once.
666- [ ] **Push and read hub CI** on the tip. It proves Go and the catalog only (Gates).
667- [ ] **Hand checks on a Mac with this build,** against the deployed server (Task 4):
668 - Store install and uninstall on a test Base;
669 - an invite to a test address;
670 - Apps folds, and stays folded after a relaunch and offline;
671 - paste, drop, the paperclip and Quick Look;
672 - sign-out clears `Caches/Attachments/<accountKey>`;
673 - an upload whose answer is held for 45 s still completes: Task 5's listener helper, run once by hand with a 45 s hold.
674- [ ] **An independent code review** of the whole branch (Fable, or Codex Astra), with this plan and spec 7.4 to 7.6 as the brief. Answer it on the branch.
675
676### Task 22 (Controller): Copy review, land, release
677
678- [ ] Luna reviews `copy-review/slice2-part1.json` from 2026-12-02. Run `sync-strings.py`, then `check-strings.py`.
679- [ ] Land the branch on main through the hub, and read hub CI on main.
680- [ ] Release **0.1.3 (5):** Mac through Sparkle (`release-mac.sh`) and TestFlight (`testflight.sh`).
681- [ ] **Check the release:**
682 - the appcast lists 0.1.3;
683 - TestFlight shows build 5 processed;
684 - one Mac takes the update and opens Store natively.
685
686## Review
687
688How each finding from Fable's plan review (2026-11-28) is answered:
689
690| Finding | Answer |
691|---|---|
692| **B1** | P6 and Task 5: `upload` is a requirement with no default. Task 6 forwards it in `SwappableTransport`, with tests through it, including a swap mid-session |
693| **S1** | The `401` test moved from the kit (Task 5) to the client (Task 13, Task 7), where `rejected` is called |
694| **S2** | P6: a per-request timeout of 90 s, tested by inspecting the request. P8.9: a plain-text `400` shows the failed chip with Retry |
695| **S3** | Task 5 is on its own rastrillo/native branch, with its own Fable review before it lands. Base repins after (Task 6) |
696| **S4** | Gates: `check-native.sh` twice only (after Task 12, and in Task 21), filtered `swift test` per task, `build-iphone.sh` where iOS code changes, `-j 4` in the script. Hub CI's native step stated as it is (`--core-only`: the catalog only). Task 18's logic lives in the platform-neutral `AttachSources` |
697| **S5** | Task 17: Paste through a replaced Edit menu command, and drop on the pane with the field's drag types narrowed. Proven by hand in step 1, with Equipo's `ComposerEditor` as the fallback. Task 18: the `+` menu keeps Paste, and the field accepts image pastes (`pasteConfiguration`, `ComposerPaste`). P7: the fixtures adapted |
698| **S6** | P8.4 and P8.5: no discard on background. Uploads run as background tasks. A lost answer gives Retry, and the orphan is accepted and written down |
699| **S7** | P8.4: discard from `end()` with the old client, bounded at 2 s, never blocking. It covers every cause of `end()`. The kit's sign-out from another app is stated. The cache hangs off `end()`, and the launch sweep removes other accounts' folders. No quit hook: quitting is left to the 24-hour drop |
700| **S8** | P8.2 and Task 14: one gate for preparing and uploading, two at a time. P10: sizes checked before reading, and Photos loaded as files. Task 18: five 48 MP photos on the device |
701| **S9** | P8.3: three tries with backoff, the ring restarting, then the busy chip with Retry |
702| **S10** | Task 16: location checked on converted output only. Small PNGs and JPEGs go up as they are (Equipo strips on arrival). `convertedFrom` makes `AttachmentFile` "copied, then changed" in P7 |
703| **S11** | P9: exact path and name sanitising, the hashed account, iOS `.complete`, the date from the message, sweeps at launch, active, window open and daily, clearing on disconnect, one download per id, and Share copies stated (spec 7.6 amended) |
704| **S12** | P2: `503` everywhere a read can fail; a failed `Start` decided; repeat installs decided; invite answers `{"person"}` (spec 7.4 amended); `joined` dropped; a no-Remove test (Task 2) |
705| **S13** | Part A lands and deploys first (Task 4), with a rollback SHA, a live `/api/version` check with a restart if needed, a `401`-not-`404` route check, and the lagged team named. P12: 0.1.3 (4) internal and 0.1.3 (5) release |
706| **Accessibility** | Tasks 9, 11, 17, 18, 19: the ring's value, keyboard and VoiceOver actions, numbered photo names, quiet polling, named row actions, bubble labels and focus return, announced invite errors, and the missing AX3 and dark snapshots |
707| **Nits taken** | 1 (P7's "not copied on purpose"); 2 (fixtures generated); 3 (`@escaping`, `maxBytes`, `Content-Length`); 4 ("a member's session"); 5 (the count from `/api/v1/people` only); 6 (spec 7.5: a button heading); 7 (P5 keyed on the account); 8 (P4 backoff, stop on `401`); 9 (Task 19 deletes the preview); 10 (Live Photo and ProRAW on the device); 11 (`attachment_sent`: the chip just goes); 12 (Remove disabled while sending) |
708| **Order** | Task 12 is split into 14 and 15. Task 12 names every file it copies |
709
710How the re-review (2026-11-28, approved) is folded in:
711
712| Finding | Answer |
713|---|---|
714| **R1** | Task 5: body, `Content-Length` and progress tested against a `127.0.0.1` listener. The `URLProtocol` stub, through a configuration seam, keeps the header and status tests |
715| **R2** | Spike M at the start of Part C proves paste and drop. The `NSTextView` fallback is its own Task 16A, with its own review. The drag-type narrowing is re-applied on every focus gain. Only the main window's Ask composer uses `AttachIntake`. A test checks that rich paste still becomes Markdown through the command |
716| **R3** | P9: the sweep skips files open in Quick Look and removes expired ones on close. A message without `created_at` dates its file at download |
717| **Nit 1** | Task 14: the expiry handler cancels and shows Retry; queued files wait for the foreground; `build-iphone.sh` added to its gate |
718| **Nit 2** | Spike M tries retargeting the existing Paste item first. Context-menu Paste bypassing the command is accepted and stated (Task 17) |
719| **Nit 3** | P10: Photos staged inside the importing closure, then prepared from the URL |
720| **Nit 4** | P9: the 120-byte cut falls on a character boundary |
721| **Nit 5** | Task 4: account `bds`, as Base was deployed on 2026-11-27 (`07ec2ec`) |
722| **Nit 6** | Task 21: a hand check that an upload held for 45 s completes |
723