// TABLE TWO — a LOCAL reminder's tap, `{kind, id}` through `RecordRoute`.//// ported. Its own header says why it is not the push table://// > Cotton's notifications are local and carry the record itself (`{kind, id}`),// > so the routing is `recordPath`, the same pure table every in-app link goes// > through. Adopting the platform hook would mean inventing push "types" for// > records the app is already holding, and maintaining a second link table// > beside `recordPath` that could drift from it.//// **The two tables are not rivals and they must keep rejecting each other's// payloads.** They used to be two hooks on one native response; in Swift// there is ONE `UNUserNotificationCenterDelegate` callback, so they become two// parsers behind one entry point — and the mutual rejection is what makes that// merge safe. `NotificationRoutes.route` answers `nil` for anything without a// mapped string `type`; ``ReminderTaps/parse(_:)`` answers `nil` for anything// that is not exactly `{kind: <one of five>, id: <non-empty>}`. Neither can// claim the other's tap, so the ORDER they are tried in does not matter — and// `NotificationTapTests` proves that rather than assuming it.//// **The parse is suspicious on purpose.** A notification sitting in// Notification Centre can outlive the build that scheduled it, so anything not// exactly this shape resolves to `nil` and routes nowhere, rather than// navigating somewhere wrong.//// **The local reminders never touch the server, and that is the ratified rule**// (2026-08-11, unchanged by the 2026-08-14 return of push): everything Cotton// reminds about already lives on the device that would be reminded, so a round// trip through a database, a push worker and APNs would add three failure modes// to deliver a fact the phone already holds. The accepted trade, stated there:// nothing here survives an uninstall or reaches a second device.importFoundation/// The payload every Cotton reminder carries.////// Deliberately two fields: the tap handler resolves the path from the KIND, so/// a route move never strands a notification already sitting in Notification/// Centre.publicstructReminderPayload: Equatable, Sendable {publiclet kind: NotificationKindpubliclet id: Stringpublicinit(kind: NotificationKind, id: String) {self.kind = kindself.id = id }}/// The local-reminder tap table.publicenumReminderTaps {/// Read a tap's payload back — pure, and suspicious. See the header.publicstaticfunc parse(_ data: JSONValue) -> ReminderPayload? {guardcase .object = data,let kind = data["kind"]?.string,let known = NotificationKind(rawValue: kind),let id = data["id"]?.string, !id.isEmptyelse { returnnil }returnReminderPayload(kind: known, id: id) }/// Where a tap lands when it lands on a RECORD.////// TOTAL over the four kinds, with no `default`, so a kind added without an/// address does not compile. `birthday` opens the PERSON — a birthday is/// not a record of its own — and `alarm` is not a record either: it has no/// detail screen, only a tool, so it routes through ``toolRoute(for:)``.publicstaticfunc recordKind(for kind: NotificationKind) -> RecordKind? {switch kind {case .todo: return .todocase .event: return .eventcase .birthday: return .personcase .alarm: returnnil } }/// Where a tap lands when the kind has a TOOL but no record screen.////// Until 2026-08-14 an alarm tap deliberately routed nowhere — opening the/// app was the whole response, because guessing at a route that did not/// exist would have been worse. Both tools exist now, so the tap can say/// where it came from.////// **Never overlaps ``recordKind(for:)``**, and the test says so: a kind/// answering both would make the landing depend on the order two lookups/// happen to be written in.publicstaticfunc toolRoute(for kind: NotificationKind) -> Route? {switch kind {case .alarm: return .alarmscase .todo, .event, .birthday: returnnil } }/// Where this reminder's tap lands, or `nil` when the kind leads nowhere/// and opening the app is the whole response.publicstaticfunc route(for payload: ReminderPayload) -> Route? {iflet kind = recordKind(for: payload.kind) {return .record(kind, payload.id) }return toolRoute(for: payload.kind) }/// Where a tap on this payload lands, or `nil` when it is not ours.publicstaticfunc route(for data: JSONValue) -> Route? {guardlet payload = parse(data) else { returnnil }return route(for: payload) }}