interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

fix(authority): read dispatch state inside the acquisition lock

merged ed28f1731d49f023 #685 · opened 2026-10-24 09:02 UTC · closed 2026-11-06 04:06 UTC · merged 2026-11-06 04:06 UTC

Imported from GitHub aien-dev/omega-mv#685, by drakestapleton

Base 1db941627f637312ce60e49872dcdd18b49a54b7 · Head 727eba45ea0b56d15d086246d62a6753dfb82aaa

Merged on GitHub as 2a1e6d29bdec50b29ddf66799086853e5f6c0d1c; reachable from main c7acd2607139eedfabeac16b6042cefe8ede431f (observed 2026-11-18T16:35:47Z)

drakestapleton wrote on 2026-10-24 09:02 UTC

Evidence 2026-10-31 (AuthStack lane, head 727eba45ea0b56d15d086246d62a6753dfb82aaa)

Classification vs main 1db94162 (#970): NOT_CONTAINED. #970 squash-merged fix/security673-qualified (head 03ec4baf, tree 0d4d15a9 == main tree); every commit this stack inherited from it (dd6c4ad7 and earlier) is an ancestor of 03ec4baf and is on main. The stack's own changes are not on main (main seed/authority/dispatch.om still calls readrec before lacq; lock.om lrm returns 0 on unlink failure; no store-exact/store-cleanup/dispatch-order gates on main). Base stays as is (parent not merged). Compiler: seed/out/omc sha256 7a8b84fcc07808a52e6cbb65aa7450c754b3ad62eeddf9ec64cc0edd0938b2de, reproduced by sh seed/omega-from-seed.sh (rc 0, no diff). All runs under taskset -c 6-9,15-19 nice -n 19 ionice -c3, Linux AArch64 host (DGX Spark), repo root as cwd. Helper /tmp/prfix/AuthStack-qual.sh; logs /tmp/prfix/AuthStack-logs/<N>/.

Merged origin/main via a merge commit d1832b80 whose tree is main + this PR's own change (inherited content taken from main, .crumb taken from main and recompiled); README native results commit 727eba45. MEASURED (exit codes):

  • dispatch-order-gate.om: dispatch order checks=3 fails=0, exit 0
  • negative control, dispatch.om from main 1db94162 (pre-acquisition read): FAIL dispatch acquired-record refusal, FAIL dispatch read-error release, FAIL dispatch acquisition-error refusal, exit 1
  • dispatch-gate (37) exit 0; it also passes on the pre-fix source, so only the new regression detects the order
  • lock 5/5, store 77 exit 0
  • build/gate669: exit 0, GATE669 PASS bounded Linux AArch64 execution and independent decoding only
  • crumb verify . : OK 184 current; tests/gates/run.sh zero-disk-secrets exit 0; om-units exit 0 (BLAKE3-PARITY PASS) Defect on main fixed by this PR: main's README says dispatch holds the lock across the read, but main's dispatch.om reads the record before lacq.

NOT_RUN: physical/real concurrent-process reproduction; hosted CI pending at push. NOT_RUN is not PASS. Host AArch64 runs are not hardware qualification.


Verification

PASS: whitespace checks; committed gate sources match the declared component concatenations. Independent parent source review checked the read/acquire ordering, error-release path and expected performed-state refusal (22).

NOT_RUN: native compilation, positive and pre-fix negative controls, full security gate, real concurrent-process reproduction and physical qualification. Editing host is x86_64; no bundled AArch64 executable was run. This draft must not merge before required qualification.

Defect and correction

At a35697e94b5eeb72efadfee6edab7f14344aea43, dispatch reads its durable record before acquiring lacq. Two callers may read ready state and subsequently serialize stale copies, defeating the promised read-check-persist transaction even if the lock excludes correctly.

Acquire first, read second, release on read error. Preserve existing error codes and lock protocol. Add a deterministic handwritten .om acquisition-schedule regression: the test-only acquisition double writes performed state before granting the lock, then production dispatch must refuse it. Additional checks cover protected-read failure release and acquisition failure without release.

Stacked on the existing security development branch, not a replacement for its owner or a main-line qualification claim. Refs #649, #670, #673. Independent stale-lock reclaim, release-error and generation-fencing limitations remain explicitly documented. No runtime ABI, shared compiler, production cutover or historical evidence changes.

Published candidate 708f5378847deeed6c4854b259c7f4f4b3f9ece2; tree 95c94b1a99e69b059bdbb75d58b612a5e239dc32. Source-only review note: evidence/SECURITY-673/dispatch-locked-read/REVIEW.md. No automatic issue closure.

drakestapleton wrote on 2026-10-24 16:02 UTC

Exact-head Spark receipt: real FAIL, not missing-bundle NOT_RUN (2026-10-24 15:50 UTC)

New signed publication a214ddb4f8718a8 contains this PR's bundle: exact unchanged head 346c9ad3d171a19ea3f015773a41ceeb3feac8f1, repository identity github.com/aien-dev/omega, Spark executor, hardware-finished at 15:49:18Z. The hosted exact-head verifier job fetched it and completed at 15:50:58Z with verify-bundle exit 1 (FAIL), not 2 (NOT_RUN) or absent-bundle 404. The signed file has a signature; the hosted verifier used the base-ref trust anchor and reports bundle digest 6898bc1e2c44c18630d81f28151894756f42812c82492d24f455ca8cd517c5db.

Required gate matrix: 52/52 evaluated, 49 PASS, 2 FAIL (OMEGA-M19 GB10, OMEGA-R11-OWN-HOLD host), 1 BLOCKED_OPERATOR (OMEGA-NUMERIC-TRANSC-FULL host). Signed plan is NOT_RUN / UNMAPPED_PATH with 189 unclassified paths (mostly seed/). No whole-PR signed PASS or native authority gate qualification.

Useful differential versus Omega #688: that PR's 15:10Z bundle has the same receipt digests for M19 and R11 failures, while OMEGA-R13-TESTBUILD-HOST is PASS here but FAIL on #688. Receipt reuse does not establish that two independent silicon executions occurred; likewise, differing R13 verdicts do not prove the cause. Obtain the underlying stdout/stderr and actual worker/environment/physics pins to discriminate shared baseline versus head-specific failures. Keep Omega #523 owning M19 silicon gate investigation, #598 owning R11/R13 host gates and #524 plus existing mapping owner on unclassified seed paths; no silent gate waiver or broad pipeline trust modification. This PR owner still owns the dispatch lock/read-order test and its pre-fix negative control.

Merge remains blocked: draft, no independent final-head review, no native compile + positive/pre-fix negative + concurrency evidence, real FAIL gates, operator BLOCKED gate and unmapped paths. A repaired head needs fresh exact-repo/exact-head Spark qualification and independent review. Do not rerun any missing-bundle verification blindly, start another worker, alter reservations or restart Renda/Spark serving.

Fetch it

A git bundle of the pull request's head, 160623 bytes.

curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/ed28f1731d49f023.bundle -o ed28f1731d49f023.bundle
git fetch ed28f1731d49f023.bundle refs/pull/685/head

Raw bundle · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/omega-mv
685
727eba45ea0b56d15d086246d62a6753dfb82aaa
{"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":685,"url":"https://github.com/aien-dev/omega-mv/pull/685","export_sha256":"7319147b350ad908bf0b731068ec3be7b8dee848041dc862f71455e8e4680140","imported_utc":"2026-11-18T16:35:47Z"}

Changes

diff --git a/.crumb b/.crumb
index 39a2131d9..f4ff64d4f 100644
--- a/.crumb
+++ b/.crumb
@@ -48,7 +48,7 @@
         },
         {
           "digest": "00a168ce33f2d6478487effe177276c7013627b49d077fd8c111905f68f32b1b",
-          "last_commit": "d3763c7f2",
+          "last_commit": "1db941627",
           "name": "docs",
           "purpose": "Directory docs. Purpose not yet described by a human."
         },
