soma.cell

Pager escalation — no page resolves without a human acknowledging it

In the 2013 Target breach, FireEye flagged the malware and fired alerts to the security team — twice. The alerts were reviewed and dismissed without action; 40 million card numbers walked out during the busiest shopping weeks of the year. The killer pattern is the auto-resolve: an alert that nobody acknowledged quietly disappears from the queue, and the system that paged looks healthy again. In this pager, `resolved` is only reachable from `acked` — there is no triggered -> resolved edge for an auto-close to take, and `soma verify` proves it. An unacknowledged page can only ESCALATE: on-call, then secondary, then the manager — a one-way ladder with no edge pointing down. The unanswered-escalation counter is invariant-capped: past three hops the page cannot be re-escalated into the void, it must be acknowledged at the top of the chain.

A Soma program from the devops part of the verified corpus: 110 lines, cells Pager, PagerTests. It passes soma check with soma 3.2.4.

How it is built

The cell Pager declares 5 signals in its face: page_oncall(p: String) -> Map, escalate_page(p: String) -> Map, acknowledge(p: String) -> Map, resolve(p: String) -> Map and page_state(p: String) -> String; keeps 1 memory slot: hops (Map<String, Int>, persistent and consistent) under the invariant hops >= 0 && hops <= 3. Its state machine page starts in queued and allows 7 transitions: queued -> oncall_paged, oncall_paged -> secondary_paged, secondary_paged -> manager_paged, oncall_paged -> acked, secondary_paged -> acked, manager_paged -> acked and acked -> resolved. resolved is terminal. Handlers: page_oncall (line 48), escalate_page (line 55), acknowledge (line 67), resolve (line 73) and page_state (line 79).

The file also holds 1 test cell (PagerTests) with 12 assertions, run by soma test.

Generated from soma describe on this file.

The source

pager_escalation.cell

// ============================================================================
// PAGER ESCALATION — no page resolves without a human acknowledging it
// ============================================================================
//
// In the 2013 Target breach, FireEye flagged the malware and fired
// alerts to the security team — twice. The alerts were reviewed and
// dismissed without action; 40 million card numbers walked out during
// the busiest shopping weeks of the year. The killer pattern is the
// auto-resolve: an alert that nobody acknowledged quietly disappears
// from the queue, and the system that paged looks healthy again.
//
// In this pager, `resolved` is only reachable from `acked` — there is
// no triggered -> resolved edge for an auto-close to take, and `soma
// verify` proves it. An unacknowledged page can only ESCALATE: on-call,
// then secondary, then the manager — a one-way ladder with no edge
// pointing down. The unanswered-escalation counter is invariant-capped:
// past three hops the page cannot be re-escalated into the void, it
// must be acknowledged at the top of the chain.
// ============================================================================

cell Pager {
    face {
        signal page_oncall(p: String) -> Map
        signal escalate_page(p: String) -> Map
        signal acknowledge(p: String) -> Map
        signal resolve(p: String) -> Map
        signal page_state(p: String) -> String
    }

    memory {
        hops: Map<String, Int> [persistent, consistent]
        invariant hops >= 0 && hops <= 3
    }

    // `resolved` is terminal and has exactly one parent: `acked`.
    // No edge de-escalates, no edge auto-closes.
    state page {
        initial: queued
        queued -> oncall_paged
        oncall_paged -> secondary_paged
        secondary_paged -> manager_paged
        oncall_paged -> acked
        secondary_paged -> acked
        manager_paged -> acked
        acked -> resolved
    }

    on page_oncall(p: String) {
        let r = try { transition(p, "oncall_paged") }
        if r.error != () { return map("ok", false, "reason", "{r.error}") }
        hops.set(p, 1)
        return map("ok", true, "state", "oncall_paged")
    }

    on escalate_page(p: String) {
        let s = get_status(p)
        let next = "secondary_paged"
        if s == "secondary_paged" { next = "manager_paged" }
        let r = try { transition(p, next) }
        if r.error != () { return map("ok", false, "reason", "{r.error}") }
        let n = hops.get(p) ?? 0
        let w = try { hops.set(p, n + 1) }
        if w.error != () { return map("ok", false, "reason", "{w.error}") }
        return map("ok", true, "state", next, "hop", n + 1)
    }

    on acknowledge(p: String) {
        let r = try { transition(p, "acked") }
        if r.error != () { return map("ok", false, "reason", "{r.error}") }
        return map("ok", true, "state", "acked")
    }

    on resolve(p: String) {
        let r = try { transition(p, "resolved") }
        if r.error != () { return map("ok", false, "reason", "{r.error}") }
        return map("ok", true, "state", "resolved")
    }

    on page_state(p: String) {
        return get_status(p)
    }
}

