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

closed derived caee18c5fb8b230c #1006

Imported from GitHub aien-dev/omega-mv#1006 (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 28513391aad34c17067ef252857666202548efdb · Head 251e7be222ad84daf44f63d32b893a69efd0fe2d

Fetch it

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

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

Changes

diff --git a/.crumb b/.crumb
index fa5d6739e..0cdbf712a 100644
--- a/.crumb
+++ b/.crumb
@@ -48,7 +48,7 @@
         },
         {
           "digest": "c90443bd3d00414c2b75a7dd64703381ba635c8b0fa0f355f222fb5dd0840424",
-          "last_commit": "a20577258",
+          "last_commit": "2638a49bd",
           "name": "docs",
           "purpose": "Directory docs. Purpose not yet described by a human."
         },
@@ -89,14 +89,14 @@
           "purpose": "Directory spec. Purpose not yet described by a human."
         },
         {
-          "digest": "0b45b3b8037fb89222c06563d9cde31caf762b9751994fafa603e1c84d350d91",
-          "last_commit": "9920aab14",
+          "digest": "fd1213241c865c525cdbb1d84e9dbe42ed3f33056db94d08157617a88722e0a9",
+          "last_commit": "a99239a52",
           "name": "src",
           "purpose": "Directory src. Purpose not yet described by a human."
         },
         {
-          "digest": "0a1bedfebbcc0e923a70af1b3537bc5af1f45a79c527e517aace0bf4c5287dcf",
-          "last_commit": "0ccdd31d7",
+          "digest": "4d1c0dbfc70db83a69e68f262048bfd70e7216afda8bf0e5071ef4fb31f3a297",
+          "last_commit": "a99239a52",
           "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:4528fa18f79e23cd41bc4ed361e521f933ecaa24e7d8818e381da2bff65ddb52",
-      "compiled_at": "2026-10-31T13:47:48Z",
+      "children_root": "sha256:4db466878771f1c8f38aef28e5802ffb9adbd99712976c14cb4baeb22b1550c1",
+      "compiled_at": "2026-10-31T14:35:27Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:64a8772e9febd419577e2a06126b5cc71379e4737a9a4d9caed72c1b558426de",
+      "digest": "sha256:aad4acc546afc0f42bf4fbddc32cbfd9b8b5916fa2eca4c9c0e29047b0941838",
       "evidence_files": 14989,
       "evidence_root": "sha256:90148c46bbc2cd096c96064273ac90d63efb54260fe285e18d84429cdf657830",
-      "files": 23228,
-      "generated_at_commit": "a20577258e854e38709c7e5fcc64b287c5b04105",
-      "source_tree": "sha256:08cfab639f4a3ada0d7d8b8f1c12dbd8ff611e2afbb4d22ac64ef387db93cc88"
+      "files": 23229,
+      "generated_at_commit": "a99239a52cff9b67d4daf41fc3ab5111bd3e17b1",
+      "source_tree": "sha256:03061c6431aaebdc8f63c0ce7f0dcfd8c53f787a47b74b93c356f5b9f6149d47"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/src/.crumb b/src/.crumb
index 85650d7f0..1da4940a1 100644
--- a/src/.crumb
+++ b/src/.crumb
@@ -145,8 +145,8 @@
           "purpose": "Ionic-droplet reservoir simulator (omega#440): binary32 fixed-step RK4 of the authors' droplet m"
         },
         {
-          "digest": "43126cdfbfc4a67b3ab8785a1358a861960954e0374b7118781d06f117f9de5c",
-          "last_commit": "f56a372ae",
+          "digest": "7cbe4137297afac5dbf4062a5727be580be8cd1461785b1791d4781d2a0b1986",
+          "last_commit": "79a475666",
           "name": "runtime",
           "purpose": "Directory src/runtime. Purpose not yet described by a human."
         },
@@ -187,15 +187,15 @@
           "purpose": "Directory src/visor. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:6ade3e583c9df260fbfc768469dae662b88153725b14f7086431861419cfffe3",
-      "compiled_at": "2026-10-31T10:16:13Z",
+      "children_root": "sha256:85eaf778bf3ab98a260da21c06a6b2c60b3b1ca7c798df744060dbe2f3311a5a",
+      "compiled_at": "2026-10-31T14:02:07Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:0b45b3b8037fb89222c06563d9cde31caf762b9751994fafa603e1c84d350d91",
+      "digest": "sha256:fd1213241c865c525cdbb1d84e9dbe42ed3f33056db94d08157617a88722e0a9",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "files": 599,
-      "generated_at_commit": "7715c4e792abc9d99496d4e1ecfe8bccc79a5c17",
-      "source_tree": "sha256:efcba46d11640ffaa85dc9c407a9dea9d0cbe2b6cc60319505dfd327b4d852d2"
+      "files": 600,
+      "generated_at_commit": "79a4756660da249ec53c0438069ecec8174e6620",
+      "source_tree": "sha256:d34ce1a6ce129f2d2ab6a2b12bb0cf47eae80390621b560159a4739712483432"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/src/omega_blackwell_codegen.c b/src/omega_blackwell_codegen.c
index a0520f4c9..97a727a97 100644
--- a/src/omega_blackwell_codegen.c
+++ b/src/omega_blackwell_codegen.c
@@ -17,6 +17,7 @@
 #include "omega_blackwell_codegen.h"
 #include "omega_blackwell_submit.h"
 #include "sha256.h"
