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
aien-sovereign-core-mv / evidence / core925-20261107-r4 / README.md
| 1 | # Core #925 evidence, round 4: clock read after the write lock (DRA-288, DRA-162) |
| 2 | |
| 3 | Host only, 2026-11-07, DGX Spark, every command under `taskset -c 5,6 nice -n 10`, cargo with |
| 4 | `--offline -j2`. Ephemeral 127.0.0.1 ports, scratch HOME and database per run; the live cockpit and |
| 5 | its database were not touched. Runs are from the working tree that became this commit; the |
| 6 | fresh-clone rerun of the commit is kept outside the tree with the PR handoff. |
| 7 | |
| 8 | Round 4 answers the local signed review of `94b08ba6` (MERGE_AFTER_FIX, one blocking finding): claim |
| 9 | and heartbeat read `Utc::now()` and computed the new expiry before the store mutex and `BEGIN |
| 10 | IMMEDIATE`, and the no-id path had no explicit transaction, so its `UPDATE` bound `now` and then |
| 11 | waited in the 5 s busy handler. A 1 s claim that waited 2 s was granted an expired lease, and a |
| 12 | heartbeat renewed a lease that ran out during the wait. |
| 13 | |
| 14 | The fix (`crates/spark-hive/src/store.rs`, `run_command`): every write (claim, heartbeat, submit, |
| 15 | verify, reclaim, with or without a command id) opens one `BEGIN IMMEDIATE` transaction, reads the |
| 16 | clock once the write lock is granted, passes that `now` to the rule, and commits with the error |
| 17 | checked. A replay under a known command id returns the recorded answer before the rule runs and |
| 18 | renews nothing. Round 1 to 3 evidence stays in `evidence/core925-20261107/` and |
| 19 | `evidence/core925-20261107-r3/`. |
| 20 | |
| 21 | Binaries (sha256): |
| 22 | |
| 23 | | Binary | sha256 | |
| 24 | |---|---| |
| 25 | | omc (seed, omega-mv `e5b32567` pin) | `2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f` | |
| 26 | | `task.bin` (om/hive-task/task.om, unchanged) | `cf832002a7f674f859d52b15b476db4ef5434c27e78c1c1f9a797bca57ac5d9f` | |
| 27 | | `drive.bin` (om/hive-task/drive.om) | `49aa026c01aa82e36e9602f19b7189ece707e1f280bf220dc976b67baed1dd55` | |
| 28 | | cockpit branch (`cargo build --offline -j2 -p spark-cockpit-rs`, debug, this tree) | `7d8bb79fc1cd5fbf83ef462c3ce17115e42a3d61093b070eab130609b2cc548c` | |
| 29 | | cockpit `94b08ba6` (round 3, negative control for the lock checks) | `bd8b8a6d1f549071b7893bcc9f58bb7be24f4d3ac9fef361c08eb621f912608a` | |
| 30 | | cockpit main (`9d7b3433`) | `7679ee6a2d7e2d6dedce8a3127550cdc087c57741be4e984ed18109207150682` | |
| 31 | |
| 32 | Each `drive-<mode>-<build>.cmd` holds the exact command, exit code and wall time; `.out` holds the |
| 33 | output. `cargo-test.txt` is `cargo test -p spark-hive -p spark-cockpit-rs`. |
| 34 | |
| 35 | | Run | Result | |
| 36 | |---|---| |
| 37 | | `cases` | 88/88 PASS | |
| 38 | | `http` branch | 58 PASS, 0 FAIL, 0 NOT_RUN | |
| 39 | | `http` 94b08ba6 (negative control) | 53 PASS, 5 FAIL, exit 1: exactly the 5 new lock checks fail | |
| 40 | | `http` main (negative control) | 14 PASS, 44 FAIL, exit 1 | |
| 41 | | `table` branch | 2052 rows, 0 mismatches; 29/29 mutants killed; 31 PASS | |
| 42 | | `table` main | driver error exit 80: main's table has no fence columns, so the rows cannot be seeded (expected) | |
| 43 | | `migrate` branch | 10/10 PASS | |
| 44 | | `migrate` 94b08ba6 | 10/10 PASS (the migration did not change in round 4) | |
| 45 | | `migrate` main (negative control) | 4 PASS, 6 FAIL, exit 1 | |
| 46 | | cargo fmt --check, clippy `-D warnings` (spark-hive, spark-cockpit-rs, all targets) | exit 0, exit 0 | |
| 47 | | cargo test | spark-cockpit-rs 34 passed, spark-hive 24 passed, exit 0 | |
| 48 | |
| 49 | The five new `http` checks (`slock` in `drive.om`). A second connection (`/usr/bin/sqlite3`) |
| 50 | holds `BEGIN IMMEDIATE`; the request is sent; the driver sleeps 2 s, longer than the 1 s ttl and |
| 51 | shorter than the 5 s busy timeout; the lock is released and the reply read. |
| 52 | |
| 53 | | Check | Branch | 94b08ba6 | |
| 54 | |---|---|---| |
| 55 | | `lock_claim_ttl_crossed_lease_live_at_grant`: claim, ttl 1, no id; 200 and `lease_expires_ms` later than SQLite's clock read after the reply | PASS 200 | FAIL 200 with a lease already expired | |
| 56 | | `lock_claim_cmd_ttl_crossed_lease_live_at_grant`: the same with a command id | PASS 200 | FAIL 200, lease expired | |
| 57 | | `lock_heartbeat_expired_while_waiting_refused_row_unchanged`: fresh 1 s claim, then heartbeat ttl 300 under the lock, no id; 409 and the row unchanged | PASS 409 | FAIL 200 (renewed) | |
| 58 | | `lock_heartbeat_cmd_expired_while_waiting_refused_not_recorded`: the same with a command id, then the same id again after release; 409 both times, row unchanged, no `forge_commands` row for the id | PASS 409 | FAIL 200 | |
| 59 | | `lock_submit_expired_while_waiting_refused_row_unchanged`: fresh 1 s claim, then submit under the lock, no id; 409 and the row unchanged | PASS 409 | FAIL 200 | |
| 60 | |
| 61 | The race check is tightened as the review asked: `race_two_cockpits_single_grant` now requires |
| 62 | exactly one grant in each of the 400 trials (`one_grant=400`, so `zero_grant=0` and |
| 63 | `double_grant=0`) besides no other loser code and 400 claimed rows. Branch and 94b08ba6: |
| 64 | `one_grant=400 zero_grant=0 double_grant=0 loser_refused_409=400`. |
| 65 | |
| 66 | Reviewer notes kept: |
| 67 | |
| 68 | - The migration is a coordinated cutover: every old writer stops before the new build opens the |
| 69 | file. The `migrate` driver stops the old cockpit first; mixed old and new writers on one file are |
| 70 | not tested (NOT_RUN by design). |
| 71 | - A replayed answer is the historical receipt of the original request, not the current lease; the |
| 72 | docs say so (`AGENTS.md`, `om/hive-task/README.md`). |
| 73 | |
| 74 | Not covered here: reclaim and verify under a held lock have no dedicated check (reclaim reads the |
| 75 | same post-lock `now`; verify does not use the clock). No rolling upgrade, no GPU, no live service, |
| 76 | no CI (not pushed). |