Uld loadmaster — National Airlines 102, refused at the manifest
On 29 April 2013, National Airlines Flight 102 lifted off from Bagram with five armored vehicles strapped to its main deck. At rotation, at least one 12-tonne MRAP broke loose, slid aft, smashed the jackscrew of the horizontal stabilizer — and the 747 stalled onto the runway, killing all seven crew. The NTSB found the cargo was restrained by a scheme the operator had invented, far below the required tie-down strength, and the load was never properly verified. This loadmaster makes both failures structural: a unit load device's weight ledger refuses any write past the position's certified limit, and the pallet lifecycle has no path onto the aircraft that skips `restraints_verified`. An unverified pallet cannot board — the edge does not exist.
A Soma program from the logistics part of the verified corpus: 111 lines, cells UldLoadmaster, Bagram102. It passes soma check with soma 3.2.4.
How it is built
The cell UldLoadmaster declares 4 signals in its face: add_cargo(uld: String, kg: Int) -> Map, verify_restraints(uld: String) -> Map, board_aircraft(uld: String) -> Map and uld_weight(uld: String) -> Int; keeps 1 memory slot: weight_kg (Map<String, Int>, persistent and consistent) under the invariant weight_kg >= 0 && weight_kg <= 6804. Its state machine pallet starts in building and allows 3 transitions: building -> restraints_verified, restraints_verified -> building and restraints_verified -> aboard. aboard is terminal. Handlers: add_cargo (line 43), verify_restraints (line 58), board_aircraft (line 67) and uld_weight (line 75).
The file also holds 1 test cell (Bagram102) with 17 assertions, run by soma test.
The source
uld_loadmaster.cell
// ============================================================================
// ULD LOADMASTER — National Airlines 102, refused at the manifest
// ============================================================================
//
// On 29 April 2013, National Airlines Flight 102 lifted off from Bagram
// with five armored vehicles strapped to its main deck. At rotation, at
// least one 12-tonne MRAP broke loose, slid aft, smashed the jackscrew
// of the horizontal stabilizer — and the 747 stalled onto the runway,
// killing all seven crew. The NTSB found the cargo was restrained by a
// scheme the operator had invented, far below the required tie-down
// strength, and the load was never properly verified.
//
// This loadmaster makes both failures structural: a unit load device's
// weight ledger refuses any write past the position's certified limit,
// and the pallet lifecycle has no path onto the aircraft that skips
// `restraints_verified`. An unverified pallet cannot board — the edge
// does not exist.
// ============================================================================
cell UldLoadmaster {
face {
signal add_cargo(uld: String, kg: Int) -> Map
signal verify_restraints(uld: String) -> Map
signal board_aircraft(uld: String) -> Map
signal uld_weight(uld: String) -> Int
}
memory {
// PMC pallet on a 747 main-deck position: 6,804 kg max gross
weight_kg: Map<String, Int> [persistent, consistent]
invariant weight_kg >= 0 && weight_kg <= 6804
}
// building -> restraints_verified -> aboard. No shortcut to aboard;
// touching the load voids the verification (back to building).
state pallet {
initial: building
building -> restraints_verified
restraints_verified -> building
restraints_verified -> aboard
}
on add_cargo(uld: String, kg: Int) {
if kg <= 0 { return map("ok", false, "reason", "cargo weight must be positive") }
if get_status(uld) == "aboard" {
return map("ok", false, "reason", "ULD is aboard — load is closed")
}
// adding cargo to a verified pallet voids the verification
if get_status(uld) == "restraints_verified" { transition(uld, "building") }
let cur = weight_kg.get(uld) ?? 0
let w = try { weight_kg.set(uld, cur + kg) }
if w.error != () {
return map("ok", false, "reason", "REFUSED: {cur} + {kg} kg exceeds 6804 kg position limit")
}
return map("ok", true, "uld", uld, "weight_kg", cur + kg)
}
on verify_restraints(uld: String) {
if (weight_kg.get(uld) ?? 0) == 0 {
return map("ok", false, "reason", "empty ULD — nothing to verify")
}
let r = try { transition(uld, "restraints_verified") }
if r.error != () { return map("ok", false, "reason", "{r.error}") }
return map("ok", true, "state", "restraints_verified")
}
on board_aircraft(uld: String) {
let r = try { transition(uld, "aboard") }
if r.error != () {
return map("ok", false, "reason", "restraints not verified: {r.error}")
}
return map("ok", true, "state", "aboard", "weight_kg", weight_kg.get(uld))
}
on uld_weight(uld: String) { return weight_kg.get(uld) ?? 0 }
}
cell test Bagram102 {
rules {
// legal build-up
assert add_cargo("PMC-1", 4000).ok == true
assert add_cargo("PMC-1", 2500).ok == true
assert uld_weight("PMC-1") == 6500
// overweight for the position: the ledger refuses
assert add_cargo("PMC-1", 1000).ok == false
assert uld_weight("PMC-1") == 6500
assert_fails weight_kg.set("PMC-1", 12000)
// THE BAGRAM PATH: boarding without restraint verification.
// building -> aboard does not exist.
assert board_aircraft("PMC-1").ok == false
assert_fails transition("PMC-1", "aboard")
// verified, it boards — and the load is then closed
assert verify_restraints("PMC-1").ok == true
assert board_aircraft("PMC-1").ok == true
assert add_cargo("PMC-1", 10).ok == false
assert_fails transition("PMC-1", "building")
// touching the load AFTER verification voids it
assert add_cargo("PMC-2", 3000).ok == true
assert verify_restraints("PMC-2").ok == true
assert add_cargo("PMC-2", 500).ok == true
assert board_aircraft("PMC-2").ok == false
// an empty pallet cannot be "verified" pro forma
assert verify_restraints("PMC-3").ok == false
}
}What the toolchain says
$ soma check uld_loadmaster.cell
✓ All checks passed.$ soma test uld_loadmaster.cell
test Bagram102 ...
✓ assert add_cargo("PMC-1", 4000).ok == true
✓ assert add_cargo("PMC-1", 2500).ok == true
✓ assert uld_weight("PMC-1") == 6500
✓ assert add_cargo("PMC-1", 1000).ok == false
✓ assert uld_weight("PMC-1") == 6500
✓ assert_fails weight_kg.set("PMC-1", 12000) — raised memory invariant violated on 'weight_kg': weight_kg >= 0 && weight_kg <= 6804 — rejected write of 12000 (key "PMC-1"); the slot is unchanged
✓ assert board_aircraft("PMC-1").ok == false
✓ assert_fails transition("PMC-1", "aboard") — raised invalid transition: building → aboard. Current state: 'building'. Valid targets: [restraints_verified]
✓ assert verify_restraints("PMC-1").ok == true
✓ assert board_aircraft("PMC-1").ok == true
✓ assert add_cargo("PMC-1", 10).ok == false
✓ assert_fails transition("PMC-1", "building") — raised invalid transition: aboard → building. Current state: 'aboard'. Valid targets: []
✓ assert add_cargo("PMC-2", 3000).ok == true
✓ assert verify_restraints("PMC-2").ok == true
✓ assert add_cargo("PMC-2", 500).ok == true
✓ assert board_aircraft("PMC-2").ok == false
✓ assert verify_restraints("PMC-3").ok == false
17 tests: 17 passed, 0 failed$ soma verify uld_loadmaster.cell
Verifying uld_loadmaster.cell...
State machine 'pallet': 3 states, initial 'building'
States: [aboard, building, restraints_verified]
✓ 3 states, 3 transitions
✓ all states reachable from 'building'
✓ terminal states: [aboard]
✓ no deadlocks
✓ liveness: every state can eventually reach a terminal state
✓ think-isolated: CTL safety properties hold regardless of LLM output (3 handlers, 3 literal transitions, 0 dynamic)
✓ termination: all 4 handlers structurally terminate
✓ refinement: handler `add_cargo` ⟶ {restraints_verified → building [if get_status(uld) == "restraints_verified"]}
✓ refinement: handler `verify_restraints` ⟶ {restraints_verified}
✓ refinement: handler `board_aircraft` ⟶ {aboard}
· transition sources: `verify_restraints`, `board_aircraft` call transition(id, target) without declaring the source — the runtime refuses a move the graph forbids, but the proof does not see where the handler starts; `transition(id, from, to)` names the edge (checked by `soma check`, refused at run time from any other state)
UldLoadmaster/invariants:
✓ invariant weight_kg >= 0 — writer 'add_cargo' proven by induction (writes cur + kg)
⚠ invariant weight_kg >= 0 && weight_kg <= 6804 — runtime-checked (computed values): add_cargo → weight_kg [weight_kg <= 6804] because `cur + kg` is only known to lie in [1, ∞) — narrow it: `require (cur + kg) <= 6804 else …`
11 passed, 1 warnings, 0 failures
Temporal properties for 'pallet':
✓ deadlock_free — no deadlocks in any reachable state
Temporal: 1 passed, 0 failed
VERIFY OK