Cogneris
Environmental Compliance & Inspection

Intent · Every environmental obligation current and evidenced — zero reportable exceedances at Woodbine (UTS).

Operating tolerance: issues closed in ≤ 5 days · no repeat findings · every permit condition met.

← Documentsdocs/PLAN-field-and-console-2026-08-06.md1,692 words

Build plan — the field app and the console, one experience

  • Date: 2026-08-06 · Claude Opus 5 (Claude Code, session 0add9fc1)
  • Status: FOR REVIEW. Nothing in here is built yet.
  • Source: docs/UX-inspection-experience-codex-2026-08-06.md (Codex proposal), filtered through the Bernard Principles below.
  • Scope: apps/esg-field (React Native, iOS + Android) and app/ (the console).

The principles, applied as a filter and not as decoration

PrincipleWhat it changed in this plan
Highest value firstThe demo story end to end beats any single screen's completeness. Slice 1 is the one an operator cannot work without.
High impact, lowest effortFour of the six slices are finishing something already 80% built. The event log, the map, the applicability map and the D1 receiver all exist.
Fewer features, flawlessCodex proposed ~11 workstreams. Six are cut below, in writing, with the reason. An H&S framework is a new product, not a slice.
Simplest EXPERIENCE, not simplest UIThe note flow asks "what are you recording" — one extra tap — because the alternative is one screen that quietly files an observation as a non-conformance. More UI, less confusion.

What is already true (so the plan does not re-buy it)

  • Place-first walk, applicability map, and the Ontario Line bound to 10 control areas.
  • Spatial map: OSM basemap, named zoom, drill-down, worst-state badges, default view.
  • Selected project is sticky context; leaving an action prompts save-for-later or abandon.
  • Append-only event log incl. NoteRecorded (no producer yet) and LocationStageObserved.
  • Console: D1 store with ncrs (8 rows in production) + delivered_inspections, device-authenticated endpoints, an inspection receiver, and a register that reads live rows.

The slices

Each is independently shippable and independently reviewable — nothing here blocks anything else landing (CDT PR-independence rule).

Slice 0 · Voice that gives real-time feedback and keeps the audio — FIELD

Value: highest. Effort: low-medium. Why it is now first: the stated reason for wanting on-device recognition is (a) real-time feedback while entering information and (b) keeping the audio so a better model can re-read it offline later. Both are mostly built and switched off.

What is already true, verified in the binary installed on the phone: 5,619 sherpa symbols and 6,093 onnxruntime strings compiled in; 345 MB of models bundled (whisper-base.en-int8, whisper-tiny-int8, zipformer-en-stream); getAudioEngine('ondevice') resolves to sherpa with no cloud fallback; bundledModel.ts exists so it works with no network at all.

TaskWhatState
V1lib/audio/pcmWav.ts — the live session's Float32 frames → a durable 16 kHz WAV in the document directorywritten, compiling, unwired
V2startNoteCapture / finishNoteCapture on the streaming engine — live partials AND the kept audio AND the accurate second passwritten, compiling, unwired
V3Turn streaming ON for dictation (EXPO_PUBLIC_SHERPA_MODE, default is batch today, which is why words only appear after you stop)not started
V4Transcript provenance on NoteRecorded — engine, modelId, so a later better model's pass is distinguishable from the live one and from an operator's correctionnot started
V5Show the transition honestly: live words, then "refined by Whisper" as a distinct fact, never text quietly changing under the operatornot started

The constraint that shaped it: iOS gives one microphone session, so you cannot run the streaming and batch engines together. The streaming engine already receives the samples to decode them, so V1/V2 keep those same samples — one mic, three outputs: live words, an accurate re-read, and the recording.

Done when: an operator holds the mic at Port Lands, watches words appear as they speak, releases, sees the refined transcript arrive labelled as such, and the WAV is on the handset for a stronger model to re-read later.

Slice 1 · Dictation that files the right kind of record — FIELD

Value: highest. Effort: LOW — revised down. screens/capture/NoteCapture.tsx is a finished dictation screen (push-to-talk with slide-up-to-lock, every engine state narrated, keeps audio and transcript) and it is imported by nothing. The engine, the models, the screen and the NoteRecorded event all exist; what is missing is the route.

  • F1.1 The capture affordance asks "What are you recording?" → Location note · Check note · Finding, preselected by where it was opened from.
  • F1.2 Wire NoteCapture from the walk and from the map's location card.
  • F1.3 Write NoteRecorded, keeping the transcript BESIDE any correction. Category derived from the check, optional elsewhere.
  • F1.4 Notes appear on the location card and in the record; a note never changes coverage.
  • Done when: an operator can stand at Port Lands, say a sentence, and see it filed against that place with the right kind, offline.

