Files
parking_solution/wiki/decisions/forgiven-exit.md
T
julian 82e5833e4e
Build & push images / images (push) Successful in 3m13s
feat(exit): manual-exit dialog + wording — styled modal replaces window.prompt; copy says 'manual exit' / 'dalje manuale'
- BoothScreen: the no-ticket open uses the app's Modal (explainer, optional reason,
  red confirm; Enter confirms, Escape/Cancel abort) instead of a browser prompt.
- en/sq: forgive/forgiven/forgone wording dropped from every user-facing string
  (buttons, dialog, results, live-feed reasons, shift figures); Albanian edited by the
  user, English aligned. Printed Z line is 'Dalje manuale (N)'. The signed English
  fallback sentences follow. Identifiers (exit.forgiven, forgoneMinor, barrier:create)
  unchanged.
- wiki: forgiven-exit §Wording, shift, log.
2026-10-09 08:37:44 +02:00

110 lines
7.2 KiB
Markdown

---
type: decision
tags: [parking, decisions, exit, barrier, threat-model, shift, z-report, permissions]
sources: []
updated: 2026-10-08
status: built 2026-10-08
---
# Forgiven exit — the owner opens the EXIT barrier with no payment
> **Built 2026-10-08** (same day as decided). As-built notes at the end of this page; the
> decisions below are what shipped.
**The ask (user, 2026-10-08).** The owner/admin sometimes needs to let a car out regardless:
a transient that took a ticket but will not be charged, or a car with no session at all (it
came in while the barriers were up). The open must produce **no money** and must be **flagged**
in the live feed. First floated for both directions; **narrowed the same day to the EXIT
barrier only** — the entry keeps its existing paths ([[operator-issued-entry]] when the button
is broken, barriers physically up otherwise).
## Why it is safe to give the operator this at all
This is the exact move the [[threat-model]] worries about (pocket the fee, "lose" the ticket,
let the car out). As with [[operator-issued-entry]], the defence is not to withhold the
capability but to make every use **signed, attributed, photographed and impossible to hide**:
it lands on a named operator's shift, with the fee it forgave, where the owner reads it.
## Decisions
1. **Exit only.** Reuses the human-intervention re-open path in `exit-flow.ts`
(`reopenBarrier`: anomaly signed FIRST, then the human-intervention `vehicle_exit`, exit
snapshot, `pulseOpen`). Today that path refuses an unpaid or grace-expired transient; the
feature is a **second authorization branch** on it, behind a dedicated permission.
2. **Accounting: a signed ZERO-amount payment that carries the forgone fee.** The Z-report
([[shift]]) sums `amountMinor` by tender, so a zero payment adds nothing to cash, card or the
drawer — the shift total is untouched by construction. The fee the car owed is recorded in
its **own field** (`forgoneMinor`, with a reason code), reported as its **own line**
("forgone exits: N, amount X"), and is NOT the merchant-validation `discountMinor` — the
owner must be able to tell "the bar validated it" from "the operator let it out".
Signing the payment also **closes the ticket**, so it cannot be reused ([[plate-reconciliation]]
ticket-swap).
3. **No session (car has no ticket, e.g. came in with the barriers up):** signed anomaly with
the exit snapshot and the plate read, then the pulse. Nothing to forgive, nothing to close.
4. **Permission:** a new one, **admin only by default**; the owner decides whether operators get
it. Requires an **open shift** (same `requireShift` as the pay routes) so every use is on
someone's report.
5. **Reason text is OPTIONAL** (user, 2026-10-09 — reversed from "mandatory" the day before:
"We don't need to force the user to write a reason"). The accountability is the
signature, the operator name, the snapshot and the Z-report line; an empty note is signed
as "(no reason given)" so the English sentence stays readable.
6. **Print nothing.** No receipt, no slip — there is no payment to receipt (user, 2026-10-08).
7. **Visibility:** warn-level log line, anomaly in the live feed with the snapshot, the Z-report
line. **No cap, no blocking** — blocking the owner at the gate recreates the "lot stuck"
problem; the defence is reporting.
8. **Safety unchanged:** `pulseOpen` only, never a timed close ([[fail-state-safety]]).
## Not decided / out of scope
- Entry-side free open: **rejected** for now (the entry has its own paths).
- Whether a forgiven exit should also void an attached car-wash charge line: open; today the
zero payment would carry no charge lines at all.
## Build sketch (when asked)
`exit-flow.reopenBarrier(identity, operator, { forgive: { reason } })` → quote the fee as the
pay flow would (PayStation quote), sign `payment { amountMinor: 0, forgoneMinor, reason }`,
then the existing re-open body. Route `POST /api/barrier/forgive` with the new permission +
`requireShift`. Z-report: `forgoneTotalMinor` + `forgoneCount` (old reports → 0), one print
line. Web: a guarded button in the pay/exit modal, reason field optional. Reason codes:
`exit.forgiven`, `exit.forgiven.noSession`. Tests on the no-money invariant (cash/card/drawer
unchanged) and on the ticket being closed.
## As built (2026-10-08)
- **Permission `barrier:create`** (new resource `barrier` in the code-defined grid,
`packages/shared`). Admin has it by the all-permissions invariant; the owner grants it to any
role from Setup → Roles — "the owner can give permission to other operators" (user).
- **`PayStation.forgive(identity, { operator, note })`** — quotes the fee as the pay flow
would, signs `payment { amountMinor: 0, forgoneMinor: <quote>, operator, reasonCode:
"exit.forgiven", reason: "manual exit by X — fee of N CUR, no payment: <note>" }` with **no
tender** (nothing was tendered), marks the projection paid. Refuses (409) when the quote
carries module charge lines (a wash on the ticket): parking is forgiven, a wash is not.
- **`ExitFlow.reopenBarrier(id, operator, { forgiven })`** — the existing human-intervention
re-open with the walk-back check bypassed for a forgiven call (a 0-minute grace tariff must
not refuse it); the anomaly and the `vehicle_exit` carry `exit.forgiven` + `forgiven: true`
+ `forgoneMinor`. **`ExitFlow.forgiveExitNoSession(operator, note)`** — anomaly under a fresh
`forgiven:<uuid>` identity (so its exit snapshot shows in the feed) + pulse; no payment, no
exit event. Relay driving shared in `#pulseExit` (signed first; a failed pulse is
`ok:true, opened:false` + "open by hand").
- **Route `POST /api/barrier/forgive { identity?, note? }`** — `barrier:create` + the open-shift
gate (`409 no_shift`); the note is optional; no identity = the no-session path.
- **Z-report**: `forgoneTotalMinor` + `forgoneCount` summed from `forgoneMinor` (never into
cash/card; `discountTotalMinor` untouched), on the signed `shift_z_report` only when > 0, one
print line `Dalje manuale (N): X`, shown in the X-report, the close confirm and history.
- **Web**: in the pay/exit modal a red ghost "Forgive & open" for an OPEN transient that owes
money (unpaid or overstay) → reason box → "Confirm — open exit, no payment"; on the booth
header a "Forgive & open exit" next to the exit lane light for the no-ticket case
(a small styled dialog, same chrome as every other form — optional reason, red confirm). Both only render with
`barrier:create` + own open shift.
Live-feed reason texts in en/sq. **Nothing is printed.**
- Tests: exit-flow (ticketed + no-session), pay-station (`forgive`), shift-service (totals
untouched, own line, history), routes (403 without the permission, 409 no shift, 400 no
note accepted, ledger sequence entry→payment→anomaly→exit, report figures).
**Wording (user, 2026-10-09).** The user-facing words are **"manual exit" / "dalje manuale"**,
not forgive/forgiven/forgone — too much "fal, falur, falje" (user). Applies to both language
files, the printed Z-report line (`Dalje manuale (N)`) and the signed English fallback
sentences. Internal names stay (`exit.forgiven`, `forgoneMinor`, `barrier:create`) — they
are code identifiers, not copy.