Formal Verification & Assurance

An agent claiming its change works carries zero weight in Selûne. Every assurance tier records exact scope, explicit trusted computing base assumptions, and non-upgradable verdicts—combining SMT verification of MoonBit kernels, Lean 4 inductive proofs of protocol models, bounded finite-instance model checking, and deterministic simulation.

On this page

Four-Layer Assurance Stack

moon prove — 10 / 10 live goals

4/4 queue kernel + 6/6 Ledgerflow kernel obligations proved via Why3 + Z3/CVC5 under both default and prelude_proof_machine_int (0 timeouts).

Machine-Checked

Veil 2.0 Finite-Instance Exhaustive Search — 11,437,544 states

Bounded finite-instance exhaustive exploration of 4,149,597 commit-queue states and 7,287,947 cell-lifecycle states under explicit finite instance bounds (0 violations; Level 1 evidence only).

Evidence (Finite Bounds)

Lean 4.35 Inductive Proofs — 18 / 18 protocol-model goals

Protocol models (7/7 commit-queue incl. inv_all + 11/11 cell-lifecycle unbounded proofs; 0 sorry, 0 SMT trust, 3 standard axioms; Quint→Veil embedding trusted). Code refinement remains open (QueueImplementation).

Machine-Checked (Models)

Live Host Gates (15/15) & 1M DST

15/15 live Linux worktree-cell security/GC gates plus 1,000,000 seeded DST schedules (34/34 ITF traces, 0 violations).

Measured Live Sensitivity Model

Quint 0.35 + Veil 2.0 + Lean 4.35 Protocol Model Proofs

Selûne's two highest-risk distributed protocols—the speculative read-set commit queue (spec/commit_queue.qnt) and the 6-phase worktree cell controller (spec/cell_lifecycle.qnt)—are specified in Quint 0.35.0, embedded into Lean 4.35.0 via Veil 2.0's quint_module (a trusted translation step), and audited by ProofAudit. These theorems verify the protocol models; code-level refinement (QueueImplementation) remains open.

Protocol Specification Bounded Finite-Instance Exhaustive Search (Veil MC) Unbounded Lean 4.35 Model Proofs Core Safety Properties
spec/commit_queue.qnt
spec/commit_queue_proofs.lean
4,149,597 states explored on the configured finite model instance (0 violations, 34.3 s; Level 1 evidence) 7/7 protocol-model proofs (5 safety invariants + inv_all & all_invariants)
0 sorry · 0 SMT trust · propext, Classical.choice, Quot.sound
No broken whole-program head, single-tip batch history soundness (failed prefix never marked passed), read-set match at commit, exact candidate-closure evidence binding, no lost accepted commit, cancelled candidate never publishes.
spec/cell_lifecycle.qnt
spec/cell_lifecycle_proofs.lean
7,287,947 post-hardening states explored under finite mcStateBound instance constants (0 violations, 39.02 s; Level 1 evidence) 11/11 protocol-model proofs (unbounded 5 constants)
0 sorry · 0 SMT trust · propext, Classical.choice, Quot.sound
Private per-cell object isolation, supervisor/collector lease-version fencing, live-lease protection, 4-valued positive process-termination evidence before seal/reclaim, exclusive validation slots, CAS head monotonicity.
# Typecheck, run scenario tests (including negative bug-control witnesses), and verify Lean 4 model proofs via Veil 2.0
quint typecheck spec/commit_queue.qnt
quint test spec/commit_queue_test.qnt
quint verify spec/commit_queue.qnt --backend veil --proofs spec/commit_queue_proofs.lean --invariants inv_all

quint typecheck spec/cell_lifecycle.qnt
quint test spec/cell_lifecycle_test.qnt
quint verify spec/cell_lifecycle.qnt --backend veil --proofs spec/cell_lifecycle_proofs.lean

Native moon prove — 10 / 10 Live Goals (Why3 1.7.2 + Z3 5.3.3 / CVC5 1.4.2)

