Skip to content

How the rules are enforced

Each step asks for a specific kind of proof. The database won't mark it done without that proof, and won't close a check while a required step is still open.

Templates, checks, steps

A workflow template is a named sequence of steps for a kind of work — receiving, installation, testing, commissioning, maintenance, removal, or custom. Each step asks for one kind of proof: a required photo, a reading that has to land in a set range (with a minimum, maximum and unit), a checklist that has to pass, a verified seal, a signature, or an uploaded document (photo_required, measurement_in_range, checklist_pass, seal_verified, signature, document_upload). Opening a check against an asset copies the template's steps onto that check, all still open.

There's one way to start a check and no way to slip in a step that's already done: checks and their steps come into being only through lt_open_case and lt_open_inspection. A direct insert of a pre-satisfied step is refused by a trigger (a rule the database runs on every change); so is deleting a step, so the trick of removing the blocking step and then closing doesn't work.

The gates

Marking a step done is checked against the proof its type demands (a BEFORE UPDATE trigger): a photo step needs at least one stored photograph, a reading must fall inside the configured range, a signature needs a signature certificate, a document step needs a document reference. Steps are completed in order. Every completed step names the person who did it.

Closing a check is refused while any required step is still open; the refusal says how many are left. Some check kinds also require independent acceptance by someone who did not perform the work. Once closed, the check and its steps are frozen — updates are refused, and the freeze survives the row moving to a new owner at handover because a stewardship-only change (org_id and nothing else) is the one edit the freeze lets through.

Nobody outranks the gate
The triggers do not check who you are. A database superuser cannot close an incomplete check; the stress suite proves it.
Corrections are added
A wrong entry is not edited. A correction is a new, attributed, logged entry on an open check; closed evidence is never rewritten.
Deficiencies close with proof
A deficiency cannot move to closed without at least one fix photograph and a named verifier; NCRs cannot close without a documented corrective action.
Where to check it yourself
  • · db/013, db/030, db/031, db/063, db/078 (the stewardship exemption)
  • · test/enforcement.test.mjs, test/stress.test.mjs, test/moat.test.mjs
  • · The tour's open check: try to close it

These are files in our codebase. If you’re a customer under agreement, we’ll walk you through any of them.