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

closed derived 4e4efb2850c88a07 #305

Imported from GitHub aien-dev/omega-mv#305 (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 c2c30730c5fc660157f998e03c7f1b8ce2f10bc3 · Head f3ac8c2040ec9b9eb19209611a9cd23b0c144f59

Apply it

git checkout -b patch-4e4efb2850c88a07 c2c30730c5fc660157f998e03c7f1b8ce2f10bc3
curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/4e4efb2850c88a07.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
305
f3ac8c2040ec9b9eb19209611a9cd23b0c144f59
{"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":305,"url":"https://github.com/aien-dev/omega-mv/pull/305","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:37:14Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.crumb b/.crumb
index b6c8cfe93..65be78dd9 100644
--- a/.crumb
+++ b/.crumb
@@ -88,32 +88,32 @@
         },
         {
           "digest": "216a1cd73e993694a7c2ff9580d2b9ec299ddb0876e29ddcaf23e35844ef73bd",
-          "last_commit": "bf89cda",
+          "last_commit": "c2c3073",
           "name": "src",
           "purpose": "Directory src. Purpose not yet described by a human."
         },
         {
-          "digest": "4dd032138822b16a873570aa3da09b5eacf47b1cbc91db74a44abf069317cdaf",
-          "last_commit": "bf89cda",
+          "digest": "54875b73cdd1fad056918c0ea3dbadfb1f02ea072a1e2115a8933a202c1d7012",
+          "last_commit": "6c93c0e",
           "name": "tests",
           "purpose": "Directory tests. Purpose not yet described by a human."
         },
         {
-          "digest": "cc003d272b6b0ba376a8fa7eb4f05a51041c945677ebe6eedcdccaaa929b6545",
-          "last_commit": "79a805d",
+          "digest": "6a6bc2fc769c40efe05fcaaa1bc5169b89e3446d1e427060747b78b43dd729a9",
+          "last_commit": "6c93c0e",
           "name": "tools",
           "purpose": "Directory tools. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:3d84efc61f05712e5b42769e1e986edefb43081fece5a56b225b528edd8c67c8",
-      "compiled_at": "2026-10-05T20:10:00Z",
+      "children_root": "sha256:ec128923135d5c8ffefa1d9295d0046f313f600cd30f09e04b4096ba92e1d7b4",
+      "compiled_at": "2026-10-05T22:53:19Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:ddec05bd6282c2eb67389050974498d6e43c3f7e9dae4f1d35e577ca507ec9a9",
+      "digest": "sha256:64c48291581e4edd8e53b866b55e3d4b3217c6f98c5147eee2d1f685c0b3a2f8",
       "evidence_files": 3304,
       "evidence_root": "sha256:9594e3e2a05603747e60ab08376dcf98a6857a89e43720f33126d5b68e41f4d1",
       "files": 5109,
-      "generated_at_commit": "f8ce768210e58d33e675a7bbae2208ccbfc58db7",
-      "source_tree": "sha256:0f967d2f0047b5ebadb0ca0cfc765dd1f7a8f9a6a3b0108d1cdd60d6db94f03d"
+      "generated_at_commit": "120e281a85954a716fc6693a5592759df330f78f",
+      "source_tree": "sha256:50d7628ab849023c4a45f54a8e11a21480322b2ea458e57d1ee616cdbfc2e767"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/tests/.crumb b/tests/.crumb
index ead2cc6ac..12349e8ac 100644
--- a/tests/.crumb
+++ b/tests/.crumb
@@ -254,7 +254,7 @@
         },
         {
           "digest": "71ee11a9ea01b73efaf1c3f4fa3495aa98cc7d610b5570ce591f0718bb25a4d4",
-          "last_commit": "bf89cda",
+          "last_commit": "c2c3073",
           "name": "runtime",
           "purpose": "Directory tests/runtime. Purpose not yet described by a human."
         },
@@ -284,14 +284,14 @@
         }
       ],
       "children_root": "sha256:5e49c39abb592f9a527e51b78cbb625925b7c4421476815cdcebe6b394a7ecda",
-      "compiled_at": "2026-10-05T20:10:00Z",
+      "compiled_at": "2026-10-05T22:53:19Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:4dd032138822b16a873570aa3da09b5eacf47b1cbc91db74a44abf069317cdaf",
+      "digest": "sha256:54875b73cdd1fad056918c0ea3dbadfb1f02ea072a1e2115a8933a202c1d7012",
       "evidence_files": 11,
       "evidence_root": "sha256:d5c1bceb4d57ef0eb42797c58801b5926509711614c3e38bb7105b6efa3942f2",
       "files": 808,
