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