@@ -66,13 +66,13 @@
         },
         {
           "digest": "622d98bd2dfcae7f3a0caab34e583cb63659a500afb4eb31264e839ce2529dc3",
-          "last_commit": "e1968fe5e",
+          "last_commit": "1db941627",
           "name": "native",
           "purpose": "Handwritten .om units of omega-mv that are not part of the seed ladder: the ORIG-4 shadow adviso"
         },
         {
           "digest": "ef71e3b8758de407b6644ae4d069c6eecea07849c57b7de1ce67ce03386ff2e8",
-          "last_commit": "e1968fe5e",
+          "last_commit": "1db941627",
           "name": "neuralese",
           "purpose": "Bounded untrusted representation envelopes and explicit checked Omega decoding; learned extensio"
         },
@@ -90,13 +90,13 @@
         },
         {
           "digest": "7d8a7c8029dba378d0c59047ad32885348baf084b3ad9dbc06921b6bb490659e",
-          "last_commit": "e1968fe5e",
+          "last_commit": "1db941627",
           "name": "src",
           "purpose": "Directory src. Purpose not yet described by a human."
         },
         {
           "digest": "4e7251847298392c2e24591e45747e2b214c48f66a636063fbd7b3ab32a55a6d",
-          "last_commit": "a370a673e",
+          "last_commit": "d94617177",
           "name": "tests",
           "purpose": "Directory tests. Purpose not yet described by a human."
         },
