wiki: users and permissions for the new booth, TypeScript with Docker
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
This commit is contained in:
@@ -9,9 +9,11 @@ status: 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 will provide the instructions and a guidelines document.
|
||||
**Nothing is designed or built until that document arrives.** This page holds what is decided,
|
||||
what is not, and what the decisions touch in the code as it stands.
|
||||
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.
|
||||
@@ -41,10 +43,11 @@ How it came up: the discussion on bringing the ideas of the [[zone-anpr-poc]] in
|
||||
|
||||
## Not decided
|
||||
|
||||
- **Which bus, and how it relates to the platform.** Suggested by the assistant and not
|
||||
confirmed by the user: the buffered NATS leaf on the booth PC that the platform wiki describes
|
||||
for syncing the ledger (`EDA/wiki/queries/q-parking-core-service-on-the-platform.md`, deferred
|
||||
by the user on 2026-10-20) could also be this local bus.
|
||||
- **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.
|
||||
@@ -93,6 +96,171 @@ over").
|
||||
6. **The repository's `CLAUDE.md`** still 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/booth` and `apps/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_dev` was cut from `stage` on 2026-11-23, which was 80 commits ahead of `dev` and had
|
||||
nothing behind it.
|
||||
- The build and deploy workflows run on `dev`, `stage` and `main` only, and the Komodo stacks
|
||||
are pinned to `stage` tags, so a push of `eda_dev` builds and deploys nothing
|
||||
(`.gitea/workflows/`, `komodo/resources.toml`).
|
||||
- `pnpm-workspace.yaml` takes every directory under `apps/` and `packages/`, so a new directory
|
||||
with a `package.json` joins 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:** `auth` for users, members and policies (the platform's catalogue,
|
||||
always on); `parking` for everything else, registered on the platform, in the form
|
||||
`parking.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
|
||||
|
||||
Reference in New Issue
Block a user