# Notification actions, slice 8

Status: approved by the controller, including privacy and durable-receipt rulings.
Date: 2026-11-27. Branch: `notify/actions`, from `origin/main` at
`602b91fe`. This replaces D4's open-only rule for the actions below.
Landing is allowed; production deployment waits for the production upgrade.

## Flow and privacy

Use ordinary UserNotifications categories on iPhone and Mac, with the
existing app screens after unlock. No notification content or service
extension, new bundle ID or signing capability is needed.

Keep today's alert title and clipped question/task preview unchanged.
APNs gains versioned routing and binding data only: a notification ID,
registration binding ID, card kind/ID/revision, or task ID/revision and
failed step ID/revision/attempt. It carries no credentials, email address,
new question text, option text, checks logs, Review summary or preview URL.
The registration binding is a random non-secret identifier stored for the
current origin/person/device session and rotated on account changes.
It prevents a delayed notification being acted on using another account.
The client chooses the API origin from its authenticated session, never
from a payload URL. A binding is routing data, never authority.

**Privacy tradeoff for approval:** the mockup shows arbitrary question
options on the lock screen. Those are additional private, model-written
text that today's push does not send. This slice instead offers direct
text entry only for an optionless question whose complete question fits
today's preview. An option question, or a clipped question, opens the
bound question card after unlock, with every option visible. There is no
generic Yes/No mapping, numbered choice guessing or free-text answer to a
card that only accepts its listed options. Arbitrary option buttons in the
notification would require a separate privacy decision and dynamic
notification UI work.

## Categories and action titles

Register fixed versioned categories at launch, while keeping `needs_you`.
All response actions below use `.authenticationRequired` **and**
`.foreground`: unlock, then open the app to handle the response and show
any failure. Free-text entry is supplied by
`UNTextInputNotificationAction`; its submitted answer is handled without a
second Send tap. Foreground handling also makes a 409 reliably presentable,
rather than hoping a background handler can open the app later.

| Category | Actions | What the tap does |
| --- | --- | --- |
| `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. |
| `equipo.question.choices.v1` | Answer | Open the exact question after unlock; fetch and display its options, then the person's choice submits. |
| `equipo.stopped.v1` | Try again, Open the task | Retry the named failed attempt only, using the existing creator and termination rules. |
| `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. |
| `needs_you` and unsupported kinds | Existing default tap | Open the card/task without submitting anything. |

A dismiss gesture has no write semantics. Do not add Not now as a
notification button: it could be confused with dismissing the notification
rather than answering or setting aside a card. Access, placement, held,
direction, policy and other unfamiliar cards retain open-only handling.
Merge categories apply only to merge kinds the existing native helper
fully understands and offers; they cannot expose an otherwise hidden merge.