+#include "omega_path_check.h"
 #include <string.h>
 /* native v1 P07 cut A.2 (aienos#286, docs/numeric/OMEGA_GPU_NATIVE_BOUNDARY.md): with OMEGA_GPU_NO_POSIX this file
  * builds -ffreestanding. Code generation then runs only through the allocation-free entry points
@@ -1146,8 +1147,15 @@ int omega_blackwell_verify_codegen_fixtures_fb1cut4(void) {
  * every kernel the library builds. Unset (the normal case) it does nothing; the freestanding build has no files. */
 void omega_kernel_dump(const uint8_t *code, size_t len) {
 #ifndef OMEGA_GPU_NO_POSIX
-    const char *dir = getenv("OMEGA_KERNEL_DUMP_DIR");
-    if (!dir || !dir[0] || !code || !len) return;
+    const char *env = getenv("OMEGA_KERNEL_DUMP_DIR");
+    if (!env || !env[0] || !code || !len) return;
+    /* Only the checked copy (src/omega_path_check.h) is opened; a refused directory is a diagnostic, which
+     * tools/sm121dis/corpus.sh fails on, never a silent skip. */
+    char dir[4000];
+    if (omega_path_copy(dir, sizeof dir, env) != 0) {
+        BW_DIAG("omega_kernel_dump: OMEGA_KERNEL_DUMP_DIR refused (src/omega_path_check.h)\n");
+        return;
+    }
     uint8_t d[SHA256_DIGEST_SIZE]; sha256_hash(code, len, d);
     char path[4096];
     int n = snprintf(path, sizeof path, "%s/%02x%02x%02x%02x%02x%02x%02x%02x.bin",
diff --git a/src/omega_evidence.c b/src/omega_evidence.c
index 5060c3318..c258ed6f1 100644
--- a/src/omega_evidence.c
+++ b/src/omega_evidence.c
@@ -47,6 +47,11 @@ static bool popen_read_line(const char *cmd, char *out, size_t n) {
     return true;
 }
 
+/* c when it is a lower-case hex digit, -1 otherwise */
+static int hex_byte(int c) {
+    return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') ? c : -1;
+}
+
 /* ---- run_id -------------------------------------------------------------- */
 
 static char g_run_id[96] = {0};
@@ -60,10 +65,20 @@ const char *omega_evidence_run_id(void) {
         char ts[32];
         strftime(ts, sizeof(ts), "%Y%m%dT%H%M%SZ", &tm_info);
 
-        char sha[64];
-        if (!popen_read_line("git rev-parse --short=12 HEAD 2>/dev/null", sha, sizeof(sha))) {
-            snprintf(sha, sizeof(sha), "unknown");
+        /* The run id names the evidence directory (omega_evidence_path), so git's answer is kept only as
+         * lower-case hex, copied byte by byte; anything else is "unknown". */
+        char line[64], sha[64];
+        size_t k = 0;
+        if (popen_read_line("git rev-parse --short=12 HEAD 2>/dev/null", line, sizeof(line))) {
+            for (; line[k]; k++) {
+                int c = hex_byte((unsigned char)line[k]);
+                if (c < 0) break;
+                sha[k] = (char)c;
+            }
+            if (line[k]) k = 0;
         }
+        sha[k] = '\0';
+        if (k == 0) snprintf(sha, sizeof(sha), "unknown");
         snprintf(g_run_id, sizeof(g_run_id), "%s-%s", ts, sha);
         g_run_id_ready = true;
     }
@@ -133,6 +148,15 @@ int omega_evidence_write_digest(const char *relstem, const char *ext, const void
     return 0;
 }
 
+FILE *omega_evidence_create(const char *path) {
+    if (!path) return NULL;
+    int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
+    if (fd < 0) return NULL;
+    FILE *f = fdopen(fd, "w");
+    if (!f) close(fd);
+    return f;
+}
+
 /* ---- commit identity --------------------------------------------------- */
 
 bool omega_evidence_run_commit(char out[41]) {
diff --git a/src/omega_evidence.h b/src/omega_evidence.h
index c7497dced..474918272 100644
--- a/src/omega_evidence.h
+++ b/src/omega_evidence.h
@@ -39,6 +39,7 @@
 
 #include <stddef.h>
 #include <stdbool.h>
+#include <stdio.h>
 #include "nvrm.h"
 
 /* ---- (a) run-scoped, non-clobbering evidence paths -------------------- */
@@ -74,6 +75,13 @@ int omega_evidence_path(const char *relpath, char *out, size_t n);
 int omega_evidence_write_digest(const char *relstem, const char *ext, const void *buf,
                                 size_t len, char *out, size_t n);
 
+/*
+ * Open `path` (from omega_evidence_path) for writing, created or truncated
+ * with mode 0644 (not fopen's 0666 & ~umask): a receipt is never
+ * world-writable. NULL on failure.
+ */
+FILE *omega_evidence_create(const char *path);
+
 /* The run_id used by omega_evidence_path(), computed lazily on first use. */
 const char *omega_evidence_run_id(void);
 
diff --git a/src/omega_path_check.h b/src/omega_path_check.h
new file mode 100644
index 000000000..a0ebf22fa
--- /dev/null
+++ b/src/omega_path_check.h
@@ -0,0 +1,56 @@
+/* SPDX-License-Identifier: Apache-2.0
+ * Copyright 2026 Drake Stapleton (AIEN / aien-dev)
+ *
+ * omega_path_check.h: a checked copy of a file system path that came from outside the program (an
+ * environment variable, a command's output, a caller's argument) before anything opens it.
+ *
+ * A path is accepted only when it is 1..cap-1 bytes long, every byte is in the POSIX portable file name set
+ * [A-Za-z0-9._-] or one of / + , = @ : ~ (no space, quote, control, shell or non-ASCII byte), and no
+ * component is "..". Absolute and relative paths are both accepted. The accepted path is copied byte by byte
+ * through omega_path_byte, so the bytes the caller later opens are exactly the bytes that were checked.
+ * A refused path leaves out as the empty string.
+ */
+#ifndef OMEGA_PATH_CHECK_H
+#define OMEGA_PATH_CHECK_H
+
+#include <stddef.h>
+
+/* c when it may appear in a checked path, -1 otherwise */
+static inline int omega_path_byte(int c) {
+    if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')) return c;
+    switch (c) {
+    case '.': case '_': case '-': case '/': case '+': case ',': case '=': case '@': case ':': case '~':
+        return c;
+    default:
+        return -1;
+    }
+}
+
+/* 0 with out = in when in is an acceptable path shorter than cap; -1 with out = "" otherwise */
+static inline int omega_path_copy(char *out, size_t cap, const char *in) {
+    if (!out || cap == 0) return -1;
+    out[0] = '\0';
+    if (!in || !in[0]) return -1;
+    size_t k = 0;
+    for (; in[k]; k++) {
+        int b = omega_path_byte((unsigned char)in[k]);
+        if (b < 0 || k + 1 >= cap) {
+            out[0] = '\0';
+            return -1;
+        }
+        out[k] = (char)b;
+    }
+    out[k] = '\0';
+    for (size_t i = 0; i < k;) {
+        size_t j = i;
+        while (j < k && out[j] != '/') j++;
+        if (j - i == 2 && out[i] == '.' && out[i + 1] == '.') {
+            out[0] = '\0';
+            return -1;
+        }
+        i = j + 1;
+    }
+    return 0;
+}
+
+#endif /* OMEGA_PATH_CHECK_H */
diff --git a/src/runtime/.crumb b/src/runtime/.crumb
index bcd420c68..0a76069aa 100644
--- a/src/runtime/.crumb
+++ b/src/runtime/.crumb
@@ -7,14 +7,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-10-30T11:21:25Z",
+      "compiled_at": "2026-10-31T14:01:27Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:43126cdfbfc4a67b3ab8785a1358a861960954e0374b7118781d06f117f9de5c",
+      "digest": "sha256:7cbe4137297afac5dbf4062a5727be580be8cd1461785b1791d4781d2a0b1986",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 65,
-      "generated_at_commit": "dd39bf71fb8eb14c45bf0abd20c74d5da69c807c",
-      "source_tree": "sha256:701918e639effadd136bf5e99dd06480103741211efce5e5232f7521aab82c87"
+      "generated_at_commit": "2638a49bd83d12c1e0c76a4c446d6be1c9a4d4f4",
+      "source_tree": "sha256:bfc3482cdd40894b47db6d71d8ec38c8791ff7bb996c1d2e5d4968400e1ad8fc"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/src/runtime/aien_machine_id.c b/src/runtime/aien_machine_id.c
index a41ec4f53..bd1686f89 100644
--- a/src/runtime/aien_machine_id.c
+++ b/src/runtime/aien_machine_id.c
@@ -19,6 +19,7 @@
  * canonical machine identity. The codec is in aien_machine_id.h.
  */
 #include "aien_machine_id.h"
+#include "omega_path_check.h"
 
 #include <errno.h>
 #include <fcntl.h>
@@ -40,18 +41,21 @@ int aien_mid_store(const char *path, const AienMachineId *m) {
     int rc = aien_mid_encode(m, rec);
     if (rc != AIEN_MID_OK) return rc;
 
+    /* The caller's path, checked (src/omega_path_check.h), is the only path opened or renamed. */
+    char p[4091];
+    if (omega_path_copy(p, sizeof p, path) != 0) return AIEN_MID_E_ARG;
     char tmp[4096];
-    if ((size_t)snprintf(tmp, sizeof tmp, "%s.tmp", path) >= sizeof tmp) return AIEN_MID_E_ARG;
+    if ((size_t)snprintf(tmp, sizeof tmp, "%s.tmp", p) >= sizeof tmp) return AIEN_MID_E_ARG;
     int fd = open(tmp, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
     if (fd < 0) return AIEN_MID_E_IO;
     if (write_all(fd, rec, sizeof rec) != 0 || fsync(fd) != 0) {
         close(fd); unlink(tmp); return AIEN_MID_E_IO;
     }
-    if (close(fd) != 0 || rename(tmp, path) != 0) { unlink(tmp); return AIEN_MID_E_IO; }
+    if (close(fd) != 0 || rename(tmp, p) != 0) { unlink(tmp); return AIEN_MID_E_IO; }
 
     /* fsync the directory so the rename survives a crash */
     char dir[4096];
-    snprintf(dir, sizeof dir, "%s", path);
+    snprintf(dir, sizeof dir, "%s", p);
     char *slash = strrchr(dir, '/');
     if (slash == dir) dir[1] = 0;
     else if (slash) *slash = 0;
@@ -63,7 +67,9 @@ int aien_mid_store(const char *path, const AienMachineId *m) {
 
 int aien_mid_load(const char *path, AienMachineId *out) {
     if (!path || !out) return AIEN_MID_E_ARG;
-    int fd = open(path, O_RDONLY | O_CLOEXEC);
+    char p[4096];
+    if (omega_path_copy(p, sizeof p, path) != 0) return AIEN_MID_E_ARG;
+    int fd = open(p, O_RDONLY | O_CLOEXEC);
     if (fd < 0) return AIEN_MID_E_IO;
     uint8_t buf[AIEN_MID_RECORD_BYTES + 1];
     size_t got = 0;
diff --git a/src/runtime/aien_machine_id.h b/src/runtime/aien_machine_id.h
index 86ecf4dcb..7494642ab 100644
--- a/src/runtime/aien_machine_id.h
+++ b/src/runtime/aien_machine_id.h
@@ -247,7 +247,9 @@ static inline int aien_mid_from_text(const char *s, AienMachineId *out) {
 
 /* ---- aien_machine_id.c -------------------------------------------------- */
 
-/* Persist atomically (temp file, fsync, rename, fsync directory). */
+/* Persist atomically (temp file, fsync, rename, fsync directory). A path that
+ * src/omega_path_check.h refuses (a ".." component, a byte outside its set, too
+ * long) is AIEN_MID_E_ARG for both calls, before any file is touched. */
 int aien_mid_store(const char *path, const AienMachineId *m);
 /* Load; any file that is not exactly one valid record is rejected. */
 int aien_mid_load(const char *path, AienMachineId *out);
diff --git a/src/runtime/rx_generation.c b/src/runtime/rx_generation.c
index 42bb41316..dff8c965e 100644
--- a/src/runtime/rx_generation.c
+++ b/src/runtime/rx_generation.c
@@ -22,6 +22,7 @@
 #include "runtime/rx_generation.h"
 #include "runtime/rx_argus.h"
 #include "sha256.h"
+#include "omega_path_check.h"
 
 #include <errno.h>
 #include <fcntl.h>
@@ -694,7 +695,8 @@ int rx_gen_open(const char *dir, RxGenStore **out) {
     RxGenStore *store = calloc(1, sizeof(*store));
     if (!store) return RX_GEN_ERR_IO;
     pthread_mutex_init(&store->active_mu, NULL);
-    if (snprintf(store->dir, sizeof store->dir, "%s", dir) >= (int)sizeof store->dir) {
+    /* The caller's directory, checked (src/omega_path_check.h), is the only one this store opens. */
+    if (omega_path_copy(store->dir, sizeof store->dir, dir) != 0) {
         free(store);
         return RX_GEN_ERR_ARG;
     }
@@ -776,8 +778,9 @@ int rx_gen_read_blob(const RxGenStore *store, uint64_t id, const char *name, uin
     if (view.id != id) return RX_GEN_ERR_TORN;
     if (view.lengths[which] > cap) return RX_GEN_ERR_ARG;
     char folder[512], path[512];
+    /* BLOB_NAME[which], not the caller's string: the name opened is the table's, never the input's */
     if (gen_dir(store->dir, id, folder, sizeof folder) != 0 ||
-        path_join(path, sizeof path, folder, name) != 0) return RX_GEN_ERR_IO;
+        path_join(path, sizeof path, folder, BLOB_NAME[which]) != 0) return RX_GEN_ERR_IO;
     rc = file_matches(path, view.digest[which], view.lengths[which]);
     if (rc != RX_GEN_OK) return rc;
     if (view.lengths[which] && read_full(path, buf, (size_t)view.lengths[which]) != 0)
@@ -1255,6 +1258,10 @@ done:
 int rx_gen_recover(const char *dir, RxRecoveryRecord *out) {
     if (!dir || !out) return RX_GEN_ERR_ARG;
     memset(out, 0, sizeof(*out));
+    /* From here dir is the checked copy (src/omega_path_check.h): no other path is opened. */
+    char checked[sizeof ((RxGenStore *)0)->dir];
+    if (omega_path_copy(checked, sizeof checked, dir) != 0) return RX_GEN_ERR_ARG;
+    dir = checked;
     char lock[512];
     if (path_join(lock, sizeof lock, dir, "barrier.lock") == 0) unlink(lock);
 
diff --git a/src/runtime/rx_generation.h b/src/runtime/rx_generation.h
index 433b16e55..9cdd7adab 100644
--- a/src/runtime/rx_generation.h
+++ b/src/runtime/rx_generation.h
@@ -172,6 +172,9 @@ typedef struct {
     uint64_t event_ns;           /* event log appended and synced */
 } RxGenPhases;
 
+/* rx_gen_open, rx_gen_recover and rx_gen_reject_replay answer RX_GEN_ERR_ARG,
+ * before touching any file, for a dir that src/omega_path_check.h refuses
+ * (a ".." component, a byte outside its set, or too long for RxGenStore). */
 int rx_gen_open(const char *dir, RxGenStore **out);
 void rx_gen_close(RxGenStore *store);
 /* R15: process-wide bytes written and fsync calls made by every store.
diff --git a/src/runtime/rx_world.c b/src/runtime/rx_world.c
index 028169beb..379e41c85 100644
--- a/src/runtime/rx_world.c
+++ b/src/runtime/rx_world.c
@@ -21,6 +21,7 @@
 #include "rx_argus.h"
 #include "sha256.h"
 #include "rx_generation.h"   /* RX_GEN_HALT_MARK */
+#include "omega_path_check.h"
 
 #include <errno.h>
 #include <fcntl.h>
@@ -967,11 +968,15 @@ static int fsync_dir(const char *dir) {
 }
 
 /* Write `buf` to dir/name durably (temporary file, fsync, rename, fsync dir).
- * With excl, an existing dir/name is never replaced (link, not rename). */
+ * With excl, an existing dir/name is never replaced (link, not rename). The
+ * name is one checked component (src/omega_path_check.h, no '/'); dir is
+ * w->halt_dir, checked when it was set. */
 static int durable_write(const char *dir, const char *name, const char *buf, size_t len, bool excl) {
-    char tmp[512], dst[512];
-    if (snprintf(tmp, sizeof tmp, "%s/%s.partial", dir, name) >= (int)sizeof tmp ||
-        snprintf(dst, sizeof dst, "%s/%s", dir, name) >= (int)sizeof dst)
+    char nm[160], tmp[512], dst[512];
+    if (omega_path_copy(nm, sizeof nm, name) != 0 || strchr(nm, '/') || strcmp(nm, ".") == 0)
+        return -EINVAL;
+    if (snprintf(tmp, sizeof tmp, "%s/%s.partial", dir, nm) >= (int)sizeof tmp ||
+        snprintf(dst, sizeof dst, "%s/%s", dir, nm) >= (int)sizeof dst)
         return -ENAMETOOLONG;
     int fd = open(tmp, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
     if (fd < 0) return -errno;
@@ -1062,14 +1067,16 @@ static uint64_t halt_crumb(RxWorld *w, RxCrumbKind kind, RxCapRef cap, int32_t r
 }
 
 int rx_world_set_halt_dir(RxWorld *w, const char *dir) {
-    if (!w || !dir || !dir[0] || strlen(dir) >= sizeof w->halt_dir) return RX_ERR_ARG;
+    /* Only the checked copy (src/omega_path_check.h) is kept and opened. */
+    char checked[sizeof w->halt_dir];
+    if (!w || omega_path_copy(checked, sizeof checked, dir) != 0) return RX_ERR_ARG;
     pthread_mutex_lock(&w->mu);
     pthread_mutex_lock(&w->callers_mu);
-    snprintf(w->halt_dir, sizeof w->halt_dir, "%s", dir);
+    memcpy(w->halt_dir, checked, strlen(checked) + 1);
     RxHaltStatus h;
     char raw[600];
     size_t raw_len = 0;
-    int rc = halt_mark_read(dir, &h, raw, sizeof raw, &raw_len);
+    int rc = halt_mark_read(w->halt_dir, &h, raw, sizeof raw, &raw_len);
     if (rc == 0 && w->halted) {
         w->halt.durable = halt_mark_write(w);   /* a stop taken before the directory was set */
     } else if (rc != 0 && !w->halted) {
diff --git a/src/runtime/rx_world.h b/src/runtime/rx_world.h
index b4029bcd8..f9f2603d3 100644
--- a/src/runtime/rx_world.h
+++ b/src/runtime/rx_world.h
@@ -836,6 +836,8 @@ int  rx_world_caller_check_fn(void *world, uint32_t subject, const RxCallerCred
                                            capability may also pause the world */
 #define RX_HALT_ALREADY       1   /* stop: already stopped, nothing changed */
 #define RX_HALT_NOT_STOPPED   2   /* resume: not stopped, nothing changed */
+/* A dir that src/omega_path_check.h refuses (a ".." component, a byte outside
+ * its set, too long) is RX_ERR_ARG, and the world's halt directory is unchanged. */
 int  rx_world_set_halt_dir(RxWorld *w, const char *dir);
 int  rx_world_emergency_stop(RxWorld *w, uint32_t subject, const RxCallerCred *cred,
                              RxCapRef cap, int32_t reason, RxHaltStatus *out);
diff --git a/tests/.crumb b/tests/.crumb
index 2cfdee8e1..14270d374 100644
--- a/tests/.crumb
+++ b/tests/.crumb
@@ -271,8 +271,8 @@
           "purpose": "Reservoir tests (omega#440): Gate 1 simulator and readout checks against an independent binary64"
         },
         {
-          "digest": "bd7d40c4941f8820fb03ff558b323e41a80edf02caf0068baf7307ed855dcaa5",
-          "last_commit": "1b9e0b553",
+          "digest": "3c0c470be85111fb756052d050a5d4620aad93b56908050d9135bc77e441ad42",
+          "last_commit": "0ccdd31d7",
           "name": "runtime",
           "purpose": "Directory tests/runtime. Purpose not yet described by a human."
         },
@@ -307,15 +307,15 @@
           "purpose": "Directory tests/visor. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:de9b552720cd8a79c9152deabd8c8087c756688d8a849af5e987373f2d0c512d",
-      "compiled_at": "2026-10-31T12:25:49Z",
+      "children_root": "sha256:63ecced764c3e1a6584cf63fe2465b5120d719658dbb804ed4f5e81cf7aae9aa",
+      "compiled_at": "2026-10-31T14:01:27Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:0a1bedfebbcc0e923a70af1b3537bc5af1f45a79c527e517aace0bf4c5287dcf",
+      "digest": "sha256:4d1c0dbfc70db83a69e68f262048bfd70e7216afda8bf0e5071ef4fb31f3a297",
       "evidence_files": 74,
       "evidence_root": "sha256:9aa38bf7dcfa5eb3499356a0a2a1dd7704fedfae2d16822a7c9e1400f3a72723",
       "files": 2047,
-      "generated_at_commit": "1b9e0b5530e5956f8967940fb001d632f0e61859",
-      "source_tree": "sha256:642df6ca0dad60e320b57318643b02c41ac8bf9b6cfef4a3a03586260d8f289b"
+      "generated_at_commit": "2638a49bd83d12c1e0c76a4c446d6be1c9a4d4f4",
+      "source_tree": "sha256:b13fee8dc19375b9f385d3e5eabc0a6f10c06f0e3b36936e312d2c75681c8325"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/tests/gpu_attention_test.c b/tests/gpu_attention_test.c
index 8ba96c81c..fa8b39cf5 100644
--- a/tests/gpu_attention_test.c
+++ b/tests/gpu_attention_test.c
@@ -50,6 +50,7 @@
 #include "omega_blackwell_codegen.h"
 #include "omega_sm121_disasm.h" /* C6 (L386): Omega's own disassembler replaces nvdisasm here */
 #include "bw_warp_sim.h" /* omega #308: SIMT warp simulator for --divergent */
+#include <fcntl.h>
 #include <inttypes.h>
 #include <math.h>
 #include <stdio.h>
@@ -58,6 +59,14 @@
 #include <time.h>
 #include <unistd.h>
 
+/* 0644, not fopen's 0666 & ~umask: a receipt is never world-writable */
+static FILE *create_0644(const char *path) {
+    int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
+    FILE *f = fd >= 0 ? fdopen(fd, "w") : NULL;
+    if (fd >= 0 && !f) close(fd);
+    return f;
+}
+
 static int g_checks, g_failed;
 static int g_sim_mode; /* --sim: the host simulator never opens the device */
 static int g_divergent; /* --divergent (omega #308 R2): the j >= ctx branch inside a BSSY/BSYNC region */
@@ -350,7 +359,7 @@ static void batch_single_repeat_checks(const char *name, const BatchCtx *bc, con
 
 
 static int chip(const char *out_path) {
-    FILE *out = out_path ? fopen(out_path, "w") : NULL;
+    FILE *out = out_path ? create_0644(out_path) : NULL;
     if (out_path && !out) { printf("cannot open %s\n", out_path); return 2; }
     if (out) fprintf(out, "{\"schema\":\"OMEGA_GPU_ATTENTION_V1\",\"tolerances\":{\"rel\":2e-4,\"abs\":2e-5,\"large_scores_rel\":1e-3,\"large_scores_abs\":1e-4},\"cases\":[");
     uint32_t seed = 0xfb1c0005u;
@@ -858,7 +867,7 @@ static int cmp_d(const void *a, const void *b) { double x = *(const double *)a,
  * context falls with more CTAs per (sequence, head) or stays flat (bandwidth bound: the four query heads of a
  * kv head each read its slice). */
 static int split_timing(const char *out_path) {
-    FILE *out = out_path ? fopen(out_path, "w") : NULL;
+    FILE *out = out_path ? create_0644(out_path) : NULL;
     if (out_path && !out) { printf("cannot open %s\n", out_path); return 2; }
     enum { N = 100 };
     const uint32_t hd = g_hd, nqh = 32, nkv = 8, bs = 16, layers = 2, layer = 1;
@@ -912,7 +921,7 @@ static int split_timing(const char *out_path) {
 }
 
 static int timing(const char *out_path) {
-    FILE *out = out_path ? fopen(out_path, "w") : NULL;
+    FILE *out = out_path ? create_0644(out_path) : NULL;
     if (out_path && !out) { printf("cannot open %s\n", out_path); return 2; }
     enum { N = 100 };
     const uint32_t hd = 64, nqh = 32, nkv = 4, seq = 2048;
@@ -968,7 +977,7 @@ static int timing(const char *out_path) {
  * through this path and are reported as unavailable. Under --sim the timings are host-simulator
  * timings and the receipt says so. */
 static int sweep(const char *out_path) {
-    FILE *out = out_path ? fopen(out_path, "w") : NULL;
+    FILE *out = out_path ? create_0644(out_path) : NULL;
     if (out_path && !out) { printf("cannot open %s\n", out_path); return 2; }
     const int N = g_sim_mode ? 1 : 20;
     const uint32_t hd = 64, bs = 16, layers = 1, layer = 0;
diff --git a/tests/gpu_tern_test.c b/tests/gpu_tern_test.c
index 16dfca40f..48e91db2d 100644
--- a/tests/gpu_tern_test.c
+++ b/tests/gpu_tern_test.c
@@ -36,11 +36,22 @@
 #include "omega_gpu_cmdlist.h"
 #include "algebra/realize_common.h"
 #include "bw_warp_sim_k.h"
+#include "omega_path_check.h"
+#include <fcntl.h>
 #include <inttypes.h>
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
+
+/* 0644, not fopen's 0666 & ~umask: a receipt is never world-writable */
+static FILE *create_0644(const char *path) {
+    int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
+    FILE *f = fd >= 0 ? fdopen(fd, "w") : NULL;
+    if (fd >= 0 && !f) close(fd);
+    return f;
+}
 
 #define SPEC_GBS 273.0
 #define PRACTICAL_GBS 237.2
@@ -498,8 +509,10 @@ static void speed_judged_init(void) {
     if (f && !strcmp(f, "1")) { g_speed_judged = 1; snprintf(g_speed_why, sizeof g_speed_why, "forced (AIEN_SPEED_GATE=1)"); return; }
     if (q && *q) { g_speed_judged = 1; snprintf(g_speed_why, sizeof g_speed_why, "quiet hold %.60s", q); return; }
     if (w && *w) {
-        char p[4096], mode[16] = {0}; snprintf(p, sizeof p, "%s/gb10", w);
-        FILE *fp = fopen(p, "r"); if (fp) { if (!fgets(mode, sizeof mode, fp)) mode[0] = 0; fclose(fp); }
+        /* Only a checked SPARK_WINDOW_DIR (src/omega_path_check.h) is read; a refused one is not an exclusive window. */
+        char d[4000], p[4096], mode[16] = {0};
+        if (omega_path_copy(d, sizeof d, w) == 0) snprintf(p, sizeof p, "%s/gb10", d); else p[0] = 0;
+        FILE *fp = p[0] ? fopen(p, "r") : NULL; if (fp) { if (!fgets(mode, sizeof mode, fp)) mode[0] = 0; fclose(fp); }
         if (!strncmp(mode, "exclusive", 9)) { g_speed_judged = 1; snprintf(g_speed_why, sizeof g_speed_why, "exclusive spark-window"); return; }
     }
     g_speed_judged = 0; snprintf(g_speed_why, sizeof g_speed_why, "shared machine: no quiet hold, no exclusive spark-window");
@@ -651,7 +664,7 @@ int main(int argc, char **argv) {
             if (!no_bw) chip_bandwidth(reps);
         }
         RC("  \"checks\": %d, \"failed\": %d, \"verdict\": \"%s\"\n}\n", g_checks, g_failed, g_failed ? "FAIL" : "PASS");
-        if (out) { FILE *f = fopen(out, "w"); if (f) { fputs(g_rcpt, f); fclose(f); printf("receipt: %s\n", out); } else CHECK(0, "cannot write %s", out); }
+        if (out) { FILE *f = create_0644(out); if (f) { fputs(g_rcpt, f); fclose(f); printf("receipt: %s\n", out); } else CHECK(0, "cannot write %s", out); }
     }
     printf("gpu_tern_test: %d checks, %d failed: %s\n", g_checks, g_failed, g_failed ? "FAIL" : "PASS");
     return g_failed ? 1 : 0;
diff --git a/tests/runtime/.crumb b/tests/runtime/.crumb
index 32871f3ba..d13ad2876 100644
--- a/tests/runtime/.crumb
+++ b/tests/runtime/.crumb
@@ -7,14 +7,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-10-31T12:25:49Z",
+      "compiled_at": "2026-10-31T14:01:27Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:bd7d40c4941f8820fb03ff558b323e41a80edf02caf0068baf7307ed855dcaa5",
+      "digest": "sha256:3c0c470be85111fb756052d050a5d4620aad93b56908050d9135bc77e441ad42",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 70,
-      "generated_at_commit": "1b9e0b5530e5956f8967940fb001d632f0e61859",
-      "source_tree": "sha256:95a4f85487a355d9a5b1e8315c3b6131ce63b079bc10579dea6d3543735e6f6a"
+      "generated_at_commit": "2638a49bd83d12c1e0c76a4c446d6be1c9a4d4f4",
+      "source_tree": "sha256:948a02bb5e6024a6af400bfa8a1c666844391f7ec51bdca6235ce02d1b533cc6"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/tests/runtime/rx_action_graph.c b/tests/runtime/rx_action_graph.c
index f04cc2a48..51d879276 100644
--- a/tests/runtime/rx_action_graph.c
+++ b/tests/runtime/rx_action_graph.c
@@ -1240,7 +1240,7 @@ static void binary_digest(char out[65]) {
 static void write_receipt(void) {
     char path[512];
     if (omega_evidence_path("ACTION_GRAPH/rx_action_graph_receipt.json", path, sizeof path) != 0) return;
-    FILE *fp = fopen(path, "w");
+    FILE *fp = omega_evidence_create(path);
     if (!fp) return;
     char commit[41];
     memset(commit, 0, sizeof commit);
diff --git a/tests/runtime/rx_r11_aien.c b/tests/runtime/rx_r11_aien.c
index beb6f9a72..ff254f79c 100644
--- a/tests/runtime/rx_r11_aien.c
+++ b/tests/runtime/rx_r11_aien.c
@@ -40,6 +40,7 @@
 #include "runtime/rx_world.h"
 #include "omega_evidence.h"
 #include "sha256.h"
+#include "omega_path_check.h"
 
 #include <dirent.h>
 #include <sched.h>
@@ -689,9 +690,14 @@ static int quiet_flag_is_mine(const char *flag) {
  * is already loaded, the numbers would describe the other work, so the
  * living run is not started. Same test as rx_plan_reuse.c. */
 static int other_load(char *why, size_t n) {
-    const char *home = getenv("HOME");
-    char flag[512];
-    snprintf(flag, sizeof flag, "%s/workspace/.spark-quiet", home ? home : "");
+    /* Only a checked HOME (src/omega_path_check.h) names the flag; a refused one cannot rule a measurement out. */
+    const char *h = getenv("HOME");
+    char home[400] = "", flag[512];
+    if (h && h[0] && omega_path_copy(home, sizeof home, h) != 0) {
+        snprintf(why, n, "HOME refused by src/omega_path_check.h");
+        return 1;
+    }
+    snprintf(flag, sizeof flag, "%s/workspace/.spark-quiet", home);
     if (access(flag, F_OK) == 0 && !quiet_flag_is_mine(flag)) {
         snprintf(why, n, "an R15 timed measurement holds ~/workspace/.spark-quiet");
         return 1;
@@ -947,7 +953,7 @@ static void binary_digest(char out[65]) {
 static void write_receipt(void) {
     char path[512];
     if (omega_evidence_path("R11/rx_aien_faculty_receipt.json", path, sizeof path) != 0) return;
-    FILE *fp = fopen(path, "w");
+    FILE *fp = omega_evidence_create(path);
     if (!fp) return;
     char commit[41];
     memset(commit, 0, sizeof commit);
diff --git a/tests/runtime/rx_r13_living.c b/tests/runtime/rx_r13_living.c
index a390362be..f386308e1 100644
--- a/tests/runtime/rx_r13_living.c
+++ b/tests/runtime/rx_r13_living.c
@@ -44,6 +44,7 @@
 #endif
 #include "omega_evidence.h"
 #include "sha256.h"
+#include "omega_path_check.h"
 
 #include <dirent.h>
 #include <errno.h>
@@ -240,10 +241,13 @@ static int rm_one(const char *p, const struct stat *sb, int flag, struct FTW *ft
     return remove(p);
 }
 
-/* A scratch directory under $TMPDIR (default /tmp). */
+/* A scratch directory under $TMPDIR (default /tmp); a TMPDIR that src/omega_path_check.h refuses fails the
+ * caller rather than naming a directory from unchecked bytes. */
 static int scratch_dir(char *out, size_t n, const char *stem) {
-    const char *t = getenv("TMPDIR");
-    if (!t || !t[0]) t = "/tmp";
+    const char *e = getenv("TMPDIR");
+    char t[160];
+    if (!e || !e[0]) e = "/tmp";
+    if (omega_path_copy(t, sizeof t, e) != 0) return -1;
     if ((size_t)snprintf(out, n, "%s/%s-XXXXXX", t, stem) >= n) return -1;
     return mkdtemp(out) ? 0 : -1;
 }
@@ -2024,7 +2028,7 @@ static void receipt(int tests_ok) {
                  "\"activations_cancelled_under_stop\": %llu},\n",
                  (unsigned)RX_OPERATOR_SUBJ, U(g_op_stops), U(g_op_resumes), U(g_op_restored),
                  U(g_op_open), U(g_op_cancelled));
-    FILE *f = fopen(path, "w");
+    FILE *f = omega_evidence_create(path);
     if (!f) return;
     fprintf(f,
         "{\n"
diff --git a/tests/runtime/rx_r14_recovery.c b/tests/runtime/rx_r14_recovery.c
index 4a4d6a31a..a5cf2031f 100644
--- a/tests/runtime/rx_r14_recovery.c
+++ b/tests/runtime/rx_r14_recovery.c
@@ -2529,7 +2529,7 @@ static int receipt(int tests_ok) {
     struct utsname host;
     memset(&host, 0, sizeof host);
     uname(&host);
-    FILE *f = fopen(path, "w");
+    FILE *f = omega_evidence_create(path);
     if (!f) return 0;
     uint64_t crumbs = 0, holders_max = 0, unexpected = 0;
     uint64_t final_gen = 0;
diff --git a/tests/runtime/rx_workflow_fusion.c b/tests/runtime/rx_workflow_fusion.c
index 70d13cd86..debbf338a 100644
--- a/tests/runtime/rx_workflow_fusion.c
+++ b/tests/runtime/rx_workflow_fusion.c
@@ -1523,7 +1523,7 @@ static void measure_json(FILE *fp, const char *name, const AgFusionMeasure *m, i
 static void write_receipt(void) {
     char path[512];
     if (omega_evidence_path("WORKFLOW_FUSION/rx_workflow_fusion_receipt.json", path, sizeof path) != 0) return;
-    FILE *fp = fopen(path, "w");
+    FILE *fp = omega_evidence_create(path);
     if (!fp) return;
     char commit[41];
     memset(commit, 0, sizeof commit);
diff --git a/tests/test_omega_divsqrt_gb10.c b/tests/test_omega_divsqrt_gb10.c
index 5a3968ea7..583d1c876 100644
--- a/tests/test_omega_divsqrt_gb10.c
+++ b/tests/test_omega_divsqrt_gb10.c
@@ -37,6 +37,7 @@
 #include "omega_blackwell_encoder.h"
 #include "omega_blackwell_qmd.h"
 
+#include <fcntl.h>
 #include <inttypes.h>
 #include <math.h>
 #include <pthread.h>
@@ -44,6 +45,15 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
+#include <unistd.h>
+
+/* 0644, not fopen's 0666 & ~umask: a dumped kernel or listing is never world-writable */
+static FILE *create_0644(const char *path, const char *mode) {
+    int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
+    FILE *f = fd >= 0 ? fdopen(fd, mode) : NULL;
+    if (fd >= 0 && !f) close(fd);
+    return f;
+}
 
 static int g_pass, g_fail;
 static void check(int ok, const char *id) {
@@ -329,11 +339,11 @@ static int dump(const char *dir) {
         const char *nm = NM[op];
         if (build((OmegaDsOp)op, code, &len) != 0 || omega_ds_listing((OmegaDsOp)op, lst, sizeof(lst)) != 0) return 1;
         snprintf(path, sizeof(path), "%s/%s.bin", dir, nm);
-        FILE *f = fopen(path, "wb");
+        FILE *f = create_0644(path, "wb");
         if (!f || fwrite(code, 1, len, f) != len) return 1;
         fclose(f);
         snprintf(path, sizeof(path), "%s/%s.lst", dir, nm);
-        f = fopen(path, "w");
+        f = create_0644(path, "w");
         if (!f || fputs(lst, f) < 0) return 1;
         fclose(f);
     }