interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core-mv / om / hive-task / README.md

106 lines · 9018 bytes Raw Blame History Source

om/hive-task: forge task transition rules

task.om is the source of truth for the forge task state machine of the hive cockpit (#925, DRA-288, DRA-162). crates/spark-hive/src/store.rs is the host adapter: each mutation is one conditional UPDATE ... RETURNING whose predicate is the rule in task.om, stepped to completion so a failed commit is reported instead of lost. drive.om drives the real spark-cockpit-rs binary over HTTP and checks that the adapter does what the rules say. store.rs and the forge handlers in crates/spark-cockpit-rs/src/main.rs stay host adapters for now; #925 itself tracks moving the store logic into .om (successor: this directory).

Pinned compiler: omega-mv seed omc, sha256 2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f (the omega MCP pin, omega-mv e5b32567; the same pin as om/residency).

Rules (task.om)

States: open, claimed, submitted, verified, failed. Operations: claim, renew (heartbeat), submit, verify, reap (reclaim of expired leases), dberr (classification of a store error), command id.

OperationAllowed fromEffectRefused when
claimopen, failed, claimed with an expired leaseclaimed, generation + 1, new attempt idlive lease (HELD), submitted or verified (BADSTATE), generation at 2^53-1 (EXHAUST), ttl outside 1..86400 (BADTTL, HTTP 400)
renewclaimed by the same attempt and generation, lease not expirednew leaseother attempt or generation (STALE), expired (EXPIRED), other state (BADSTATE), bad ttl (400)
submitsame as renewsubmitted, records branch, pr_url, artifactas renew
verifysubmitted, same generation and artifact digestverified or failed, records verifier and notesother state (BADSTATE), other generation or artifact (MISMATCH)
reapclaimed with an expired leaseopenanything else is left alone
dberrbusy or locked: RETRY (HTTP 503, retryable); anything else: DBFAIL
command idany write that carries command_ida new id proceeds; a known id with the same request digest replays the recorded answer; a known id with another digest is 409 command_conflictan id that is empty, over 128 bytes, or has a byte outside A-Z a-z 0-9 . _ : - (400 invalid)

Only claim changes the generation. A lease is expired when now >= expiry. The default lease is 300 seconds.

Clock after lock (#925 round 4): every write (claim, heartbeat, submit, verify, reclaim, with or without a command id) first takes the SQLite write lock with BEGIN IMMEDIATE, and only then reads now. Expiry checks and the new expiry (now + ttl) use that reading. A request that waited up to the 5 s busy timeout behind another writer is therefore judged at the moment it can write: a claim gets a lease that is live when granted, and a heartbeat or submit whose lease ran out during the wait is refused (409, row unchanged, nothing recorded).

Command ids (#925 acceptance 2, DRA-288 "or a defined idempotent replay"): the digest covers the operation, the task id and every normalized request field. Only an allowed outcome is recorded, in the same BEGIN IMMEDIATE transaction as the change it answers, so a refusal, a 404, a 400, a busy database or a failure is decided again when retried with the same id. A replay changes nothing (a replayed heartbeat does not extend the lease; a replayed reclaim does not sweep again). A replayed answer is the historical receipt of the original request, returned as it was then: the lease, status and generation it shows may have changed since, so a client reads the task to learn its current state.

Order of checks in the adapter: command id shape, then ttl, then the database. A JSON body that does not parse or lacks a required field is 400 {"code":"invalid"}, like every other bad input.

Deployment rules

Running

OMC=<pinned omc>
$OMC < om/hive-task/task.om  > task.bin  && chmod +x task.bin
$OMC < om/hive-task/drive.om > drive.bin && chmod +x drive.bin
./drive.bin MODE ./task.bin COCKPIT SCRATCH om/hive-task $OMC MAIN_COCKPIT

COCKPIT is the spark-cockpit-rs build under test, SCRATCH an empty directory, MAIN_COCKPIT a build of main (used by migrate to make an old-schema database). Every cockpit runs on an ephemeral 127.0.0.1 port outside 18000-18999, with a scratch HOME, HIVE_DB_PATH and a throwaway token; the live cockpit and its database are never touched. Output is one line per check (PASS|FAIL <name> http=<code>) and a SUMMARY line; exit 0 only when nothing failed.

ModeWhat it checks
casestask.om against the 88 hand-written expectations in cases.tsv (including the negative cases).
httpCreate, T1 verify(open), T2 claim(verified), T3 submit(verified), verify bound to generation and artifact, persisted branch/pr_url/artifact/verifier/notes, stale attempt (same agent name, older generation), expired heartbeat and submit (row unchanged), generation exhaustion, ttl bounds (400 invalid), a bad JSON body and a missing field (400 invalid), a held write lock (503 busy, retryable, then the retry is granted), command id replay of claim, heartbeat, submit, verify and reclaim (same body, row unchanged), command conflict (409), id length and byte checks, a refused request decided again, one record per id, a 400-trial race of two cockpit processes on one database file (exactly one grant in every trial; loser codes tallied), one id sent to both processes (replay and conflict), a 40-trial race of one id on both processes (one record, same body), a write lock held for 2 s by another connection while a request with a 1 s lease waits (a claim with and without an id must get a lease still live after the grant; a heartbeat with and without an id and a submit whose lease ran out during the wait must be 409 with the row unchanged; a retry of the refused heartbeat id is 409 again and the id is not recorded), and a rollback-journal database with a held reader (the cockpit must not serve it).
tableCross-check: every relevant (operation, state, generation, attempt, expiry, artifact, verdict) combination, and 60 command id combinations (prior request or none, id shape, same or other request, task open, verified or absent), is set up in a fresh database, sent to the cockpit, and the observed outcome is compared with what task.om decides. Then 29 mutants of task.om (one rule line changed each) are compiled and must each be killed by cases or table.
migrateThe main build creates an old-schema (13 column) database with an open, a claimed and a submitted task; the build under test must migrate it to 21 columns, add forge_commands, keep the claimed lease held, turn the legacy submitted row (no artifact digest) into failed with verified_by = 'migration' so it can be claimed again, and reopen the migrated file unchanged.

Host tools on the test path

These run only in the test driver; neither ships.

Not covered by drive.om