feat: visitor details per ticket (dynamic form answers) #173

Merged
amiryahaya merged 19 commits from feat/visitor-details into main 2026-11-07 15:50:06 +01:00
Owner

Visitor details per ticket, first of three pieces (then the gate review/confirm lookup and the gate app's sunlight redesign). Spec docs/superpowers/specs/2026-11-07-visitor-details-design.md, ADR 0038.

Every park-entry ticket sold on the website, the customer app and the tour operator portal now carries its own visitor: the answers to its product's dynamic form (name, ID/passport, nationality, email, plate). holder_name is the visitor's name, not the buyer's. This is what gate staff and rangers need to catch "declared one thing, someone else arrived".

What changed

  • Migration 0042 ticket_visitors: one row per sale line unit, with answers jsonb plus purpose columns. UPDATE and TRUNCATE are refused, and so is an INSERT unless the sale is pending. tickets.visitor_id is immutable and has no FK, so answers can be purged while the tickets stay.
  • Checkout visitors: [{cart_line_id, unit, answers}] is validated by sales.Visitors against the live form: required, length, range, type, active country, at most 200 runes, no control or format characters.
    • Field errors are named lines[L].visitors[U][.<input id>].
    • The limits are 2000 visitors and a 1 MiB body.
    • It is strict from day one, since the system is not live yet.
  • Itinerary sales copy each traveller's partner_customers name, ID number, country and email.
  • Completion links the tickets by (line, unit). A top-up replacement keeps the old visitor_id.
  • Retention job sales.visitors_purge (hourly, worker) deletes answers of cancelled sales after 24 h and of completed sales 7 years after checkout. The 7 years is marked [verify] with KWS legal / the DPO. The job runs two indexed deletes over a 30-day window.
  • Cart lines carry form_id (live forms only). The website and the Flutter app gain a Visitors step: one block per ticket, the first prefilled from the profile. The server is the only judge of the answers, and the idempotency key changes with the answers.
  • No route returns answers yet. They never go into logs, audit, URLs, job payloads or PDFs.

Checks

  • Coverage: make cover total 91.8% (minimum 80%); internal/sales 86.5%, internal/sales/pgstore 80.5%.
  • API: make lint reports 0 issues; contract tests pass.
  • Website: vitest 376 passed, Playwright e2e 313 passed (the journey fills the visitor details).
  • Mobile: flutter analyze is clean, and flutter test passes 284 tests.
  • Review: dual-pass review done (ponytail, then superpowers whole-branch). All Must-fix and Important findings are fixed.

Owner check

  • The 7-year retention.
  • A top-up shares the old ticket's visitor (an input the new form needs stays empty for the gate to fill).
  • An inactive form means no answers are required.
  • No ID numbers on PDFs.

Known gaps, parked

  • On mobile: errors do not clear on edit, there is no scroll-to-error, and date inputs are text.
  • A worker down for more than 30 days leaves older rows unpurged.

🤖 Generated with Claude Code

Visitor details per ticket, first of three pieces (then the gate review/confirm lookup and the gate app's sunlight redesign). Spec `docs/superpowers/specs/2026-11-07-visitor-details-design.md`, ADR 0038. Every park-entry ticket sold on the website, the customer app and the tour operator portal now carries its own visitor: the answers to its product's dynamic form (name, ID/passport, nationality, email, plate). `holder_name` is the visitor's name, not the buyer's. This is what gate staff and rangers need to catch "declared one thing, someone else arrived". ## What changed - **Migration 0042 `ticket_visitors`:** one row per sale line unit, with answers jsonb plus purpose columns. UPDATE and TRUNCATE are refused, and so is an INSERT unless the sale is pending. `tickets.visitor_id` is immutable and has no FK, so answers can be purged while the tickets stay. - **Checkout `visitors: [{cart_line_id, unit, answers}]`** is validated by `sales.Visitors` against the live form: required, length, range, type, active country, at most 200 runes, no control or format characters. - Field errors are named `lines[L].visitors[U][.<input id>]`. - The limits are 2000 visitors and a 1 MiB body. - It is strict from day one, since the system is not live yet. - **Itinerary sales** copy each traveller's `partner_customers` name, ID number, country and email. - **Completion** links the tickets by (line, unit). A top-up replacement keeps the old `visitor_id`. - **Retention job `sales.visitors_purge`** (hourly, worker) deletes answers of cancelled sales after 24 h and of completed sales 7 years after checkout. The 7 years is marked **[verify]** with KWS legal / the DPO. The job runs two indexed deletes over a 30-day window. - **Cart lines carry `form_id`** (live forms only). The website and the Flutter app gain a Visitors step: one block per ticket, the first prefilled from the profile. The server is the only judge of the answers, and the idempotency key changes with the answers. - **No route returns answers yet.** They never go into logs, audit, URLs, job payloads or PDFs. ## Checks - **Coverage:** `make cover` total **91.8%** (minimum 80%); `internal/sales` 86.5%, `internal/sales/pgstore` 80.5%. - **API:** `make lint` reports 0 issues; contract tests pass. - **Website:** vitest 376 passed, Playwright e2e 313 passed (the journey fills the visitor details). - **Mobile:** `flutter analyze` is clean, and `flutter test` passes 284 tests. - **Review:** dual-pass review done (ponytail, then superpowers whole-branch). All Must-fix and Important findings are fixed. ## Owner check - The 7-year retention. - A top-up shares the old ticket's visitor (an input the new form needs stays empty for the gate to fill). - An inactive form means no answers are required. - No ID numbers on PDFs. ## Known gaps, parked - On mobile: errors do not clear on edit, there is no scroll-to-error, and date inputs are text. - A worker down for more than 30 days leaves older rows unpurged. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A block per ticket for cart lines with a visitor form, prefilled from the
profile, sent as visitors; the server's answer errors show under their field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fix: visitor form keeps its state on rebuild; one live-form query; drop unused index
All checks were successful
clients / clients (pull_request) Successful in 1m49s
mobile-pos / mobile-pos (pull_request) Successful in 8m17s
web-partner / web-partner (pull_request) Successful in 2m59s
web-ticket / web-ticket (pull_request) Successful in 4m53s
web-admin / web-admin (pull_request) Successful in 9m34s
mobile-ticket / mobile-ticket (pull_request) Successful in 20m12s
api / api (pull_request) Successful in 32m31s
e0db93f179
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
primatekuntech/kws!173
No description provided.