Files
parking_solution/wiki/decisions/event-driven-refactor.md
T
julian dd2dd53d7e wiki: H.264 test on park-lab, event-driven refactor decided
- zone-anpr-poc: H.264 instead of MJPEG (load, delay, a car in the zone,
  staff traffic, bad weather); the relay-less test copy is left running
- event-driven-refactor (new): the user's decisions of 2026-11-23, what
  is not decided, what they touch in today's code; waits for the user's
  guidelines
- passage-confirmation: the 2026-11-19 phase order superseded; where the
  video work lives
- vision-hardening, zone-anpr-poc-review: on-screen label read as a
  plate (moved by the user), day-time oversized box, still pause carried
  over
- pointers on vision-service, camera-live-view, lane-presence-and-anpr-entry,
  dingtian-vs-mqtt, entry gates, standing decisions, open questions,
  overview, index

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RZgP5oZdzvo92Eouc9eRv5
2026-11-23 12:02:18 +01:00

7.0 KiB
Raw Blame History

type, tags, sources, updated, status
type tags sources updated status
decision
parking
decisions
architecture
event-driven
vision
camera
bus
refactor
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 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.

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)

  1. The repository is refactored as a whole, event-driven. The shape comes from the user's guidelines.
  2. A bus connects the vision side, the server and the booth screen. Its details settle with the guidelines.
  3. 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.
  4. 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.
  5. Services that die together are an accepted concession, and a watchdog service takes care of crashed services. Not designed.
  6. 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").
  7. Watching the live picture from outside the booth's network is out of scope for now.

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.
  • 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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  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.

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.