# Tasks
Design: `design.md` (technical contracts) and `docs/superpowers/specs/2026-12-04-event-ticketing-design.md` (product).
**Mode:** all tasks run serially in the main session (the owner asked for no worker subagents). Each task starts with failing tests (TDD).
## 1. Data
- [x] 1.1 Write the SQL:
- `sql/01-ticket-attendees.sql`: the three `ticket` columns, the two keys, and codes for active tickets on Paid orders that have none;
- `sql/99-rollback.sql`.
Mirror 01 in `local/seed/03-colite.sql` and apply it to the local database.
- Depends on: none
- Scope: `local/seed/**`, `openspec/changes/add-event-tickets/sql/**`
- Verify: `SHOW CREATE TABLE ticket` shows the columns and keys; local Paid tickets have 22-character codes.
## 2. services-counter
- [x] 2.1 Ticket codes, ticket state and the ticket lookups.
- Depends on: 1.1
- Tests first:
- **Codes:**
- a free order's tickets get codes at creation;
- mark paid (from Awaiting payment and from Expired) gives each active ticket a distinct 22-character code;
- an Awaiting-payment order has none.
- **`TicketState.of`:** valid, checked in, awaiting, order cancelled, order expired and ticket cancelled.
- **`ticket/byCode`:**
- returns the event, type, attendee first name, state and check-in time;
- never returns mobile, email or buyer details;
- an unknown code is 404 `TICKET_NOT_FOUND`.
- **`byToken`:** lists tickets (id, type, attendee name, code, state) only when Paid, without contacts.
- Scope: `solvway-services-counter/src/**`
- Verify: `mvn -T 1C -q -pl solvway-services-counter verify`
- [x] 2.2 Naming attendees, consent and ticket emails.
- Depends on: 2.1
- Tests first:
- **Naming:**
- refused without `permission`, when the order is not Paid, when the ticket is cancelled, and when it is checked in (`ALREADY_CHECKED_IN`);
- an unknown token or a ticket of another order is 404;
- a save sets a new code and `attendee_named_at`, and clears consent and the lead link.
- **Consent:**
- refused on an invalid or unnamed ticket;
- calls registration with source `TICKET`, the notice and no salesperson, and stores consent time, notice id and lead uuid.
- **Mailer:**
- PAID lists every active ticket with its QR `` URL, its link and the "Name your attendees" link;
- TICKET goes to the attendee's email;
- naming with only a mobile sends nothing.
- **Resend ticket:** goes to the attendee's email, else the buyer; refused for an invalid ticket.
- Scope: `solvway-services-counter/src/**`
- Verify: `mvn -T 1C -q -pl solvway-services-counter verify`
- [x] 2.3 Door check-in, self check-in rules and the counts.
- Depends on: 2.2
- Tests first:
- **Staff check-in:**
- records the time and user;
- a second check-in gives `ALREADY_CHECKED_IN|