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
3Status: approved by the controller, including privacy and durable-receipt rulings.
4Date: 2026-11-27. Branch: `notify/actions`, from `origin/main` at
5`602b91fe`. This replaces D4's open-only rule for the actions below.
6Landing is allowed; production deployment waits for the production upgrade.
7
8## Flow and privacy
9
10Use ordinary UserNotifications categories on iPhone and Mac, with the
11existing app screens after unlock. No notification content or service
12extension, new bundle ID or signing capability is needed.
13
14Keep today's alert title and clipped question/task preview unchanged.
15APNs gains versioned routing and binding data only: a notification ID,
16registration binding ID, card kind/ID/revision, or task ID/revision and
17failed step ID/revision/attempt. It carries no credentials, email address,
18new question text, option text, checks logs, Review summary or preview URL.
19The registration binding is a random non-secret identifier stored for the
20current origin/person/device session and rotated on account changes.
21It prevents a delayed notification being acted on using another account.
22The client chooses the API origin from its authenticated session, never
23from a payload URL. A binding is routing data, never authority.
24
25**Privacy tradeoff for approval:** the mockup shows arbitrary question
26options on the lock screen. Those are additional private, model-written
27text that today's push does not send. This slice instead offers direct
28text entry only for an optionless question whose complete question fits
29today's preview. An option question, or a clipped question, opens the
30bound question card after unlock, with every option visible. There is no
31generic Yes/No mapping, numbered choice guessing or free-text answer to a
32card that only accepts its listed options. Arbitrary option buttons in the
33notification would require a separate privacy decision and dynamic
34notification UI work.
35
36## Categories and action titles
37
38Register fixed versioned categories at launch, while keeping `needs_you`.
39All response actions below use `.authenticationRequired` **and**
40`.foreground`: unlock, then open the app to handle the response and show
41any failure. Free-text entry is supplied by
42`UNTextInputNotificationAction`; its submitted answer is handled without a
43second Send tap. Foreground handling also makes a 409 reliably presentable,
44rather than hoping a background handler can open the app later.
45
46| Category | Actions | What the tap does |
47| --- | --- | --- |
48| `equipo.question.text.v1` | Answer (text input), Open the task when task-bound | Submit the typed answer to the exact card revision; display the question/conversation and result. |
49| `equipo.question.choices.v1` | Answer | Open the exact question after unlock; fetch and display its options, then the person's choice submits. |
50| `equipo.stopped.v1` | Try again, Open the task | Retry the named failed attempt only, using the existing creator and termination rules. |
51| `equipo.merge.v1` | Merge, Open the task | Load fresh facts and show the existing Merge confirmation. No write on the notification tap or on unlock. |
52| `needs_you` and unsupported kinds | Existing default tap | Open the card/task without submitting anything. |
53
54A dismiss gesture has no write semantics. Do not add Not now as a
55notification button: it could be confused with dismissing the notification
56rather than answering or setting aside a card. Access, placement, held,
57direction, policy and other unfamiliar cards retain open-only handling.
58Merge categories apply only to merge kinds the existing native helper
59fully understands and offers; they cannot expose an otherwise hidden merge.
60
61Apple documents [authenticationRequired](https://developer.apple.com/documentation/usernotifications/unnotificationactionoptions/authenticationrequired)
62as requiring unlock before delivery, and
63[foreground](https://developer.apple.com/documentation/usernotifications/unnotificationactionoptions/foreground)
64as opening the app for further interaction. Fixed categories and text input
65follow [actionable notification types](https://developer.apple.com/documentation/usernotifications/declaring-your-actionable-notification-types).
66Keep at most two actions per category so the primary action is available in
67the limited layouts too.
68
69## Server binding and retries
70
71The push is captured in the same transaction as the card/task change.
72Keep the sealed outbox, current-device checks, deduplication and 4 KiB
73payload bound. Unknown, incomplete or oversize action metadata falls back
74to today's open-only payload; it must not lose the underlying alert.
75
76Two existing API limitations need additive changes:
77`AnswerCard` checks revision but a repeated successful answer currently
78returns a conflict, and `RetryTask` currently reads no request body or
79revision. Add a notification-capable contract to these existing routes:
80
81- `POST /cards/{id}/answer`: retain exact `revision` and `choice`; accept
82 an optional idempotency key. Question option choices remain model text
83 with the existing generated-origin attribution.
84- `POST /tasks/{id}/retry`: accept an optional bound request with task
85 revision, step ID/revision/attempt and idempotency key. Every supplied
86 binding must match inside the write transaction before calling the same
87 retry helper. Missing or partial bindings from the new notification
88 dispatcher refuse the action; it never falls back to unbound retry.
89 Existing callers without a body retain their current API behavior.
90
91A durable, indexed operation receipt records the key, request digest and
92result identifiers/attempt atomically with the action. Scope it to the
93authenticated person/device, route and target; identical retries return
94the original result, a changed body with the same key is
95`api.idempotency_conflict`. Recheck the active member/device before any
96receipt read. Store no duplicate answer text in receipts or audit logs.
97Retain receipts for seven days, prune in bounded batches; after pruning,
98the original card revision or step attempt still prevents repeating the
99effect. Add an additive migration and schema snapshot.
100
101Native persists the original key and exact request before POST in a
102bounded, protected pending-action journal, bound to origin, person and
103session generation. Credentials remain in the keychain. Duplicate delegate
104delivery and relaunch reuse that request; no automatic new key or rebinding
105to the latest revision. Clear completed/definitely refused entries and
106clear all entries on sign-out/account switch; expire pending sends after
10724 hours without replay. A new notification cannot be replaced by an
108earlier uncertain send. No background retry timer sends without the
109person's requested retry.
110
111All writes reuse current roster, ownership, visibility and task/card rules
112inside their transaction, with the real authenticated actor and existing
113audit semantics. A stale answer shows `api.card_stale` or
114`api.card_answered`; a changed retry binding shows `api.not_retryable`.
115On 409, open/refetch the relevant card or task and show those reviewed
116words. Never apply the old response to its replacement. Other errors use
117the existing offline, read/write failure and API copy mappings.
118
119## Merge facts and confirmation
120
121The notification's Merge action is navigation to a confirmation, not merge
122authorization. After unlock, fetch task detail and the bound card. Show
123candidate/branch, Checks status and reasons, Review status and the current
124candidate's Review summary, using slice 3's evidence selection. Link to
125Changed files and Preview through their existing screens.
126
127Require a distinct final Merge tap through `TaskDetailModel` and its
128existing server action. If the card revision/candidate moved, open the
129updated task with the reviewed changed words, without preselecting its new
130Merge decision. If facts cannot be read, show the read failure and no Merge
131button. A change while the confirmation is open invalidates the intent;
132the final server transaction still rechecks authority and current merge
133eligibility. Notification payload facts never authorize a merge.
134
135## Compatibility and copy
136
137Advertise `notification_actions_v1` through `GET /capabilities`.
138Only after that signal does a new app include the version and registration
139binding in `POST /push-registrations`; older servers use strict JSON
140decoding, so sending new fields speculatively is unsafe. The new server
141stores the opt-in per registration and sends actionable categories only
142there. Missing capability, old registration, old payload, unknown version,
143unknown action or malformed binding means open-only. Preserve existing
144`kind/card_id/task_id/turn_id` fields so older apps can still route an
145unexpected new payload safely. Document all additive fields and request
146bodies in OpenAPI and the API guide; no runner protocol change.
147
148No new product copy proposed:
149
150| Use | Existing key | Exact words |
151| --- | --- | --- |
152| Question action | `chat.card.answer` | Answer |
153| Text input submit | `composer.send` (native reviewed) | Send |
154| Text input placeholder | `conversation.placeholder` (native reviewed) | Message |
155| Retry action | `work.pause.try_again` | Try again |
156| Merge action | `chat.card.merge` | Merge |
157| Task navigation | `task.open` (native reviewed) | Open the task |
158
159Keep imported web strings byte-identical under parity. Reuse the existing
160Merge confirmation, facts and error copy; send any unforeseen new words
161to the controller before marking them reviewed.
162
163## Verification
164
165Test first, then break each guard and record the failing test:
166
167- Go/contracts: private-text-free, bounded payloads; category eligibility;
168 registration opt-in and binding; strict old-client compatibility;
169 snapshot revisions; question ownership/options; stale revisions and
170 step attempts; creator/termination and current membership/device checks;
171 concurrent identical retries, lost reply, changed-body key reuse and
172 replay after receipt expiry. Confirm one answer/attempt/audit effect.
173- Native/fake server: category flags and identifiers; direct free-text and
174 option-card routing; no partial/unknown payload writes; same key/body
175 after relaunch; account switch/sign-out; 409 opens refreshed card with
176 exact words; offline failure; Merge shows current-candidate evidence and
177 cannot POST before the separate confirmation or after invalidation.
178- Simulator, narrowly: delivered fixture payloads, text entry, cold launch,
179 option-card routing, Merge facts/confirmation, Dynamic Type and VoiceOver
180 labels. Mac notification action delivery and navigation too.
181- **Physical device required:** real APNs on a locked iPhone; hidden
182 previews; Face ID/passcode success and cancellation; submit before/after
183 unlock; terminated-app delivery; background/offline/lost reply; system
184 notification grouping and any mirrored Watch action. Simulator evidence
185 cannot prove the unlock guarantee. These checks precede enabling the
186 server capability in production.
187
188No local full gate. Before a narrow Go/Swift/build/simulator run, check load,
189swap and other heavy jobs; wait above load 20 or with two other heavy jobs.
190Use one job, at most four workers, and reuse/shut down the simulator.
191Linux hub CI runs the full server gates, contracts and schema checks;
192native-only checks follow the established Apple lane. Record mutations,
193device limitations and screenshots in the slice 8 controller report.
194
195