-      "generated_at_commit": "f8ce768210e58d33e675a7bbae2208ccbfc58db7",
-      "source_tree": "sha256:fd92b259602b73222ae782b64db0d9940e43300c46d9bec2f0efba4de7f01bfb"
+      "generated_at_commit": "120e281a85954a716fc6693a5592759df330f78f",
+      "source_tree": "sha256:c903806bc7979b01d455ddbe31854fd4385adaf591a3ec46adf07edd35865d82"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/tests/r15_energy_preflight_test.sh b/tests/r15_energy_preflight_test.sh
index a4d640acd..ab7218cd8 100644
--- a/tests/r15_energy_preflight_test.sh
+++ b/tests/r15_energy_preflight_test.sh
@@ -12,6 +12,8 @@ cd "$(dirname "$0")/.." || exit 1
 T=tools/r15_machine_state.sh; fail=0; C=tests/runtime/r15_measure.c
 W=$(mktemp -d) || exit 1; trap 'rm -rf "$W"' EXIT
 export R15_ENERGY_PREFLIGHT_SLEEP=0
+# fixture uptime: 100 s, so a 10 W floor is 1 kJ (1,000,000,000 uJ); fixtures hold 5 kJ unless a case says otherwise
+printf "100.00 90.00\n" > "$W/uptime"; export R15_UPTIME_FILE="$W/uptime"
 EL=$(sed -n 's/^static const char \*const k_elabel\[[A-Z_0-9]*\] = {\(.*\)};/\1/p' $C | tr -d '" ' | tr , ' ')
 PL=$(sed -n 's/^static const char \*const k_plabel\[[A-Z_0-9]*\] = {\(.*\)};/\1/p' $C | tr -d '" ' | tr , ' ')
 [ "$(echo $EL | wc -w)" = 5 ] && [ "$(echo $PL | wc -w)" = 5 ] || { echo "[-] cannot read label tables from $C"; exit 1; }
@@ -22,9 +24,12 @@ check() { # name expected-exit expected-text
 }
 mk() { # case: a complete, valid-looking reader tree (static counters)
     H=$W/$1/hwmon1; mkdir -p "$W/$1/hwmon0" "$H"; echo acpitz > "$W/$1/hwmon0/name"; echo aien_spbm > "$H/name"
-    i=1; for l in $EL; do echo "$l" > "$H/energy${i}_label"; echo 5000000 > "$H/energy${i}_input"; echo 0 > "$H/energy${i}_overflow_raw"; i=$((i + 1)); done
+    i=1; for l in $EL; do echo "$l" > "$H/energy${i}_label"; echo 5000000000 > "$H/energy${i}_input"; echo 0 > "$H/energy${i}_overflow_raw"; i=$((i + 1)); done
     i=1; for l in $PL; do echo "$l" > "$H/power${i}_label"; echo 20000000 > "$H/power${i}_input"; i=$((i + 1)); done
 }
+# advance <case> <start-uJ>: package counter rises 0.5 J then 1 J in the background while the preflight samples
+put() { echo "$2" > "$1.tmp" && mv "$1.tmp" "$1"; } # atomic, so the preflight never reads a half-written file
+advance() { ( sleep 0.05; put "$W/$1/hwmon1/energy1_input" $(( $2 + 500000 )); sleep 0.1; put "$W/$1/hwmon1/energy1_input" $(( $2 + 1000000 )) ) & }
 mkdir -p "$W/absent/hwmon0"; echo acpitz > "$W/absent/hwmon0/name"; check absent 5 "reason=absent"
 mkdir -p "$W/empty"; check empty 5 "reason=absent"
 mk substitute; echo nvml > "$W/substitute/hwmon1/name"; check substitute 5 "reason=absent"
@@ -43,10 +48,26 @@ mk nopower; rm "$W/nopower/hwmon1/power2_input"; check nopower 5 "power2_input"
 mk badpower; echo abc > "$W/badpower/hwmon1/power4_input"; check badpower 5 "power4_input"
 mk noenergy3; rm "$W/noenergy3/hwmon1/energy3_input"; check noenergy3 5 "energy3_input"
 mk lowhead; echo 4294967000000000 > "$W/lowhead/hwmon1/energy3_input"; check lowhead 5 "headroom"