Apple documents [authenticationRequired](https://developer.apple.com/documentation/usernotifications/unnotificationactionoptions/authenticationrequired)
as requiring unlock before delivery, and
[foreground](https://developer.apple.com/documentation/usernotifications/unnotificationactionoptions/foreground)
as opening the app for further interaction. Fixed categories and text input
follow [actionable notification types](https://developer.apple.com/documentation/usernotifications/declaring-your-actionable-notification-types).
Keep at most two actions per category so the primary action is available in
the limited layouts too.

## Server binding and retries

The push is captured in the same transaction as the card/task change.
Keep the sealed outbox, current-device checks, deduplication and 4 KiB
payload bound. Unknown, incomplete or oversize action metadata falls back
to today's open-only payload; it must not lose the underlying alert.

Two existing API limitations need additive changes:
`AnswerCard` checks revision but a repeated successful answer currently
returns a conflict, and `RetryTask` currently reads no request body or
revision. Add a notification-capable contract to these existing routes:

- `POST /cards/{id}/answer`: retain exact `revision` and `choice`; accept
  an optional idempotency key. Question option choices remain model text
  with the existing generated-origin attribution.
- `POST /tasks/{id}/retry`: accept an optional bound request with task
  revision, step ID/revision/attempt and idempotency key. Every supplied
  binding must match inside the write transaction before calling the same
  retry helper. Missing or partial bindings from the new notification
  dispatcher refuse the action; it never falls back to unbound retry.
  Existing callers without a body retain their current API behavior.

A durable, indexed operation receipt records the key, request digest and
result identifiers/attempt atomically with the action. Scope it to the
authenticated person/device, route and target; identical retries return
the original result, a changed body with the same key is
`api.idempotency_conflict`. Recheck the active member/device before any
receipt read. Store no duplicate answer text in receipts or audit logs.
Retain receipts for seven days, prune in bounded batches; after pruning,
the original card revision or step attempt still prevents repeating the
effect. Add an additive migration and schema snapshot.

Native persists the original key and exact request before POST in a
bounded, protected pending-action journal, bound to origin, person and
session generation. Credentials remain in the keychain. Duplicate delegate
delivery and relaunch reuse that request; no automatic new key or rebinding
to the latest revision. Clear completed/definitely refused entries and
clear all entries on sign-out/account switch; expire pending sends after
24 hours without replay. A new notification cannot be replaced by an
earlier uncertain send. No background retry timer sends without the
person's requested retry.

All writes reuse current roster, ownership, visibility and task/card rules
inside their transaction, with the real authenticated actor and existing
audit semantics. A stale answer shows `api.card_stale` or
`api.card_answered`; a changed retry binding shows `api.not_retryable`.
On 409, open/refetch the relevant card or task and show those reviewed
words. Never apply the old response to its replacement. Other errors use
the existing offline, read/write failure and API copy mappings.

## Merge facts and confirmation

The notification's Merge action is navigation to a confirmation, not merge
authorization. After unlock, fetch task detail and the bound card. Show
candidate/branch, Checks status and reasons, Review status and the current
candidate's Review summary, using slice 3's evidence selection. Link to
Changed files and Preview through their existing screens.

Require a distinct final Merge tap through `TaskDetailModel` and its
existing server action. If the card revision/candidate moved, open the
updated task with the reviewed changed words, without preselecting its new
Merge decision. If facts cannot be read, show the read failure and no Merge
button. A change while the confirmation is open invalidates the intent;
the final server transaction still rechecks authority and current merge
eligibility. Notification payload facts never authorize a merge.

## Compatibility and copy

Advertise `notification_actions_v1` through `GET /capabilities`.
Only after that signal does a new app include the version and registration
binding in `POST /push-registrations`; older servers use strict JSON
decoding, so sending new fields speculatively is unsafe. The new server
stores the opt-in per registration and sends actionable categories only
there. Missing capability, old registration, old payload, unknown version,
unknown action or malformed binding means open-only. Preserve existing
`kind/card_id/task_id/turn_id` fields so older apps can still route an
unexpected new payload safely. Document all additive fields and request
bodies in OpenAPI and the API guide; no runner protocol change.

No new product copy proposed:

| Use | Existing key | Exact words |
| --- | --- | --- |
| Question action | `chat.card.answer` | Answer |
| Text input submit | `composer.send` (native reviewed) | Send |
| Text input placeholder | `conversation.placeholder` (native reviewed) | Message |
| Retry action | `work.pause.try_again` | Try again |
| Merge action | `chat.card.merge` | Merge |
| Task navigation | `task.open` (native reviewed) | Open the task |

Keep imported web strings byte-identical under parity. Reuse the existing
Merge confirmation, facts and error copy; send any unforeseen new words
to the controller before marking them reviewed.

## Verification

Test first, then break each guard and record the failing test:

- Go/contracts: private-text-free, bounded payloads; category eligibility;
  registration opt-in and binding; strict old-client compatibility;
  snapshot revisions; question ownership/options; stale revisions and
  step attempts; creator/termination and current membership/device checks;
  concurrent identical retries, lost reply, changed-body key reuse and
  replay after receipt expiry. Confirm one answer/attempt/audit effect.
- Native/fake server: category flags and identifiers; direct free-text and
  option-card routing; no partial/unknown payload writes; same key/body
  after relaunch; account switch/sign-out; 409 opens refreshed card with
  exact words; offline failure; Merge shows current-candidate evidence and
  cannot POST before the separate confirmation or after invalidation.
- Simulator, narrowly: delivered fixture payloads, text entry, cold launch,
  option-card routing, Merge facts/confirmation, Dynamic Type and VoiceOver
  labels. Mac notification action delivery and navigation too.
- **Physical device required:** real APNs on a locked iPhone; hidden
  previews; Face ID/passcode success and cancellation; submit before/after
  unlock; terminated-app delivery; background/offline/lost reply; system
  notification grouping and any mirrored Watch action. Simulator evidence
  cannot prove the unlock guarantee. These checks precede enabling the
  server capability in production.

No local full gate. Before a narrow Go/Swift/build/simulator run, check load,
swap and other heavy jobs; wait above load 20 or with two other heavy jobs.
Use one job, at most four workers, and reuse/shut down the simulator.
Linux hub CI runs the full server gates, contracts and schema checks;
native-only checks follow the established Apple lane. Record mutations,
device limitations and screenshots in the slice 8 controller report.

