mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
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>