cell test PagerTests {
    rules {
        // THE TARGET MOVE: the alert fires and "resolves itself".
        // There is no path from an unacked page to resolved.
        assert page_oncall("malware-alert").ok == true
        assert_fails transition("malware-alert", "resolved")

        // ignored pages climb — and never climb back down
        assert escalate_page("malware-alert").state == "secondary_paged"
        assert_fails transition("malware-alert", "oncall_paged")
        assert escalate_page("malware-alert").state == "manager_paged"

        // at the top of the chain, the only ways out are human
        assert_fails transition("malware-alert", "resolved")
        assert acknowledge("malware-alert").ok == true
        assert resolve("malware-alert").ok == true

        // resolved is history: the page does not reopen for editing
        assert_fails transition("malware-alert", "acked")
        assert_fails transition("malware-alert", "queued")

        // the hop ledger cannot escalate into the void
        assert_fails hops.set("malware-alert", 4)
        assert_fails hops.set("malware-alert", -1)
    }
}

What the toolchain says

Run on a fresh copy of the program at build time; the outputs are pasted unedited.

$ soma check pager_escalation.cell
✓ All checks passed.
$ soma test pager_escalation.cell
test PagerTests ...
  ✓ assert page_oncall("malware-alert").ok == true
  ✓ assert_fails transition("malware-alert", "resolved") — raised invalid transition: oncall_paged → resolved. Current state: 'oncall_paged'. Valid targets: [secondary_paged, acked]
  ✓ assert escalate_page("malware-alert").state == "secondary_paged"
  ✓ assert_fails transition("malware-alert", "oncall_paged") — raised invalid transition: secondary_paged → oncall_paged. Current state: 'secondary_paged'. Valid targets: [manager_paged, acked]
  ✓ assert escalate_page("malware-alert").state == "manager_paged"
  ✓ assert_fails transition("malware-alert", "resolved") — raised invalid transition: manager_paged → resolved. Current state: 'manager_paged'. Valid targets: [acked]
  ✓ assert acknowledge("malware-alert").ok == true
  ✓ assert resolve("malware-alert").ok == true
  ✓ assert_fails transition("malware-alert", "acked") — raised invalid transition: resolved → acked. Current state: 'resolved'. Valid targets: []
  ✓ assert_fails transition("malware-alert", "queued") — raised invalid transition: resolved → queued. Current state: 'resolved'. Valid targets: []
  ✓ assert_fails hops.set("malware-alert", 4) — raised memory invariant violated on 'hops': hops >= 0 && hops <= 3 — rejected write of 4 (key "malware-alert"); the slot is unchanged
  ✓ assert_fails hops.set("malware-alert", -1) — raised memory invariant violated on 'hops': hops >= 0 && hops <= 3 — rejected write of -1 (key "malware-alert"); the slot is unchanged

12 tests: 12 passed, 0 failed
$ soma verify pager_escalation.cell
Verifying pager_escalation.cell...

State machine 'page': 6 states, initial 'queued'
  States: [acked, manager_paged, oncall_paged, queued, resolved, secondary_paged]

  ✓ 6 states, 7 transitions
  ✓ all states reachable from 'queued'
  ✓ terminal states: [resolved]
  ✓ no deadlocks
  ✓ liveness: every state can eventually reach a terminal state
  ⚠ dynamic transition targets: handler `escalate_page` uses a dynamic (computed) transition target — the state these handlers move to is computed at run time (from input or an LLM answer), so the machine's safety is checked at run time for them, not proven
  ✓ termination: all 5 handlers structurally terminate
  ⚠ refinement (partial — dynamic targets fall back to runtime check): handler `escalate_page` calls transition() with a computed target — which edge it takes is checked at run time (invalid_transition), not proven; write the target as a literal state to have it verified
  ✓ refinement (partial — dynamic targets fall back to runtime check): handler `page_oncall` ⟶ {oncall_paged}
  ✓ refinement (partial — dynamic targets fall back to runtime check): handler `escalate_page` ⟶ <dynamic>
  ✓ refinement (partial — dynamic targets fall back to runtime check): handler `acknowledge` ⟶ {acked}
  ✓ refinement (partial — dynamic targets fall back to runtime check): handler `resolve` ⟶ {resolved}
  · transition sources: `page_oncall`, `acknowledge`, `resolve` 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)

Pager/invariants:

  ✓ invariant hops >= 0 — writer 'escalate_page' proven by induction (writes n + 1)
  ✓ invariant hops >= 0 && hops <= 3 — writer 'page_oncall' proven (writes 1)
  ⚠ invariant hops >= 0 && hops <= 3 — runtime-checked (computed values): escalate_page → hops [hops <= 3] because `n + 1` is only known to lie in [1, 4] — narrow it: `require (n + 1) <= 3 else …`

12 passed, 3 warnings, 0 failures

  Temporal properties for 'page':
  ✓ deadlock_free — no deadlocks in any reachable state
Temporal: 1 passed, 0 failed
VERIFY OK

Builtins used

get_status, map, transition

Source file: /corpus/devops/pager_escalation.cell · examples/corpus/devops/pager_escalation.cell