Slice 2 · The console can open one inspection — CONSOLE

Value: highest. Effort: low. The device now delivers inspections into D1 and the console can only show them as a row in a queue. The chain ends in a list.

  • C2.1 /inspections/[id] — a delivered inspection: locations covered, not reached (with the reason), checks answered, findings, notes, signatures, receipt.
  • C2.2 Reached from the arrivals inbox row that already exists.
  • C2.3 States what is NOT there: photos are on the handset; unanswered is not compliant.
  • Done when: a director can read what an inspector did without a database client.

Slice 3 · The console walk is place-first too — CONSOLE

Value: high. Effort: medium. app/inspections/page.tsx is still the category-first screen Pete photographed. Two surfaces telling different stories about one method is the single most expensive inconsistency in the product.

  • C3.1 Restructure to the same shape as the device: site → location → the checks that apply there.
  • C3.2 Reuse the console's existing siteMap.tsx + planCanvas.tsx (named zoom and drill-down are already built there) as the entry, mirroring the device.
  • C3.3 Split areasClean into locations covered and checks clean — one label over two denominators is why /projects reads 5/8 and 6/10 for the same idea.

Slice 4 · An asset is a thing you can select — FIELD

Value: medium-high. Effort: low. Assets are printed but not selectable, and no event carries an assetId, so "the dust monitor at Exhibition" cannot be the subject of anything.

  • F4.1 Selectable assets at Street level; breadcrumb Site › Control area › Asset.
  • F4.2 Optional assetId on NoteRecorded and the NCR raise payload.
  • F4.3 The location card lists assets with their own state.

Slice 5 · Two disciplines, honestly — FIELD + CONSOLE

Value: high. Effort: medium — because it is deliberately two, not three. Development progress already has an event (LocationStageObserved). ESG already has everything. So this slice makes the READ model discipline-aware and says H&S is not assessed rather than pretending.

  • D5.1 Coverage keyed by project + location + discipline + framework version + item, so a PM confirming "structure" can never satisfy an ESG check.
  • D5.2 The location card shows three lanes: Development · ESG · Safety, each with its own state, assessor and time. Safety reads "no safety framework yet" — an absence, stated.
  • D5.3 Every assessment carries its assessor. Conflicting observations show as conflicting, never latest-wins-green.
  • D5.4 Ontario Line has no STAGE_AT_LAST_SURVEY entries: show "no prior stage observation", never the not-started fallback as a field claim.

Slice 6 · The demo tells one story — BOTH

Value: high for the demo, low for the product. Effort: low.

  • S6.1 Seed the Ontario Line sample set from §4 of the Codex report — which checks fail where, what the notes say — labelled synthetic, never presented as delivered.
  • S6.2 Geometry for the three unplotted locations (z-ol-lakeshore, z-ol-thorncliffe, z-ol-flemingdon) so the map stops apologising for them.
  • S6.3 One rehearsed path: select project → map → drill → dictate → raise → sign → see it in the console.

Cut, and why — this is the part that makes the rest flawless

CutWhy
A real H&S frameworkA new product model: hazards, controls, stop-work, safety NCRs, its own checklist vocabulary. Slice 5 shows the lane and states it is unassessed. Build it when somebody owns it.
Multi-recording audio per noteOne recording per note, one note per recording. Codex is right that the vocabulary allows only one URI — the fix is more notes, not a list of URIs.
LocationAssessmentRecorded as a generic envelopeThe specialised events already say the domain more clearly. A generic assessment envelope is the abstraction you write after the third discipline exists, not before the second.
Free pan/zoom on the mapNamed levels are a stated decision (SPATIAL-MODEL §5) and the reason the visibility rules can be written down.
Interactive console chartsAlready a documented decision (PORTAL-INFORMATION-CONTRACT). Printing the contributors beats clicking into them at this data volume.
Per-device credential enrolmentThe per-build token is honest and works. Per-device matters when handsets are lost, not before.

Sequence, and what blocks what

Slice 0 (voice: live + kept) ─► Slice 1 (dictation routes) ─┐
Slice 4 (assets)            ├─► Slice 6 (demo story)
Slice 2 (console record)  ──┤
Slice 3 (console place-first)┘
Slice 5 (disciplines) ──────► needs 1 and 2 to be worth looking at

One external dependency, and it is yours to release: the production console still runs the old code. Slices 2, 3 and 6 are only true in production after pnpm cf:deploy plus wrangler secret put ESG_DEVICE_TOKENS — which must land together, because the new auth fails closed. Everything is demonstrable locally without it.

What I would do first if you only said "go"

Slice 0, then Slice 1, then Slice 2. They are the two ends of the chain — making a record, and reading it — and between them they turn the app from something that shows state into something that captures it.