@@ -108,14 +108,14 @@
         }
       ],
       "children_root": "sha256:4b14d5958f47b6630055cf4a2246a89549620f97b64495ebf50844cac8cae2f9",
-      "compiled_at": "2026-10-31T04:29:18Z",
+      "compiled_at": "2026-10-31T05:01:59Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:dc10325615480d6d9d4f190dd04139cdf3b7d9e4feb0c756998ea7f7469a9e33",
-      "evidence_files": 14989,
-      "evidence_root": "sha256:324e080e7c8c3f9118b579e9a9045a3dc4c1f4e774c128d577635bda41dbd059",
-      "files": 23182,
-      "generated_at_commit": "6aadea5b1b2d91ae91d6db636e96bc2b6df6c393",
-      "source_tree": "sha256:d5f0a03955477b0190f5982d62aac726c0e6df2e3b560f0f6b573b6066408c8b"
+      "digest": "sha256:678687ed84785fb091850b4204c170f88c22dd3a139fa5b7f4be27093354de07",
+      "evidence_files": 14990,
+      "evidence_root": "sha256:7a010491308d7ab9202880df860a370764dfa9ead62c6b728c1f88ca6921967c",
+      "files": 23185,
+      "generated_at_commit": "d1832b802dde96cd051e9765b8ff5c102918dae2",
+      "source_tree": "sha256:9a53c168575784d0ea76fa63d6a4addc22747425041a4f353f58f3b7b3ef3f98"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/evidence/SECURITY-673/dispatch-locked-read/REVIEW.md b/evidence/SECURITY-673/dispatch-locked-read/REVIEW.md
new file mode 100644
index 000000000..cf486ed25
--- /dev/null
+++ b/evidence/SECURITY-673/dispatch-locked-read/REVIEW.md
@@ -0,0 +1,40 @@
+# Dispatcher protected-read correction: source-only candidate
+
+Base: `a35697e94b5eeb72efadfee6edab7f14344aea43`, branch `fix/security673-qualified`.
+Issue scope: #649 / #670, #673 tracker. Review date: 2026-10-24.
+
+## Finding
+
+`seed/authority/dispatch.om` loaded the record before acquiring `lacq`. Two callers can load
+ready state, then acquire the lock in turn and independently pass `actstart` using stale copies.
+Even if the lock implementation supplies mutual exclusion, serializing only check/write does
+not serialize the read-check-write transaction. README and store comments promised the latter.
+This is a source-level schedule argument, not a runtime reproduction or exploitation claim.
+
+## Change
+
+Acquire first, then read. On read failure, call the existing release operation and retain the
+existing read-failure result 70. No compiler/runtime ABI, lock protocol, release owner, or
+production consumer is replaced. Refresh the existing committed dispatch concatenation.
+
+A new seeded `.om` test uses the actual store/action/dispatch code and a lock-acquisition double
+that writes a performed record before acquisition completes. Three named checks cover the
+stale-read refusal, read-error release, and acquisition-error refusal. The double is test-only;
+it is not a second authority or production lock. The gate is a committed source concatenation.
+See `seed/authority/README.md` for qualification and negative-control commands/expectations.
+
+## Verification and limits
+
+- PASS: `git diff --check` (text/whitespace check only).
+- PASS: committed gate sources equal the declared concatenation of component source bytes.
+- NOT_RUN: compiler reconstruction, compilation of either gate, regression execution,
+  pre-fix negative control, existing dispatch gate, full security gate, and independent replay.
+- The editing host is x86_64; bundled compiler programs identify as Linux AArch64 ELF.
+  No bundled compiler or executable was run, and no toolchain was installed.
+- NOT_RUN: native concurrent-process reproduction and physical qualification.
+
+Residual findings are not silently fixed: stale-pid reclaim uses a read/check/unlink sequence
+that can unlink a replacement lock; outcome reconciliation reads generation before reacquisition;
+lock release currently suppresses unlink errors; store readers do not check for trailing bytes.
+The patch makes no general atomic-dispatch, robust-lock, crash durability, or sandbox claim.
+Existing required review, repository judges, compiler integration and release holds remain.
diff --git a/seed/authority/README.md b/seed/authority/README.md
index 4bb356faf..a69a1f3e7 100644
--- a/seed/authority/README.md
+++ b/seed/authority/README.md
@@ -55,3 +55,54 @@ also exercises the lock in its 37-check gate. A failure is a failed check count
 The lock is integrated in the dispatcher, but no production consumer uses this store yet. The C authority/reuse
 sources are deleted only after the `.om` owner has a durable store, dispatch, revocation and budget
 behaviour, and every consumer uses it. A parallel production authority path is not an end state.
