Files
ruflo/v3/@claude-flow/cli/src/missions
ruv b3b6c3469d feat(missions): ADR-406 M0 mission contract and durable storage
Versioned mission schemas (§19.3 MissionRecord exactly, strict inputs with
bounded strings and integer monetary units), the §19.4 transition table as
data with guards (exact-plan authorization, atomic budget reservation
against the ceiling, lease epochs that fence stale executors, verified
evidence bound to plan/criteria/artifact, connectivity loss never counted as
failure), and a reducer that replays a hash-chained append-only log.

Store decision: reuse ruflo's existing authoritative-state pattern (project
files + per-file lock + atomic replace, as the policy ledger, claims and
leases do) rather than optional better-sqlite3 or in-memory sql.js. Events
are one fsynced line each; a torn final line is ignored and truncated by the
next locked writer; the snapshot is a cache that must agree with the log.
Exports the policy runtime's acquireLock (dead-owner detection by pid, pid
namespace and boot id) instead of copying it.

The shared MissionService derives principal/tenant/workspace from the local
context, deduplicates by request id (same input replays, different input is
refused), rejects stale revisions with the current one, and refuses
admit/resume until a durable executor exists. Tests: table exactness,
seeded property tests over random sequences, snapshot+tail == full replay,
torn-tail repair, chain tamper, concurrent create and plan races, and a
SIGKILL of a writer process mid-stream.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-01 22:28:18 -04:00
..