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#976 (code only)

closed derived 98b4b11a502614d7 #976

Imported from GitHub aien-dev/omega-mv#976 (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 d8fc2db3f227606c02cbcbf26e54da819a816e58 · Head 11461f02002b901719fe85a2fc734f5aca7c4464

Fetch it

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

curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/98b4b11a502614d7.bundle -o 98b4b11a502614d7.bundle
git fetch 98b4b11a502614d7.bundle refs/pull/976/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
976
11461f02002b901719fe85a2fc734f5aca7c4464
{"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":976,"url":"https://github.com/aien-dev/omega-mv/pull/976","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:39:36Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.crumb b/.crumb
index 8ad94307c..7591e4474 100644
--- a/.crumb
+++ b/.crumb
@@ -95,8 +95,8 @@
           "purpose": "Directory src. Purpose not yet described by a human."
         },
         {
-          "digest": "c7007b5f5d79842fdf1c778fe77e23dca0d40e367e9ae56864e0864efebabb88",
-          "last_commit": "3c181b04f",
+          "digest": "3b3c30d517c9d2367e90906a585b5cc1f8c3f1ab1a1afe3da045b7507250fa83",
+          "last_commit": "6a6939e96",
           "name": "tests",
           "purpose": "Directory tests. Purpose not yet described by a human."
         },
@@ -107,15 +107,15 @@
           "purpose": "Directory tools. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:984d4b0c27a1ca0436c535abc743c1621196dd712bda58a009e682d69e9f3944",
-      "compiled_at": "2026-10-30T19:37:57Z",
+      "children_root": "sha256:c41451f0b7fca2f08f0a418b58ebc17d62f080371ce28587bbe1d0e7c24f3337",
+      "compiled_at": "2026-10-31T00:31:50Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:15c5771fc1011e787d59829fd022d4974ac6c8d7258c2a47de61f4f8cc01aecb",
+      "digest": "sha256:3f182c11d422d38bfc749ea46bd14f9cb5ab9b2373ade9fb55fd116ab325ce14",
       "evidence_files": 14460,
       "evidence_root": "sha256:59287e49f62c620e14a0dd56c32f5320ebe7f1ec2e365daa19d0082c70e51dc5",
       "files": 20399,
-      "generated_at_commit": "e38242fc7dfc7baf65aac2fa8130b49c3bb4d8ef",
-      "source_tree": "sha256:ce6304e0bea37bafd61ce59fe68345863eb93d6681235a09d9ca1934a72fdb7e"
+      "generated_at_commit": "6a6939e966088313c76cb59ea740a514f77f16c5",
+      "source_tree": "sha256:2ee1e582cc6a4dbb448ed364011461e398ebf34419370433bbd2e647bb8432a3"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/tests/.crumb b/tests/.crumb
index fe296ed29..80f062733 100644
--- a/tests/.crumb
+++ b/tests/.crumb
@@ -308,14 +308,14 @@
         }
       ],
       "children_root": "sha256:4e202b52b2c80d88dc93220a0c00cda479e52c2e63f847fbb30b9b1f426294f5",
-      "compiled_at": "2026-10-30T18:47:23Z",
+      "compiled_at": "2026-10-31T00:31:50Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:c7007b5f5d79842fdf1c778fe77e23dca0d40e367e9ae56864e0864efebabb88",
+      "digest": "sha256:3b3c30d517c9d2367e90906a585b5cc1f8c3f1ab1a1afe3da045b7507250fa83",
       "evidence_files": 16,
       "evidence_root": "sha256:96d08097822ad95f4e562c19e0ba5df5a035774c48632f1832912c40a27bd27a",
       "files": 1504,
-      "generated_at_commit": "f5c9bd89ae604a65d7c777a5739c176f41a036ec",
-      "source_tree": "sha256:e97a2b056f8bb668b419c8d0afa8438ef0bdce4ec96ff094d0bbd4f2a17e5873"
+      "generated_at_commit": "6a6939e966088313c76cb59ea740a514f77f16c5",
+      "source_tree": "sha256:6e2fba94a61a7c6dbc86bbc3afc1a16711b3140b64ee20c46e36a0f6f7ab1f99"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/tests/gpu_fp8_slots_test.c b/tests/gpu_fp8_slots_test.c
index 1ef57aa4f..e7c35e04e 100644
--- a/tests/gpu_fp8_slots_test.c
+++ b/tests/gpu_fp8_slots_test.c
@@ -24,6 +24,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
 
 static int g_failed, g_checks;
 #define CHECK(c, ...) do { g_checks++; if (c) { printf("ok   "); } else { printf("FAIL "); g_failed++; } printf(__VA_ARGS__); printf("\n"); } while (0)