+# whole-run headroom: 200 kJ left passes the old 300 s x 600 W (180 kJ) window check but is
+# less than the planned run (2400 s x 100 W = 240 kJ), so a wrap could land mid-run
+mk shortrun; echo 4094967295000 > "$W/shortrun/hwmon1/energy1_input"
+advance shortrun 4094967295000
+R15_ENERGY_PREFLIGHT_SLEEP=0.08 check shortrun 5 "planned run"; wait
+# wrapped / reset counter: uptime 200000 s but only 1 kJ on the counter (floor 10 W x 200000 s = 2 MJ)
+mk wrapped; echo 1000000000 > "$W/wrapped/hwmon1/energy1_input"; printf "200000.00 1.00\n" > "$W/wrapped-uptime"
+advance wrapped 1000000000
+R15_UPTIME_FILE="$W/wrapped-uptime" R15_ENERGY_PREFLIGHT_SLEEP=0.08 check wrapped 5 "wrapped or was reset"; wait
+mk nouptime; advance nouptime 5000000000; R15_UPTIME_FILE="$W/does-not-exist" R15_ENERGY_PREFLIGHT_SLEEP=0.08 check nouptime 5 "uptime"; wait
+# a decrease on any channel (not only package) invalidates the reader
+mk decr3; echo 5000000000 > "$W/decr3/hwmon1/energy1_input"
+( k=0; while [ $k -lt 60 ]; do put "$W/decr3/hwmon1/energy3_input" $((5000000000 - k * 1000)); k=$((k + 1)); sleep 0.01; done ) &  # steadily falling cpu_p counter
+advance decr3 5000000000
+R15_ENERGY_PREFLIGHT_SLEEP=0.08 check decr3 5 "energy3 counter went backwards"
+wait
 # valid: package counter advances between samples
 mk valid
-( sleep 0.05; echo 100500 > "$W/valid/hwmon1/energy1_input"; sleep 0.1; echo 101000 > "$W/valid/hwmon1/energy1_input" ) &
-echo 100000 > "$W/valid/hwmon1/energy1_input"
+put "$W/valid/hwmon1/energy1_input" 5000100000
+advance valid 5000100000
 R15_ENERGY_PREFLIGHT_SLEEP=0.08 check valid 0 "energy preflight ok"
 wait
 # blocked run: receipt refuses (exit 4), writes nothing
diff --git a/tools/.crumb b/tools/.crumb
index f0d84cbb9..f2b8b022e 100644
--- a/tools/.crumb
+++ b/tools/.crumb
@@ -56,14 +56,14 @@
         }
       ],
       "children_root": "sha256:8a042dc49a250f0d1b7ae1358fc70bf7bdc9eff651a5ff7c9ee41fd49d329041",
