feat(booth): cancel wrongly-printed ticket (signed void) + refused-vs-anomaly display; fix CI uv
CI / check (push) Failing after 56s

Cancel a misprinted/test/wrong-vehicle ticket via a SIGNED `void` event — the
vehicle_entry is never edited/deleted (append-only). VoidFlow appends void{
voidedEntryRef, voidReason, operator, reasonCode:"void.ticketCancelled" }; route
POST /api/tickets/void gated event:void + open shift; reason REQUIRED. Refuses a
subscription / already-exited / already-voided / paid ticket (refund out of scope).
The void folds the session CLOSED everywhere it's counted — occupancy (count +
reserved spots), pay-station (lookup/activeSessions), exit-flow (#sessionFor), and
reports (excluded from entries) — so a voided car stops occupying a spot, can't be
paid/exited, and doesn't inflate "cars entered". No barrier action. Booth UI: a
"Cancel ticket" action in the pay/exit lookup modal (transient + unpaid + open;
gated on event:void) with a preset-or-free reason prompt.

Reclassify the Live feed: refused-action events (exitRefused/entryRefused/
permitRefused — e.g. a double card-scan, at-capacity subscriber, exit on a closed
session) are benign warnings, not red anomalies. event-detail.tsx now shows them as
amber REFUZUAR/REFUSED, reserving red ANOMALI for genuine red-flags. Display-only —
no ledger change, so historical events reclassify too.

CI: install uv + sync vision deps before the Turbo run. @parking/vision's lint/
typecheck/test shell to `uv run …`, but CI set up only Node+pnpm, so `uv run ruff`
failed ("uv not found") and broke the whole Turbo run. The Python checks pass once
uv provisions the toolchain.

- new: void-flow.ts (+ tests, 8) ; occupancy void-fold test
- shared: reason code void.ticketCancelled ; both web catalogs (sq/en parity)
- wiki: parking-session (ticket-void folds + guards, refused/anomaly split), log

Claude-Session: https://claude.ai/code/session_01Xcm6ikLgGoCxxHrxtjkk5V
This commit is contained in:
2026-06-22 20:13:21 +02:00
parent 65328b8c11
commit 8a437d0c4b
19 changed files with 534 additions and 35 deletions
+28
View File
@@ -73,6 +73,34 @@ States, as derived from events:
Permit sessions skip PAID: a valid [[subscription]] at exit is itself the authorization to close.
### Cancel a wrongly-printed ticket — BUILT (2026-06-22)
A ticket printed in error (misprint, test press, wrong vehicle) is cancelled by appending a **signed
`void`** event — the `vehicle_entry` is NEVER edited or deleted (append-only; [[append-only-event-chain]]).
`apps/server/src/void-flow.ts` (`VoidFlow`) appends `{ type:"void", identity, payload:{ sessionRef,
voidedEntryRef:<entry id>, voidReason, operator, reasonCode:"void.ticketCancelled" } }`. Traceable: the
operator (from the JWT) + a **REQUIRED reason** are signed in. Route `POST /api/tickets/void` gated on
`event:void` + an open shift. **No barrier action** — a misprinted ticket's car never entered.
- **Refused** for: a subscription occurrence (closed via its own flow), an already-exited session, an
already-voided ticket, or a **paid** ticket (a refund is a separate, out-of-scope action) → 409.
- **The void folds the session CLOSED everywhere it's counted** — this is the correctness crux. A
`void` decrements like a `vehicle_exit` in `occupancy.ts` (count + reserved-spots), and reads as
closed in `pay-station.ts` (`lookup`/`activeSessions`) and `exit-flow.ts` (`#sessionFor`), and is
excluded from the `reports.ts` entries stat. So a voided car stops occupying a spot, can't be
paid/exited, and doesn't inflate "cars entered". The booth surfaces it in the pay/exit lookup modal
(transient + unpaid + open only).
### Live-feed display: refused-action WARNING vs. genuine ANOMALY
The signed ledger `type:"anomaly"` is overloaded: it carries both benign **refused-action** events
(`exitRefused` / `entryRefused` / `permitRefused` — e.g. a double card-scan, an at-capacity
subscriber, an exit on an already-closed session) AND genuine red-flags (barrier-open failure,
opened-without-ticket). The booth feed now classifies from those existing payload flags
(`event-detail.tsx isRefusedWarning`) and shows the refused ones as an amber **REFUZUAR / REFUSED**
warning, reserving red **ANOMALI** for true anomalies. **Display-only** — no ledger type/data change,
so historical events reclassify correctly too.
## Edge cases the model must name (not yet designed in full)
- **Overstay after payment** — exited the grace window; needs a top-up payment. The one genuinely
+17
View File
@@ -1446,3 +1446,20 @@ read flows are constructed before the hik-alarm registration. New env: `VISION_E
`ANPR_DEBOUNCE_MS`. Tests: `anpr-entry.test.ts` (7) + `hikvision-alarm.test.ts` wiring (3); full
server suite 130 green, monorepo build+lint green. Flipped [[lane-presence-and-anpr-entry]] §2 +
table row PLANNED->BUILT; updated [[lpr-camera]]. STILL OPEN: booth-PC ANPR latency (~2026-06-23).
## [2026-06-22] build | Cancel (void) a wrongly-printed ticket + refused-vs-anomaly display split
Operator need: cancel a misprinted/test/wrong-vehicle ticket, traceably. Built it as a SIGNED `void`
(append-only — the vehicle_entry is never touched): new `apps/server/src/void-flow.ts` (`VoidFlow`)
appends void{ voidedEntryRef, voidReason, operator, reasonCode:"void.ticketCancelled" }; route
POST /api/tickets/void gated event:void + open shift; operator from JWT, reason REQUIRED. Refuses a
subscription / already-exited / already-voided / PAID ticket (refund = out of scope). The CRUX: a
void must fold the session CLOSED everywhere it's counted — done in occupancy.ts (count +
reserved-spots, −1 like an exit), pay-station.ts (lookup/activeSessions), exit-flow.ts (#sessionFor),
and reports.ts (excluded from the entries stat). No barrier action (the car never entered). Booth UI:
"Cancel ticket" in the pay/exit lookup modal (transient + unpaid + open; gated on event:void) with a
preset-or-free reason prompt. Part 2 (display-only): the Live feed mislabeled benign refused-action
events (exitRefused/entryRefused/permitRefused — e.g. a double card-scan) as red ANOMALI; now
classified via event-detail.tsx isRefusedWarning and shown as amber REFUZUAR/REFUSED, reserving red
ANOMALI for genuine red-flags. No ledger change → historical events reclassify too. New reason code
void.ticketCancelled (shared + both web catalogs). Tests: void-flow.test.ts (8) + occupancy void fold;
141 server + 87 shared green; build+lint (TS + i18n parity) green. Updated [[parking-session]].