# Container lifecycle

> Move a PrismPM holo container through its Docker life. A holo that fails its check never runs, and a running one is never removed.

Inspired by UOR-Foundation/PrismPM (https://github.com/UOR-Foundation/PrismPM). PrismPM compiles Prism models into verified artifacts and runs holos as Docker-style containers. Pattern: State machine, OMG UML 2.5.1 behavioral state machine. To write one of your own, follow How to build a state machine app (../../guides/state-machine/index.md). The prompt below is data, quoted from the example.

**Figure: The Container lifecycle state machine.** Each box is a state and each arrow a step a rule can take. A run starts at created and stops at removed. Dashed arrows go back to an earlier state.

| From | Link | To |
| --- | --- | --- |
| created | REQ-009 | running |
| created | 2 rules | removed |
| created | REQ-008 | exited |
| created | otherwise | created |
| running | 2 rules | running |
| running | REQ-004 | removed |
| running | REQ-005 | exited |
| exited | REQ-009 | running |
| exited | 2 rules | removed |
| exited | 2 rules | exited |
| removed | REQ-001 | removed |

Verified by prismpm verify in the pinned SDK. Fingerprint: 7bddbb400ee6635320af130bee673eb3041114853e4c365156cd69de43e97601. Acceptance vectors: 44. Claims: 9.

## The prompt

```json
{
  "schema": "prism/prompt/1",
  "pattern": "stateMachine",
  "machine": {
    "state": "state",
    "initial": "created",
    "final": [
      "removed"
    ]
  },
  "goal": "Move a PrismPM holo container through its Docker life. A holo that fails its check never runs, and a running one is never removed.",
  "repository": "UOR-Foundation/PrismPM",
  "app": {
    "name": "prismpm-container-lifecycle",
    "title": "Container lifecycle",
    "purpose": "Give the next state of a prism.containers container from its state, the event (start, finish or remove), the check verdict, whether allowUnverified was given and whether it was created with rm.",
    "limits": [
      "It does not open the image: a holo that cannot be opened makes no container, and create rejects.",
      "It does not model a container read back from its store, which cannot be started again because the store keeps no input.",
      "Exit codes are not states; the EXIT_CODES table gives them."
    ],
    "fields": [
      {
        "name": "state",
        "kind": "choice",
        "values": [
          "created",
          "running",
          "exited",
          "removed"
        ],
        "means": "the container's state.status, or removed once its record is dropped"
      },
      {
        "name": "event",
        "kind": "choice",
        "values": [
          "start",
          "finish",
          "remove"
        ],
        "means": "start(), the guest returning or throwing (finish), or remove()"
      },
      {
        "name": "verdict",
        "kind": "choice",
        "values": [
          "passed",
          "refused"
        ],
        "means": "whether check passed the holo under the container's policy"
      },
      {
        "name": "unverified",
        "kind": "choice",
        "values": [
          "allowed",
          "denied"
        ],
        "means": "whether the container was created with allowUnverified"
      },
      {
        "name": "rm",
        "kind": "choice",
        "values": [
          "yes",
          "no"
        ],
        "means": "whether the container was created with rm: true (--rm)"
      }
    ],
    "outcomes": [
      "created",
      "running",
      "exited",
      "removed"
    ],
    "meanings": {
      "created": "create opened the image; the guest has not run",
      "running": "check passed, or allowUnverified, and the guest is running; startedAt is set",
      "exited": "the run is over: the guest returned or threw, or check refused the holo and startedAt stays null",
      "removed": "the record is dropped; inspect and remove reject with container.missing"
    },
    "rules": [
      {
        "when": [
          {
            "field": "state",
            "op": "is",
            "value": "removed"
          }
        ],
        "then": "removed",
        "why": "sdk/npm/prism-code/src/containers.mjs: every call on a removed container fails container.missing"
      },
      {
        "when": [
          {
            "field": "state",
            "op": "is",
            "value": "running"
          },
          {
            "field": "event",
            "op": "is",
            "value": "start"
          }
        ],
        "then": "running",
        "why": "containers.mjs start: a second call while it runs joins that run (inFlight)"
      },
      {
        "when": [
          {
            "field": "state",
            "op": "is",
            "value": "running"
          },
          {
            "field": "event",
            "op": "is",
            "value": "remove"
          }
        ],
        "then": "running",
        "why": "containers.mjs remove: a running container is refused with container.running, as Docker refuses it"
      },
      {
        "when": [
          {
            "field": "state",
            "op": "is",
            "value": "running"
          },
          {
            "field": "event",
            "op": "is",
            "value": "finish"
          },
          {
            "field": "rm",
            "op": "is",
            "value": "yes"
          }
        ],
        "then": "removed",
        "why": "containers.mjs exit: rm removes the container on exit whatever its code"
      },
      {
        "when": [
          {
            "field": "state",
            "op": "is",
            "value": "running"
          },
          {
            "field": "event",
            "op": "is",
            "value": "finish"
          }
        ],
        "then": "exited",
        "why": "proposal 348: running to exited when the guest returned or threw"
      },
      {
        "when": [
          {
            "field": "event",
            "op": "is",
            "value": "remove"
          }
        ],
        "then": "removed",
        "why": "containers.mjs remove: a created or exited container is dropped from its store"
      },
      {
        "when": [
          {
            "field": "event",
            "op": "is",
            "value": "start"
          },
          {
            "field": "verdict",
            "op": "is",
            "value": "refused"
          },
          {
            "field": "unverified",
            "op": "is",
            "value": "denied"
          },
          {
            "field": "rm",
            "op": "is",
            "value": "yes"
          }
        ],
        "then": "removed",
        "why": "containers.mjs run: a refused holo exits at once, and rm then drops it"
      },
      {
        "when": [
          {
            "field": "event",
            "op": "is",
            "value": "start"
          },
          {
            "field": "verdict",
            "op": "is",
            "value": "refused"
          },
          {
            "field": "unverified",
            "op": "is",
            "value": "denied"
          }
        ],
        "then": "exited",
        "why": "proposal 348: created to exited when check refused the holo; the guest never ran"
      },
      {
        "when": [
          {
            "field": "event",
            "op": "is",
            "value": "start"
          }
        ],
        "then": "running",
        "why": "proposal 348: created or exited to running when check passed or allowUnverified, as docker start runs it again"
      },
      {
        "when": [
          {
            "field": "state",
            "op": "is",
            "value": "exited"
          }
        ],
        "then": "exited",
        "why": "an exited container has no guest to finish"
      }
    ],
    "otherwise": "created",
    "otherwiseWhy": "a created container has not started, so no guest can finish",
    "properties": [
      {
        "kind": "never",
        "when": [
          {
            "field": "state",
            "op": "is",
            "value": "created"
          },
          {
            "field": "event",
            "op": "is",
            "value": "start"
          },
          {
            "field": "verdict",
            "op": "is",
            "value": "refused"
          },
          {
            "field": "unverified",
            "op": "is",
            "value": "denied"
          }
        ],
        "then": "running",
        "why": "issue 282: run is gated on check, so a refused holo never runs without allowUnverified"
      },
      {
        "kind": "never",
        "when": [
          {
            "field": "state",
            "op": "is",
            "value": "exited"
          },
          {
            "field": "event",
            "op": "is",
            "value": "start"
          },
          {
            "field": "verdict",
            "op": "is",
            "value": "refused"
          },
          {
            "field": "unverified",
            "op": "is",
            "value": "denied"
          }
        ],
        "then": "running",
        "why": "a start again is gated on check as the first start is"
      },
      {
        "kind": "never",
        "when": [
          {
            "field": "state",
            "op": "is",
            "value": "running"
          },
          {
            "field": "event",
            "op": "is",
            "value": "remove"
          }
        ],
        "then": "removed",
        "why": "a running container cannot be removed without force"
      },
      {
        "kind": "never",
        "when": [
          {
            "field": "state",
            "op": "is",
            "value": "running"
          },
          {
            "field": "event",
            "op": "is",
            "value": "finish"
          },
          {
            "field": "rm",
            "op": "is",
            "value": "yes"
          }
        ],
        "then": "exited",
        "why": "with rm, the record does not outlive the run"
      },
      {
        "kind": "never",
        "when": [
          {
            "field": "state",
            "op": "is",
            "value": "created"
          },
          {
            "field": "event",
            "op": "is",
            "value": "finish"
          }
        ],
        "then": "running",
        "why": "only start runs a guest"
      }
    ],
    "examples": [
      {
        "request": "created start passed denied no",
        "response": "running"
      },
      {
        "request": "created start refused denied no",
        "response": "exited"
      },
      {
        "request": "created start refused allowed no",
        "response": "running"
      },
      {
        "request": "running finish passed denied no",
        "response": "exited"
      },
      {
        "request": "running finish passed denied yes",
        "response": "removed"
      },
      {
        "request": "running remove passed denied no",
        "response": "running"
      },
      {
        "request": "exited start passed denied no",
        "response": "running"
      },
      {
        "request": "exited remove passed denied no",
        "response": "removed"
      },
      {
        "request": "removed start passed denied no",
        "response": "removed"
      },
      {
        "request": "created start passed",
        "response": "invalid"
      }
    ]
  },
  "stakeholders": [
    {
      "name": "Holo developer",
      "text": "Runs holos through prism.containers or prism-code run and needs each container's state to say what happened to the guest.",
      "concerns": [
        "Correct answers",
        "Proved guarantees"
      ]
    },
    {
      "name": "Holo operator",
      "text": "Runs holos from others and needs a holo that check refuses never to reach the guest unless they said allowUnverified.",
      "concerns": [
        "Refused holos never run",
        "Integrity of the published app"
      ]
    }
  ],
  "concerns": [
    {
      "name": "Refused holos never run",
      "text": "A container whose holo check refuses moves to exited with startedAt null unless allowUnverified was given.",
      "model": "security"
    }
  ],
  "components": [
    {
      "name": "prism-code SDK",
      "text": "The npm package prism-code in PrismPM sdk/npm, whose containers namespace has run, create, start, get and remove.",
      "kind": "service"
    },
    {
      "name": "Container store",
      "text": "fileContainerStore: one JSON record per container in PRISM_HOME/containers, mode 0600, written by rename.",
      "kind": "database"
    },
    {
      "name": "prism-code CLI",
      "text": "prism-code run, inspect and rm: the same lifecycle with the record on disk.",
      "kind": "cliAdapter"
    }
  ],
  "threats": [
    {
      "name": "Refused holo runs",
      "text": "A holo whose check fails reaches the guest, so unverified code runs.",
      "stride": "elevationOfPrivilege",
      "asset": "holo",
      "likelihood": "medium",
      "impact": "critical",
      "control": {
        "name": "Run gated on check",
        "text": "A start with a refused verdict and no allowUnverified never answers running, proved for every request.",
        "evidence": [
          {
            "kind": "proof",
            "reference": "PrismpmContainerLifecycleProofs::inv001Holds"
          },
          {
            "kind": "gate",
            "reference": "PrismPM sdk/npm/prism-code/test/containers.test.mjs"
          }
        ]
      }
    },
    {
      "name": "Removed container revived",
      "text": "A start on a removed container runs it again from an input the store no longer holds.",
      "stride": "tampering",
      "asset": "answer",
      "likelihood": "low",
      "impact": "major",
      "control": {
        "name": "Removed is final",
        "text": "removed is a final state: every step keeps it, as every call rejects container.missing.",
        "evidence": [
          {
            "kind": "proof",
            "reference": "PrismpmContainerLifecycleProofs::inv006Holds"
          }
        ]
      }
    },
    {
      "name": "Stale running record",
      "text": "A process that dies mid-run leaves a record that says running, and nothing acts on it yet.",
      "stride": "denialOfService",
      "asset": "answer",
      "likelihood": "medium",
      "impact": "minor",
      "accepted": "Proposal 348 leaves it to issue 350, whose ps has to account for a record left running."
    }
  ],
  "quality": [
    {
      "characteristic": "Security",
      "subcharacteristic": "Resistance",
      "requirement": "No refused holo runs",
      "text": "No start of a refused holo without allowUnverified answers running.",
      "measure": "Unverified runs",
      "measureText": "Acceptance vectors answered running from a start with verdict refused and unverified denied.",
      "threshold": 0
    },
    {
      "characteristic": "Functional suitability",
      "subcharacteristic": "Functional correctness",
      "requirement": "Every transition matches proposal 348",
      "text": "Each vector answers the state containers.mjs leaves the container in.",
      "measure": "Vectors that disagree",
      "measureText": "Acceptance vectors whose replayed state differs from the expected one.",
      "threshold": 0
    }
  ],
  "journeys": [
    {
      "stakeholder": "Holo developer",
      "steps": [
        "REQ-009",
        "REQ-005",
        "REQ-002",
        "REQ-006",
        "INV-006"
      ]
    },
    {
      "stakeholder": "Holo operator",
      "steps": [
        "REQ-008",
        "INV-001",
        "REQ-004",
        "refuse"
      ]
    }
  ],
  "axioms": {
    "inv001Holds": [
      "Classical.choice",
      "Quot.sound",
      "propext"
    ],
    "inv002Holds": [
      "Classical.choice",
      "Quot.sound",
      "propext"
    ],
    "inv003Holds": [
      "Classical.choice",
      "Quot.sound",
      "propext"
    ],
    "inv004Holds": [
      "Classical.choice",
      "Quot.sound",
      "propext"
    ],
    "inv006Holds": [
      "Classical.choice",
      "Quot.sound",
      "propext"
    ]
  },
  "license": "MIT OR Apache-2.0"
}
```

## Claims

- PC-01: The app never answers running when state is created and event is start and verdict is refused and unverified is denied
- PC-02: The app never answers running when state is exited and event is start and verdict is refused and unverified is denied
- PC-03: The app never answers removed when state is running and event is remove
- PC-04: The app never answers exited when state is running and event is finish and rm is yes
- PC-05: The app never answers running when state is created and event is finish
- PC-06: The app always answers removed when state is removed
- PC-07: The architecture description declares every stakeholder, concern, component, edge, viewpoint and view it references
- PC-08: The ISO/IEC 25010 quality model numbers every characteristic, subcharacteristic, requirement and measure, and every parent it names is declared
- PC-09: Every compliance obligation is numbered in order and names its evidence

## Pattern

State machine: OMG UML 2.5.1 behavioral state machine. The answer is the next state, given the current state and an event. This is a UML state machine written as one pure function. The state travels in the request, so the app keeps nothing between requests. The builder proves what holds over every run.

| Pattern | Standard | Answers |
| --- | --- | --- |
| State machine | OMG UML 2.5.1 behavioral state machine | created, running, exited, removed |

**Figure: Rules for each answer.** Each bar counts the rules that give one answer. When no rule matches, the answer is created.

|  | rules |
| --- | --- |
| created | 0 |
| running | 3 |
| exited | 3 |
| removed | 4 |

## Behavior

A request is state, event, verdict, unverified, rm, separated by spaces. The first rule that matches decides. If none matches, the answer is created. A request over 136 bytes, or in any other form, is answered invalid.

| Rule | When | Answer | Why |
| --- | --- | --- | --- |
| REQ-001 | state is removed | removed | sdk/npm/prism-code/src/containers.mjs: every call on a removed container fails container.missing |
| REQ-002 | state is running and event is start | running | containers.mjs start: a second call while it runs joins that run (inFlight) |
| REQ-003 | state is running and event is remove | running | containers.mjs remove: a running container is refused with container.running, as Docker refuses it |
| REQ-004 | state is running and event is finish and rm is yes | removed | containers.mjs exit: rm removes the container on exit whatever its code |
| REQ-005 | state is running and event is finish | exited | proposal 348: running to exited when the guest returned or threw |
| REQ-006 | event is remove | removed | containers.mjs remove: a created or exited container is dropped from its store |
| REQ-007 | event is start and verdict is refused and unverified is denied and rm is yes | removed | containers.mjs run: a refused holo exits at once, and rm then drops it |
| REQ-008 | event is start and verdict is refused and unverified is denied | exited | proposal 348: created to exited when check refused the holo; the guest never ran |
| REQ-009 | event is start | running | proposal 348: created or exited to running when check passed or allowUnverified, as docker start runs it again |
| REQ-010 | state is exited | exited | an exited container has no guest to finish |
| otherwise | no rule matches | created | a created container has not started, so no guest can finish |

## State machine

The state is state, and the answer is the next state. A run feeds each answer back in as the next state, starting from created (OMG UML 2.5.1, clause 14). All 96 requests of the spec's sample were stepped to find the states a run can reach. The invariants are INV-006. Each holds for one step, so by induction it holds over every run.

| State | Kind | Meaning |
| --- | --- | --- |
| created | initial, reachable | create opened the image; the guest has not run |
| running | reachable | check passed, or allowUnverified, and the guest is running; startedAt is set |
| exited | reachable | the run is over: the guest returned or threw, or check refused the holo and startedAt stays null |
| removed | final, reachable | the record is dropped; inspect and remove reject with container.missing |

## Transitions

Every step a reachable state can take, and the rule that takes it.

| From | To | By |
| --- | --- | --- |
| created | running | REQ-009 |
| created | removed | REQ-006 |
| created | removed | REQ-007 |
| created | exited | REQ-008 |
| created | created | otherwise |
| running | running | REQ-002 |
| running | running | REQ-003 |
| running | removed | REQ-004 |
| running | exited | REQ-005 |
| exited | running | REQ-009 |
| exited | removed | REQ-006 |
| exited | removed | REQ-007 |
| exited | exited | REQ-008 |
| exited | exited | REQ-010 |
| removed | removed | REQ-001 |

## Properties Lean proves

Each property is a theorem about the same definitions the app is built from. It is proved for every request, not only the tested ones.

| Property | Statement | Theorem | Why |
| --- | --- | --- | --- |
| INV-001 | It never answers running when state is created and event is start and verdict is refused and unverified is denied. | PrismpmContainerLifecycleProofs::inv001Holds | issue 282: run is gated on check, so a refused holo never runs without allowUnverified |
| INV-002 | It never answers running when state is exited and event is start and verdict is refused and unverified is denied. | PrismpmContainerLifecycleProofs::inv002Holds | a start again is gated on check as the first start is |
| INV-003 | It never answers removed when state is running and event is remove. | PrismpmContainerLifecycleProofs::inv003Holds | a running container cannot be removed without force |
| INV-004 | It never answers exited when state is running and event is finish and rm is yes. | PrismpmContainerLifecycleProofs::inv004Holds | with rm, the record does not outlive the run |
| INV-005 | It never answers running when state is created and event is finish. | PrismpmContainerLifecycleProofs::inv005Holds | only start runs a guest |
| INV-006 | It always answers removed when state is removed. | PrismpmContainerLifecycleProofs::inv006Holds | removed is a final state (UML 2.5.1 FinalState): a run that reaches it stays there |

## Architecture

Stakeholders and the concerns each one views the app through (ISO/IEC/IEEE 42010).

| Stakeholder | Who they are | Concerns |
| --- | --- | --- |
| Holo developer | Runs holos through prism.containers or prism-code run and needs each container's state to say what happened to the guest. | Correct answers, Proved guarantees |
| Holo operator | Runs holos from others and needs a holo that check refuses never to reach the guest unless they said allowUnverified. | Refused holos never run, Integrity of the published app |
| Verifier | Anyone who loads the holo, checks its fingerprint and replays its acceptance vectors before trusting an answer. | Integrity of the published app, Refused malformed requests, Proved guarantees |

## Concerns

What the stakeholders care about, and the model each is viewed in.

| Concern | What it means | Model |
| --- | --- | --- |
| Correct answers | Every well-formed request is answered by the first rule that matches it, or created when none does, as the spec states. | quality |
| Integrity of the published app | What a visitor runs is the holo the build verified, with its fingerprint and signed provenance beside it. | security |
| Proved guarantees | Each of the 6 properties of the spec holds for every request, proved by the Lean kernel. | quality |
| Refused holos never run | A container whose holo check refuses moves to exited with startedAt null unless allowUnverified was given. | security |
| Refused malformed requests | A request that is not the 5 fields in order, or is longer than 136 bytes, is answered invalid and never guessed. | security |

## Components

9 components and 13 edges between them.

| Component | Kind | What it is |
| --- | --- | --- |
| Browser | externalSystem | The visitor's web browser, which loads the page and runs the Container lifecycle guest. |
| Container lifecycle guest | service | The Core-Wasm guest built from the model: it answers one request of at most 136 bytes with one answer of at most 64. |
| Container lifecycle page | staticSite | The page the template publishes: the holo, its fingerprint, its provenance and its acceptance vectors. |
| Container store | database | fileContainerStore: one JSON record per container in PRISM\_HOME/containers, mode 0600, written by rename. |
| GitHub Pages | externalSystem | Serves the page and the holo from the repository Pages workflow. |
| Prism build | cliAdapter | prismpm verify in the SDK image prismpm.lock pins: it checks every theorem, builds the guest and replays every vector. |
| prism-code CLI | cliAdapter | prism-code run, inspect and rm: the same lifecycle with the record on disk. |
| prism-code SDK | service | The npm package prism-code in PrismPM sdk/npm, whose containers namespace has run, create, start, get and remove. |
| Source repository | externalSystem | The repository that holds the prompt, the model and its gate. |

## Design views

The SDK checks each view against the system model and draws it as OPL and PlantUML.

| View | Diagram | Viewpoint |
| --- | --- | --- |
| Deciding a Container lifecycle request | opmObjectProcess | Holo developer: Correct answers |
| Components of Container lifecycle | umlComponent | Holo operator: Integrity of the published app |
| Answering a Container lifecycle request | umlSequence | Holo developer: Correct answers |
| States of the Container lifecycle guest | umlStateMachine | Verifier: Refused malformed requests |
| The Container lifecycle state machine | umlStateMachine | Holo developer: Correct answers |

## Features and journeys

18 features. Each names the definitions that do the work and the tests that accept it. Each stakeholder has one journey.

| Feature | Calls | Accepted by |
| --- | --- | --- |
| When state is removed, the answer is removed. | PrismpmContainerLifecycle::rule1, PrismpmContainerLifecycle::judge | PrismpmContainerLifecycle::application |
| When state is running and event is start, the answer is running. | PrismpmContainerLifecycle::rule2, PrismpmContainerLifecycle::judge | PrismpmContainerLifecycle::application |
| When state is running and event is remove, the answer is running. | PrismpmContainerLifecycle::rule3, PrismpmContainerLifecycle::judge | PrismpmContainerLifecycle::application |
| When state is running and event is finish and rm is yes, the answer is removed. | PrismpmContainerLifecycle::rule4, PrismpmContainerLifecycle::judge | PrismpmContainerLifecycle::application |
| When state is running and event is finish, the answer is exited. | PrismpmContainerLifecycle::rule5, PrismpmContainerLifecycle::judge | PrismpmContainerLifecycle::application |
| When event is remove, the answer is removed. | PrismpmContainerLifecycle::rule6, PrismpmContainerLifecycle::judge | PrismpmContainerLifecycle::application |
| When event is start and verdict is refused and unverified is denied and rm is yes, the answer is removed. | PrismpmContainerLifecycle::rule7, PrismpmContainerLifecycle::judge | PrismpmContainerLifecycle::application |
| When event is start and verdict is refused and unverified is denied, the answer is exited. | PrismpmContainerLifecycle::rule8, PrismpmContainerLifecycle::judge | PrismpmContainerLifecycle::application |
| When event is start, the answer is running. | PrismpmContainerLifecycle::rule9, PrismpmContainerLifecycle::judge | PrismpmContainerLifecycle::application |
| When state is exited, the answer is exited. | PrismpmContainerLifecycle::rule10, PrismpmContainerLifecycle::judge | PrismpmContainerLifecycle::application |
| When no rule matches, the answer is created. | PrismpmContainerLifecycle::judge | PrismpmContainerLifecycle::application |
| A request that is not state, event, verdict, unverified, rm in order, separated by single spaces, or is over 136 bytes, is answered invalid. | PrismpmContainerLifecycle::dispatch, PrismpmContainerLifecycle::decodeField1 | PrismpmContainerLifecycle::application |
| It never answers running when state is created and event is start and verdict is refused and unverified is denied. | PrismpmContainerLifecycle::judge | PrismpmContainerLifecycleProofs::inv001Holds |
| It never answers running when state is exited and event is start and verdict is refused and unverified is denied. | PrismpmContainerLifecycle::judge | PrismpmContainerLifecycleProofs::inv002Holds |
| It never answers removed when state is running and event is remove. | PrismpmContainerLifecycle::judge | PrismpmContainerLifecycleProofs::inv003Holds |
| It never answers exited when state is running and event is finish and rm is yes. | PrismpmContainerLifecycle::judge | PrismpmContainerLifecycleProofs::inv004Holds |
| It never answers running when state is created and event is finish. | PrismpmContainerLifecycle::judge | PrismpmContainerLifecycleProofs::inv005Holds |
| It always answers removed when state is removed. | PrismpmContainerLifecycle::judge | PrismpmContainerLifecycleProofs::inv006Holds |

## Journeys

The ordered features each stakeholder takes.

| Stakeholder | Steps |
| --- | --- |
| Holo developer | REQ-009 → REQ-005 → REQ-002 → REQ-006 → INV-006 |
| Holo operator | REQ-008 → INV-001 → REQ-004 → refuse |
| Verifier | refuse → INV-001 → INV-002 → INV-003 → INV-004 → INV-005 → INV-006 |

## Security and threat model

15 threats against 4 assets. Each has a STRIDE category, and either a control with evidence or a risk that is accepted on purpose.

| Threat | STRIDE | Asset | Risk | Answered by |
| --- | --- | --- | --- | --- |
| Answer that breaks INV-001 | repudiation | Answer | medium likelihood, critical impact | Proof of INV-001: proof PrismpmContainerLifecycleProofs::inv001Holds |
| Answer that breaks INV-002 | repudiation | Answer | medium likelihood, critical impact | Proof of INV-002: proof PrismpmContainerLifecycleProofs::inv002Holds |
| Answer that breaks INV-003 | repudiation | Answer | medium likelihood, critical impact | Proof of INV-003: proof PrismpmContainerLifecycleProofs::inv003Holds |
| Answer that breaks INV-004 | repudiation | Answer | medium likelihood, critical impact | Proof of INV-004: proof PrismpmContainerLifecycleProofs::inv004Holds |
| Answer that breaks INV-005 | repudiation | Answer | medium likelihood, critical impact | Proof of INV-005: proof PrismpmContainerLifecycleProofs::inv005Holds |
| Answer that breaks INV-006 | repudiation | Answer | medium likelihood, critical impact | Proof of INV-006: proof PrismpmContainerLifecycleProofs::inv006Holds |
| Granted capability | informationDisclosure | Answer | low likelihood, major impact | No capability granted: gate prism-code check refuses an ungranted guest import |
| Malformed request | tampering | Request bytes | high likelihood, major impact | Strict decoder: gate malformed-request acceptance vectors, replayed in the compiled guest by prismpm verify |
| Oversized request | denialOfService | Request bytes | medium likelihood, minor impact | Bounded request: gate acceptance vectors at the request bound, one byte over it, and at the guest allocation bound, replayed by prismpm verify |
| Refused holo runs | elevationOfPrivilege | Published holo | medium likelihood, critical impact | Run gated on check: proof PrismpmContainerLifecycleProofs::inv001Holds; gate PrismPM sdk/npm/prism-code/test/containers.test.mjs |
| Removed container revived | tampering | Answer | low likelihood, major impact | Removed is final: proof PrismpmContainerLifecycleProofs::inv006Holds |
| Stale running record | denialOfService | Answer | medium likelihood, minor impact | accepted: Proposal 348 leaves it to issue 350, whose ps has to account for a record left running. |
| Substituted holo | spoofing | Published holo | low likelihood, critical impact | Fingerprint and provenance: gate actions/attest-build-provenance in the pages workflow; gate prism-code check of the holo identities in the page |
| Substituted host | spoofing | Published holo | low likelihood, critical impact | accepted: A page cannot defend against its own host. The holo carries signed build provenance a visitor can check, and the app can be rebuilt from its prompt. |
| Tampered model | tampering | Model source | low likelihood, major impact | Regenerated from the prompt: gate prismpm verify in the SDK image prismpm.lock pins; review app/prompt.json |

## Quality

ISO/IEC 25010:2023 requirements. Each has a measure and a threshold that a theorem pins.

| Requirement | Characteristic | Measure | Threshold |
| --- | --- | --- | --- |
| Bounded allocation: The guest allocates at most 272 bytes for one request. | Performance efficiency: Resource utilization | Guest allocation bytes | 272 |
| Bounded request: A request over 136 bytes is refused before any field is read. | Performance efficiency: Time behaviour | Request bytes read | 136 |
| Every property proved: All 6 properties are theorems the Lean kernel checks. | Security: Integrity | Unproved properties | 0 |
| Every request answered: Every request gets an answer: a rule, created otherwise, or invalid. | Functional suitability: Functional completeness | Unanswered requests | 0 |
| Every transition matches proposal 348: Each vector answers the state containers.mjs leaves the container in. | Functional suitability: Functional correctness | Vectors that disagree | 0 |
| Every vector replays: All 44 acceptance vectors replay in the compiled guest, the shortest 0 bytes long. | Reliability: Faultlessness | Failed vectors | 0 |
| Examples answered as stated: Every one of the 10 examples of the spec is answered as it states. | Functional suitability: Functional correctness | Example mismatches | 0 |
| No refused holo runs: No start of a refused holo without allowUnverified answers running. | Security: Resistance | Unverified runs | 0 |

## Compliance

One obligation per standard, each naming its evidence.

| Standard | Subject | Evidence |
| --- | --- | --- |
| ISO/IEC/IEEE 42010:2022 | Architecture description | Architecture::architectureDescriptionHolds |
| ISO/PAS 19450:2015 and OMG UML 2.5.1 | Design views | Design::viewOpmDecide, Design::viewUmlComponents, Design::viewUmlRequest, Design::viewUmlStates, Design::viewUmlMachine |
| ISO/IEC 25010:2023 | Product quality | Quality::qualityModelHolds |
| ISO/IEC 27034-1:2011 and ISO/IEC 27005:2022 | Application security and risk | Security::controlSet |
| OMG UML 2.5.1 behavioral state machine | State machine | PrismpmContainerLifecycle::judge, PrismpmContainerLifecycleProofs::inv006Holds |
| OpenSpec | Requirements | PrismpmContainerLifecycle::application |
| SPDX MIT OR Apache-2.0 | Licensing | PrismpmContainerLifecycle::application |

## Rendered design views

Written by the SDK from the design records when it verified the app.

### design/Design.viewOpmDecide.opl

```
View: Design::viewOpmDecide
Title: Deciding a Container lifecycle request
Viewpoint: Architecture::viewpointHoloDeveloperCorrectAnswers
Notation: ISO/PAS 19450:2015 OPM, Prism OPL profile

componentBrowser is an object.
componentContainerLifecycleGuest is an object.
componentContainerLifecycleGuest can be stateDeciding or stateIdle.
processDecide is a process.
processEncodeAnswer is a process.
processJudge is a process.
processParseRequest is a process.
componentContainerLifecycleGuest handles processDecide.
processParseRequest requires componentBrowser.
processEncodeAnswer affects componentBrowser.
processJudge invokes processEncodeAnswer.
processParseRequest invokes processJudge.
processDecide zooms into processParseRequest, processJudge, and processEncodeAnswer, in that sequence.

```

### design/Design.viewUmlComponents.puml

```
@startuml
' UML 2.5.1 component diagram
' view: Design::viewUmlComponents
' viewpoint: Architecture::viewpointHoloOperatorIntegrityOfThePublishedApp
title Components of Container lifecycle
component "componentBrowser" as c0
component "componentContainerLifecycleGuest" as c1
component "componentContainerLifecyclePage" as c2
component "componentContainerStore" as c3
component "componentGitHubPages" as c4
component "componentPrismBuild" as c5
component "componentPrismCodeCLI" as c6
component "componentPrismCodeSDK" as c7
component "componentSourceRepository" as c8
c0 --> c1 : edgeBrowserToContainerLifecycleGuest
c1 --> c0 : edgeContainerLifecycleGuestToBrowser
c1 --> c3 : edgeContainerLifecycleGuestToContainerStore
c1 --> c6 : edgeContainerLifecycleGuestToPrismCodeCLI
c1 --> c7 : edgeContainerLifecycleGuestToPrismCodeSDK
c2 --> c4 : edgeContainerLifecyclePageToGitHubPages
c3 --> c1 : edgeContainerStoreToContainerLifecycleGuest
c4 --> c0 : edgeGitHubPagesToBrowser
c5 --> c1 : edgePrismBuildToContainerLifecycleGuest
c5 --> c2 : edgePrismBuildToContainerLifecyclePage
c6 --> c1 : edgePrismCodeCLIToContainerLifecycleGuest
c7 --> c1 : edgePrismCodeSDKToContainerLifecycleGuest
c8 --> c5 : edgeSourceRepositoryToPrismBuild
@enduml

```

### design/Design.viewUmlMachine.puml

```
@startuml
' UML 2.5.1 state machine diagram
' view: Design::viewUmlMachine
' viewpoint: Architecture::viewpointHoloDeveloperCorrectAnswers
title The Container lifecycle state machine
state "stateMachineCreated" as s0
state "stateMachineExited" as s1
state "stateMachineRemoved" as s2
state "stateMachineRunning" as s3
[*] --> s0
s0 --> s3 : processRule9
s0 --> s2 : processRule6
s0 --> s2 : processRule7
s0 --> s1 : processRule8
s0 --> s0 : processOtherwise
s3 --> s3 : processRule2
s3 --> s3 : processRule3
s3 --> s2 : processRule4
s3 --> s1 : processRule5
s1 --> s3 : processRule9
s1 --> s2 : processRule6
s1 --> s2 : processRule7
s1 --> s1 : processRule8
s1 --> s1 : processRule10
s2 --> s2 : processRule1
@enduml

```

### design/Design.viewUmlRequest.puml

```
@startuml
' UML 2.5.1 sequence diagram
' view: Design::viewUmlRequest
' viewpoint: Architecture::viewpointHoloDeveloperCorrectAnswers
title Answering a Container lifecycle request
participant "componentBrowser" as p0
participant "componentContainerLifecycleGuest" as p1
p0 -> p1 : processDecide
p1 --> p0 : processDecide
@enduml

```

### design/Design.viewUmlStates.puml

```
@startuml
' UML 2.5.1 state machine diagram
' view: Design::viewUmlStates
' viewpoint: Architecture::viewpointVerifierRefusedMalformedRequests
title States of the Container lifecycle guest
state "stateAnsweredCreated" as s0
state "stateAnsweredExited" as s1
state "stateAnsweredRemoved" as s2
state "stateAnsweredRunning" as s3
state "stateDeciding" as s4
state "stateIdle" as s5
state "stateRefused" as s6
[*] --> s5
s5 --> s4 : processParseRequest
s5 --> s6 : processParseRequest
s4 --> s2 : processRule1
s4 --> s3 : processRule2
s4 --> s3 : processRule3
s4 --> s2 : processRule4
s4 --> s1 : processRule5
s4 --> s2 : processRule6
s4 --> s2 : processRule7
s4 --> s1 : processRule8
s4 --> s3 : processRule9
s4 --> s1 : processRule10
s4 --> s0 : processOtherwise
s0 --> s5 : processEncodeAnswer
s3 --> s5 : processEncodeAnswer
s1 --> s5 : processEncodeAnswer
s2 --> s5 : processEncodeAnswer
s6 --> s5 : processEncodeAnswer
@enduml

```

## Prism source

Every file the builder wrote, laid out as a repository created from UOR-Foundation/template; the download prism-prismpm-container-lifecycle.zip has them all.

- app/src/Architecture.lex.tex (434 lines)
- app/src/Compliance.lex.tex (56 lines)
- app/src/Design.lex.tex (843 lines)
- app/src/Features.lex.tex (200 lines)
- app/src/Quality.lex.tex (375 lines)
- app/src/Security.lex.tex (677 lines)
- app/src/PrismpmContainerLifecycle.lex.tex (334 lines)
- app/src/PrismpmContainerLifecycleProofs.lex.tex (315 lines)
- app/lexlean.toml (43 lines)
- app/prompt.json (566 lines)
- model/ids.toml (77 lines)
- features/suites/prismpm\_container\_lifecycle.feature (56 lines)
- crates/conformance/tests/prismpm\_container\_lifecycle.rs (152 lines)
- site/app.json (136 lines)
- openspec/specs/prismpm-container-lifecycle/spec.md (273 lines)