+
+## Dispatcher acquisition-order regression
+
+`dispatch-order-gate.om` links the production action, store and dispatch sources with a
+**test-only lock-acquisition schedule** from `dispatch-order-test.om`, rather than `lock.om`.
+The acquisition double writes a performed record before granting the lock. A dispatcher that
+reads before acquiring sees stale ready state and misses the required duplicate refusal (22).
+The other two named assertions require release on a failed protected read (70), and require an
+acquisition error (80) to return without a read or release. No timing or scheduler luck is used.
+This checks dispatcher ordering; it does not qualify pid-lock exclusion, stale-owner recovery,
+revocation fencing, or production concurrent execution.
+
+In a fresh disposable Linux AArch64 checkout, after rebuilding the existing approved compiler:
+
+```sh
+mkdir -p build
+seed/out/omc < seed/authority/dispatch-order-gate.om > build/dispatch-order-gate
+readelf -h build/dispatch-order-gate
+chmod +x build/dispatch-order-gate
+build/dispatch-order-gate
+```
+
+Run each command only after its predecessor succeeds; never execute failed compiler output.
+Expected: `dispatch order checks=3 fails=0`, exit 0. Build/run the existing dispatch gate and
+full security gate separately; this standalone regression is not yet wired into `gate669`.
+The negative control is the same compilation unit with only `dispatch.om` restored to the base
+revision's pre-acquisition read. It must exit 1 and print `FAIL dispatch acquired-record refusal`;
+the pre-acquisition read also fails the other two assertions (no release after a failed read,
+and a read before the acquisition error). A compiler failure, signal, or timeout is INVALID,
+not a passing control.
+
+Committed concatenations are the byte-for-byte sequences below (no extra separators):
+
+- `dispatch-gate.om`: action, store, lock, dispatch, dispatch-test.
+- `dispatch-order-gate.om`: action, store, dispatch, dispatch-order-test.
+
+Native run (2026-10-31, Linux AArch64, seed/out/omc sha256 7a8b84fc, after `sh seed/omega-from-seed.sh`
+reproduced it): positive `dispatch order checks=3 fails=0`, exit 0; negative control with `dispatch.om`
+from main 1db94162 printed all three `FAIL dispatch ...` lines, exit 1. The 37-check `dispatch-gate.om`
+passes on both sources, so it does not detect the read-before-acquire order; this regression does.
+
+## Fixture source correction (2026-10-24)
+
+The dispatcher-order fixture now uses global/text names within the existing
+compiler's eight-character limit and copies its scheduled record into a local
+array before calling `writerec`; global arrays cannot be function arguments.
+These correct known source compilation blockers without changing the test
+scenarios or production sources. Declared concatenated gates are regenerated
+from this revision's own component sources. Source review is not compiler
+acceptance; the native runs are recorded in the section above.
+Historical evidence is unchanged.
diff --git a/seed/authority/dispatch-gate.om b/seed/authority/dispatch-gate.om
index ee9e86d78..62228fbdb 100644
--- a/seed/authority/dispatch-gate.om
+++ b/seed/authority/dispatch-gate.om
@@ -488,14 +488,15 @@ put s add 8 i get r add 8 i
 end
 end
 fn dispatch r edit ulong 32 c view ulong 32 mode uchar to ulong
-err = readrec r
-if ne err 0
-ret 70
-end
 err = lacq get dpid 0 1000
 if ne err 0
 ret 80
 end
+err = readrec r
+if ne err 0
+lk = lrel
+ret 70
+end
 g = readgen
 if ne get sgerr 0 0
 lk = lrel