-      "compiled_at": "2026-10-05T17:01:01Z",
+      "compiled_at": "2026-10-05T19:22:53Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:cc003d272b6b0ba376a8fa7eb4f05a51041c945677ebe6eedcdccaaa929b6545",
+      "digest": "sha256:6a6bc2fc769c40efe05fcaaa1bc5169b89e3446d1e427060747b78b43dd729a9",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 134,
-      "generated_at_commit": "714835409175f776b4a5630d892cf9383ba43b44",
-      "source_tree": "sha256:4a4582c7e05916245e2cc7ad03ce80fa85e56abd1cb13d5dc4703d7113cc317a"
+      "generated_at_commit": "379eb876aee36fbd20de3dd9938ea00f8e03677d",
+      "source_tree": "sha256:fa5eb73d5b945bc496f81d94e732cb4f87a6468c351fe93318b609d652ec74c6"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/tools/r15_machine_state.sh b/tools/r15_machine_state.sh
index dcd3912cd..d255c78be 100755
--- a/tools/r15_machine_state.sh
+++ b/tools/r15_machine_state.sh
@@ -68,6 +68,9 @@ R15_MEASURE_C=$(cd "$(dirname "$0")/.." && pwd)/tests/runtime/r15_measure.c
 energy_preflight() {
     local root=${R15_HWMON_ROOT:-/sys/class/hwmon} nap=${R15_ENERGY_PREFLIGHT_SLEEP:-0.1}
     local hs=${R15_ENERGY_HEADROOM_SECONDS:-300}
+    local run_s=${R15_PLANNED_RUN_SECONDS:-2400} run_w=${R15_RUN_BOUND_WATTS:-100} min_w=${R15_ENERGY_MIN_WATTS:-10}
+    local up_file=${R15_UPTIME_FILE:-/proc/uptime} up up_s
+    declare -a last=()
     local h="" d s v prev="" first="" n=0 i lab want
     local el pl
     el=$(sed -n 's/^static const char \*const k_elabel\[[A-Z_0-9]*\] = {\(.*\)};/\1/p' "$R15_MEASURE_C" | tr -d '" ')
@@ -89,6 +92,8 @@ energy_preflight() {
         want=$(printf '%s' "$pl" | cut -d, -f$i); lab=$(cat "$h/power${i}_label" 2>/dev/null)
         [ "$lab" = "$want" ] || { echo "INSTRUMENT_UNAVAILABLE reason=invalid: power${i}_label is '$lab', not $want"; return 5; }
     done
+    up=$(cut -d" " -f1 "$up_file" 2>/dev/null); up_s=${up%%.*}
+    case "$up_s" in ''|*[!0-9]*) echo "INSTRUMENT_UNAVAILABLE reason=invalid: cannot read uptime from $up_file, so a wrapped or reset counter cannot be ruled out"; return 5;; esac
     for s in 1 2 3; do
         for i in 1 2 3 4 5; do
             v=$(cat "$h/energy${i}_overflow_raw" 2>/dev/null)
@@ -104,10 +109,21 @@ energy_preflight() {
                 [ -z "$first" ] && first=$v
                 prev=$v; n=$((n + 1))
             fi
+            # every channel is a monotonic counter: a decrease on any of them (not only package) invalidates the reader
+            if [ -n "${last[$i]:-}" ] && [ "$v" -lt "${last[$i]}" ]; then echo "INSTRUMENT_UNAVAILABLE reason=invalid: energy${i} counter went backwards (${last[$i]} -> $v uJ)"; return 5; fi
+            last[$i]=$v
+            # a counter that counts from boot cannot sit below a floor power times the uptime unless it wrapped or was reset
+            if [ "$i" = 1 ] && [ "$v" -lt $((up_s * min_w * 1000000)) ]; then
+                echo "INSTRUMENT_UNAVAILABLE reason=invalid: package counter $v uJ is below ${min_w} W x ${up_s} s of uptime: the counter wrapped or was reset (spec §17 does not unwrap)"; return 5
+            fi
             # headroom to the 32-bit mJ wrap (as uJ) at a 600 W bound over the window
             if [ $((4294967295 * 1000 - v)) -lt $((hs * 600000000)) ]; then
                 echo "INSTRUMENT_UNAVAILABLE reason=invalid: energy${i} has less than ${hs} s of headroom before the counter wraps at 600 W (spec §17)"; return 5
             fi
+            # and enough for the whole planned run, so the counter cannot wrap between trials
+            if [ $((4294967295 * 1000 - v)) -lt $((run_s * run_w * 1000000)) ]; then
+                echo "INSTRUMENT_UNAVAILABLE reason=invalid: energy${i} has less headroom than the planned run (${run_s} s at ${run_w} W) before the counter wraps"; return 5
+            fi
         done
         [ "$s" -lt 3 ] && sleep "$nap"
     done
diff --git a/tools/r15_qualify.sh b/tools/r15_qualify.sh
index 48b569dc4..1e507ce1e 100755
--- a/tools/r15_qualify.sh
+++ b/tools/r15_qualify.sh
@@ -114,6 +114,9 @@ ps -eo pid,pcpu,rss,comm --sort=-pcpu > "$OUT/processes-before.txt"
 # reader is absent or returns invalid samples, the run cannot PASS, so stop
 # before consuming an acceptance window. This is BLOCKED_INSTRUMENT, not a
 # measured FAIL: no trial runs, no summary and no receipt is written.
+# planned run length for the counter-headroom check: the full default run (12/5/5) took 2068 s (CAND-1 window 2),
+# 2400 s with margin; scaled by the number of rounds and level runs. Override with R15_PLANNED_RUN_SECONDS.
+export R15_PLANNED_RUN_SECONDS=${R15_PLANNED_RUN_SECONDS:-$(( 2400 * (ROUNDS + L1RUNS + L2RUNS) / 22 + 1 ))}
 if [ "$MODE" = silicon ]; then
     if ! ENERGY_MSG=$("$STATE" energy-preflight); then
         say "BLOCKED_INSTRUMENT: $ENERGY_MSG"