These listings are included from the exact YAML files checked by the laboratory. The first is the introductory register. The second is the governed calibration application. A fragment in a chapter is explanatory; these files are the runnable sources.
01-foundation.yaml
Download runnable 01-foundation.yaml
# Handbook: a small, complete domain before governance is introduced.
adl: "0.6.0"
domain:
name: calibration_intro
version: "1.0.0"
description: "The calibration workshop's first instrument register"
resources:
Instrument:
collection: instruments
description: "An instrument identified by a stable serial number"
object:
id: { type: uuid, primaryKey: true }
serialNumber: { type: string, required: true, unique: true, maxLength: 80 }
name: { type: string, required: true, maxLength: 160 }
permissions:
list: [technician, inspector]
get: [technician, inspector]
create: [technician]
update: [technician]
delete: []
02-calibration.yaml
Download runnable 02-calibration.yaml
# Handbook reference application. Synthetic units and organizational rules.
# Requires the compliance plugin in enforce mode for policy-covered operations.
adl: "0.6.0"
domain:
name: calibration
version: "1.0.0"
description: "A workshop that submits calibration revisions for independent review"
enums:
CalibrationStatus:
description: "The saved candidate's review lifecycle"
values:
draft: { label: "Draft" }
submitted: { label: "Submitted" }
certified: { label: "Certified", final: true }
rejected: { label: "Rejected", final: true }
resources:
Instrument:
collection: instruments
description: "An instrument identified by its serial number"
object:
id: { type: uuid, primaryKey: true }
serialNumber: { type: string, required: true, unique: true, maxLength: 80 }
name: { type: string, required: true, maxLength: 160 }
permissions:
list: [technician, inspector]
get: [technician, inspector]
create: [technician]
update: [technician]
delete: []
CalibrationRecord:
collection: calibrations
description: "One revision of a measurement, with protected review provenance"
object:
id: { type: uuid, primaryKey: true }
instrumentId: { type: uuid, required: true, immutable: true }
revision: { type: integer, required: true, min: 1, default: 1, immutable: true }
offsetMicrounits: { type: integer, required: true, immutable: true }
status: { $ref: "#/enums/CalibrationStatus", default: draft, maxLength: 24 }
submittedBy: { type: string, maxLength: 100 }
approvedBy: { type: string, maxLength: 100 }
relationships:
instrument:
type: belongsTo
target: Instrument
foreignKey: instrumentId
indexes:
- { name: by_instrument, fields: [instrumentId] }
permissions:
list: [technician, inspector]
get: [technician, inspector]
create: [technician]
update: "hasRole('technician') && $record.status == 'draft'"
delete: []
transitions:
submit: [technician]
approve: [inspector]
reject: [inspector]
fields:
status: { write: [admin] }
submittedBy: { write: [admin] }
approvedBy: { write: [admin] }
stateMachine:
field: status
initial: draft
states:
draft:
transitions:
submit:
to: submitted
guards: [technician]
sets: { submittedBy: $user.id }
submitted:
transitions:
approve:
to: certified
guards: [inspector]
guard: "user.id != $record.submittedBy"
sets: { approvedBy: $user.id }
reject:
to: rejected
guards: [inspector]
certified: { final: true }
rejected: { final: true }
policies:
approvalNeedsTraining:
description: "The policy supervisor supplies the review_trained claim"
ops: [transition]
when: "transition == 'approve'"
effect: require
obligations: ["user.claims.review_trained == true"]
error: REVIEW_TRAINING_REQUIRED
record: true
preserveSubmittedRevision:
ops: [update]
when: "record.status != 'draft'"
effect: deny
error: REVIEWED_REVISION_LOCKED
history:
integrity: sha256Chain
immutable: true
events:
submitted:
trigger: transition
transition: submit
capture: [instrumentId, revision, offsetMicrounits, submittedBy]
label: "Submitted calibration revision {revision}"
certified:
trigger: transition
transition: approve
capture: [instrumentId, revision, offsetMicrounits, submittedBy, approvedBy]
label: "Certified calibration revision {revision}"
journeys:
inspectCalibration:
title: "Inspect and certify a submitted calibration"
summary: "Read the submitted revision, then request independent approval"
actor: inspector
inputs:
calibrationId:
type: reference
references: "adl.calibration.calibration.CalibrationRecord"
required: true
inState: [submitted]
steps:
- name: inspect
call:
resource: CalibrationRecord
operation: get
id: $inputs.calibrationId
success: "$response.status == 200"
- name: certify
call:
resource: CalibrationRecord
transition: approve
id: $inputs.calibrationId
success: "$response.data.status == 'certified'"
then: end
outputs:
calibrationId: $inputs.calibrationId