| 1 | # Notification actions, slice 8 |
| 2 | |
| 3 | Status: approved by the controller, including privacy and durable-receipt rulings. |
| 4 | Date: 2026-11-27. Branch: `notify/actions`, from `origin/main` at |
| 5 | `602b91fe`. This replaces D4's open-only rule for the actions below. |
| 6 | Landing is allowed; production deployment waits for the production upgrade. |
| 7 | |
| 8 | ## Flow and privacy |
| 9 | |
| 10 | Use ordinary UserNotifications categories on iPhone and Mac, with the |
| 11 | existing app screens after unlock. No notification content or service |
| 12 | extension, new bundle ID or signing capability is needed. |
| 13 | |
| 14 | Keep today's alert title and clipped question/task preview unchanged. |
| 15 | APNs gains versioned routing and binding data only: a notification ID, |
| 16 | registration binding ID, card kind/ID/revision, or task ID/revision and |
| 17 | failed step ID/revision/attempt. It carries no credentials, email address, |
| 18 | new question text, option text, checks logs, Review summary or preview URL. |
| 19 | The registration binding is a random non-secret identifier stored for the |
| 20 | current origin/person/device session and rotated on account changes. |
| 21 | It prevents a delayed notification being acted on using another account. |
| 22 | The client chooses the API origin from its authenticated session, never |
| 23 | from a payload URL. A binding is routing data, never authority. |
| 24 | |
| 25 | **Privacy tradeoff for approval:** the mockup shows arbitrary question |
| 26 | options on the lock screen. Those are additional private, model-written |
| 27 | text that today's push does not send. This slice instead offers direct |
| 28 | text entry only for an optionless question whose complete question fits |
| 29 | today's preview. An option question, or a clipped question, opens the |
| 30 | bound question card after unlock, with every option visible. There is no |
| 31 | generic Yes/No mapping, numbered choice guessing or free-text answer to a |
| 32 | card that only accepts its listed options. Arbitrary option buttons in the |
| 33 | notification would require a separate privacy decision and dynamic |
| 34 | notification UI work. |
| 35 | |
| 36 | ## Categories and action titles |
| 37 | |
| 38 | Register fixed versioned categories at launch, while keeping `needs_you`. |
| 39 | All response actions below use `.authenticationRequired` **and** |
| 40 | `.foreground`: unlock, then open the app to handle the response and show |
| 41 | any failure. Free-text entry is supplied by |
| 42 | `UNTextInputNotificationAction`; its submitted answer is handled without a |
| 43 | second Send tap. Foreground handling also makes a 409 reliably presentable, |
| 44 | rather 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 | |
| 54 | A dismiss gesture has no write semantics. Do not add Not now as a |
| 55 | notification button: it could be confused with dismissing the notification |
| 56 | rather than answering or setting aside a card. Access, placement, held, |
| 57 | direction, policy and other unfamiliar cards retain open-only handling. |
| 58 | Merge categories apply only to merge kinds the existing native helper |
| 59 | fully understands and offers; they cannot expose an otherwise hidden merge. |
| 60 | |
| 61 | Apple documents [authenticationRequired](https://developer.apple.com/documentation/usernotifications/unnotificationactionoptions/authenticationrequired) |
| 62 | as requiring unlock before delivery, and |
| 63 | [foreground](https://developer.apple.com/documentation/usernotifications/unnotificationactionoptions/foreground) |
| 64 | as opening the app for further interaction. Fixed categories and text input |
| 65 | follow [actionable notification types](https://developer.apple.com/documentation/usernotifications/declaring-your-actionable-notification-types). |
| 66 | Keep at most two actions per category so the primary action is available in |
| 67 | the limited layouts too. |
| 68 | |
| 69 | ## Server binding and retries |
| 70 | |
| 71 | The push is captured in the same transaction as the card/task change. |
| 72 | Keep the sealed outbox, current-device checks, deduplication and 4 KiB |
| 73 | payload bound. Unknown, incomplete or oversize action metadata falls back |
| 74 | to today's open-only payload; it must not lose the underlying alert. |
| 75 | |
| 76 | Two existing API limitations need additive changes: |
| 77 | `AnswerCard` checks revision but a repeated successful answer currently |
| 78 | returns a conflict, and `RetryTask` currently reads no request body or |
| 79 | revision. 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 | |
| 91 | A durable, indexed operation receipt records the key, request digest and |
| 92 | result identifiers/attempt atomically with the action. Scope it to the |
| 93 | authenticated person/device, route and target; identical retries return |
| 94 | the original result, a changed body with the same key is |
| 95 | `api.idempotency_conflict`. Recheck the active member/device before any |
| 96 | receipt read. Store no duplicate answer text in receipts or audit logs. |
| 97 | Retain receipts for seven days, prune in bounded batches; after pruning, |
| 98 | the original card revision or step attempt still prevents repeating the |
| 99 | effect. Add an additive migration and schema snapshot. |
| 100 | |
| 101 | Native persists the original key and exact request before POST in a |
| 102 | bounded, protected pending-action journal, bound to origin, person and |
| 103 | session generation. Credentials remain in the keychain. Duplicate delegate |
| 104 | delivery and relaunch reuse that request; no automatic new key or rebinding |
| 105 | to the latest revision. Clear completed/definitely refused entries and |
| 106 | clear all entries on sign-out/account switch; expire pending sends after |
| 107 | 24 hours without replay. A new notification cannot be replaced by an |
| 108 | earlier uncertain send. No background retry timer sends without the |
| 109 | person's requested retry. |
| 110 | |
| 111 | All writes reuse current roster, ownership, visibility and task/card rules |
| 112 | inside their transaction, with the real authenticated actor and existing |
| 113 | audit semantics. A stale answer shows `api.card_stale` or |
| 114 | `api.card_answered`; a changed retry binding shows `api.not_retryable`. |
| 115 | On 409, open/refetch the relevant card or task and show those reviewed |
| 116 | words. Never apply the old response to its replacement. Other errors use |
| 117 | the existing offline, read/write failure and API copy mappings. |
| 118 | |
| 119 | ## Merge facts and confirmation |
| 120 | |
| 121 | The notification's Merge action is navigation to a confirmation, not merge |
| 122 | authorization. After unlock, fetch task detail and the bound card. Show |
| 123 | candidate/branch, Checks status and reasons, Review status and the current |
| 124 | candidate's Review summary, using slice 3's evidence selection. Link to |
| 125 | Changed files and Preview through their existing screens. |
| 126 | |
| 127 | Require a distinct final Merge tap through `TaskDetailModel` and its |
| 128 | existing server action. If the card revision/candidate moved, open the |
| 129 | updated task with the reviewed changed words, without preselecting its new |
| 130 | Merge decision. If facts cannot be read, show the read failure and no Merge |
| 131 | button. A change while the confirmation is open invalidates the intent; |
| 132 | the final server transaction still rechecks authority and current merge |
| 133 | eligibility. Notification payload facts never authorize a merge. |
| 134 | |
| 135 | ## Compatibility and copy |
| 136 | |
| 137 | Advertise `notification_actions_v1` through `GET /capabilities`. |
| 138 | Only after that signal does a new app include the version and registration |
| 139 | binding in `POST /push-registrations`; older servers use strict JSON |
| 140 | decoding, so sending new fields speculatively is unsafe. The new server |
| 141 | stores the opt-in per registration and sends actionable categories only |
| 142 | there. Missing capability, old registration, old payload, unknown version, |
| 143 | unknown 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 |
| 145 | unexpected new payload safely. Document all additive fields and request |
| 146 | bodies in OpenAPI and the API guide; no runner protocol change. |
| 147 | |
| 148 | No 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 | |
| 159 | Keep imported web strings byte-identical under parity. Reuse the existing |
| 160 | Merge confirmation, facts and error copy; send any unforeseen new words |
| 161 | to the controller before marking them reviewed. |
| 162 | |
| 163 | ## Verification |
| 164 | |
| 165 | Test 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 | |
| 188 | No local full gate. Before a narrow Go/Swift/build/simulator run, check load, |
| 189 | swap and other heavy jobs; wait above load 20 or with two other heavy jobs. |
| 190 | Use one job, at most four workers, and reuse/shut down the simulator. |
| 191 | Linux hub CI runs the full server gates, contracts and schema checks; |
| 192 | native-only checks follow the established Apple lane. Record mutations, |
| 193 | device limitations and screenshots in the slice 8 controller report. |
| 194 | |
| 195 | |