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
omega-mv / seed / authority / README.md
| 1 | # Authority and reuse transitions in seeded `.om` |
| 2 | |
| 3 | These are the `.om` replacements for the transition logic currently held by the legacy C authority |
| 4 | and reuse owners (`src/runtime/rx_capq`, `rx_caproot`, `rx_semantic`). They are pure transition |
| 5 | functions: they validate a record, bind identities, check authority, and advance a state. They do |
| 6 | not mint authority, perform I/O, persist a transition or dispatch an effect. The durable store and |
| 7 | dispatcher are the next phase; the C owner remains active until every consumer is cut over. |
| 8 | |
| 9 | | File | Role | |
| 10 | | --- | --- | |
| 11 | | `action.om` | operation lifecycle: ready/in-flight/unknown/performed, attempts, limit, generation, expiry, identity binding | |
| 12 | | `delegate.om` | child capability derivation and subset checks | |
| 13 | | `reuse.om` | exact-key reuse checks, including whole-token prefix identity | |
| 14 | | `store.om` | durable 32-word record and generation file: temp write, fsync, atomic rename, exact 256-byte read; torn/short files refused | |
| 15 | | `dispatch.om` | persists in-flight, runs /bin/true and a static execpure effect, records performed/unknown, and marks unknown if the generation changes during the effect | |
| 16 | | `lock.om` | cross-process O_EXCL pid lock with bounded retry and stale-pid reclaim; serializes read-check-persist, not the effect | |
| 17 | | `lock-test.om` | exclusive acquire, busy refusal, release, forked waiter, stale-pid reclaim, failed-release reporting, a live owner with pid 32 (not a read error) and the retry-bound refusal (43) | |
| 18 | | `dispatch-fault-test.om` | injected actlost, actrecon, record-write and release failures; checks dispatch codes 76..79 and that the lock is released on every path | |
| 19 | | `*-test.om` | transition and store checks; no provider simulation | |
| 20 | | `*-gate.om` | source + test concatenation for the current single-file compiler | |
| 21 | |
| 22 | `dispatch.om` holds `lock.om` across read, generation check, start and the in-flight write, releases |
| 23 | before the effect, and reacquires before recording the outcome. The dispatch gate therefore exercises |
| 24 | the locked path (37 checks). |
| 25 | |
| 26 | `action-gate.om`, `delegate-gate.om` and `reuse-gate.om` are committed concatenations because the |
| 27 | seeded compiler currently reads one source file. Module/import support is a compiler capability |
| 28 | dependency; it is not a reason to keep a legacy implementation. |
| 29 | |
| 30 | ## OM2 composition regression |
| 31 | |
| 32 | `action.om` also composes into OM2 units. Its identity-binding local is named `ix`, |
| 33 | because `at` is reserved in OM2. The transition logic is unchanged. The dedicated |
| 34 | fixture checks equal identities and a mismatch in each of the 24 identity words. |
| 35 | Run from the repository root, using a fresh output directory: |
| 36 | |
| 37 | ```sh |
| 38 | out=$(mktemp -d) |
| 39 | { printf 'om2\n'; cat seed/authority/action.om seed/authority/action-om2-test.om; } > "$out/action-om2.om" |
| 40 | seed/out/omc < "$out/action-om2.om" > "$out/action-om2" |
| 41 | chmod +x "$out/action-om2" |
| 42 | "$out/action-om2" |
| 43 | ``` |
| 44 | |
| 45 | ## Run |
| 46 | |
| 47 | ``` |
| 48 | seed/out/omc < seed/authority/action-gate.om > build/action-gate |
| 49 | chmod +x build/action-gate |
| 50 | ./build/action-gate |
| 51 | ``` |
| 52 | |
| 53 | Expected output and exit: |
| 54 | |
| 55 | | Gate | Output | Exit | |
| 56 | | --- | --- | --- | |
| 57 | | action | `action checks=219 000` | 0 | |
| 58 | | delegate | `delegate checks=074 000` | 0 | |
| 59 | | reuse | `reuse checks=074 000` | 0 | |
| 60 | | store | `store checks=077 000` | 0 | |
| 61 | | dispatch | `dispatch checks=037 000` | 0 | |
| 62 | | lock | `lock checks=10 fails=0` | 0 | |
| 63 | | dispatch-order | `dispatch order checks=3 fails=0` | 0 | |
| 64 | | store-exact | `store exact checks=4 fails=0` | 0 | |
| 65 | | store-cleanup | `store cleanup cases=18 fails=0` | 0 | |
| 66 | | dispatch-fault | `dispatch fault checks=10 fails=0` | 0 | |
| 67 | |
| 68 | The authority gates and the standalone lock gate are run by |
| 69 | `seed/qualification/security673/gate669.om` as part of the security qualification; the dispatcher |
| 70 | also exercises the lock in its 37-check gate. A failure is a failed check count or a nonzero exit; a compile failure is |
| 71 | `INVALID`, not a pass. The three newer regressions run after the existing authority gates, |
| 72 | each with its own fresh child working directory beneath `build/security673-native`. Their |
| 73 | relative `build/authority-store` fixtures cannot overwrite each other or the earlier gates. |
| 74 | This filesystem separation is not a sandbox. See the coordinator README for retained artifacts |
| 75 | and native verification limits. |
| 76 | |
| 77 | ## Cutover rule |
| 78 | |
| 79 | The lock is integrated in the dispatcher, but no production consumer uses this store yet. The C authority/reuse |
| 80 | sources are deleted only after the `.om` owner has a durable store, dispatch, revocation and budget |
| 81 | behaviour, and every consumer uses it. A parallel production authority path is not an end state. |
| 82 | |
| 83 | ## Dispatcher acquisition-order regression |
| 84 | |
| 85 | `dispatch-order-gate.om` links the production action, store and dispatch sources with a |
| 86 | **test-only lock-acquisition schedule** from `dispatch-order-test.om`, rather than `lock.om`. |
| 87 | The acquisition double writes a performed record before granting the lock. A dispatcher that |
| 88 | reads before acquiring sees stale ready state and misses the required duplicate refusal (22). |
| 89 | The other two named assertions require release on a failed protected read (70), and require an |
| 90 | acquisition error (80) to return without a read or release. No timing or scheduler luck is used. |
| 91 | This checks dispatcher ordering; it does not qualify pid-lock exclusion, stale-owner recovery, |
| 92 | revocation fencing, or production concurrent execution. |
| 93 | |
| 94 | In a fresh disposable Linux AArch64 checkout, after rebuilding the existing approved compiler: |
| 95 | |
| 96 | ```sh |
| 97 | mkdir -p build |
| 98 | seed/out/omc < seed/authority/dispatch-order-gate.om > build/dispatch-order-gate |
| 99 | readelf -h build/dispatch-order-gate |
| 100 | chmod +x build/dispatch-order-gate |
| 101 | build/dispatch-order-gate |
| 102 | ``` |
| 103 | |
| 104 | Run each command only after its predecessor succeeds; never execute failed compiler output. |
| 105 | Expected: `dispatch order checks=3 fails=0`, exit 0. This regression is also wired into |
| 106 | `gate669`; the existing dispatch and lock gates remain in that campaign. |
| 107 | The negative control is the same compilation unit with only `dispatch.om` restored to the base |
| 108 | revision's pre-acquisition read. It must exit 1 and print `FAIL dispatch acquired-record refusal`; |
| 109 | the pre-acquisition read also fails the other two assertions (no release after a failed read, |
| 110 | and a read before the acquisition error). A compiler failure, signal, or timeout is INVALID, |
| 111 | not a passing control. |
| 112 | |
| 113 | Committed concatenations are the byte-for-byte sequences below (no extra separators): |
| 114 | |
| 115 | - `dispatch-gate.om`: action, store, lock, dispatch, dispatch-test. |
| 116 | - `dispatch-order-gate.om`: action, store, dispatch, dispatch-order-test. |
| 117 | |
| 118 | Native run (2026-10-31, Linux AArch64, seed/out/omc sha256 7a8b84fc, after `sh seed/omega-from-seed.sh` |
| 119 | reproduced it): positive `dispatch order checks=3 fails=0`, exit 0; negative control with `dispatch.om` |
| 120 | from main 1db94162 printed all three `FAIL dispatch ...` lines, exit 1. The 37-check `dispatch-gate.om` |
| 121 | passes on both sources, so it does not detect the read-before-acquire order; this regression does. |
| 122 | |
| 123 | ## Exact store-input consumption regression |
| 124 | |
| 125 | `readrec` accepts exactly 256 bytes and `readgen` accepts exactly 8 bytes. Both now probe for |
| 126 | EOF before decoding. A trailing byte or an error in that probe is refused through the existing |
| 127 | record error (22) or generation error (`sgerr=32`, returned value 0). This is exact stream |
| 128 | consumption, not authentication or a defense against concurrent file replacement/writes. |
| 129 | |
| 130 | `store-exact-gate.om` is exactly `store.om` followed by `store-exact-test.om`. It uses real |
| 131 | store writes/reads and appends a synthetic byte with Linux `O_WRONLY | O_APPEND` (1025). |
| 132 | It checks the exact-length positives and both trailing-byte refusals. In a fresh disposable |
| 133 | Linux AArch64 checkout, using the reconstructed and approved existing compiler: |
| 134 | |
| 135 | ```sh |
| 136 | mkdir -p build |
| 137 | seed/out/omc < seed/authority/store-exact-gate.om > build/store-exact-gate |
| 138 | readelf -h build/store-exact-gate |
| 139 | chmod +x build/store-exact-gate |
| 140 | build/store-exact-gate |
| 141 | ``` |
| 142 | |
| 143 | Run each command only after its predecessor succeeds. Expected output is |
| 144 | `store exact checks=4 fails=0`, exit 0. The negative control concatenates the unmodified |
| 145 | `store.om` from `a35697e94b5eeb72efadfee6edab7f14344aea43` with this test; it must report |
| 146 | `FAIL store trailing-record refusal` and `FAIL store trailing-generation refusal`, exit 1. |
| 147 | The test deliberately has no dependency on the new EOF-probe scratch buffer, so the old-source |
| 148 | control remains a valid compilation unit. Failed compilation, signals and timeouts are INVALID. |
| 149 | Run the existing store, dispatch, dispatcher-order and complete security gates as regressions. |
| 150 | This gate is also wired into `gate669`. Native run (2026-10-31, Linux AArch64, |
| 151 | seed/out/omc 7a8b84fc): positive `store exact checks=4 fails=0`, exit 0; negative controls with |
| 152 | `store.om` from main 1db94162 and from a35697e9 each printed both `FAIL store trailing-...` lines, |
| 153 | exit 1. |
| 154 | |
| 155 | `store-gate.om` has been regenerated as `store.om` followed by `store-test.om`. Its prior copy |
| 156 | also lacked the already-existing `sgerr` generation-error interface; it now tests the current |
| 157 | implementation rather than preserving that stale copy. |
| 158 | |
| 159 | ## Lock release errors |
| 160 | |
| 161 | `lrm`/`lrel` return 0 only when unlink succeeds, and 41 on unlink failure (including |
| 162 | an absent path). The lock gate checks ordinary release, directory refusal and |
| 163 | missing-path refusal. Its directory fixture is removed with `rmdir`; run gates |
| 164 | only in disposable test working directories, never against an active store. |
| 165 | |
| 166 | The pre-effect dispatcher release check returns 78 on this failure. Since DRA-419 every later |
| 167 | release goes through `dfinish`, which releases and keeps an earlier failure code, or returns 78 |
| 168 | when the release is the only failure. This change does not redesign stale-lock reclamation. |
| 169 | |
| 170 | ## Return codes added by the DRA-419 critical profile |
| 171 | |
| 172 | `seed/profile/profile.om` refused the pre-fix modules (dropped results, unbounded loops, host words |
| 173 | outside declared effect functions). The fixes add these codes: |
| 174 | |
| 175 | | Code | Function | Meaning | |
| 176 | | --- | --- | --- | |
| 177 | | 43 | `lacq` | more than 1000 tries requested; refused before any attempt (the retry loop is bounded by 1000) | |
| 178 | | 40 | `ltry` | the owner pid file could not be read (`lerr` set by `lread`: 32 open, 33 close, 34 short read). `lread` used to return 32..34 as the pid itself, so a live owner with pid 32 looked like a read error | |
| 179 | | 76 | `dispatch` | reconcile (`actrecon`) refused the receipt; the current (still in-flight) record is persisted unchanged by the following record write | |
| 180 | | 77 | `dispatch` | the post-effect record write failed, on the reconcile, lost-generation or normal path (lost-generation and reconcile write errors were dropped before) | |
| 181 | | 78 | `dispatch` | the lock release failed and no earlier failure is set (post-effect release errors were dropped before) | |
| 182 | | 79 | `dispatch` | `actlost` refused to mark the record unknown after a generation change (the error was overwritten before) | |
| 183 | |
| 184 | `dispatch-fault-gate.om` is `action.om`, `store.om`, then `dispatch.om` with the lines |
| 185 | `err = actlost r`, `err = actrecon r s` and `err = writerec r` calling `factlost`, `factrecon` and |
| 186 | `fwriterec`, then `dispatch-fault-test.om`, which replaces `lock.om` with a counting double. |
| 187 | `seed/profile/check.om` regenerates it with the same line replacements, compares, runs it, and runs the same injection over |
| 188 | the frozen pre-fix `seed/profile/cases/dispatch-943d955.om`. The pre-fix module fails cases 2, 3, 4, 5, 7 |
| 189 | and 8 (79, 77, 78, 79, 77, 78). Cases 0, 1, 6 and 9 (0, 60, 76, 77 normal path) are regressions that the |
| 190 | old code also passed. This is fault injection at the call results, not a qualification of real disk or |
| 191 | lock failure, and it is not yet in `gate669`. |
| 192 | |
| 193 | Native run (2026-10-31, Linux AArch64, seed/out/omc 7a8b84fc): `lock checks=8 fails=0`, exit 0. |
| 194 | Negative control with `lock.om` from main 1db94162 (`lrm` returns 0 on unlink failure): no pass |
| 195 | line, exit 1 (the gate's failed-check exit; its setup errors exit 100..102). |
| 196 | |
| 197 | ## Fixture source correction (2026-10-24) |
| 198 | |
| 199 | The dispatcher-order fixture now uses global/text names within the existing |
| 200 | compiler's eight-character limit and copies its scheduled record into a local |
| 201 | array before calling `writerec`; global arrays cannot be function arguments. |
| 202 | The exact-store fixture likewise uses global/text names within that limit. |
| 203 | These correct known source compilation blockers without changing the test |
| 204 | scenarios or production sources. Declared concatenated gates are regenerated |
| 205 | from this revision's own component sources. Source review is not compiler |
| 206 | acceptance; the native runs are recorded in the section above. |
| 207 | Historical evidence is unchanged. |
| 208 | |
| 209 | ## Store write failure cleanup |
| 210 | |
| 211 | `writerec` and `writegen` close their opened descriptor once on failed/short |
| 212 | write and failed fsync, preserving the primary errors (11/12 and 41/42) even |
| 213 | if cleanup also fails. Close is never retried. Successful-path close errors |
| 214 | remain 13/43, and record rename is skipped after any earlier error. |
| 215 | |
| 216 | `store-cleanup-test.om` provides 18 handwritten deterministic fake-effect cases. |
| 217 | The committed `store-cleanup-gate.om` contains a test-only derivation of `store.om` |
| 218 | followed by this test verbatim. It checks effect order, exactly-one close, |
| 219 | descriptor identity and primary error precedence. It does not test real syscalls, |
| 220 | fd ownership, durability or hardware. Production code has no test hooks. |
| 221 | |
| 222 | ### Derivation and manual source-correspondence review |
| 223 | |
| 224 | New first-party runners/automation must be seeded `.om`. The temporary shell |
| 225 | composer used during preparation is removed from active source; it was disposable |
| 226 | authoring validation, not a supported runner. No replacement compiler or runner |
| 227 | is introduced. Keep the handwritten test and committed `.om` gate reviewable. |
| 228 | |
| 229 | To derive the store prefix, preserve every line and scalar argument of `store.om` |
| 230 | except these exact effect-call prefixes (ignore `note` comments): |
| 231 | |
| 232 | | Production prefix | Test-only prefix | |
| 233 | | --- | --- | |
| 234 | | `fopen spath` | `cfopen` | |
| 235 | | `write int fd sb` | `cwrite int fd` | |
| 236 | | `fsync int fd` | `cfsync int fd` | |
| 237 | | `fclose int fd` | `cfclose int fd` | |
| 238 | | `renames spkt` | `crenames` | |
| 239 | |
| 240 | The omitted global-buffer arguments cannot be passed to ordinary Omega functions; |
| 241 | buffer contents are outside this test. Append `store-cleanup-test.om` unchanged. |
| 242 | Before any approved compilation, manually compare the gate prefix against |
| 243 | `store.om`: only the five substitutions above may differ. Compare its remaining |
| 244 | suffix byte-for-byte against the test. Check that no executable `fopen`, `write`, |
| 245 | `fsync`, `fclose` or `renames` token remains in the derived store prefix; reject |
| 246 | any unrecognized call shape rather than leave a real write-side effect behind. |
| 247 | The store read functions retain real `read` primitives but are never called by |
| 248 | this fixture. The harness alone uses real stdout for its success message. |
| 249 | |
| 250 | For approved Linux AArch64 replay, compile the committed `store-cleanup-gate.om` |
| 251 | with the existing reconstructed compiler, inspect the output, and execute only |
| 252 | a successfully compiled artifact. Expected output: `store cleanup cases=18 |
| 253 | fails=0`, exit 0. For the negative control, apply the same reviewed derivation |
| 254 | to `store.om` from `95529421e9a0e6d6d63ca5d8b8cdfaf443e0ef78`, followed by the |
| 255 | current test unchanged. That prefix must differ only by four missing cleanup |
| 256 | calls. Expected: exit 1 without the success message. Compilation failure, |
| 257 | signal or timeout is INVALID, not a passing control. |
| 258 | |
| 259 | The historical preparation checks in |
| 260 | [`store-write-cleanup/REVIEW.md`](../../evidence/SECURITY-673/store-write-cleanup/REVIEW.md) |
| 261 | remain unchanged as evidence of checks observed then; its removed shell-helper |
| 262 | commands are not current replay instructions. The manual derivation above and |
| 263 | committed gate supersede those commands. Current source correspondence, absence |
| 264 | of unmatched write-side effects, and metadata checks pass. This gate is wired |
| 265 | into the existing security coordinator with its own fresh child working |
| 266 | directory; the standalone replay and negative control remain available. |
| 267 | |
| 268 | Native run (2026-10-31, Linux AArch64, seed/out/omc 7a8b84fc after `sh seed/omega-from-seed.sh` |
| 269 | reproduced it): the derivation above applied to this revision's `store.om` plus the test is |
| 270 | byte-identical to the committed `store-cleanup-gate.om`; positive `store cleanup cases=18 fails=0`, |
| 271 | exit 0. Negative control with the same derivation applied to `store.om` from 95529421 (differs only |
| 272 | by the four missing `cleanup = cfclose int fd` lines): compiled, no output, exit 1 (the gate prints |
| 273 | no per-case lines; exit 1 is its failed-case exit). Security qualification on hardware remains |
| 274 | NOT_RUN. |
| 275 | |
| 276 | ## Native replay and compiler register bound (2026-10-25) |
| 277 | |
| 278 | The original cleanup gate at `08bd7aa7d7b73864e56163772ccceaa9cc91de0b` |
| 279 | failed compilation with error 12 at line 274. Moving its unchanged three-part |
| 280 | assertion into `cbadcase` reduces live register pressure in `main`. The committed |
| 281 | concatenation, ending with the handwritten test verbatim, now compiles. No |
| 282 | production store behavior or expected outcome changes. |
| 283 | |
| 284 | Linux AArch64 native replay with the reconstructed compiler |
| 285 | `66b4cf34e5cd2c8ff003bd142e7309f52178b66c2380f78ac313b6eb8b67471b` |
| 286 | passed dispatch-order (3), store-exact (4), lock (8), and cleanup (18). |
| 287 | Compiled controls restoring read-before-lock, accepting a trailing record byte, |
| 288 | masking unlink failure, and omitting the four error-path closes each compiled |
| 289 | successfully and exited 1 from their fixture assertions. The cleanup control |
| 290 | fails `cbadcase`; the lock control fails its accumulated release-result checks. |
| 291 | These are not crashes or failed-build controls. The exact-input control covers |
| 292 | the record probe only; it does not claim the generation-probe mutant was run. |
| 293 | |
| 294 | Raw bindings and output are in `../qualification/security673/repairs/native.json`. |
| 295 | The `.om` mutation producer in that directory requires exactly the declared |
| 296 | number of source matches before writing a mutant. Historical NOT_RUN statements |
| 297 | above describe their original preparation; this replay supersedes them only for |
| 298 | these four positive fixtures and these four controls. The full coordinator, |
| 299 | production revocation fencing, stale-pid ABA exclusion, actual concurrent |
| 300 | effects, power loss and durable aggregate accounting remain unqualified here. |
| 301 | |
| 302 | Replay on 2026-10-31 with the current seed compiler `7a8b84fc` after merging |
| 303 | #688 at 101823e5 reproduced every source and executable SHA-256, exit and stdout |
| 304 | of that replay, including the error 12 for the pre-`cbadcase` gate; see |
| 305 | `../qualification/security673/repairs/replay-7a8b84fc.json`. Host execution |
| 306 | only; hardware security qualification remains NOT_RUN. |
| 307 | |
| 308 | ### Arboris world-step signing |
| 309 | |
| 310 | The Spark host gate builds `world-signer` from `arboris-signer.om`, the seeded SHA-256/SHA-512 units and the Ed25519 verifier. Launch one instance per retired step in the world’s private receipt directory. The trusted supervisor holds the world writer lock and supplies the following descriptors. |
| 311 | |
| 312 | | FD | Owner and content | |
| 313 | | --- | --- | |
| 314 | | 0 and 1 | Private request and reply pipes to the worker. The request is the 184-byte `ARBSTP02` claim and the reply is the 64-byte Ed25519 signature. | |
| 315 | | 3 | Supervisor policy for the admitted dispatch. Supply claim bytes 0–127 followed by bytes 176–183. Derive these 136 bytes from the admitted grant, immutable inputs, installed kernel and dispatch controls. | |
| 316 | | 4 | The world’s pinned 32-byte Ed25519 public key. | |
| 317 | | 5 | A connected socket to the dedicated OpenSSH signing agent holding the world identity. | |
| 318 | |
| 319 | The signer verifies the agent response and records the 248-byte claim and signature under their lowercase SHA-256 before replying. It syncs the file and directory. A retry verifies any existing record byte for byte. The worker independently verifies the signature and its current grant before the epoch store. The optional `--arboris-signed-silicon` probe takes the public-key descriptor on FD9 and private request and reply descriptors on FD10 and FD11 respectively. FD12 carries the signing policy from the trusted pre-submission path to the signer’s FD3. |