diff --git a/seed/authority/dispatch-order-gate.om b/seed/authority/dispatch-order-gate.om
new file mode 100644
index 000000000..0e69ced94
--- /dev/null
+++ b/seed/authority/dispatch-order-gate.om
@@ -0,0 +1,607 @@
+note SPDX-License-Identifier: AGPL-3.0-only
+note OM-CONTROL-659 action contract v1. See ../README.md for the trusted-caller boundary.
+note No I/O, authority minting or persistence. Caller serializes and durably commits transitions.
+note Record words 0..7: version,state,attempt,limit,generation,epoch,expiry,reserved.
+note Words 8..31: operation,request,scope,provider,policy,grant identities, four words each.
+note State 1 ready,2 in-flight,3 unknown,4 performed. No timeout implies not performed.
+
+fn actvalid r view ulong 32 to ulong
+if ne get r 0 1
+ret 11
+end
+if or lt get r 1 1 gt get r 1 4
+ret 12
+end
+if or eq get r 3 0 gt get r 3 1024
+ret 12
+end
+if gt get r 2 get r 3
+ret 12
+end
+if and ne get r 1 1 eq get r 2 0
+ret 12
+end
+if or eq get r 4 0 eq get r 5 0
+ret 12
+end
+if or eq get r 6 0 ne get r 7 0
+ret 12
+end
+for g ulong 6
+bits = ulong 0
+for j ulong 4
+bits = or bits get r add 8 add mul g 4 j
+end
+if eq bits 0
+ret 12
+end
+end
+ret 0
+end
+
+fn actbind r view ulong 32 c view ulong 32 to ulong
+for g ulong 6
+diff = ulong 0
+for j ulong 4
+at = add 8 add mul g 4 j
+diff = or diff xor get r at get c at
+end
+if ne diff 0
+ret add 40 g
+end
+end
+ret 0
+end
+
+fn actauth r view ulong 32 c view ulong 32 to ulong
+if ne get c 0 1
+ret 11
+end
+if or ne get c 3 0 or ne get c 6 0 ne get c 7 0
+ret 12
+end
+if ne get c 1 1
+ret 30
+end
+if ne get r 4 get c 4
+ret 31
+end
+if ne get r 5 get c 5
+ret 32
+end
+if ge get c 2 get r 6
+ret 33
+end
+ret actbind r c
+end
+
+fn actstart r edit ulong 32 c view ulong 32 to ulong
+err = actvalid r
+if ne err 0
+ret err
+end
+if eq get r 1 3
+ret 21
+end
+if eq get r 1 4
+ret 22
+end
+if ne get r 1 1
+ret 20
+end
+if ge get r 2 get r 3
+ret 23
+end
+err = actauth r c
+if ne err 0
+ret err
+end
+put r 2 add get r 2 1
+put r 1 2
+ret 0
+end
+
+fn actlost r edit ulong 32 to ulong
+err = actvalid r
+if ne err 0
+ret err
+end
+if eq get r 1 3
+ret 0
+end
+if ne get r 1 2
+ret 20
+end
+put r 1 3
+ret 0
+end
+
+note A trusted receipt maps outcome 0 unknown,1 definitely not performed,2 performed.
+note Not-found or timeout is outcome 0 unless the provider proves absence and quiescence.
+note Receipt words 2/3: exact attempt and verification=1. Words 6/7 must be zero.
+note Recording an observed outcome is permitted after expiry; another attempt is not.
+fn actrecon r edit ulong 32 s view ulong 32 to ulong
+err = actvalid r
+if ne err 0
+ret err
+end
+if not or eq get r 1 2 eq get r 1 3
+ret 20
+end
+if ne get s 0 1
+ret 11
+end
+if or gt get s 1 2 or ne get s 6 0 ne get s 7 0
+ret 12
+end
+if ne get s 3 1
+ret 36
+end
+if ne get s 2 get r 2
+ret 35
+end
+if ne get s 4 get r 4
+ret 31
+end
+if ne get s 5 get r 5
+ret 32
+end
+err = actbind r s
+if ne err 0
+ret err
+end
+if eq get s 1 0
+put r 1 3
+ret 21
+end
+if eq get s 1 1
+put r 1 1
+else
+put r 1 4
+end
+ret 0
+end
+note SPDX-License-Identifier: AGPL-3.0-only
+note Durable 32-word authority record store. Caller supplies the record and generation.
+note Writes a temporary 256-byte file, fsyncs it, then atomically renames it into place.
+note Reads require exactly 256 bytes; a short or torn file is refused. Store calls do not lock; the
+note dispatcher holds lock.om around its read-check-persist window.
+text recp "build/authority-store/rec"
+text tmpp "build/authority-store/tmp"
+text genp "build/authority-store/gen"
+global sb uchar 256
+global spkt uchar 256
+global sn ulong 1
+global spath uchar 128
+global splen ulong 1
+global sgerr ulong 1
+fn put16 v ulong to void
+put spkt get sn 0 uchar and v 255
+put spkt add get sn 0 1 uchar shr v 8
+put sn 0 add get sn 0 2
+end
+fn setrec to void
+put splen 0 len recp
+for i ulong len recp
+put spath i get recp i
+end
+end
+fn settmp to void
+put splen 0 len tmpp
+for i ulong len tmpp
+put spath i get tmpp i
+end
+end
+fn setgen to void
+put splen 0 len genp
+for i ulong len genp
+put spath i get genp i
+end
+end
+fn pack2 to ulong
+put sn 0 0
+put16 2
+put16 len tmpp
+for i ulong len tmpp
+put spkt add get sn 0 i get tmpp i
+end
+put sn 0 add get sn 0 len tmpp
+put16 len recp
+for i ulong len recp
+put spkt add get sn 0 i get recp i
+end
+put sn 0 add get sn 0 len recp
+ret get sn 0
+end
+fn enc r view ulong 32 to void
+for i ulong 32
+v = get r i
+for j ulong 8
+put sb add mul i 8 j uchar and shr v mul j 8 255
+end
+end
+end
+fn dec r edit ulong 32 to ulong
+for i ulong 32
+v = ulong 0
+for j ulong 8
+v = or v shl ulong get sb add mul i 8 j mul j 8
+end
+put r i v
+end
+ret 0
+end
+fn writerec r view ulong 32 to ulong
+enc r
+settmp
+fd = fopen spath 0 get splen 0 577 384
+if lt fd 0
+ret 10
+end
+n = write int fd sb 0 256
+if ne n 256
+ret 11
+end
+if ne fsync int fd 0
+ret 12
+end
+if ne fclose int fd 0
+ret 13
+end
+pn = pack2
+rr = renames spkt 0 pn 0
+if lt rr 0
+ret 14
+end
+ret 0
+end
+fn readrec r edit ulong 32 to ulong
+setrec
+fd = fopen spath 0 get splen 0 0 0
+if lt fd 0
+ret 20
+end
+n = read int fd sb 0 256
+if ne fclose int fd 0
+ret 21
+end
+if ne n 256
+ret 22
+end
+dv = dec r
+ret 0
+end
+fn readgen to ulong
+put sgerr 0 0
+setgen
+fd = fopen spath 0 get splen 0 0 0
+if lt fd 0
+put sgerr 0 30
+ret 0
+end
+n = read int fd sb 0 8
+if ne fclose int fd 0
+put sgerr 0 31
+ret 0
+end
+if ne n 8
+put sgerr 0 32
+ret 0
+end
+v = ulong 0
+for j ulong 8
+v = or v shl ulong get sb j mul j 8
+end
+ret v
+end
+fn writegen v ulong to ulong
+setgen
+fd = fopen spath 0 get splen 0 577 384
+if lt fd 0
+ret 40
+end
+for j ulong 8
+put sb j uchar and shr v mul j 8 255
+end
+n = write int fd sb 0 8
+if ne n 8
+ret 41
+end
+if ne fsync int fd 0
+ret 42
+end
+if ne fclose int fd 0
+ret 43
+end
+ret 0
+end
+fn storevalid r view ulong 32 g ulong to ulong
+if ne get r 0 1
+ret 51
+end
+if ne get r 4 g
+ret 52
+end
+ret 0
+end
+note SPDX-License-Identifier: AGPL-3.0-only
+note Single-effect dispatcher over the action contract and durable store.
+note The state is persisted in-flight before the effect. A generation change during the effect
+note marks the operation unknown; a duplicate or performed record is refused. The effect here is
+note a synthetic fork child: mode '1' writes generation2, mode '2' exits1, mode '0' exits0.
+global dstat uchar 4
+global dpkt uchar 256
+global dn ulong 1
+global dpath uchar 128
+global dplen ulong 1
+global dpid ulong 1
+text truep "/bin/true"
+text strictp "seed/authority/effect-ok"
+fn dput16 v ulong to void
+put dpkt get dn 0 uchar and v 255
+put dpkt add get dn 0 1 uchar shr v 8
+put dn 0 add get dn 0 2
+end
+fn dcopy to void
+for i ulong get dplen 0
+put dpkt add get dn 0 i get dpath i
+end
+put dn 0 add get dn 0 get dplen 0
+end
+fn packtrue to ulong
+put dn 0 0
+dput16 1
+dput16 len truep
+for i ulong len truep
+put dpkt add get dn 0 i get truep i
+end
+put dn 0 add get dn 0 len truep
+ret get dn 0
+end
+fn doreceipt r view ulong 32 s edit ulong 32 outcome ulong to void
+for i ulong 32
+put s i 0
+end
+put s 0 1
+put s 1 outcome
+put s 2 get r 2
+put s 3 1
+put s 4 get r 4
+put s 5 get r 5
+for i ulong 24
+put s add 8 i get r add 8 i
+end
+end
+fn dispatch r edit ulong 32 c view ulong 32 mode uchar to ulong
+err = lacq get dpid 0 1000
+if ne err 0
+ret 80
+end
+err = readrec r
+if ne err 0
+lk = lrel
+ret 70
+end
+g = readgen
+if ne get sgerr 0 0
+lk = lrel
+ret 71
+end
+err = storevalid r g
+if ne err 0
+lk = lrel
+ret err
+end
+err = actstart r c
+if ne err 0
+lk = lrel
+ret err
+end
+err = writerec r
+if ne err 0
+lk = lrel
+ret 72
+end
+lk = lrel
+if ne lk 0
+ret 78
+end
+pid = fork
+if lt pid 0
+ret 73
+end
+if eq pid 0
+if eq mode 49
+e = writegen 2
+if ne e 0
+exit int 97
+end
+end
+if eq mode 50
+exit int 1
+end
+if eq mode 51
+n = packtrue
+rr = execprog dpkt 0 n
+exit int 98
+end
+if eq mode 52
+put dn 0 0
+dput16 1
+dput16 get dplen 0
+dcopy
+rx = execpure dpkt 0 get dn 0
+exit int 98
+end
+exit int 0
+end
+wr = waitpid int pid dstat 0 len dstat 0
+if ne wr long pid
+ret 74
+end
+sig = ulong get dstat 0
+code = ulong get dstat 1
+g2 = readgen
+if ne get sgerr 0 0
+ret 75
+end
+if ne g2 g
+err = lacq get dpid 0 1000
+if ne err 0
+ret 80
+end
+err = actlost r
+err = writerec r
+lk = lrel
+ret 60
+end
+err = lacq get dpid 0 1000
+if ne err 0
+ret 80
+end
+s = new ulong 32 0
+outcome = ulong 0
+if and eq sig 0 eq code 0
+outcome = ulong 2
+end
+doreceipt r s outcome
+err = actrecon r s
+if ne err 0
+err = writerec r
+lk = lrel
+ret 76
+end
+err = writerec r
+lk = lrel
+if ne err 0
+ret 77
+end
+if eq outcome 0
+ret 61
+end
+ret 0
+end
+note SPDX-License-Identifier: AGPL-3.0-only
+note Deterministic lock-acquisition schedule, not a qualification of the real pid lock.
+note Link action.om, store.om, dispatch.om and this file, WITHOUT lock.om.
+note The acquisition double commits another owner's performed record before returning.
+note Production dispatch must read that record after acquisition and refuse a duplicate.
+global schedrec ulong 32
+global acqmode ulong 1
+global releases ulong 1
+global acquired ulong 1
+global failures ulong 1
+text orderdir "build/authority-store"
+text ordbuild "build"
+text stalechk "FAIL dispatch acquired-record refusal\n"
+text relcheck "FAIL dispatch read-error release\n"
+text acqcheck "FAIL dispatch acquisition-error refusal\n"
+text okorder "dispatch order checks=3 fails=0\n"
+fn lacq p ulong tries ulong to ulong
+put acquired 0 add get acquired 0 1
+if eq get acqmode 0 2
+ret 22
+end
+if eq get acqmode 0 1
+r = unlink recp 0 len recp
+if ne r 0
+ret 40
+end
+ret 0
+end
+localrec = new ulong 32 0
+for i ulong 32
+put localrec i get schedrec i
+end
+ret writerec localrec
+end
+fn lrel to ulong
+put releases 0 add get releases 0 1
+ret 0
+end
+fn orderfail mode ulong to void
+put failures 0 add get failures 0 1
+if eq mode 0
+w = write 1 stalechk 0 len stalechk
+if ne w long len stalechk
+exit 90
+end
+end
+if eq mode 1
+w = write 1 relcheck 0 len relcheck
+if ne w long len relcheck
+exit 90
+end
+end
+if eq mode 2
+w = write 1 acqcheck 0 len acqcheck
+if ne w long len acqcheck
+exit 90
+end
+end
+end
+fn main to int
+mk = makedir ordbuild 0 len ordbuild 448
+if not or eq mk 0 eq mk -17
+ret 91
+end
+mk = makedir orderdir 0 len orderdir 448
+if not or eq mk 0 eq mk -17
+ret 92
+end
+put dpid 0 ulong getpid
+r = new ulong 32 0
+c = new ulong 32 0
+put r 0 1
+put r 1 1
+put r 3 3
+put r 4 1
+put r 5 9
+put r 6 100
+put c 0 1
+put c 1 1
+put c 2 50
+put c 4 1
+put c 5 9
+for i ulong 24
+put r add i 8 add i 100
+put c add i 8 add i 100
+end
+for i ulong 32
+put schedrec i get r i
+end
+put schedrec 1 4
+put schedrec 2 1
+if ne writegen 1 0
+ret 93
+end
+if ne writerec r 0
+ret 94
+end
+result = dispatch r c 48
+if or ne result 22 or ne get acquired 0 1 ne get releases 0 1
+orderfail 0
+end
+put acqmode 0 1
+put acquired 0 0
+put releases 0 0
+result = dispatch r c 48
+if or ne result 70 or ne get acquired 0 1 ne get releases 0 1
+orderfail 1
+end
+put acqmode 0 2
+put acquired 0 0
+put releases 0 0
+result = dispatch r c 48
+if or ne result 80 or ne get acquired 0 1 ne get releases 0 0
+orderfail 2
+end
+if ne get failures 0 0
+ret 1
+end
+w = write 1 okorder 0 len okorder
+if ne w long len okorder
+ret 95
+end
+ret 0
+end
diff --git a/seed/authority/dispatch-order-test.om b/seed/authority/dispatch-order-test.om
new file mode 100644
index 000000000..c0034d27c
--- /dev/null
+++ b/seed/authority/dispatch-order-test.om
@@ -0,0 +1,124 @@
+note SPDX-License-Identifier: AGPL-3.0-only
+note Deterministic lock-acquisition schedule, not a qualification of the real pid lock.
+note Link action.om, store.om, dispatch.om and this file, WITHOUT lock.om.
+note The acquisition double commits another owner's performed record before returning.
+note Production dispatch must read that record after acquisition and refuse a duplicate.
+global schedrec ulong 32
+global acqmode ulong 1
+global releases ulong 1
+global acquired ulong 1
+global failures ulong 1
+text orderdir "build/authority-store"
+text ordbuild "build"
+text stalechk "FAIL dispatch acquired-record refusal\n"
+text relcheck "FAIL dispatch read-error release\n"
+text acqcheck "FAIL dispatch acquisition-error refusal\n"
+text okorder "dispatch order checks=3 fails=0\n"
+fn lacq p ulong tries ulong to ulong
+put acquired 0 add get acquired 0 1
+if eq get acqmode 0 2
+ret 22
+end
+if eq get acqmode 0 1
+r = unlink recp 0 len recp
+if ne r 0
+ret 40
+end
+ret 0
+end
+localrec = new ulong 32 0
+for i ulong 32
+put localrec i get schedrec i
+end
+ret writerec localrec
+end
+fn lrel to ulong
+put releases 0 add get releases 0 1
+ret 0
+end
+fn orderfail mode ulong to void
+put failures 0 add get failures 0 1
+if eq mode 0
+w = write 1 stalechk 0 len stalechk
+if ne w long len stalechk
+exit 90
+end
+end
+if eq mode 1
+w = write 1 relcheck 0 len relcheck
+if ne w long len relcheck
+exit 90
+end
+end
+if eq mode 2
+w = write 1 acqcheck 0 len acqcheck
+if ne w long len acqcheck
+exit 90
+end
+end
+end
+fn main to int
+mk = makedir ordbuild 0 len ordbuild 448
+if not or eq mk 0 eq mk -17
+ret 91
+end
+mk = makedir orderdir 0 len orderdir 448
+if not or eq mk 0 eq mk -17
+ret 92
+end
+put dpid 0 ulong getpid
+r = new ulong 32 0
+c = new ulong 32 0
+put r 0 1
+put r 1 1
+put r 3 3
+put r 4 1
+put r 5 9
+put r 6 100
+put c 0 1
+put c 1 1
+put c 2 50
+put c 4 1
+put c 5 9
+for i ulong 24
+put r add i 8 add i 100
+put c add i 8 add i 100
+end
+for i ulong 32
+put schedrec i get r i
+end
+put schedrec 1 4
+put schedrec 2 1
+if ne writegen 1 0
+ret 93
+end
+if ne writerec r 0
+ret 94
+end
+result = dispatch r c 48
+if or ne result 22 or ne get acquired 0 1 ne get releases 0 1
+orderfail 0
+end
+put acqmode 0 1
+put acquired 0 0
+put releases 0 0
+result = dispatch r c 48
+if or ne result 70 or ne get acquired 0 1 ne get releases 0 1
+orderfail 1
+end
+put acqmode 0 2
+put acquired 0 0
+put releases 0 0
+result = dispatch r c 48
+if or ne result 80 or ne get acquired 0 1 ne get releases 0 0
+orderfail 2
+end
+if ne get failures 0 0
+ret 1
+end
+w = write 1 okorder 0 len okorder
+if ne w long len okorder
+ret 95
+end
+ret 0
+end
diff --git a/seed/authority/dispatch.om b/seed/authority/dispatch.om
index 5c4cdefca..32f550185 100644
--- a/seed/authority/dispatch.om
+++ b/seed/authority/dispatch.om
@@ -47,14 +47,15 @@ put s add 8 i get r add 8 i
 end
 end
 fn dispatch r edit ulong 32 c view ulong 32 mode uchar to ulong
-err = readrec r
-if ne err 0
-ret 70
-end
 err = lacq get dpid 0 1000
 if ne err 0
 ret 80
 end
+err = readrec r
+if ne err 0
+lk = lrel
+ret 70
+end
 g = readgen
 if ne get sgerr 0 0
 lk = lrel