New decision page booth-users-and-permissions: identity has its home in the platform and the booth is in constant two-way sync, local login from the copy, product keys auth and parking, 37 proposed keys with all 44 of today's permissions mapped, two jobs, the rules, key-pair signing, what the platform needs, and what is left to the sync design. Hub page event-driven-refactor: the decisions of 2026-11-23 on users and permissions, validation and car wash out of the booth (postponed), and the language (TypeScript with Docker; Rust abandoned). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RZgP5oZdzvo92Eouc9eRv5
18 KiB
type, tags, sources, updated, status
| type | tags | sources | updated | status | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| decision |
|
2026-11-23 | open |
Event-driven refactor of the repository
Decided by the user on 2026-11-23: this repository is to be refactored as a whole, following an
event-driven pattern. The user's guidelines document arrived the same day:
EDA/wiki/guideline-joining-the-platform.md (the platform wiki, not this vault). The user's
instructions on what to do with it have not been given. Nothing is designed or built. This
page holds what is decided, what is not, what the decisions touch in the code as it stands, and
how the guideline reads against this repository.
How it came up: the discussion on bringing the ideas of the zone-anpr-poc into the product (passage-confirmation), and the H.264 decoding test of the same day.
Decided (user, 2026-11-23)
- The repository is refactored as a whole, event-driven. The shape comes from the user's guidelines.
- A bus connects the vision side, the server and the booth screen. Its details settle with the guidelines.
- The server holds no video or image work. Using MJPEG locked the system to cameras that offer it; another vendor's stream has to be decoded into a usable form, and the server is not the place for that. The vision side talks to the cameras, decodes whatever they send, and produces what the rest needs.
- The server is agnostic about the camera side. A signal from a camera is one way in among several. If it comes, good. If it does not, an RF card, a barcode or a push-button ticket does the job. The user's examples: a car with no plate at all; a leaf, a piece of cardboard or a plastic bag in front of the lens; a camera that dies. The server does nothing special in any of them. Where a missing camera or radar signal blocks a ticket, the admin bypass unblocks it (entry-presence-bypass). The monitoring already in place shows that a service or a device is down (device-status-monitoring), and the operator raises the issue.
- Services that die together are an accepted concession, and a watchdog service takes care of crashed services. Not designed.
- Plate reading from H.264 frames is work to be done, and does not hold up this direction. The morning's records neither blame nor clear H.264 (zone-anpr-poc, "Staff traffic").
- Watching the live picture from outside the booth's network is out of scope for now.
Not decided
- Whether the parking system joins the platform as a leaf under the guideline. The guideline
names the bus for any service that joins: NATS JetStream, on a site through the leaf stack of
the nats repo. It also lists "Parking as the first leaf product" under its own "Not decided"
(
EDA/wiki/queries/q-parking-core-service-on-the-platform.md, deferred by the user on 2026-10-20). See "The guideline against this repository" below. - The events: their names, their contents, who publishes and who consumes.
- How the booth screen gets the live picture, and how the vision side gets the camera logins. Both were left to this refactor.
- The watchdog.
- The order of the work, and what happens to the features that are built.
What the decisions touch in today's code
| Today | Where |
|---|---|
| The server holds the live view: an RTSP client that takes MJPEG only, and a hub that serves the booth tiles | apps/server/src/camera-live.ts, packages/devices/src/drivers/rtsp-mjpeg.ts, packages/devices/src/drivers/rfc2435.ts (camera-live-view) |
| The server pulls stills from the cameras, re-encodes them and reads their size | apps/server/src/snapshot.ts, packages/devices/src/drivers/camera.ts |
| The plate bridge: on a camera's push the server pulls a still and posts it to the vision service | apps/server/src/anpr-entry.ts, apps/server/src/vision-client.ts, apps/server/src/routes/hikvision-alarm.ts (lane-presence-and-anpr-entry) |
| The vision service is stateless: it is handed pictures and never talks to a camera | apps/vision/ (vision-service, vision-service-packaging) |
| The server cuts and blurs the car-wash review picture | apps/server/src/modules/carwash/review-outbox.ts (vision-review-outbox) |
| The server stores and serves the evidence pictures of ledger events | apps/server/src/routes/snapshots.ts |
Monitoring: the server probes each camera for reachability and the vision service's /health, and shows both in the booth footer |
apps/server/src/device-monitor.ts (device-status-monitoring) |
The zone flow, the relay rules and the plate consensus exist only in the prototype
(poc/zone-anpr/), with their checks and recorded visits (vision-hardening, "What carries
over").
Where the decisions meet what is built
- The camera gates the entry button today. Settled (user, 2026-11-23): it stays, and the
bypass is the answer. With an entry camera configured, a press on the button prints a
ticket only while that camera reports a vehicle (
apps/server/src/entry-flow.ts, entry-double-press), and the operator-issued entry needs the radar and the camera (operator-issued-entry). A camera that is dead or blinded stops the button ticket until an admin sets the bypass (entry-presence-bypass). The user: that unblocking mechanism for camera and radar events is in place.- The signal behind that gate is the camera's own vehicle detection, pushed to the server
(
apps/server/src/routes/hikvision-alarm.ts), not the vision service.
- The signal behind that gate is the camera's own vehicle detection, pushed to the server
(
- A blinded camera shows as healthy. Settled (user, 2026-11-23): not the system's concern. The monitoring probes whether a camera answers, not whether it sees. A camera that is healthy but blinded is an operational matter of the business.
- A broker was skipped on purpose in 2026-06 (open) (dingtian-vs-mqtt): new infrastructure on a single-purpose appliance, and one more thing on the path that opens the barrier. That page named its own condition for looking again, several subsystems sharing events, and it is now met. Its objections still want an answer in the plan.
- Evidence pictures (open). A snapshot is written before the barrier pulse and attached to the signed entry (standing-decisions, "Bounded request cost"; append-only-event-chain). Who takes it and who keeps it once the server holds no image work is open.
- vision-service, decision 3, has the Node backend call the vision service over localhost HTTP with pictures the camera driver pulled. The refactor replaces that.
- The repository's
CLAUDE.mdstill describes the server as the home of the device drivers. Left as it is until the guidelines arrive.
Scope, and the language (user, 2026-11-23)
Stated by the user after reading the guideline's collisions:
- A multi-tenant core server handles all future parks. The core only shows records, and only those a booth has synced to it.
- The parks already running (park-buzi, park-2) stay out of this refactor for now. Later it must be possible to migrate them into the new architecture.
- The park is offline-first. The leaf lives with no internet connection and without the core infrastructure.
- The guideline binds the leaf only for the structure of users and permissions. That was
said while Rust was on the table; with TypeScript and Docker chosen, the guideline's
technology table is the nearest standard for
apps/boothandapps/core.
Where it is built (user, 2026-11-23): in this repository, on its own branch eda_dev, in
parallel to the existing code. New directories stand beside the
existing ones, named for what they are: apps/booth (the site) and apps/core (the
multi-tenant core), agreed by the user in place of the first examples apps/web_new and
apps/server_new. The existing apps keep serving the running parks from dev → stage →
main.
eda_devwas cut fromstageon 2026-11-23, which was 80 commits ahead ofdevand had nothing behind it.- The build and deploy workflows run on
dev,stageandmainonly, and the Komodo stacks are pinned tostagetags, so a push ofeda_devbuilds and deploys nothing (.gitea/workflows/,komodo/resources.toml). pnpm-workspace.yamltakes every directory underapps/andpackages/, so a new directory with apackage.jsonjoins the workspace and the Turbo tasks on that branch.
The language is TypeScript, delivered with Docker (decided, user, 2026-11-23): "I abandoned the idea of Rust." Earlier the same day the user had asked whether to remove Docker from the leaf and rebuild every service in Rust, because the booth relies on a lot of RAM and SSD today. The measurements below were taken for that question and stay as a record.
Measured on park-lab the same day (7.2 GB RAM, 5.0 GB available; 231 GB disk, 23 GB used):
| Memory | Disk | |
|---|---|---|
| Server (Node) | 87 MB | image 378 MB |
| Vision service (Python) | 425 MB | image 1.95 GB |
| Proxy (Caddy) | 11 MB | image 92 MB |
| Docker itself (dockerd, containerd, shims, proxy) | about 230 MB | build cache 4.5 GB |
| Komodo Periphery | 23 MB | |
| The zone PoC, for comparison | 401 MB | image 3.37 GB |
- The memory sits in the vision side (model runtime and frames), not in the Node server.
- The disk incident at park-2 was backups and snapshots, not images (park-2-disk-growth).
- Size of what a rewrite covers: about 26,000 lines of TypeScript behind the API (server, device drivers, database, shared) with about 11,000 lines of tests; 19,000 lines of web app that could stay if the API is kept; about 1,000 lines of Python in the vision service.
What staying with Docker keeps: deployment and remote control on Komodo, which drives
compose stacks (fleet-deployment-komodo, container-deployment), and the platform's leaf,
which is delivered as a compose stack (nats/compose.leaf.yaml).
Users and permissions, the first piece (2026-11-23)
The user asked where to start; users and permissions is the candidate, as a model on paper
before any code. The old permissions are, in the user's words, sloppy work. What the code shows:
verbs standing in for scope (shift:cash, drawer:review, subscription:plan,
carwash:cash), a catch-all (site:update), names that hide what they grant (barrier:create,
session:create), one role per user with extra bindings outside the grid, module permissions in
the one shared list (packages/shared/src/index.ts), a login token with no expiry
(apps/server/src/auth.ts).
Decided by the user (2026-11-23); the detail is on booth-users-and-permissions:
- Everything about identity is in the platform, and the booth is in constant sync with it, both ways. Users, members, policies and the catalogue have their home in the platform's auth service; the booth holds a copy, password hashes included. With no link the booth goes on working and catches up later.
- Login at the booth is local, against the copy, with a session cookie for the booth's own domain or IP address.
- Users and policies can be changed at the booth or on the platform, at any time, by whoever holds the right. The same holds for creating a park's operators.
- Login is by username; email is optional. The platform is to take this (a change in the platform, not made from here).
- Three kinds of people, all platform users: our staff (tenants, access, subscriptions; no access to the services), the tenant admin (the owner; holds everything on the tenant's parks; can have many parks), the park's people (policies, and the parks assigned to them).
- A park is one site with one booth host; no level between them until a park has two hosts.
- The booth is the only writer of its ledger. The platform syncs, reads and monitors, and a booth is recovered from it. Entries are signed with a key pair on P-256.
- Two product keys:
authfor users, members and policies (the platform's catalogue, always on);parkingfor everything else, registered on the platform, in the formparking.payment:take. - Scope in the permission string (
parking.shift:read@assigned,@all), a password of at least 12 characters, no lock for wrong passwords, a first password given as a one-time code valid 24 hours. - Validation and the car wash are not part of the booth. They will connect to each other and to parking as business to business. Postponed: the user asked not to be asked about them again; separate services are built if need be (car wash, hotels, cafés).
Earlier the same day the accounts of a park were placed on the booth only ("three rings"), with signed commands from the core. That was replaced by the first point above; the model page lists each earlier ruling and what became of it, what the platform needs for this, and the technical points left to the design of the sync.
The platform's structure this is mapped onto: nats/wiki/decisions/adr-0002-auth-and-tenancy-model.md,
auth-service/wiki/concepts/policies.md, auth-service/wiki/concepts/data-model.md,
EDA/wiki/decisions/xadr-0002-permission-catalogue-registration.md (paths from the EDA/ root).
The guideline against this repository (2026-11-23)
Source: EDA/wiki/guideline-joining-the-platform.md. A reading, with nothing designed from it.
Whose rule is what, as the guideline itself says:
- Rule 1, one concern, one service, is the user's. A system that arrives with its own login, its own administration screens and its own cloud back end in one deployable is split first.
- Rule 2, the site carries only what must be on the site, is the platform architect's reading, not yet confirmed by the user. So is the rule that unproven leaf mechanics are proven on the lab box first.
- Its "Not decided" list holds three things this refactor runs into: parking as the first leaf product; a local operator login while the link is down; a standard for a service with no HTTP API, which is what a vision service that talks to cameras would be.
Rule 1, row by row, against what this repository does today:
| Concern | Owner on the platform | In this repository today |
|---|---|---|
| Users, login, sessions | auth-service | its own: tables users, roles, sessions (packages/db/src/schema.ts), apps/server/src/routes/auth.ts, @fastify/jwt (local-jwt-auth) |
| Which tenant may use which product | auth-service | its own flags: MODULES_ENTITLED and the site's activation (apps/server/src/modules.ts, venue-modules) |
| Permissions | declared by the service, evaluated by auth-service | its own roles and permissions (apps/server/src/routes/roles.ts, users.ts) |
| Login page, administration | admin-ui | in its own SPA, with Setup (apps/server/src/routes/setup.ts) |
| Product screens | a static product app | the SPA is served by the server (@fastify/static) and wrapped by the desktop shell (desktop-shell-tauri) |
| Data from another service | the backbone, never a REST call at run time | the server calls the vision service over HTTP (apps/server/src/vision-client.ts); the review outbox posts over HTTP (apps/server/src/modules/carwash/review-outbox.ts) |
| Live updates to browsers | websocket-service | its own socket, /api/ws (apps/server/src/routes/ws.ts, booth-console) |
| Device protocols | adapters that publish canonical events | drivers inside the server process (packages/devices/), and device pushes received by the server (apps/server/src/routes/hikvision-alarm.ts, qr-reader.ts) |
| Streams, buckets, consumers | the nats repo, as config | none |
| Shared schemas and guards | eda-libs (@eda/*) |
packages/shared/ |
| Build and deploy | Gitea CI builds, Komodo deploys | already so (komodo/resources.toml, fleet-deployment-komodo, container-deployment) |
Technologies the guideline requires, against the repository's own guide (CLAUDE.md):
| Guideline | This repository | |
|---|---|---|
| NestJS on Fastify | plain Fastify | differs |
| Its own PostgreSQL through Drizzle | SQLite through Drizzle; PostgreSQL a deferred sync target | differs |
| A static app on nginx | the SPA served by Fastify | differs |
| No user table and no login route in the service | local login, "no external identity provider" (offline-first) | collides |
| No socket of its own to browsers | /api/ws to the booth screen |
collides |
| NATS JetStream between services | direct calls; a broker was skipped in 2026-06 (dingtian-vs-mqtt) | collides for the path that opens the barrier |
| A wiki in the repository, Komodo, Gitea | present | matches |
Agents push dev only; branches dev → stage → main |
the three branches exist; work here has gone to stage |
differs |
None of these is resolved here. The repository's guide binds until the user changes it.
What the guideline does not answer:
- Video. It has no word on streams, pictures or a live picture; how the booth screen gets its picture stays open.
- Device logins. It covers a service's own NATS key, not the logins of cameras, relays or readers.
- A booth screen that has to work while the link is down. It places screens and browser push on the hub side and lists the offline operator login as not decided. offline-first needs the booth to work with no link at all.
- The signed ledger and its single signer. Not a subject of the guideline; the platform wiki's parking query treats it.
Steps that are not in this repository. The guideline's first steps are an accepted cross-service decision, a row in the platform's service registry, backbone access and a key. They are made in the platform wiki and the nats repository.
What stays whatever the shape
From the repository's guide, and not put in question by the user: offline-first, the signed append-only ledger (append-only-event-chain), barrier-not-a-door, fail-state-safety, and the licence rule of standing-decisions.
Evidence so far
The H.264 test on park-lab (zone-anpr-poc, "H.264 instead of MJPEG"): the vision side decoding H.264 sub-streams costs the same CPU as MJPEG and an eighth of the network; the live picture arrives 0.12–0.24 s behind the camera with one decode thread; the stream held for a morning with no decode error.