diff --git a/.crumb b/.crumb index d121d2dad..96271afc6 100644 --- a/.crumb +++ b/.crumb @@ -77,14 +77,14 @@ "purpose": "Directory spec. Purpose not yet described by a human." }, { - "digest": "dfa36de2ac8649f66f80587abea51a7f166285ee0b92e0e09774c98689055250", - "last_commit": "333091a6", + "digest": "c296c77597a9f7be28f887f1df11908e3da49736534b90a1038ce633d27f0c29", + "last_commit": "e0fdd7cf", "name": "src", "purpose": "Directory src. Purpose not yet described by a human." }, { - "digest": "4eb9d4d76234448c0ed691f0aeb9c90d785f8a47b1b1291d728bbe3e1509dc10", - "last_commit": "88e24bdd", + "digest": "c610d329879c01df4bdbc5d8621ed28e79a491484646c800508fe712348a3111", + "last_commit": "332bda37", "name": "tests", "purpose": "Directory tests. Purpose not yet described by a human." }, @@ -95,15 +95,15 @@ "purpose": "Directory tools. Purpose not yet described by a human." } ], - "children_root": "sha256:e1a8c008214ad5dbc33a3e184d7e882dc56d1d50f9bd14c58f8773992961557e", - "compiled_at": "2026-10-18T21:10:38Z", + "children_root": "sha256:4b56484a92e52f2968150c5636f2d826532456feb62e391551be73a13a06b5b1", + "compiled_at": "2026-10-18T23:54:39Z", "compiler": "crumb-compile/1", - "digest": "sha256:be7220db494238bb4c33023d1df17286c35f947336bee5fc2e0405c136ec3e73", + "digest": "sha256:f1c98af390d4b707a1772250b05aedc643d9e17bf7f65dbf9a247eba05dbcd64", "evidence_files": 11127, "evidence_root": "sha256:4528085ec1661c442b64fb5dc8def65067ea2620ff88e42bcf52d58b7642ea6e", - "files": 14100, - "generated_at_commit": "f4a9849fb127f8d2d664dfc56890752ad180c507", - "source_tree": "sha256:21f93defce6c9ba159a4bd31083db787e156dfaa4afb80c3427cf88f732f8258" + "files": 14102, + "generated_at_commit": "e0fdd7cfb746c979b5d8ec1b6a7b310719bf958d", + "source_tree": "sha256:3ec171e83ba5d838b0d2938271ec63a620f666fb80ae0d38e3fe43c487df1bcf" }, "owner_lane": "", "provenance": { diff --git a/Makefile b/Makefile index 3551fea3f..e22ae924c 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ SRCS = src/sha256.c src/omega_canonical.c src/omega_validate.c src/omega_core.c src/omega_matvec.c src/omega_accelerator.c src/omega_accelerator_world.c \ src/omega_vector.c src/omega_blackwell_encoder.c src/omega_blackwell_qmd.c \ src/omega_blackwell_realize.c src/omega_blackwell_submit.c src/omega_blackwell_engine.c src/omega_gpu_engine.c src/omega_blackwell_gates.c src/omega_blackwell_matmul.c src/omega_blackwell_codegen.c src/omega_gpu_session.c src/omega_gpu_platform.c src/omega_gpu_platform_linux.c src/omega_gpu_fmt.c src/omega_gpu_matmul_api.c src/omega_gpu_elementwise_api.c src/omega_gpu_attention_api.c src/omega_gpu_serving.c src/omega_world_gates.c src/omega_gpu_wait.c \ - src/omega_evidence.c \ + src/omega_evidence.c src/omega_clean_clone.c \ $(PHYSICS_DIR)/m16/m16_native.c $(PHYSICS_DIR)/nvrm/nvrm.c \ tools/omegatool.c # OWN-30B cut 2 (2026-10-13): column windows over a resident bf16 tensor for the MoE path. New file, @@ -2387,7 +2387,7 @@ test-vc-bridge: tests/test_omega_vc_bridge.c src/omega_vc_bridge.c src/omega_vc_ # they compile the physics checkout path into the object (-DOMEGA_PHYSICS_DIR), which made the # archive digest depend on where physics was checked out. Without them libomega_gpu.a is # byte-identical for any PHYSICS_DIR and any omega checkout directory. -GPU_API_OBJS = $(filter-out $(OUT_DIR)/omegatool.o $(OUT_DIR)/omega_blackwell_gates.o $(OUT_DIR)/omega_world_gates.o,$(OBJS)) +GPU_API_OBJS = $(filter-out $(OUT_DIR)/omegatool.o $(OUT_DIR)/omega_blackwell_gates.o $(OUT_DIR)/omega_world_gates.o $(OUT_DIR)/omega_clean_clone.o,$(OBJS)) GPU_API_TEST = $(OUT_DIR)/gpu_matmul_api_test GPU_R4_RECEIPT = $(OUT_DIR)/gpu_matmul_r4_receipt $(OUT_DIR)/libomega_gpu.a: $(GPU_API_OBJS) | check-physics-lock diff --git a/src/.crumb b/src/.crumb index 4fe5298a4..bdb00f959 100644 --- a/src/.crumb +++ b/src/.crumb @@ -182,14 +182,14 @@ } ], "children_root": "sha256:15012a017b26a269feb256b64875ece2912f5f82c57804baafa3777c4fcb80b9", - "compiled_at": "2026-10-16T07:33:43Z", + "compiled_at": "2026-10-18T23:54:39Z", "compiler": "crumb-compile/1", - "digest": "sha256:dfa36de2ac8649f66f80587abea51a7f166285ee0b92e0e09774c98689055250", + "digest": "sha256:c296c77597a9f7be28f887f1df11908e3da49736534b90a1038ce633d27f0c29", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 537, - "generated_at_commit": "1d481ab853a14d3c11eff926ce1e25993085f76a", - "source_tree": "sha256:200c9243151691313acb5f86d3e9cb3058f1a1b92ece2a255b3340b691dfb894" + "files": 539, + "generated_at_commit": "e0fdd7cfb746c979b5d8ec1b6a7b310719bf958d", + "source_tree": "sha256:3c517fada2cf1941df57e8d3757d2bb6170bd69305800a95727e37a0ccf1ed15" }, "owner_lane": "", "provenance": { diff --git a/src/omega_blackwell_gates.c b/src/omega_blackwell_gates.c index 5c7634b41..48add9ccc 100644 --- a/src/omega_blackwell_gates.c +++ b/src/omega_blackwell_gates.c @@ -17,7 +17,10 @@ #include #include #include +#include #include "omega_physics_dir.h" +#include "omega_clean_clone.h" +#include static int m17_gate_count = 0; static int m17_gate_passed = 0; @@ -975,31 +978,89 @@ fail: return false; } +/* Remove the built copy a clean-clone gate made under its private folder; the + * log beside it stays for the reader. Hundreds of MB per run otherwise pile up + * in /tmp (omega#526). */ +static void m18_clean_clone_remove_checkout(const char *clone) { + char checkout[PATH_MAX]; + int n = snprintf(checkout, sizeof(checkout), "%s/checkout", clone); + if (n < 0 || (size_t)n >= sizeof(checkout)) return; + /* No shell: a file-tree walk that never follows a symlink (omega#565). */ + if (omega_cc_remove_tree(checkout) != 0) { + fprintf(stderr, "M18 clean clone: could not remove %s\n", checkout); + } +} + static bool test_m18_gate16_clean_clone(void) { if (getenv("OMEGA_IN_CLEAN_CLONE") != NULL) { return true; } /* Copy the repo this omegatool runs from (the code under test), not a * hardcoded checkout, and pass the PHYSICS_DIR this process resolves at run time - * (omega_physics_dir.h) as an absolute path so the copy in /tmp does not fall back to - * the Makefile default ../physics (= /tmp/physics). Mirrors M19. */ + * (omega_physics_dir.h) as an absolute path so the copy does not fall back to + * the Makefile default ../physics. Mirrors M19. + * + * The copy and its log live in a private mkdtemp folder (omega#526). A fixed + * /tmp path is shared by every user of the machine, and the sticky /tmp lets + * neither the judge user nor the operator remove or overwrite what the other + * left behind ("rm: Permission denied", "cannot create ...log: Permission denied"), + * so the gate failed for whoever ran second. + * + * OUT_DIR is unset for the nested build: tests/gates/run.sh exports a per-step + * OUT_DIR (omega#511), so `make` in the copy would put the binary at + * $OUT_DIR/omegatool and "./build/omegatool" would not exist (sh exit 127 in + * the judge run of e466b138, omega#526). The copy is private, so it needs no + * per-step build directory. */ char physics_dir_resolved[PATH_MAX], physics_err[OMEGA_PHYSICS_ERR_SIZE]; if (!omega_physics_dir_resolve_pinned(physics_dir_resolved, sizeof(physics_dir_resolved), 0, physics_err, sizeof(physics_err))) { fprintf(stderr, "%s\n", physics_err); return false; } - char command[4608]; - int len = snprintf(command, sizeof(command), - "root=$(git rev-parse --show-toplevel) && " - "rm -rf /tmp/omega_clean_m18 && " - "cp -r \"$root\" /tmp/omega_clean_m18 && " - "cd /tmp/omega_clean_m18 && " - "make clean >/dev/null 2>&1 && " - "make -j PHYSICS_DIR='%s' >/dev/null 2>&1 && " - "OMEGA_IN_CLEAN_CLONE=1 ./build/omegatool --run-m18-gates >/tmp/clean_clone_m18.log 2>&1", - physics_dir_resolved); - if (len < 0 || (size_t)len >= sizeof(command)) return false; - int rc = system(command); + const char *tmp = getenv("TMPDIR"); + if (!tmp || !*tmp) tmp = "/tmp"; + char clone[PATH_MAX]; + int cl = snprintf(clone, sizeof(clone), "%s/omega_clean_m18_XXXXXX", tmp); + if (cl < 0 || (size_t)cl >= sizeof(clone)) return false; + if (!mkdtemp(clone)) { + fprintf(stderr, "M18 clean clone: mkdtemp %s: %s\n", clone, strerror(errno)); + return false; + } + /* No shell (omega#565): each step is its own program with an argument vector, + * so nothing in TMPDIR or PHYSICS_DIR can change what runs. Paths outside the + * plain charset are refused (fail closed); make would also expand a '$'. */ + if (!omega_cc_path_is_plain(clone) || !omega_cc_path_is_plain(physics_dir_resolved)) { + fprintf(stderr, "M18 clean clone: refusing a path with characters outside [A-Za-z0-9/._+-]: %s | %s\n", + clone, physics_dir_resolved); + (void)rmdir(clone); + return false; + } + char root[PATH_MAX], checkout[PATH_MAX], log_path[PATH_MAX], physics_arg[PATH_MAX + 16]; + char *git_top[] = {"git", "rev-parse", "--show-toplevel", NULL}; + if (!omega_cc_capture_line(NULL, "git", git_top, root, sizeof(root))) { + fprintf(stderr, "M18 clean clone: git rev-parse --show-toplevel failed\n"); + (void)rmdir(clone); + return false; + } + int n1 = snprintf(checkout, sizeof(checkout), "%s/checkout", clone); + int n2 = snprintf(log_path, sizeof(log_path), "%s/clean_clone_m18.log", clone); + int n3 = snprintf(physics_arg, sizeof(physics_arg), "PHYSICS_DIR=%s", physics_dir_resolved); + if (n1 < 0 || (size_t)n1 >= sizeof(checkout) || n2 < 0 || (size_t)n2 >= sizeof(log_path) || + n3 < 0 || (size_t)n3 >= sizeof(physics_arg)) { + (void)rmdir(clone); + return false; + } + char *cp_argv[] = {"cp", "-r", "--", root, checkout, NULL}; + char *clean_argv[] = {"make", "clean", NULL}; + char *make_argv[] = {"make", "-j", physics_arg, NULL}; + char *run_argv[] = {"./build/omegatool", "--run-m18-gates", NULL}; + const char *step = "cp"; + int rc = omega_cc_run(NULL, "cp", cp_argv, NULL, false); + if (rc == 0) { step = "make clean"; rc = omega_cc_run(checkout, "make", clean_argv, NULL, false); } + if (rc == 0) { step = "make"; rc = omega_cc_run(checkout, "make", make_argv, NULL, false); } + /* The log sits beside the checkout: /clean_clone_m18.log. */ + if (rc == 0) { step = "omegatool --run-m18-gates"; rc = omega_cc_run(checkout, "./build/omegatool", run_argv, "../clean_clone_m18.log", true); } + if (rc != 0) fprintf(stderr, "M18 clean clone failed at %s (rc %d); log: %s\n", step, rc, log_path); + m18_clean_clone_remove_checkout(clone); return (rc == 0); } diff --git a/src/omega_clean_clone.c b/src/omega_clean_clone.c new file mode 100644 index 000000000..db83e4d17 --- /dev/null +++ b/src/omega_clean_clone.c @@ -0,0 +1,133 @@ +#include "omega_clean_clone.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +bool omega_cc_path_is_plain(const char *s) { + if (!s || !*s) return false; + for (const char *p = s; *p; p++) { + char c = *p; + bool ok = (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || + c == '/' || c == '.' || c == '_' || c == '+' || c == '-'; + if (!ok) return false; + } + return true; +} + +/* Child side: environment, directory, output, then exec. Never returns. */ +static void cc_child(const char *dir, const char *prog, char *const argv[], const char *out_rel, bool in_clean_clone) { + if (unsetenv("OUT_DIR") != 0) _exit(127); + if (in_clean_clone && setenv("OMEGA_IN_CLEAN_CLONE", "1", 1) != 0) _exit(127); + if (dir && chdir(dir) != 0) _exit(127); + /* Opened after chdir: the name is fixed by the caller, never built from a path. */ + int out_fd = out_rel ? open(out_rel, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW, 0644) + : open("/dev/null", O_WRONLY | O_CLOEXEC); + if (out_fd < 0) _exit(126); + if (dup2(out_fd, STDOUT_FILENO) < 0) _exit(127); + if (dup2(out_fd, STDERR_FILENO) < 0) _exit(127); + if (out_fd != STDOUT_FILENO && out_fd != STDERR_FILENO) close(out_fd); + execvp(prog, argv); + _exit(127); +} + +static int cc_wait(pid_t pid) { + int status = 0; + while (waitpid(pid, &status, 0) < 0) { + if (errno != EINTR) return -1; + } + if (WIFEXITED(status)) return WEXITSTATUS(status); + if (WIFSIGNALED(status)) return 128 + WTERMSIG(status); + return -1; +} + +int omega_cc_run(const char *dir, const char *prog, char *const argv[], const char *out_rel, bool in_clean_clone) { + if (!prog || !argv || !argv[0]) return -1; + fflush(NULL); + pid_t pid = fork(); + if (pid < 0) return -1; + if (pid == 0) cc_child(dir, prog, argv, out_rel, in_clean_clone); + return cc_wait(pid); +} + +bool omega_cc_capture_line(const char *dir, const char *prog, char *const argv[], char *out, size_t out_size) { + if (!prog || !argv || !argv[0] || !out || out_size == 0) return false; + out[0] = '\0'; + int fds[2]; + if (pipe2(fds, O_CLOEXEC) != 0) return false; + int err_fd = open("/dev/null", O_WRONLY | O_CLOEXEC); + if (err_fd < 0) { + close(fds[0]); + close(fds[1]); + return false; + } + fflush(NULL); + pid_t pid = fork(); + if (pid < 0) { + close(fds[0]); + close(fds[1]); + close(err_fd); + return false; + } + if (pid == 0) { + if (dir && chdir(dir) != 0) _exit(127); + if (dup2(fds[1], STDOUT_FILENO) < 0) _exit(127); + if (dup2(err_fd, STDERR_FILENO) < 0) _exit(127); + execvp(prog, argv); + _exit(127); + } + close(fds[1]); + close(err_fd); + size_t used = 0; + bool overflow = false; + char buf[256]; + for (;;) { + ssize_t n = read(fds[0], buf, sizeof(buf)); + if (n < 0 && errno == EINTR) continue; + if (n <= 0) break; + for (ssize_t i = 0; i < n; i++) { + if (used + 1 < out_size) out[used++] = buf[i]; + else overflow = true; + } + } + close(fds[0]); + out[used] = '\0'; + int rc = cc_wait(pid); + char *nl = strpbrk(out, "\r\n"); + if (nl) *nl = '\0'; + else if (overflow) return false; + return rc == 0 && out[0] != '\0'; +} + +static int cc_remove_entry(const char *path, const struct stat *sb, int type, struct FTW *ftw) { + (void)sb; + (void)ftw; + int rc = (type == FTW_DP) ? rmdir(path) : unlink(path); + if (rc != 0 && errno != ENOENT) { + fprintf(stderr, "clean clone: cannot remove %s: %s\n", path, strerror(errno)); + return -1; + } + return 0; +} + +int omega_cc_remove_tree(const char *path) { + if (!omega_cc_path_is_plain(path) || path[0] != '/' || strcmp(path, "/") == 0) { + fprintf(stderr, "clean clone: refusing to remove '%s' (not a plain absolute path)\n", + path ? path : "(null)"); + return -1; + } + struct stat st; + if (lstat(path, &st) != 0) return (errno == ENOENT) ? 0 : -1; + /* FTW_DEPTH: children before their directory. FTW_PHYS: never follow a symlink, + * so a link inside the copy cannot reach outside it. FTW_MOUNT: stay on one + * file system. */ + return nftw(path, cc_remove_entry, 32, FTW_DEPTH | FTW_PHYS | FTW_MOUNT) == 0 ? 0 : -1; +} diff --git a/src/omega_clean_clone.h b/src/omega_clean_clone.h new file mode 100644 index 000000000..b829f483b --- /dev/null +++ b/src/omega_clean_clone.h @@ -0,0 +1,42 @@ +#ifndef OMEGA_CLEAN_CLONE_H +#define OMEGA_CLEAN_CLONE_H + +#include +#include + +/* Process and file helpers for the M18 and M19 clean-clone gates (omega#526, #565). + * + * No shell anywhere: every child program is started with fork + execvp and an + * argument vector, and trees are removed with nftw + unlink/rmdir. A path is + * never pasted into a command string, so a quote or shell metacharacter in + * TMPDIR, PHYSICS_DIR or a clone path cannot change what runs. + * + * Fail closed: a path outside the plain charset (letters, digits, / . _ + -) + * is refused before anything runs, because it is also handed to make as + * PHYSICS_DIR= and make expands '$' in variable values. */ + +/* True when every byte of s is in [A-Za-z0-9/._+-] and s is non-empty. */ +bool omega_cc_path_is_plain(const char *s); + +/* Run prog (looked up on PATH; callers pass a string literal) with argv in + * directory dir (NULL: the current directory). stdout and stderr go to out_rel, + * a path opened by the child AFTER it changes to dir, so callers pass a fixed + * relative name such as "../qualification.log"; NULL means /dev/null. + * OUT_DIR is removed from the child environment; when in_clean_clone is true + * the child also gets OMEGA_IN_CLEAN_CLONE=1. + * Returns the child's exit code (126: output file could not be opened, 127: + * program could not be started), 128 + signal if it was killed, or -1 if the + * child could not be created. */ +int omega_cc_run(const char *dir, const char *prog, char *const argv[], const char *out_rel, bool in_clean_clone); + +/* Run prog with argv in dir and capture the first line of its stdout (newline + * stripped) into out. stderr goes to /dev/null. Returns true only when the + * program exits 0 and printed a line that fit. */ +bool omega_cc_capture_line(const char *dir, const char *prog, char *const argv[], char *out, size_t out_size); + +/* Remove path and everything under it without following symlinks. + * Refuses an empty path, "/", a relative path, or a path outside the plain + * charset. Returns 0 when the tree is gone (or was never there), -1 otherwise. */ +int omega_cc_remove_tree(const char *path); + +#endif diff --git a/src/omega_world_gates.c b/src/omega_world_gates.c index e0f6d310c..0fff1a947 100644 --- a/src/omega_world_gates.c +++ b/src/omega_world_gates.c @@ -18,6 +18,7 @@ #include #include #include "omega_physics_dir.h" +#include "omega_clean_clone.h" static int m19_gate_count = 0; static int m19_gate_passed = 0; @@ -38,17 +39,13 @@ static bool m19_fault_zero_device_reset = false; /* Resolve the full 40-hex revision of a working tree via git. */ static bool m19_git_head(const char *repo_dir, char out[41]) { - char cmd[512]; - int n = snprintf(cmd, sizeof(cmd), "git -C %s rev-parse HEAD 2>/dev/null", repo_dir); - if (n < 0 || (size_t)n >= sizeof(cmd)) return false; - FILE *p = popen(cmd, "r"); - if (!p) return false; - char *got = fgets(out, 41, p); - pclose(p); - if (!got) return false; - size_t len = strlen(out); - while (len > 0 && (out[len - 1] == '\n' || out[len - 1] == '\r')) out[--len] = '\0'; - return (len == 40); + /* No shell (omega#565): git gets the directory as an argument. */ + char line[64]; + char *argv[] = {"git", "-C", (char *)repo_dir, "rev-parse", "HEAD", NULL}; + if (!omega_cc_capture_line(NULL, "git", argv, line, sizeof(line))) return false; + if (strlen(line) != 40) return false; + memcpy(out, line, 41); + return true; } static const uint32_t WORLD_SETUP_WORDS[18] = { @@ -1759,6 +1756,15 @@ static bool test_m19_gate15_zero_libcuda(void) { return true; } +/* Remove the built copy under the private clone folder; qualification.log stays + * beside it (omega#526: five such copies per day filled /tmp). */ +static void m19_clean_clone_remove_checkout(const char *checkout) { + /* No shell: a file-tree walk that never follows a symlink (omega#565). */ + if (omega_cc_remove_tree(checkout) != 0) { + fprintf(stderr, "M19 clean clone: could not remove %s\n", checkout); + } +} + /* Gate 16: OMEGA_ACCEL_RESIDENT_CLEAN_CLONE_PASS */ static bool test_m19_gate16_clean_clone(void) { char src_sha[41] = {0}; @@ -1796,19 +1802,43 @@ static bool test_m19_gate16_clean_clone(void) { return false; } - char command[4608]; - int len = snprintf(command, sizeof(command), - "git clone --quiet --no-hardlinks . %s && cd %s && git checkout --quiet %s && " - "make clean >/dev/null 2>&1 && make -j PHYSICS_DIR=%s >/dev/null 2>&1 && " - "OMEGA_IN_CLEAN_CLONE=1 ./build/omegatool --run-m19-gates >%s/qualification.log 2>&1", - checkout, checkout, src_sha, physics_dir_resolved, clone); - if (len < 0 || (size_t)len >= sizeof(command)) return false; - if (system(command) != 0) return false; + /* OUT_DIR is unset for the nested build so the copy builds ./build/omegatool: + * tests/gates/run.sh exports a per-step OUT_DIR (omega#511) that would move the + * binary to $OUT_DIR/omegatool (sh exit 127, omega#526). */ + /* No shell (omega#565): each step is its own program with an argument vector. + * Paths outside the plain charset are refused (fail closed). */ + if (!omega_cc_path_is_plain(checkout) || !omega_cc_path_is_plain(physics_dir_resolved)) { + fprintf(stderr, "M19 clean clone: refusing a path with characters outside [A-Za-z0-9/._+-]: %s | %s\n", + checkout, physics_dir_resolved); + return false; + } + char log_path[600], physics_arg[PATH_MAX + 16]; + int n1 = snprintf(log_path, sizeof(log_path), "%s/qualification.log", clone); + int n2 = snprintf(physics_arg, sizeof(physics_arg), "PHYSICS_DIR=%s", physics_dir_resolved); + if (n1 < 0 || (size_t)n1 >= sizeof(log_path) || n2 < 0 || (size_t)n2 >= sizeof(physics_arg)) return false; + char *clone_argv[] = {"git", "clone", "--quiet", "--no-hardlinks", ".", checkout, NULL}; + char *checkout_argv[] = {"git", "checkout", "--quiet", src_sha, NULL}; + char *clean_argv[] = {"make", "clean", NULL}; + char *make_argv[] = {"make", "-j", physics_arg, NULL}; + char *run_argv[] = {"./build/omegatool", "--run-m19-gates", NULL}; + const char *step = "git clone"; + int rc = omega_cc_run(NULL, "git", clone_argv, NULL, false); + if (rc == 0) { step = "git checkout"; rc = omega_cc_run(checkout, "git", checkout_argv, NULL, false); } + if (rc == 0) { step = "make clean"; rc = omega_cc_run(checkout, "make", clean_argv, NULL, false); } + if (rc == 0) { step = "make"; rc = omega_cc_run(checkout, "make", make_argv, NULL, false); } + /* The log sits beside the checkout: /qualification.log. */ + if (rc == 0) { step = "omegatool --run-m19-gates"; rc = omega_cc_run(checkout, "./build/omegatool", run_argv, "../qualification.log", true); } + if (rc != 0) { + fprintf(stderr, "M19 clean clone failed at %s (rc %d); log: %s\n", step, rc, log_path); + m19_clean_clone_remove_checkout(checkout); + return false; + } /* The built checkout must be exactly the named candidate revision. */ char clone_sha[41] = {0}; - if (!m19_git_head(checkout, clone_sha)) return false; - if (strcmp(clone_sha, src_sha) != 0) return false; + bool same = m19_git_head(checkout, clone_sha) && strcmp(clone_sha, src_sha) == 0; + m19_clean_clone_remove_checkout(checkout); + if (!same) return false; memcpy(m19_candidate_commit, src_sha, sizeof(m19_candidate_commit)); return true; @@ -1864,9 +1894,13 @@ static bool test_m19_gate18_receipt(void) { if (!candidate || strcmp(candidate, head_sha) != 0 || omega_evidence_tree_dirty()) return false; } + /* Hash the binary that is running these gates. Under tests/gates/run.sh it is + * $OUT_DIR/omegatool (per-step build dir, omega#511), so the fixed path + * build/omegatool does not exist in a fresh judge worktree and this gate + * failed with every other gate passing (omega#526). */ uint8_t digest[32]; char hex[65]; - return compute_file_sha256("build/omegatool", digest, hex); + return compute_file_sha256("/proc/self/exe", digest, hex); } int run_m19_gates(void) { diff --git a/tests/.crumb b/tests/.crumb index bd5535a8b..44abd920b 100644 --- a/tests/.crumb +++ b/tests/.crumb @@ -265,8 +265,8 @@ "purpose": "Reservoir tests (omega#440): Gate 1 simulator and readout checks against an independent binary64" }, { - "digest": "bc2b514054f69604a155900fb1884948a78e12b88a15852296cbea1f751055b2", - "last_commit": "501d555c", + "digest": "8d9902bfef6302ea10880ea50d88ef5d6b8bf2619e9c10b3a756968421bedbbb", + "last_commit": "e466b138", "name": "runtime", "purpose": "Directory tests/runtime. Purpose not yet described by a human." }, @@ -295,15 +295,15 @@ "purpose": "Directory tests/visor. Purpose not yet described by a human." } ], - "children_root": "sha256:ddc3618190458bc5073e3bee67ffccc68a2ee9f065f2cb0d86545386a29fddf8", - "compiled_at": "2026-10-16T19:04:20Z", + "children_root": "sha256:4aee8c2d8f21fd9452fadad70e84057e0b44f93e85fe1bebb34074676f999ad2", + "compiled_at": "2026-10-18T21:37:52Z", "compiler": "crumb-compile/1", - "digest": "sha256:4eb9d4d76234448c0ed691f0aeb9c90d785f8a47b1b1291d728bbe3e1509dc10", + "digest": "sha256:c610d329879c01df4bdbc5d8621ed28e79a491484646c800508fe712348a3111", "evidence_files": 16, "evidence_root": "sha256:96d08097822ad95f4e562c19e0ba5df5a035774c48632f1832912c40a27bd27a", "files": 1270, - "generated_at_commit": "88e24bdd57b27817d030d0ad95f62c3f3eacf426", - "source_tree": "sha256:e6c4f0021d383ba2e59da0d85d06a0b98170f6d188289c891b5745200548e6fc" + "generated_at_commit": "11166a26d30bb96a833e0206440cdcfeddd4c2ad", + "source_tree": "sha256:4df4909f694a2a9646ec5ad92e5c444fc79174a72e7ed1cf7aaeaa00bfccff38" }, "owner_lane": "", "provenance": { diff --git a/tests/runtime/.crumb b/tests/runtime/.crumb index 48918ae9f..3652a3a24 100644 --- a/tests/runtime/.crumb +++ b/tests/runtime/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-13T02:12:57Z", + "compiled_at": "2026-10-18T21:37:52Z", "compiler": "crumb-compile/1", - "digest": "sha256:bc2b514054f69604a155900fb1884948a78e12b88a15852296cbea1f751055b2", + "digest": "sha256:8d9902bfef6302ea10880ea50d88ef5d6b8bf2619e9c10b3a756968421bedbbb", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 70, - "generated_at_commit": "95829f2abd7f66461b4ba153ea807f39e9d06db8", - "source_tree": "sha256:e037c5156071865094d0e60262d34ca920be2dd6f98e2603a1f0082330ba7841" + "generated_at_commit": "11166a26d30bb96a833e0206440cdcfeddd4c2ad", + "source_tree": "sha256:2b9d483a1f8068dfe689b5457e6d9f4a9bc928626e4ae525030f12b74609f0f3" }, "owner_lane": "", "provenance": { diff --git a/tests/runtime/r11_own_hold_test.sh b/tests/runtime/r11_own_hold_test.sh index d16128cc1..13325f0b9 100755 --- a/tests/runtime/r11_own_hold_test.sh +++ b/tests/runtime/r11_own_hold_test.sh @@ -2,17 +2,43 @@ # R11 living run inside its own quiet hold (tests/runtime/rx_r11_aien.c # quiet_flag_is_mine). With a fake HOME whose ~/workspace/.spark-quiet carries # hold=q1-abc: no QUIETLOCK_HOLD, a prefix and an extension of the id must all -# refuse the living run (someone else's measurement); QUIETLOCK_HOLD=q1-abc -# must run it. usage: r11_own_hold_test.sh +# refuse the living run because of the flag (someone else's measurement); +# QUIETLOCK_HOLD=q1-abc must run it. +# +# The binary also refuses the living run when the machine is loaded (1-minute +# load average above 2, or an R15 program alive): "SKIPPED-LOADED: ". +# Only the flag reason counts as the refusal this test is about. When the +# q1-abc case is refused for load, the test waits for the machine to quiet down +# and runs it again, for at most R11_QUIET_WAIT seconds (default 1800). If the +# machine never quiets, the case stays a failure: a skipped living run is never +# a pass. usage: r11_own_hold_test.sh B=${1:?rx_r11_aien_test binary}; H=$(mktemp -d); fail=0 +WAIT=${R11_QUIET_WAIT:-1800} trap 'rm -rf "$H"' EXIT mkdir -p "$H/workspace" echo "other quietlock X start=2026-10-05T00:00:00Z expected_end=2099-01-01T00:00:00Z pid=1 hold=q1-abc" > "$H/workspace/.spark-quiet" +FLAG_WHY='holds ~/workspace/.spark-quiet' + +load_ok() { awk '{ exit !($1 <= 2.0) }' /proc/loadavg; } + for hold in "" q1-ab q1-abcd q1-abc; do - out=$(HOME=$H QUIETLOCK_HOLD=$hold "$B" 2>&1) - if printf '%s\n' "$out" | grep -Fq "living run not exercised"; then got=refused; else got=ran; fi if [ "$hold" = q1-abc ]; then want=ran; else want=refused; fi + waited=0 + while :; do + out=$(HOME=$H QUIETLOCK_HOLD=$hold "$B" 2>&1) + if ! printf '%s\n' "$out" | grep -Fq "living run not exercised"; then got=ran + elif printf '%s\n' "$out" | grep -Fq "$FLAG_WHY"; then got=refused + else got=loaded; fi + [ "$got" = loaded ] && [ "$want" = ran ] && [ "$waited" -lt "$WAIT" ] || break + why=$(printf '%s\n' "$out" | sed -n 's/^\[-\] SKIPPED-LOADED: living run not started: //p' | head -n 1) + echo "[~] hold='$hold': living run refused for load ($why), waiting for a quiet machine (${waited}s of ${WAIT}s)" + while [ "$waited" -lt "$WAIT" ]; do + sleep 15; waited=$((waited + 15)) + load_ok && break + done + done printf '%s\n' "$out" | grep -Eq '^checks [0-9]+ failures 0$' || { got="$got+failures"; } if [ "$got" = "$want" ]; then echo "[+] hold='$hold': $got"; else echo "[-] hold='$hold': $got, want $want"; fail=$((fail + 1)); fi + [ "$got" = loaded ] && printf '%s\n' "$out" | grep -F "SKIPPED-LOADED" | head -n 1 done echo "failures $fail"; [ "$fail" = 0 ]