From d3649669eeb9dddb864c8f4d989745322cd9e720 Mon Sep 17 00:00:00 2001 From: Julian Cuni Date: Thu, 19 Nov 2026 12:38:53 +0100 Subject: [PATCH] wiki: passage confirmation scope and relay maps, crossing-line editor, desktop WS hello fix, cameras push to the dev machine Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RZgP5oMncSaVmKRKk1UvN4 --- wiki/concepts/passage-confirmation.md | 57 ++++++++++++++++++++++++++- wiki/decisions/camera-live-view.md | 4 +- wiki/decisions/desktop-shell-tauri.md | 15 +++++++ wiki/index.md | 2 +- wiki/log.md | 28 +++++++++++++ 5 files changed, 101 insertions(+), 5 deletions(-) diff --git a/wiki/concepts/passage-confirmation.md b/wiki/concepts/passage-confirmation.md index 7c622d3..04669a0 100644 --- a/wiki/concepts/passage-confirmation.md +++ b/wiki/concepts/passage-confirmation.md @@ -77,6 +77,8 @@ with the test results attached. ## Test plan — on park-lab (user, 2026-10-24: "we will test it on park-lab") +0. Verify the interlock with a meter: hold the open relay, pulse the close relay, `DOWN` must stay + dead. Then assert `UP` and `DOWN` together on the unit: open must win. 1. Confirm the operator's close input; wire a spare relay to it. 2. Close with a car on the safety loop → boom must not move / must reverse. 3. Close with the photocell beam broken by a person → same. @@ -111,7 +113,7 @@ Two cameras mounted on **one physical lane that serves both directions** (user, | Sub-stream (102) | 1280×720 **MJPEG**, 12.5 fps (was 640×360 H.264, keyframe every 4 s) | 1280×720 **MJPEG**, 20 fps (was 640×360 H.264, keyframe every 2.5 s) | | Line crossing / intrusion (`ISAPI/Smart/LineDetection`, `FieldDetection`) | `notSupport` | `notSupport` | | Motion detection | on, target `vehicle`, grid drawn | on, target `vehicle`, grid drawn | -| Alarm server (`httpHosts`) | not set (`0.0.0.0`) | not set (`0.0.0.0`) | +| Alarm server (`httpHosts`) | the dev machine `10.0.10.203:3000` (user, 2026-11-19) | the dev machine `10.0.10.203:3000` (user, 2026-11-19) | Read from the cameras over ISAPI the same day; bench snapshot results are on [[lpr-camera]]. @@ -129,13 +131,64 @@ Read from the cameras over ISAPI the same day; bench snapshot results are on [[l does the tracking. - ~~Both sub-stream keyframe intervals are above the ≤ 1 s this design asks for (item 1).~~ Moot since the switch to MJPEG (2026-11-17). -- Neither camera pushes to park-lab yet, and neither is in its device registry. +- Both cameras push to the local dev machine, which runs on a copy of park-lab's database where + both are registered (bound to Dingtian relay 1, ANPR auto-open on). They push to the dev + machine, not to park-lab, so a subscriber read there raises the real boom. - [[k200l-printer]] records `10.0.10.7` as the park-lab printer's fixed address — the exit camera now answers there. To be resolved with the user. - **Shared lane — not covered by the design above**, which assumes a camera sees only its own direction. Here a car driving in passes the entry camera and then drives away through the exit camera's view, and the reverse for a car driving out. Open in "Open questions". +## Decided with the user (2026-11-17) + +- **Layout.** park-lab is **one lane, one barrier** for both directions (relay 1 registered as + `both`, both cameras bound to it). park-2 and park-buzi have **two lanes, two barriers**. +- **Every open is watched**, not only ANPR subscriber opens: a ticket printed by someone who then + drives off leaves the boom up the same way. No A→B passage inside the window ⇒ close. +- **Scope, phase 1: the close only.** The ledger part (`vehicle_passed`, `*.abandoned`, ticket + invalidation) is phase 2. The close itself is a signed event from the start. +- **Wiring.** park-lab: R1 opens, R2 closes (`DOWN`). The user believes R2 is interlocked behind + R1's NC as [[zkteco-cmp200-barrier]] prescribes; this is **not yet verified**. Relays 3 and 4 are + **not** interlocked. Until a pair is verified interlocked (a meter on `DOWN` with the open relay + held), that barrier gets no close. +- **Relay maps at the other sites (user, 2026-11-19).** **No close relay exists at either site.** + A close there needs new wiring to the operator's close input first. + + | Site | R1 | R2 | R3 | R4 | + |---|---|---|---|---| + | park-2 | opens the entry barrier | opens the exit barrier | — | — | + | park-buzi | opens the entry barrier | opens the exit barrier | pulses the entry ticket button when a vehicle is in the drawn zone | — | + + park-buzi is offline (the site does not run this software). + Config validation must refuse a close relay that already has a direction or an input role. +- **The line is our own Line Crossing rule (user, 2026-11-19).** The model is Hikvision's: a + segment with sides A and B and a direction, where A → B, B → A or A ↔ B is what counts as a + crossing. The fleet cameras have no such rule, so Setup draws it and the booth's tracker judges. + +### Phase-1 shape (proposed) + +- **Built (uncommitted).** Setup → camera → *Crossing line* draws the segment over the live + picture. You drag across the picture to draw it, drag an end to move it, and can swap A/B and + pick A → B, B → A or A ↔ B. It is stored as camera `config.crossing` (`CrossingLine` in + `packages/shared`): two normalised points and a direction, with side A on the screen-left of + p1→p2. The save validates it, and `null` clears it. +- The watch is **per barrier**, started by the **open** (any source), not by a camera push. A + barrier without a drawn line gets no watch and no close. +- The direction of the open picks the confirming line; "lane clear" must hold on **every** camera + bound to that barrier (park-lab: a car approaching from the other side holds the close). +- The close relay is named **explicitly** per barrier in the controller config (never derived from + the open relay), may have no other role, and is a separate optional driver capability. The driver + serialises open/close per barrier with open always winning — which does **not** replace the + hardware interlock (a second server on the same board, e.g. a dev machine, has its own lock). +- **Dry run first:** the verdict and a "would close now" record with the evidence frame; the real + pulse sits behind a per-barrier switch, off by default, until the bench tests pass and + [[barrier-not-a-door]] is revised. +- Frames come from the live-view hub ([[camera-live-view]]): one MJPEG session per camera, shared. +- A drawn **line alone may not be enough**: the entry view has parked vehicles in the background, + so "nothing in view" is never true there. The recordings decide whether Setup also needs a lane + area. + ## Open questions - **One lane, both directions (park-lab rig).** Every car crosses both cameras' views. Does the far diff --git a/wiki/decisions/camera-live-view.md b/wiki/decisions/camera-live-view.md index cf24b7c..ad80f02 100644 --- a/wiki/decisions/camera-live-view.md +++ b/wiki/decisions/camera-live-view.md @@ -155,8 +155,8 @@ reconnect); the close rules held. images. - Through Caddy (`reverse_proxy` upgrades WebSockets; not exercised). - The live → snapshot return 30 s after the last push in the browser (covered by unit tests only). -- A real vehicle push from the cameras (park-lab's alarm server is not set yet — see - [[passage-confirmation]] park-lab rig). +- A real vehicle push from the cameras to park-lab itself. Since 2026-11-19 both cameras push to + the local dev machine instead (`10.0.10.203:3000`, user) — see [[passage-confirmation]] park-lab rig. ## Where the code is diff --git a/wiki/decisions/desktop-shell-tauri.md b/wiki/decisions/desktop-shell-tauri.md index d2b417d..6d34160 100644 --- a/wiki/decisions/desktop-shell-tauri.md +++ b/wiki/decisions/desktop-shell-tauri.md @@ -183,6 +183,21 @@ Per the user's choices — the operator **keeps OS access** (no fullscreen lockd together; a `resources.toml` change still needs a Komodo sync + Stack redeploy to take effect on a live booth, it isn't automatic from a git push alone — and see [[fleet-deployment-komodo]] for a real ResourceSync-branch gotcha this exact fix ran into. + - **Gotcha: the first frame could be lost (found and fixed 2026-11-19, uncommitted).** The + plugin's Rust side starts its read loop at the handshake, before `connect()` resolves + (`tauri-plugin-websocket` 2.4.3 `src/lib.rs` spawns the reader, then returns the id). Its JS + wrapper only accepts a listener on the object `connect()` returns. The server sends `hello` + (the full device list, lanes, radar, active cameras) at once, so it could reach an empty + listener set and be dropped. + - **Symptom:** the desktop footer showed only the devices that pushed later (one camera chip; + no relay), while the browser was complete. The footer trusts a non-empty live list over its + REST seed. + - **Fix:** `platform-ws.ts` calls `plugin:websocket|connect` / `|send` itself through + `@tauri-apps/api/core`, with its own `Channel` listening from the start. Frames that arrive + before the open are held and delivered right after `onopen`. + - The same fix covers the camera live socket's first `status` message. + - Still to be checked in the desktop app; an installed build keeps the bug until it is + re-bundled. - **No way to see the installed app's own version (found + fixed 2026-09-03).** `VersionBadge` in `router.tsx` shows the *server's* `-` (from `/api/version`, gated `site:read`) — but nothing showed the *desktop client's* own version. An operator debugging a stuck update had no way diff --git a/wiki/index.md b/wiki/index.md index d253c0e..ba0326d 100644 --- a/wiki/index.md +++ b/wiki/index.md @@ -103,7 +103,7 @@ Counts: 4 sources · 19 entities · 47 concepts · 9 decision records. - [[tariff-industry-survey]] — 2026-07 web survey of industry tariff structures: coverage map vs our engine; gaps = early bird (pick-table-by-entry-time) + merchant validations; per-minute & dynamic pricing ruled out. - [[booth-exit-flow]] — manned booth: pay → voucher (self-exit later) or immediate exit; active sessions; audited barrier re-open. - [[park-2-event-loop-stall]] — INCIDENT 2026-10-24: `/api/sessions/active` ran ~2 s synchronously (per-row unindexed ledger scans × 664 open unpaid tickets), froze the event loop, and made healthy Dingtian pulses report "timeout" (timers run before socket I/O) → signed entries with no snapshot/session row. Fix: fold-once pricing, hot-path indexes (0032), deferred UDP timeout, evidence before pulse. Rule: bounded request cost whatever the operator data. -- [[passage-confirmation]] — DESIGN 2026-10-24 (open): confirm a car actually crossed after the open, on the booth PC (cheap cameras have no line-crossing): sub-stream watcher + YOLOX tracker + a drawn segment → signed `vehicle_passed` / `entry.abandoned`; lane free on passage; evidence-driven (never timed) close on a spare relay after an abandonment; park-lab test plan; measured 66–132 ms/frame. +- [[passage-confirmation]] — DESIGN 2026-10-24 (open): confirm a car actually crossed after the open, on the booth PC (cheap cameras have no line-crossing): sub-stream watcher + YOLOX tracker + a drawn segment → signed `vehicle_passed` / `entry.abandoned`; lane free on passage; evidence-driven (never timed) close on a spare relay after an abandonment; phase 1 = the close only (dry run first); A→B/B→A/A↔B line editor in Setup built; relay maps per site; park-lab test plan. - [[operator-issued-entry]] — operator mints an entry ticket when the physical button is broken; presence-gated (radar AND camera, both sides), flagged (source=manual + operatorInitiated + anomaly), capacity-override allowed; needs `session:create` (2026-07-01). - [[plate-reconciliation]] — ANPR plate-as-invariant catches the ticket-swap fraud (paid car let out on a fresh $0 ticket, original lingers "inside"); exact/high-conf match vs open sessions; booth = flag + operator override, reader = log-only fail-open (2026-07-01). - [[shift]] — manned-only accountability period; explicit Start/End; End → signed + printed Z-report; drawer float carries across shifts. Drawer cash movements (operator records, admin reviews via signed cash_review — a flag, not a reversal) live at the /drawer route (2026-07-01). diff --git a/wiki/log.md b/wiki/log.md index c97ab1d..6bb194a 100644 --- a/wiki/log.md +++ b/wiki/log.md @@ -3731,3 +3731,31 @@ either end. Built: a neighbours route per camera snapshot (`{ older, newer }`, ` the date in the caption; the tile stays on the newest. Verified in headless Firefox with four snapshots on one camera, including a slow load (caption keeps the shown picture's date) and a missing still ("unavailable"). Updated [[camera-live-view]]. + +## [2026-11-17] query | Passage confirmation — scope decided for phase 1 + +User raised the abandoned-open case again (subscriber read opens, driver turns back; same for exit) +and asked to draw A→B lines and close via R2. That is [[passage-confirmation]]. Decided: park-lab +one lane/one barrier, park-2/park-buzi two; every open is watched (a ticket taker who drives off +too); phase 1 = the close only, ledger later; R1/R2 interlock believed but unverified, R3/R4 not +interlocked. Recorded the phase-1 shape (per-barrier watch, explicit close relay, dry run first, +hub frames, possible lane area) and a step 0 for the interlock in the test plan. + +## [2026-11-19] query | Passage confirmation — relay maps, crossing-line editor built + +User gave the relay maps. park-2: R1 entry open, R2 exit open. park-buzi (offline): the same, plus +R3 for the entry ticket button. So no close relay exists outside park-lab. They restated that the +line is a Hikvision-style Line Crossing rule (A → B / B → A / A ↔ B) we draw ourselves. Built, +uncommitted: Setup's *Crossing line* editor over the live picture, stored as camera +`config.crossing` and validated on save. Checked in headless Firefox against `.6`, with server +tests for save, keep and clear. Updated [[passage-confirmation]]. + +## [2026-11-19] query | Desktop footer showed one device — the WS `hello` was dropped + +User saw the desktop app's footer list only the entry camera while the browser was complete. +Cause: `tauri-plugin-websocket`'s JS wrapper only lets a listener attach after `connect()` +resolves, but the native reader starts at the handshake, so the server's immediate `hello` could be +lost. Fixed (uncommitted) in `platform-ws.ts`: the plugin's commands are called directly, with our +own channel from the start, and early frames are held until the open. Not yet checked in the +desktop app. Also recorded that both park-lab cameras now push to the dev machine. Updated +[[desktop-shell-tauri]], [[camera-live-view]], [[passage-confirmation]].