oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1# Notification actions, slice 8
2
3Branch: `notify/actions`. Approved design: `2026-11-27-notification-actions.md`.
4Normal merges of main `8ac4dbaf` and `a2619ce3` (merge `69219bb0`); no runner protocol change.
5
6## Behavior and release boundary
7
8Notification actions are opt-in at both ends. Production defaults off;
9`EQUIPO_NOTIFICATION_ACTIONS=1` enables the capability after the physical-device
10checks below. Old registrations, old payloads, unknown categories and malformed
11bindings retain open-only behavior. Every native response action requires
12`.authenticationRequired` and `.foreground`.
13
14The mockup's model-written lock-screen option buttons were deliberately not
15built, pending any future privacy decision by Paul. Only optionless questions
16whose complete text is already in today's alert offer direct text entry.
17Other questions open their bound card after unlock. The alert adds no private
18text. Merge opens fresh task detail, Checks and the current candidate's Review
19summary, then the existing confirmation with a separate final tap.
20
21Server receipts bind person, credential, operation, target, request key and
22digest. They retain result identifiers for seven days, not duplicate answer
23text. Repeated answers return those identifiers with current presentation
24fields; timestamp formatting need not be byte-identical to the first response.
25Native stores the exact request before POST, keeps uncertain writes for at most
2624 hours and never retries on a timer. Credentials stay in the Keychain.
27The registration binding rotates with the account or device sign-in.
28
29Migration 0111 adds receipt storage and registration opt-in fields, with the
30schema snapshot. The existing API routes are extended; no new GET route or
31performance-budget exemption is introduced.
32
33## Test-first evidence
34
35Scratch logs: physical TMPDIR `notify-actions-evidence/` (archive before handoff).
36Commands use `GOMAXPROCS=4 GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0`, `go test -p 4`,
37and `swift test --package-path native/apple --jobs 4 --disable-xctest --filter 'Notification.*Tests'`.
38No full local gate. Machine load/swap and other heavy jobs checked before each
39run; work paused above load 20, including a spike above 100.
40
41- `new-guards-red.log`: changed whitespace under an answer key was incorrectly
42 accepted. `new-guards-green.log`: digest now uses the submitted body before
43 answer trimming; notification and migration checks pass.
44- `payload-red.log`, `http-red.log`, `server-contract.log`: capability, payload
45 opt-in and HTTP binding tests started red, then pass, including old empty
46 retry requests and partial/unknown binding refusal.
47- `schema-red.log`: bound retry undocumented. `receipts-schema.log`: generated
48 retry and both 409 response shapes pass; concurrent receipt deliveries produce
49 one answer, and current membership/device checks apply before receipt reads.
50- `native-parser-red.log`, `native-journal-red2.log`, `native-dispatch-red.log`:
51 missing native functionality before implementation.
52- `native-dispatch-green3.log`: 13/14 tests pass; lost-reply restoration caught
53 snake-case decoding of the journal envelope. Corrected to plain Codable for
54 the envelope; original HTTP request remains unchanged. `native-dispatch-green4.log`: all 14 focused tests pass.
55- `merge-options-red.log`: the filter omitted the web's `not_now` and `wait_mac` alternatives. The allowlist now covers those known merge choices.
56- `native-restore-red.log`: pending replies did not reappear after relaunch. `native-restore-green.log`: all 17 focused tests pass. Restoration exposes an explicit Retry and never posts automatically. Account switch, sign-out cleanup and stale-response refresh tests pass.
57- Sign-in lifetime source guard and parity: pass, 336 web strings byte-identical.
58
59## Direct card read and compatibility
60
61`GET /cards/{id}` remains the same URL. Reserved `c_` IDs select the thin
62store before lookup, with no fallback after any refusal; other IDs preserve
63`personapi` and `ProjectCard`. Thin reads use an indexed primary-key lookup,
64current person/member/device checks, Coordinator lane and not-held visibility,
65and `cardView` plus its revision/ETag. OpenAPI's oneOf distinguishes the thin
66Card shape (state/question) from PersonAPICard (resource_id/actions); the
67compatibility operation and both shapes have contract coverage.
68
69The old newest-50 scan fails `card-read-red.log`; `card-contract-green.log`
70passes the older-than-window question/options, projection byte equality,
71visibility, dispatch and legacy regression tests. Native tests place both the
72bound question and merge outside the snapshot, then use the direct read.
73`final-go-focused.log` passes the six focused packages, including migration
74snapshot, API copy and operation/schema checks.
75
76Legacy message and Coordinator-turn IDs use crypto/rand.Text's RFC 4648
77uppercase Base32 alphabet, which contains neither lowercase c nor underscore;
78native question aliases start `native:`. The generator and aliases are pinned
79by `TestLegacyCardIDsCannotUseThinPrefix`. A counts-only read of the production
80CARLOS replica at transaction 206586 (2026-11-26 23:08:47 UTC) found 68 legacy
81conversation_cards and 341 coordinator_turns, with zero c_ IDs in both tables.
82No live database writes or row contents were read. The existing measured legacy
83GET perf path remains; its new device branch uses a primary-key lookup instead
84of a list scan. No new route or perf exemption.
85
86## Mutations
87
88All 19 server mutations die: digesting the trimmed answer; ignoring receipt
89digest mismatch, disabled capability or current device; dropping task revision,
90step revision or attempt; ignoring the retry receipt; exposing text input for
91option/clipped questions; dropping retry creator/termination or merge-choice
92validation; and dropping direct-card person, held, lane, current-person,
93member/device or store-prefix checks. The initially noncompiling device
94mutation was corrected and rerun: only its valid failed test is counted.
95
96All 19 native mutations die: dropping unlock, foreground, payload version,
97registration capability, response account binding, journal-before-POST,
98question options, switch-notice cleanup, sign-out journal cleanup,
99stale refresh, journal binding/expiry/count, double-submit guard, final Merge
100tap, card revision, dispatch capability, omitting the direct stale-card refresh and replacing direct lookup with the
101snapshot window. Every mutation was restored. Logs are
102`mutation-<name>.log` and `mutation-native-<name>.log`, with per-case JSON results.
103A narrow SwiftPM invocation stalled before running tests; its helper was
104sampled and terminated, then the explicit Swift Testing invocation ran. It is
105not counted as a killed mutation.
106
107The stale-response regression also first failed (`stale-direct-red.log`): a
108409 refreshed only the snapshot and retained the old card. It now refetches the
109bound ID for navigation, merges the current projection, and never changes the
110original request's key/body/revision. The restored native suite passes all 19
111tests (`final-native-focused.log`). Merge confirmations use the large phone
112sheet so the checks, Review summary and final decision fit; long content remains
113scrollable. No new copy.
114
115## Physical-device checks still required
116
117Real APNs on a locked iPhone; hidden previews; Face ID/passcode success and
118cancellation; submit before/after unlock; terminated-app delivery; offline and
119lost replies; grouping and mirrored Watch actions. Simulator and unit tests do
120not prove the unlock guarantee. Keep the production capability off until these
121pass. No deployment or release performed.
122
123Cold launch (added with the held-input follow-up):
124
125- From a terminated app, reply by text from the lock screen, then unlock.
126 The app opens on the card with the reply pre-filled, and nothing is sent
127 until Answer is tapped.
128- Do the same with Try again on a stopped task. The sheet shows Try again,
129 and the retry starts only after the tap.
130- Repeat both behind a system prompt (permission alert, Face ID sheet) so the
131 app is still `.inactive` when the response is handled.
132- Check that `applicationState` and `isProtectedDataAvailable` read active
133 and available by the time a confirmed tap is sent.
134
135## Captures and handoff validation
136
137iPhone UI tests pass: 2 tests, 0 failures (`iphone-ui-final.log`). Both
138captures are in `site/build/slice8/`; the Merge capture shows facts, summary and
139the final Merge/Not now buttons. The first run hit XCTest's 128-character
140identifier limit; its assertion now uses NSPredicate. The existing booted
141iPhone 18 Pro was reused and the fixture app terminated. No simulator created
142or booted. Mac capture uses an in-app NSView snapshot with its sheet backing
143composited to an opaque image, without screen-capture permission.
144
145The restored native run has 19 notification tests in 8 suites. Mac builds
146(`mac-build.log`). The no-credential-write guard, share packaging/copy guard and
147336-key parity check pass. Full suites belong to Linux hub CI; its head and
148verdict are recorded in the handoff and archived CI JSON after push.
149
150## First CI follow-up
151
152CI at `209cf741` passed the notification, card, contract and security tests,
153but failed four budget reasons longer than 200 bytes and the existing
154`TestBrowserRosterVisual` spacing assertion in all four appearances, including
155its retry. Budget reasons now retain the measured counts and a concise reason;
156`go test -p 4 ./internal/testci -run '^TestBudgetRecordsAreShort$' -count=1`
157passes (`budget-reasons.log`). The browser assertion is unchanged, with computed
158spacing diagnostics added. Main `a2619ce3` had green CI. No browser templates,
159CSS or scripts differ from main. The first local narrow browser invocation
160could not locate Chromium; the installed Playwright browser was then located,
161but load exceeded 20, so the next narrow run is left to hub CI.
162
163## Review fixes (Fable)
164
165Taken over from the Codex implementer's uncommitted worktree. The roster
166spacing change moved to its own branch, `fix/roster-visual-report-card`
167(`4836c9f2`); this branch's `roster_browser_test.go` is back to main's, so
168the diagnostic log added at `18cd2fcb` is gone too.
169
170- **Placement cards are open-only.** `cardView` sets `placement_question`
171 on every placement question (options or by name; OpenAPI and API notes
172 updated). `notificationIntent` returns open-only when `Placement` is set.
173 Native decodes the field and, after the bound card read, opens any
174 placement question instead of writing. `TestNotificationPlacementPushRuleIsOpenOnly`
175 covers both states through the real card-event enqueue and `cardView`.
176- **Try again eligibility.** The intent is offered exactly when
177 `retryReason` accepts the failed, terminated newest step, and never for
178 a Merge or Publish step. The bound write still goes through
179 `personRetry`. Enqueued through the real task push: Engineering and
180 Checks failures are offered; Merge, non-owner, another step person and
181 no runner are not. Failed Review and Publish steps raise no task alert
182 (Review reads `NeedsReviewBlocked`; `task_fails` fires only on
183 `NeedsRetry`, and progress ignores Publish), so their eligibility is
184 read through `notificationIntent` directly: Review is offered, Publish is not.
185- **403 on registration.** When a registration with actions is refused 403,
186 `PushRegistrar` re-reads `/capabilities` and, when actions are off,
187 registers again without the action fields (once; no loop).
188- **App-side guard.** The dispatcher writes the journal and POSTs only
189 while protected data is available and the app is active; otherwise it
190 opens the card. The guard sits immediately before the journal save and
191 before the POST, not at the start of the action: a `.foreground`
192 response usually arrives while the app is still `.inactive`, and the
193 card and capability reads are harmless. A restored journal entry skips
194 the save, so the POST guard is tested separately. The inherited
195 in-progress change was trimmed: a check in the 409 path dismissed by the
196 card ID, not the notice, and the `answer()` placement check was
197 unreachable (run re-reads the card first).
198
199Evidence: notification Go tests pass; `./internal/wire/...` and
200`plan3test -run 'Notification|Contract'` pass; Linux build, vet and
201staticcheck v0.7.0 on `chat` and `wire` are clean. Native: 22 notification
202tests in 10 suites pass; iOS Simulator app build succeeds (UIKit branch).
203
204Mutations, every one killed and restored:
205
206| Guard | Killed by |
207|---|---|
208| intent skips `Placement` | PlacementPushRuleIsOpenOnly/options, /by-name |
209| `cardView` sets `PlacementQuestion` | PlacementPushRuleIsOpenOnly/options, /by-name |
210| intent consults `retryReason` | RetryPushRuleRefusals/member, /other-step-person, /no-runner |
211| intent refuses Merge | RetryPushRuleRefusals/merge |
212| intent refuses Publish | RetryPushRuleRefusals/publish |
213| native placement refusal after read | wrongBindingDisabledCapabilityAndStaleCardNeverWrite |
214| native decodes `placement_question` | wrongBindingDisabledCapabilityAndStaleCardNeverWrite |
215| foreground guard before journal save | lockedOrInactiveBeforeOrAfterReadNeverJournalsOrPosts |
216| foreground guard before POST | restoredReplyNeverResendsWhileLockedOrInactive |
217| guard requires protected data | both foreground tests |
218| guard requires active | both foreground tests |
219| registrar 403 fallback | forbiddenActionsRefreshCapabilitiesAndRegisterOpenOnly |
220
221Not run: physical-device checks (above), browser tests (hub CI). The
222capability stays off by default.
223
224CI at `f49270cf` failed two shards: `TestBrowserRosterVisual` (this branch
225then had main's test; fixed by merging main `6616af91`) and the size budget
226(chat 35801/10650, wire 7448 lines; exemptions raised to the measured
227counts). Headless flakes in the same run passed on their retry.
228
229## Follow-up: held input (Fable P2)
230
231Branch `notify/actions-followup` from main `10659d1f`. When the unlock/active
232guard fails, the dispatcher no longer dismisses the notice or discards input.
233It holds the action in memory on its notice (`held`), bound to the card and
234revision it read:
235
236- a typed reply is pre-filled in the card's existing answer field and is sent
237 only by its existing Answer button;
238- Try again shows the existing Try again button.
239
240A redelivery of the same response never sends a held action. The person's
241tap wins over the alert's text, so an edited reply sends as edited. Nothing
242is journalled until the tap. The tests walk the journal directory and assert
243it holds no files. No new copy.
244
245Tests: `lockedOrInactiveBeforeOrAfterReadNeverJournalsOrPosts` (held,
246pre-filled, redelivery-safe, edited reply sent once on tap) and
247`coldLaunchTryAgainWaitsForTheTap` (inactive and locked). The restored-reply
248test now also checks that the notice stays on screen. 23 notification tests
249in 10 suites pass.
250
251Mutations, every one killed and restored:
252
253| Mutation | Killed by |
254|---|---|
255| card not held | lockedOrInactive… |
256| reply not pre-filled | lockedOrInactive… |
257| Try again not offered | coldLaunchTryAgain… |
258| redelivery sends a held action | both cold-launch tests |
259| guard dismisses again | both, plus restoredReply… |
260| alert text beats the tap | lockedOrInactive… |
261| `held` not reset on tap | lockedOrInactive… |
262| guard before journal save removed | both cold-launch tests |
263
264### Review fix: retry sends what the screen shows (Fable P2)
265
266Suppose a held reply was edited, then failed before it was journalled (the
267capability or card read was offline). Try again used to send the alert's
268original text. Now, while a card is shown and nothing is journalled, Try again
269goes through `answer` with the notice's current choice. A free-text card in
270the choices flow, after the same kind of failure, keeps its inputs enabled.
271
272The inputs now lock on `uncertain` (a journalled request may have reached the
273server) instead of `canRetry`. A locked card takes no new answer; Try again
274resends the stored request exactly.
275
276Hardening: `run` refuses a notice whose own binding is not the current
277selection, before any read or write.
278
279Tests:
280
281- `editedReplyThatFailsBeforeJournallingRetriesTheEdit`: the edit is sent
282 exactly once.
283- `choicesFlowFreeTextRetriesWhatTheScreenShows`: inputs re-enabled; the
284 re-typed text is sent once, then locks.
285- `aNoticeFromAnotherBindingNeverWrites`: no card read, no POST, no file.
286
28726 notification tests in 10 suites pass.
288
289Mutations, every one killed and restored:
290
291| Mutation | Killed by |
292|---|---|
293| retry ignores the shown choice | both retry tests |
294| `uncertain` never set | choicesFlow… |
295| `uncertain` on any failure | both retry tests |
296| `answer` takes a locked card | choicesFlow… |
297| `run` skips the notice binding | aNoticeFromAnotherBinding… |
298