feat(review): sample every detected car, not only ticketed entries
Build & push images / images (push) Successful in 5m20s

The entry stream for the reviewer was fed from the session-tied read only (ticket
printed / exit signed). park-2 ran an afternoon with its barriers up: hundreds of
camera vehicle pushes, zero tickets, zero samples.

- anpr-entry: keep the best-framed vehicle of each poll loop (highest body-type
  confidence with a box), store that frame as a snapshot (identity pass:<id>, no
  session) and emit a vehicle read with the camera id — plate or no plate. One
  sample per detection, fire-and-forget, never on the ANPR path.
- snapshot.ts: normalizedBoxes() shared by the session-tied read and the bridge;
  vehicle reads now carry deviceId.
- review-outbox: sampleEntry(deviceId) dedups per camera for 30 s so the pass
  sample and a ticket entry's read (same car, seconds apart) go once.
- wiki: outbox page (entry stream, troubleshooting checklist for 'nothing arrives':
  the month-long silence was a missing Netbird policy, not code), park-2 camera
  port-forward procedure (site-device-installation §7), log.
This commit is contained in:
2026-10-08 19:30:03 +02:00
parent 354de04a3d
commit 30a1180108
10 changed files with 288 additions and 28 deletions
+43
View File
@@ -285,6 +285,49 @@ barcode with a real ticket (the KP-300H garbled overflowing barcodes until the g
8. Record in the site record: every IP, serial, camera password, printer model, which relay is
which, photos of the labels. Remove the temporary laptop addresses. Log out of every device UI.
## 7. Reaching the cameras remotely — port forward through the booth host (park-2, 2026-10-08)
park-buzi exposed its two Hikvision web UIs on the site router (`park-buzi.msai.al:8081` / `:8082`,
see [[lpr-camera]]). park-2 does the same **through the booth host**, because its router only
knows the 192.168.1.0/24 side while the cameras live on the device VLAN:
| | address |
| --- | --- |
| router / internet side | `eno1` 192.168.1.101, gateway 192.168.1.1, public 91.230.255.154 |
| device VLAN side | `eno1` 10.0.10.101 (same NIC, second address) |
| Netbird | `wt0` 100.75.7.237 = `park-2.nb.infra` |
| entry camera | 10.0.10.9:80 → published as **8081** |
| exit camera | 10.0.10.10:80 → published as **8082** |
Done with iptables on the host (needs root; the admin account has no passwordless sudo).
`ip_forward` is already 1 because Docker set it. Docker also sets the FORWARD policy to DROP, so
the explicit ACCEPTs are mandatory, and the SNAT is what brings the camera's replies back through
the host (the cameras' gateway is not the booth):
```bash
iptables -t nat -A PREROUTING -p tcp --dport 8081 -j DNAT --to-destination 10.0.10.9:80
iptables -t nat -A PREROUTING -p tcp --dport 8082 -j DNAT --to-destination 10.0.10.10:80
iptables -t nat -A POSTROUTING -p tcp -d 10.0.10.9 --dport 80 -j SNAT --to-source 10.0.10.101
iptables -t nat -A POSTROUTING -p tcp -d 10.0.10.10 --dport 80 -j SNAT --to-source 10.0.10.101
iptables -I FORWARD -p tcp -d 10.0.10.9 --dport 80 -j ACCEPT
iptables -I FORWARD -p tcp -d 10.0.10.10 --dport 80 -j ACCEPT
iptables -I FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
apt install -y iptables-persistent && netfilter-persistent save # survive reboots
```
- **Reach:** from any Netbird peer with a policy to park-2, `http://park-2.nb.infra:8081/`
(no router change needed). From the internet only once the router forwards 8081/8082 to
192.168.1.101. PREROUTING does not apply to the host's own traffic — test from another machine.
- **Netbird-only variant:** add `-d 100.75.7.237` to the two PREROUTING rules; then the public
forward can never reach the cameras even if someone adds it on the router.
- **Undo:** the same lines with `-D`. **ufw**, if ever enabled there, also needs
`ufw route allow proto tcp to 10.0.10.9 port 80` (and `.10`).
- **Why not Docker:** `docker run -p 100.75.7.237:8081:80 alpine/socat …` would do the same
without sudo, bound to the overlay only; the user chose the iptables route.
- This is a deliberate hole in [[network-isolation]] (camera web UI reachable off the VLAN);
the camera's own digest auth is the only gate behind it. Keep the public side off unless
needed; prefer the Netbird path.
## Gaps to fill next time you hold the hardware
- Factory address and configuration tool of the **Cashino KP-300H** and the **Rongta RP** units
+44 -1
View File
@@ -1,7 +1,7 @@
---
title: Vision review outbox — harvesting the operator's category choice for a trusted reviewer
type: concept
status: booth side built 2026-09-06; collector pending
status: live — first package delivered park-2 → collector 2026-10-08 (after a month blocked by a missing Netbird policy)
related: [venue-modules, opencv-anpr-service, threat-model, append-only-event-chain, network-isolation]
---
@@ -58,6 +58,20 @@ exactly one in N) and calls `enqueueEntry()`; the core never imports the module.
as "entry stream — label the vehicle", the export carries a `kind` column, and **operator
agreement is computed from wash items only** (an entry sample has no operator decision).
**Every car that passes, not only ticketed ones (2026-10-08).** The entry stream was fed from
the session-tied read only (`snapshot.ts`, taken when a ticket is printed or an exit is signed).
park-2 ran a whole afternoon with its barriers up: hundreds of camera vehicle pushes, zero
tickets, zero samples. So the ANPR bridge (`anpr-entry.ts`), which already pulls and analyses
frames for every vehicle push on an `anpr: true` camera, now keeps the **best-framed vehicle of
each poll loop** (highest body-type confidence with a box), stores that one frame as a snapshot
(`identity = pass:<snapshotId>`, no session) and emits a vehicle read with the camera's id —
plate or no plate. One sample per detection (the loop is one per car, joins slide it). The
module's `sampleEntry(deviceId)` **dedups per camera for 30 s** (`ENTRY_DEDUP_MS`): the pass
sample and the ticket entry's read, seconds apart from the same camera, are one car. The plate
box is handed over whenever the detector saw a plate, confident or not — it is what the crop
blurs. Pass snapshots ride the normal retention/pruning. Needs `anpr: true` and the per-camera
auto-trigger on (the bridge bails before polling otherwise) — same gate as recognition today.
An internet feed was considered the same day and kept OUT of the collector's ingest: licensed
sets only, in a separate folder with provenance, used as warm-up and weighted down, and never
the judge of accuracy — the evaluation set is gate crops only.
@@ -177,3 +191,32 @@ that start like a spreadsheet formula (category/service names are booth-supplied
**Status (2026-09-07).** Live: the collector runs on `art-docker-station` and park-2 is wired to
it (`stage-dbbb051` on both stacks, every entry sampled). The review screen at
`http://docker-station.nb.infra:8090/review` is filling; no labels reviewed yet.
## Troubleshooting — "the cameras are busy but nothing reaches the collector" (2026-10-08)
Found a month after both sides were built: **not one package had ever arrived**. Both codebases
were fine; the Netbird **policy** between the booths group and the collector host did not exist,
so `docker-station.nb.infra` resolved nowhere from the booth (Node: `fetch failed`, cause
`ENOTFOUND`; every row `queued`, attempts climbing, the 6 h backoff cap hiding it). Adding the
policy in the Netbird dashboard was the whole fix — the first row went out at its next scheduled
retry, nothing restarted. Checklist, in order:
1. **Is anything queued at all?** Only a vehicle read **tied to a session** (ticket taken or an
exit) is sampled; the camera's motion pushes feed subscription plate matching only. Barriers
left open = no tickets = no samples, however busy the lane. Query on the booth (no sqlite3
there; use the image's own driver):
```bash
s=$(docker ps -q --filter name=server); m=/app/node_modules/.pnpm/better-sqlite3@12.10.1/node_modules/better-sqlite3
docker exec $s node -e "const D=require('$m');const db=new D('/data/parking.sqlite',{readonly:true});
console.log(db.prepare(\"select status, json_extract(payload,'\$.kind') kind, count(*) n, max(sent_at) lastSent, max(last_error) err from carwash_review_outbox group by 1,2\").all())"
```
(`kind` lives inside `payload`; the image is in the row until delivered.)
2. **`fetch failed`** → from the booth host: `resolvectl query docker-station.nb.infra` and
`netbird status -d | grep -A4 docker-station`. Not found / not listed = the booth and the
collector host are not peers → Netbird policy. Resolves = `curl -X POST
http://docker-station.nb.infra:8090/ingest` must answer **401** (the collector's token check),
anything else is the collector.
3. **Collector side:** `docker logs wash-collector-collector-1 | grep -c /ingest` — zero means
nothing ever arrived; the container's health lines are its own probes.
4. After the fix, rows drain on **their own timers** (`1 min · 2^attempts`, cap 6 h); a restart
does not reset `next_attempt_at`. Expect a backlog to trickle in over hours, new rows at once.
+25
View File
@@ -3442,3 +3442,28 @@ code, not by level: `/health` silent on both services, one request line instead
`onError` hook so 5xx keep logging under `disableRequestLogging`), hik-alarm HIT and per-snapshot
byte lines demoted to debug via a level on `stubLog`. Pages: [[app-logs]] §Noise cut.
- 2026-10-08 — **stage-1167e27 never built**: the code fix and the TAG bump were pushed together, so CI tagged the image with the push head (`stage-32b4d9e`); Komodo deploy failed "not found". Re-pinned all four stacks to `stage-32b4d9e`; rule added to [[fleet-deployment-komodo]] (push code first, bump after the build).
## [2026-10-08] query | Review outbox never delivered — missing Netbird policy, not code
A month of silence from the collector: park-2 had 22 entry samples `queued`, all `fetch failed`
(`ENOTFOUND docker-station.nb.infra`). park-2's Netbird peer list had no docker-station and vice
versa — no policy booths → collector host. User added the access in the Netbird dashboard; the
first package went out at its next scheduled retry (16:49Z) and the collector logged the ingest.
Also clarified why camera traffic ≠ samples (only session-tied reads are sampled; barriers were
open, so almost no tickets). Troubleshooting checklist added to [[vision-review-outbox]].
## [2026-10-08] ingest | park-2 camera port forward through the booth host (iptables)
8081 → entry camera 10.0.10.9:80, 8082 → exit camera 10.0.10.10:80, DNAT + SNAT + FORWARD
ACCEPTs on park-2 (Docker's FORWARD DROP policy makes the ACCEPTs mandatory). Reachable over
Netbird as `park-2.nb.infra:8081/8082`; public only if the router forwards to 192.168.1.101.
Procedure, undo and the Netbird-only variant in [[site-device-installation]] §7.
## [2026-10-08] ingest | Review outbox: sample every detected car, not only ticketed entries
User: "I need every car that passes to be pushed to the server" — park-2's barriers were up, so
hundreds of camera pushes produced no session-tied reads and no samples. The ANPR bridge now
records one PASS sample per detection (best-framed vehicle of its poll loop → stored snapshot
`pass:<id>` + vehicle read with `deviceId`); the Car Wash sampler dedups per camera for 30 s so a
ticketed car is not sent twice. Also flushed park-2's 21 backed-off rows (`next_attempt_at = now`)
so the reviewer got the day's backlog at once. Pages: [[vision-review-outbox]] §entry stream.