Derive every fact about a trip in the shared Rust core and keep only presentation in the clients
Decision
Derive every fact about a trip in the shared Rust core, and have clients read it from there. The device calls it through UniFFI. The server exposes it through GraphQL or MCP once a client other than the device needs it. A fact is a pure function of the trip's content and explicit inputs whose answer does not change when a screen is redesigned: date spans, night counts, the day an item belongs to, chronological order, what a booking is attached to, what conflicts and what is still missing. A client owns presentation: wording, localisation, formatting, layout, emphasis, and view state. Grouping, sorting or filtering chosen for one screen is view state unless an agent must reproduce the result. Emphasis is presentation mapped from a fact, such as whether a stay is booked.
Core never reads the clock, the device time zone or the locale. A caller passes today's date. Trip days are naive calendar dates with no zone, and timing comes back as data (upcoming, active, a date) for the client to word as "in 3 days".
Core may compose facts into a record shaped for one screen, but no record in core carries user-facing text.
Core itemizes missing detail as it itemizes conflicts (ADR-0056): a night with no stay, a leg with no booking, an activity with no day. Each item states its kind, conflict or gap, and carries no severity. A gap is normal while planning, so a client lists it plainly and never warns. A gap has a content-derived id, so the user can set one aside, as an overnight train stands in for a hotel.
Extensions on core types in a client format facts and never derive them. Client services hold no domain derivation.
Why
Core already runs on the device (ADR-0073), so working offline is never a reason to derive in a client. A fact computed in a view can never reach the assistant, which then cannot tell the user what their own screen shows; a fact in core is one the server can expose the day the assistant needs it. Copies drift: the app showed a destination's nights while the prompt that judges the itinerary was handed its inclusive day count as nights, one more. Core tests run against trip fixtures in milliseconds, without an app build.
Rejected alternatives
- Swift extensions on the core types. One copy, but agents and the server cannot read it, and it is tested only through an app build.
- Derive on the server and expose GraphQL fields only. The app renders from local replay, so it would lose the fact offline.
- A view-model layer separate from core. The same second copy under another name. Screen-shaped records inside core cover the need.
- Move presentation into core as well. Platform formatters own localisation, and every copy change would regenerate the bindings.
Consequences
Each fact becomes public API on the bindings, so removing one breaks older apps that replay offline. A fact the server exposes is public API there too. A discrepancy carries no prose and no severity, only its kind and the entities involved, so each client words it. A web client inherits every fact once the server exposes it.