Pure algorithmic kernels enable proof_enabled = true in moon.pkg and discharge arithmetic and state invariants via MoonBit 1.0 RC1's bundled Why3 backend and host SMT solvers:

  • Queue kernel (libs/queue/proofs/kernel.mbt): 4/4 formal obligations proved under both mathematical and machine-integer preludes, called directly on production paths where preconditions hold.
  • Ledgerflow accounting kernel (beta-app/ledgerflow/packages/ledger/kernel/): 6/6 formal obligations (conservation-of-value and checked Int64 overflow-free balance updates) proved under BOTH default AND prelude_proof_machine_int with 0 timeouts.
  • Honest prover accounting: Validation workers parse explicit named proved obligations (N goals proved with N > 0) rather than trusting exit code 0 alone; missing solvers or timeouts are recorded strictly as unsupported or timeout.
export PATH="$HOME/.moon/bin:$HOME/.local/bin:$PATH" LC_ALL=C TZ=UTC
(cd libs/queue && moon prove proofs)
(cd beta-app/ledgerflow && moon prove packages/ledger/kernel)

1,000,000-Schedule Deterministic Simulation & ITF Trace Conformance

Seeded Fault-Injection DST

Executes 1,000,000 deterministic schedules (25.3M steps, 26.3M invariant checks) injecting concurrent head advances, stale read sets, speculative batch failures, cancellations, cache misses, and lease timeouts under virtual TestClock with 0 invariant violations.

Sensitivity Model

Quint ITF Trace Conformance & Host Gates

Replays exported Quint .itf.json execution traces into CommitQueue::step_quint comparing all 14 projected state variables 1:1 (34/34 traces, 335/335 states, incl. failed-prefix batch witness), alongside 15/15 live Linux worktree-cell host gates.

Measured Live

Exact 10-State Evidence Taxonomy (moonbit-evidence/1)

Enforced simultaneously in schemas/moonbit-evidence.v1.schema.json, schemas/fact_store.sql SQLite triggers, and MoonBit libs/evidence + libs/facts. No process may ever upgrade one status into a stronger one, and evidence records remain immutable (reverts append supersession events rather than mutating or deleting records).

Status Tier Cacheable Operational Semantics
proved Discharged Yes Formal prover (moon prove / Veil / Lean) discharged all named obligations with 0 gaps.
passed Verified Yes Sandboxed compiler check, unit/property test suite, or policy gate passed completely.
timeout Inconclusive Never Hard execution deadline hit; recorded for audit and strictly excluded from cache reuse.
unknown Inconclusive Policy-gated SMT solver returned unknown; cannot satisfy an obligation requiring proved.
unsupported Inconclusive Policy-gated Required solver or capability absent; surfaced honestly instead of faking a pass.
cancelled Inconclusive Never Superseded or cancelled mid-flight; a cancelled candidate can never publish.
failed Rejected Yes Deterministic compilation, test assertion, or policy gate failure.
disproved Rejected Yes Formal specification explicitly refuted.
counterexample Rejected Yes Concrete falsifying input or trace returned by QuickCheck, Quint, or SMT solver.
tool-error Rejected Never Sandbox, runner, or infrastructure failure; never conflated with a pass or a killed mutant.

IOG DrWatt EARS, OpenSpec & MARS Ledgers

Selûne maintains two distinct obligation artifacts—do not conflate their coverage counts:

DrWatt EARS (requirements.json)

18 structured EARS requirements (SEL-001..SEL-012 for platform invariants, SC-001..SC-006 for SelûneCraft E2E), each bound to a specification file, check command, and timeout.

OpenSpec (specifications/)

Normative behavioral specifications (selune-platform.md and selunecraft-e2e.md) defining observable invariants and failure contracts with stable section anchors.

Pre-1.0 vs MARS 1.0 Ledgers

spec/SELUNE.mars is a pre-1.0 (v0.1) platform ledger listing 18/18 source IDs and explicit TCB statements (MOONBIT_TCB, WHY3_SMT_TCB, LEAN_VEIL_TCB); it is not MARS 1.0 syntax. The MARS 1.0 module (mars-next/examples/selune_commit_queue/obligations.mars) currently binds 1/18 requirements (SEL-005, 7/7 model proofs, QueueImplementation open).

# Inspect the 18 EARS requirements and run the MARS 1.0 commit-queue freshness check
python3 -c 'import json; d=json.load(open("requirements.json")); print(len(d["requirements"]), "requirements:", [r["id"] for r in d["requirements"]])'
./bin/selune mars check mars-next/examples/selune_commit_queue/obligations.mars --fresh