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

GitHub aien-dev/omega-mv#233 (code only)

closed derived 7dc0d2ce882590df #233

Imported from GitHub aien-dev/omega-mv#233 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base fc96141e3da05019247b39f9db75c3fe548b8e99 · Head 9ae573aa446965b8b9e3a0c2a7ea09109ad33a6d

Apply it

git checkout -b patch-7dc0d2ce882590df fc96141e3da05019247b39f9db75c3fe548b8e99
curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/7dc0d2ce882590df.patch | git am

Raw patch (mbox) · 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
233
9ae573aa446965b8b9e3a0c2a7ea09109ad33a6d
{"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":233,"url":"https://github.com/aien-dev/omega-mv/pull/233","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:54Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.github/workflows/host-suites.yml b/.github/workflows/host-suites.yml
index f2fb70ccc..7d3bb8e45 100644
--- a/.github/workflows/host-suites.yml
+++ b/.github/workflows/host-suites.yml
@@ -121,6 +121,8 @@ jobs:
         run: make PHYSICS_DIR=/nonexistent PHYSICS_LOCK_CHECK=0 test-e1-combine
       - name: GPU completion wait primitive (host-only, fake memory and clock, mutants must die)
         run: make PHYSICS_DIR=/nonexistent PHYSICS_LOCK_CHECK=0 test-gpu-wait
+      - name: GPU completion wait real-code mutants (each flagged build of the real code must fail)
+        run: make PHYSICS_DIR=/nonexistent PHYSICS_LOCK_CHECK=0 test-gpu-wait-mutants
 
   train:
     runs-on: ubuntu-24.04-arm
diff --git a/mk/omega-gpu-wait.mk b/mk/omega-gpu-wait.mk
index 8d5eab94e..42e5ed25b 100644
--- a/mk/omega-gpu-wait.mk
+++ b/mk/omega-gpu-wait.mk
@@ -8,3 +8,18 @@ build/test_omega_gpu_wait: tests/test_omega_gpu_wait.c src/omega_gpu_wait.c src/
 	gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -Isrc -o $@ tests/test_omega_gpu_wait.c src/omega_gpu_wait.c
 test-gpu-wait: build/test_omega_gpu_wait
 	./build/test_omega_gpu_wait
+
+# Real-code mutants: src/omega_gpu_wait.c carries one-line compile-flag mutants.
+# Each flagged build of the real primitive must FAIL the suite; the unflagged
+# build must PASS. A mutant that does not compile is an error, not a kill.
+GPU_WAIT_MUTANTS := OMEGA_GPU_WAIT_MUTANT_STALL_NO_RESET OMEGA_GPU_WAIT_MUTANT_PROGRESS_EXTENDS_HARD OMEGA_GPU_WAIT_MUTANT_NO_READ_BARRIER
+.PHONY: test-gpu-wait-mutants
+test-gpu-wait-mutants: build/test_omega_gpu_wait
+	@./build/test_omega_gpu_wait >/dev/null || { echo "unflagged build FAILED"; exit 1; }
+	@echo "unflagged: PASS"
+	@set -e; for m in $(GPU_WAIT_MUTANTS); do \
+	  gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -D$$m -Isrc -o build/test_omega_gpu_wait_$$m tests/test_omega_gpu_wait.c src/omega_gpu_wait.c; \
+	  if ./build/test_omega_gpu_wait_$$m >build/test_omega_gpu_wait_$$m.log 2>&1; then echo "MUTANT SURVIVED: $$m"; exit 1; fi; \
+	  echo "$$m: killed ($$(grep -c 'FAIL' build/test_omega_gpu_wait_$$m.log) failing checks)"; \
+	done
+	@echo "OMEGA_GPU_WAIT_MUTANTS PASS"
diff --git a/src/omega_gpu_wait.c b/src/omega_gpu_wait.c
index 4702d9be6..ad5169497 100644
--- a/src/omega_gpu_wait.c
+++ b/src/omega_gpu_wait.c
@@ -83,7 +83,9 @@ static bool wait_core(omega_gpu_wait_kind_t kind, volatile uint32_t *word, uint3
             rpt->elapsed_ns = now - start;
             return false;
         }
+#ifndef OMEGA_GPU_WAIT_MUTANT_NO_READ_BARRIER
         barrier(cfg->hook_ctx);
+#endif
         m = *word;
         if (cfg->marker2) m2 = *cfg->marker2;
         if (cfg->snapshot) cfg->snapshot(cfg->snapshot_ctx, snap);
@@ -101,7 +103,12 @@ static bool wait_core(omega_gpu_wait_kind_t kind, volatile uint32_t *word, uint3
         if (changed && !first) {
             rpt->progress_count++;
             rpt->last_progress_ns = now;
+#ifndef OMEGA_GPU_WAIT_MUTANT_STALL_NO_RESET
             stall_deadline = now + stall_ns;
+#endif
+#ifdef OMEGA_GPU_WAIT_MUTANT_PROGRESS_EXTENDS_HARD
+            hard_deadline = now + total_ns;
+#endif
         }
         bool ok = kind == OMEGA_GPU_WAIT_FIXED ? (m == expected) : ((int32_t)(m - expected) >= 0);
         if (ok && (!cfg->marker2 || m2 == cfg->marker2_want)) {
diff --git a/tests/test_omega_gpu_wait.c b/tests/test_omega_gpu_wait.c
index f02930e14..7dc1a0eb7 100644
--- a/tests/test_omega_gpu_wait.c
+++ b/tests/test_omega_gpu_wait.c
@@ -19,6 +19,9 @@ typedef struct {
     int nsched;
     uint32_t invalid_value; /* valid() rejects this value when nonzero */
     int abort_at;           /* abort() true once relaxes >= abort_at when nonzero */
+    uint64_t snaps;         /* polls seen by the snapshot hook (it runs right after the reads) */
+    uint64_t last_snap_barriers;
+    uint64_t order_violations; /* polls whose reads were not preceded by a fresh barrier */
 } Fake;
 
 static uint64_t fk_now(void *c) { return ((Fake *)c)->t_ns; }
@@ -30,6 +33,13 @@ static void fk_relax(void *c) {
     for (int i = 0; i < f->nsched; i++)
         if (f->at[i] == f->relaxes) *f->target[i] = f->value[i];
 }
+static void fk_snapshot(void *c, uint32_t out[2]) {
+    Fake *f = c;
+    out[0] = out[1] = 0;
+    f->snaps++;
+    if (f->barriers <= f->last_snap_barriers) f->order_violations++;
+    f->last_snap_barriers = f->barriers;
+}
 static bool fk_valid(void *c, uint32_t v) { return !((Fake *)c)->invalid_value || v != ((Fake *)c)->invalid_value; }
 static bool fk_abort(void *c) { Fake *f = c; return f->abort_at && f->relaxes >= (uint64_t)f->abort_at; }
 
@@ -180,9 +190,14 @@ static int scenario(const char *name, WaitFn fx, WaitFn sq, int which) {
         break;
     case S_BARRIER:
         sched(&f, 5, &w, 1);
+        cfg.snapshot = fk_snapshot; /* runs after the reads of each poll: marks where the read happened */
+        cfg.snapshot_ctx = &f;
         ok = sq(&w, 1, &r, &cfg);
         CHECK(ok && r.polls > 0 && f.barriers >= r.polls + 1, "%s: barriers %llu polls %llu", name,
               (unsigned long long)f.barriers, (unsigned long long)r.polls);
+        CHECK(f.snaps == r.polls && f.order_violations == 0, "%s: a barrier must precede every read (%llu of %llu polls unordered)", name,
+              (unsigned long long)f.order_violations, (unsigned long long)f.snaps);
+        CHECK(f.barriers > f.last_snap_barriers, "%s: barrier after the PASS observation", name);
         break;
     case S_HARD_DEADLINE:
         cfg.total_timeout_ms = 200;