@@ -32,23 +33,56 @@ static uint32_t lcg(uint32_t *s) { *s = *s * 1664525u + 1013904223u; return *s;
 
 /* ---------------- host-only: the state machine ---------------- */
 
-typedef struct { OmegaFp8SlotTable *t; uint64_t *shadow_version; volatile int stop; uint64_t observed_rewrites, pins_ok; } Race;
+/* The race must not depend on how the threads are scheduled (a 1-CPU taskset starved the writer; a loaded host hid the
+ * mutant). The writer publishes every reload attempt under m; a reader holds its pin until two attempts have finished
+ * after it pinned, so at least one begin_load runs entirely inside the pin, and pins again only after the writer
+ * published a reload, so pins always drain and the writer always gets through. Waits block on cv (no spinning or
+ * yielding), so a host with every CPU busy only slows the hand-offs, it cannot starve them. */
+typedef struct {
+    OmegaFp8SlotTable *t; uint64_t *shadow_version;
+    pthread_mutex_t m; pthread_cond_t cv; int stop; uint64_t attempts, reloads; /* guarded by m */
+    uint64_t observed_rewrites, pins_ok; /* atomic */
+} Race;
+
+/* waits until *ctr >= target or stop; returns the value of *ctr seen */
+static uint64_t race_wait(Race *r, const uint64_t *ctr, uint64_t target) {
+    pthread_mutex_lock(&r->m);
+    while (*ctr < target && !r->stop) pthread_cond_wait(&r->cv, &r->m);
+    const uint64_t v = *ctr;
+    pthread_mutex_unlock(&r->m);
+    return v;
+}
+
+static int race_stopped(Race *r) {
+    pthread_mutex_lock(&r->m); const int s = r->stop; pthread_mutex_unlock(&r->m);
+    return s;
+}
 
 static void *reader(void *arg) {
     Race *r = arg;
-    while (!r->stop) {
+    uint64_t after = 0; int pinned_once = 0;
+    while (!race_stopped(r)) {
+        if (pinned_once) race_wait(r, &r->reloads, after + 1);
         OmegaFp8SlotRec rec;
         if (omega_fp8_slot_query(r->t, 0, &rec) != 0) continue;
         if (rec.state != OMEGA_FP8_SLOT_READY) continue;
         if (omega_fp8_slot_pin(r->t, 0, rec.version) != 0) continue;
-        r->pins_ok++;
+        pinned_once = 1;
+        __atomic_fetch_add(&r->pins_ok, 1, __ATOMIC_RELAXED);
         /* while pinned, the shadow (the slot bytes) must keep holding the content of the pinned key */
-        for (int i = 0; i < 64; i++) if (__atomic_load_n(r->shadow_version, __ATOMIC_ACQUIRE) != rec.key) r->observed_rewrites++;
+        uint64_t seen = __atomic_load_n(r->shadow_version, __ATOMIC_ACQUIRE) != rec.key;
+        const uint64_t a0 = race_wait(r, &r->attempts, 0);
+        race_wait(r, &r->attempts, a0 + 2);
+        seen += __atomic_load_n(r->shadow_version, __ATOMIC_ACQUIRE) != rec.key;
+        if (seen) __atomic_fetch_add(&r->observed_rewrites, seen, __ATOMIC_RELAXED);
+        after = race_wait(r, &r->reloads, 0);
         (void)omega_fp8_slot_unpin(r->t, 0, rec.version);
     }
     return NULL;
 }
 
+static double now_s(void) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return (double)ts.tv_sec + ts.tv_nsec * 1e-9; }
+
 static int host_tests(void) {
     OmegaFp8SlotTable t;
     CHECK(omega_fp8_slot_table_init(&t, 4) == 0, "init 4 slots");
@@ -88,35 +122,47 @@ static int host_tests(void) {
     omega_fp8_slot_table_fini(&t);
 
     /* threaded race: 4 readers pin slot 0 at its current version; one writer reloads it as fast as it can. The shadow
-     * stands for the slot's bytes: the writer bumps it between begin_load and finish_load (while the slot is hidden). */
+     * stands for the slot's bytes: the writer bumps it between begin_load and finish_load (while the slot is hidden).
+     * The writer runs until RELOADS reloads and PINS reader pins happened (60 s cap, which only a hung table reaches). */
+    enum { RELOADS = 10000, PINS = 1000 };
     for (int mutant = 0; mutant <= 1; mutant++) {
         OmegaFp8SlotTable rt; omega_fp8_slot_table_init(&rt, 1);
         omega_fp8_slot_table_set_mutant(&rt, mutant);
         uint64_t shadow = 0, v = 0;
         omega_fp8_slot_begin_load(&rt, 0); omega_fp8_slot_finish_load(&rt, 0, 0, 1, &v);
         __atomic_store_n(&shadow, 0, __ATOMIC_RELEASE);
-        Race r = { .t = &rt, .shadow_version = &shadow };
+        Race r = { .t = &rt, .shadow_version = &shadow, .m = PTHREAD_MUTEX_INITIALIZER, .cv = PTHREAD_COND_INITIALIZER };
         pthread_t th[4];
         for (int i = 0; i < 4; i++) pthread_create(&th[i], NULL, reader, &r);
         uint64_t reloads = 0, busy = 0;
-        for (int i = 0; i < 200000; i++) {
-            if (omega_fp8_slot_begin_load(&rt, 0) != 0) { busy++; continue; }
-            __atomic_store_n(&shadow, 0xDEADull << 32, __ATOMIC_RELEASE); /* "bytes" half-written */
-            __atomic_store_n(&shadow, (uint64_t)i + 1, __ATOMIC_RELEASE); /* "bytes" complete: the content of key i + 1 */
-            uint64_t nv = 0; omega_fp8_slot_finish_load(&rt, 0, (uint64_t)i + 1, 1, &nv);
-            reloads++;
+        const double t0 = now_s();
+        for (uint64_t i = 0; reloads < RELOADS || __atomic_load_n(&r.pins_ok, __ATOMIC_RELAXED) < PINS; i++) {
+            if ((i & 1023) == 0 && now_s() - t0 > 60.0) break;
+            const int rc = omega_fp8_slot_begin_load(&rt, 0);
+            if (rc == 0) {
+                __atomic_store_n(&shadow, 0xDEADull << 32, __ATOMIC_RELEASE); /* "bytes" half-written */
+                __atomic_store_n(&shadow, i + 1, __ATOMIC_RELEASE); /* "bytes" complete: the content of key i + 1 */
+                uint64_t nv = 0; omega_fp8_slot_finish_load(&rt, 0, i + 1, 1, &nv);
+                reloads++;
+            } else busy++;
+            pthread_mutex_lock(&r.m);
+            r.attempts = i + 1; r.reloads = reloads;
+            pthread_cond_broadcast(&r.cv);
+            pthread_mutex_unlock(&r.m);
         }
-        r.stop = 1;
+        pthread_mutex_lock(&r.m); r.stop = 1; pthread_cond_broadcast(&r.cv); pthread_mutex_unlock(&r.m);
         for (int i = 0; i < 4; i++) pthread_join(th[i], NULL);
+        const int ran = reloads >= RELOADS && r.pins_ok >= PINS;
         if (!mutant)
-            CHECK(r.observed_rewrites == 0 && reloads > 0 && r.pins_ok > 0,
+            CHECK(ran && r.observed_rewrites == 0,
                   "race: %" PRIu64 " reloads, %" PRIu64 " busy refusals, %" PRIu64 " reader pins, rewrites seen under a pin = %" PRIu64,
                   reloads, busy, r.pins_ok, r.observed_rewrites);
         else
-            printf("info negative control (mutant ignores pins): %" PRIu64 " reloads, %" PRIu64 " reader pins, rewrites seen under a pin = %" PRIu64 " (%s)\n",
-                   reloads, r.pins_ok, r.observed_rewrites, r.observed_rewrites ? "CAUGHT" : "not observed this run");
-        if (mutant) CHECK(r.observed_rewrites > 0, "mutant: readers observe rewrites under a pin (the race check has teeth)");
+            CHECK(ran && r.observed_rewrites > 0,
+                  "mutant (ignores pins): %" PRIu64 " reloads, %" PRIu64 " reader pins, rewrites seen under a pin = %" PRIu64 " (the race check has teeth)",
+                  reloads, r.pins_ok, r.observed_rewrites);
         omega_fp8_slot_table_fini(&rt);
+        pthread_cond_destroy(&r.cv); pthread_mutex_destroy(&r.m);
     }
     return 0;
 }