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/ARCHITECTURE-and-process-models.md1,521 words

ESG — Process, Architecture and Conceptual Models

Purpose: the diagram set behind BRD-field-processes.md — what the business processes are, what the platform is made of, and where the two do not yet meet. Status: draft for review. Date: 2026-07-29. Assessed against: this repository at feat/rn-app-parity. Diagrams: hand-authored SVG in diagrams/esg, house style per diagrams/svg.

Colour carries status in every diagram, and nothing else does:

TintMeaning
greenBuilt — exists in the repository and is exercised
amberPartial — exists but does not meet its business rule, or is a scaffold fed by nothing
redAbsent or blocked — nothing does this, or the path is severed

1. Conceptual model — the work objects

Conceptual model

The domain is six work objects, not one. Prior design work treated the tri-state checklist item as the organising abstraction; it is not (BRD §1.1). Tri-state is a print-fidelity control belonging to one form. The objects in the diagram are what have identity, lifecycle and ownership.

A walk is the shared shape of an inspection and an audit: traverse a defined scope, section by section, attesting coverage. They are two processes, not one, because their scope vocabulary and their output differ (BR-AU1, BR-AU6).

Two things the model turns on:

  • Finding → NCR is the load-bearing edge. An NCR is a ticket with its own identity that outlives the walk that found it (BR-CA2). It is the single closure mechanism for a non-conformance found by any process (BR-X6). Nothing else in the model closes one.
  • Coverage is not conformity. Coverage is a claim about the walker; a finding is a claim about the site. A section with no finding against it must never print as inspected-and-compliant unless coverage was separately attested (BR-S2).

2. Process map — how the four processes interlock

Process map

Three processes find non-conformances and all three funnel into one ticket. Each also produces its own distinct output document, and not one of those documents closes anything.

Read the colours as the as-is state: the inspection walk is built, the NCR ticket is half-built, and the audit and incident columns do not exist.


3. Process 1 — NCR lifecycle

NCR lifecycle

This is the one lifecycle now implemented on the device, in apps/esg-field/lib/ncr/ticket.ts as a fold over the append-only log. The transitions in the diagram are the real event names from apps/esg-field/lib/store/events.ts.

Two rules carry the design:

  • BR-CA5 — the corrected closure is reachable only through verified. Closing as corrected without recorded and verified work is not a permitted path, and the state machine has no such edge.
  • BR-CA6 — a finding raised in error exits as not-a-non-conformance directly from open or assigned. That retracts the finding rather than asserting a correction that never happened.

The log is append-only (BR-X2): a reopen is a new NcrReopened event, never a mutation of the closure.


4. Process 2 — Site inspection walk

Site inspection walk

Panels B and C of the diagram are drawn as two separate emissions on purpose. Collapsing them is the failure BR-S2 exists to prevent: that a section was reached is a claim about the inspector, that it was compliant is a claim about the site.

The whole path is required to run offline, report included (BR-S7). It does: capture, fold and render are all on-device, with no network call in the path. The one thing the walk does not do is close its own findings — that is the NCR ticket in §3 (BR-S6).


5. Process 3 — Audit walk

Audit walk

Nothing in this diagram exists. It is the largest gap in scope — no vocabulary package, no device capture, no console surface.

The grading gate is the reason an audit cannot be an inspection with a different label. An inspection item verdict (satisfactory / deficient / N-A) and an audit finding grade (major / minor / observation / OFI) are different vocabularies with different consequences: two of the four grades must raise a ticket and two must not (BR-AU4, BR-AU5).

Blocked on DP-2: the audit standard and clause set must be confirmed before BR-AU1 can be built.


6. Process 4 — Incident, investigation, report

Incident to report

Three chained records, each with its own identity. The vocabulary is contracted in packages/esg-events-incident/src/index.ts; nothing captures it, and the investigation is not modelled at all.

Whether an investigation is opened for every incident or only above a severity threshold is an open business decision (BRD OD-3), which is why the notifiable? gate routes into the investigation on both branches rather than gating it.


7. Platform architecture

Platform architecture

Twelve Cloudflare Workers, one React Native field client, one Next.js console. CQRS with an append-only, hash-chained event store on the write side and rebuilt read models on the read side.

The severed boundary in the middle of the diagram is the whole problem. Capture works, the server side is scaffolded and boots green, and nothing crosses between them:

  • lib/store → esg-sync — the worker demands an HMAC gateway assertion a handset cannot mint.
  • lib/store → console — the ingest route sits behind Cloudflare Access, which returns 403 to a device.

Objective BO-6 — captured work reaches the office — currently fails at the first hop, and its resolution is an operations dependency, not a code change (BRD AS-5, DP-1).

A second, quieter architectural fact: the field app declares no dependency on any @esg/* package. The contracted vocabularies govern the server side only; the device restates its own shapes locally.


8. Framework — how the layers compose

Framework layers

Sixteen packages under one envelope, in five layers, and four invariants that hold across all of them:

InvariantMechanism
Append-only. A correction is a new event; nothing is edited or deleted (BR-X2)No edit or delete event kind exists in any vocabulary, on server or device — it cannot be expressed
No invented values. Where GPS, transcription or any input is unavailable, the record says so (BR-X4)Nullable fix types and explicit unavailable variants; there is no default coordinate to fall back to
No model in the compliance path. Determinism where a claim is asserted (BR-P2)esg-compliance forbids any LLM SDK, checked by a CI guard; esg-import requires human confirmation before AI-extracted data crosses in
Tamper-evidence. Every claim traces to an event with author, time and evidence binding (BO-5)Hash-chained event store, hourly Merkle roll-up, RFC 3161 external anchor

Two structural facts the layering makes visible: layer 1 has a hole where the audit belongs — six aggregates are contracted and the audit is not one of them, which is where every gap in §5 begins — and layer 4's field app is not bound by layers 0 to 3 at all.


9. Event flow — one inspection, capture to console

Event flow

Steps 1 to 7 are real and tested end to end, offline. Step 8 onward is unreachable from a handset. The device holds a complete, durable, signed record that no one in the office can see — which is the single most consequential finding in the BRD.

Note step 5: an NCR raised during the walk gets its own aggregate id and records the walk only as its origin. Two aggregates now share the one local log and never share an id. That is what makes a ticket outlive the walk that found it.


10. Status matrix

Per BRD §2.4, against this repository on 2026-07-29.

ProcessVocabularyDevice captureConsoleDeliveryVerdict
1 · NCR ticket✅ contracted⚠️ full ticket fold on device, no server binding❌❌Lifecycle exists on the device only
2 · Site inspection✅✅ capture, sign and report, all offline⚠️ three flat tables, open → submitted❌Captured, never delivered
3 · Audit❌❌❌❌Absent entirely
4 · Incident → investigation → report⚠️ incident contracted, investigation not❌❌❌Contracted, never built

Three independent layers exist — contracted vocabularies, a scaffolded server estate, and a working offline capture client — and they do not meet. The vocabularies govern nothing that runs on a device; the server estate is fed by nothing; the client delivers to nobody.


11. Traceability

Business rules and objectives cited here are defined in BRD-field-processes.md §5 and §3. The pinned report structure is reference/Test_Aecon_Report_Structure.md. Open business decisions that would change these models — notably OD-1 (is an NCR the same object as a corrective action) and OD-3 (is an investigation mandatory) — are listed in BRD §9; the conceptual model in §1 assumes the BRD's recommendation of a distinct parent NCR.

Diagram sources and the colour convention are documented in diagrams/esg/README.md.