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#1012 (code only)
Fetch it
curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/76e3be069fe83e7c.bundle -o 76e3be069fe83e7c.bundle git fetch 76e3be069fe83e7c.bundle refs/pull/1012/head
Provenance
github-import 1
aien-dev/omega-mv
1012
7b54baa5aba4bf69b5f179f92d109ec7f4b8608d
{"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":1012,"url":"https://github.com/aien-dev/omega-mv/pull/1012","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:15Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/.crumb b/.crumb index 409b8f224..d42a963de 100644 --- a/.crumb +++ b/.crumb @@ -90,13 +90,13 @@ }, { "digest": "7fe15f310334744a70fe070087efafdae311d623cddee79d64fa439a46142dfb", - "last_commit": "829cf6832", + "last_commit": "c77d3ddf2", "name": "src", "purpose": "Directory src. Purpose not yet described by a human." }, { - "digest": "d62144d84091ad9f29e5e93d463285d01c01ad9f0c4ac939fcbd8076f1aca1bc", - "last_commit": "829cf6832", + "digest": "a33fa5e71c275f1c7a580c9c5851b8fccbb3c801a0dbaacb3d77cd12d4d19616", + "last_commit": "664c16893", "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:fcc00e3c3f8dd8fc0b056b265fbd53fd7c15533cad9e4b1d854a3f37a5cd03d9", - "compiled_at": "2026-10-31T15:59:27Z", + "children_root": "sha256:13aac465be065bf868696964e12de70d0f4b40850eddb7f5c4fe1e9107641879", + "compiled_at": "2026-10-31T16:13:55Z", "compiler": "crumb-compile/1", - "digest": "sha256:f5665a54f1571af49bd03f852b6a5e05c5d64cb4298bc0e319c392faa78d7006", + "digest": "sha256:36d74aaf503498e54d854a0b791046221330f06bab32a44dc6f446328cb7d86e", "evidence_files": 14989, "evidence_root": "sha256:90148c46bbc2cd096c96064273ac90d63efb54260fe285e18d84429cdf657830", "files": 23230, - "generated_at_commit": "829cf68321a46418e039a70f48ae538505c37a0e", - "source_tree": "sha256:977be74680755ef5b30323a2d64a809f49a84039393842c93ce368728e310dd1" + "generated_at_commit": "664c16893d6b2ad3ec307b4c4f809007e0e75e4e", + "source_tree": "sha256:55ffd2b8014e3c0e150dd0f747a2a29f1de0e0a8bfa3379c7d20e69dcc8ca4bb" }, "owner_lane": "", "provenance": { diff --git a/tests/.crumb b/tests/.crumb index da0c55161..2c75e4f11 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": "b2c2b1e9935a1e5043268b0a58aa384378dfefe617243d443fdf1e88267e2dac", - "last_commit": "159c4b51f", + "digest": "bcb53f4b937ac70130b76922af36da6f9efd27709c0c3060f715b50f8405df48", + "last_commit": "664c16893", "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:e34ef36159fcc2b1427126b2b8faca9ec4cb074427a79ef209cbcd4a2e089156", - "compiled_at": "2026-10-31T15:59:27Z", + "children_root": "sha256:9c54a9886a82d0e15934a64058ab1dd73977453f55c6577cca6d70b4789b8242", + "compiled_at": "2026-10-31T16:13:55Z", "compiler": "crumb-compile/1", - "digest": "sha256:d62144d84091ad9f29e5e93d463285d01c01ad9f0c4ac939fcbd8076f1aca1bc", + "digest": "sha256:a33fa5e71c275f1c7a580c9c5851b8fccbb3c801a0dbaacb3d77cd12d4d19616", "evidence_files": 74, "evidence_root": "sha256:9aa38bf7dcfa5eb3499356a0a2a1dd7704fedfae2d16822a7c9e1400f3a72723", "files": 2048, - "generated_at_commit": "829cf68321a46418e039a70f48ae538505c37a0e", - "source_tree": "sha256:938cb95da2874b523a4c06f518179da7176568ec9252825e58e0c14f54dd3b79" + "generated_at_commit": "664c16893d6b2ad3ec307b4c4f809007e0e75e4e", + "source_tree": "sha256:3b7cd999a2e5f59ed2f4e12f7226bed6d098f654a7701eb4d6aa09dffa7d0ebd" }, "owner_lane": "", "provenance": { diff --git a/tests/gates/run.sh b/tests/gates/run.sh index a315aeda1..618d5b403 100755 --- a/tests/gates/run.sh +++ b/tests/gates/run.sh @@ -83,12 +83,15 @@ receipt() { gates_pass() { grep -E 'TOTAL GATES: [0-9]+ \| PASSED: [0-9]+ \| FAILED: 0' "$1" && ! grep -E 'FAILED: [1-9]' "$1"; } # speed <make target> <receipt file> <gate word>: a speed test (tests/runtime/rx_quiet_reps.h) that found -# the machine too busy to time ends with `AIEN-OBS not_run_reason "cpu_busy"` and exit 77; make reports +# the machine too busy to time, or a leg it claims faster disturbed significantly more often than the +# other leg, ends with `AIEN-OBS not_run_reason "cpu_busy"` (or "leg_skew") and exit 77; make reports # any failing recipe as 2, so the refusal is read from the test's own receipt for this step: "failures": 0 # and the gate word NOT_RUN, which the test writes only when nothing it judged failed. Then the step goes -# on, so every other check is still judged, and ends NOT_RUN (exit 77) only if nothing else failed. +# on, so every other check is still judged, and ends NOT_RUN (exit 77) only if nothing else failed, with +# reason leg_skew when any refused receipt says so, else cpu_busy. # Anything else is the failure it was. A passing run gets the receipt check it always had. BUSY=0 +BUSY_REASON=cpu_busy speed() { local target="$1" file="$2" word="$3" rc=0 r f bad=1 make "$target" || rc=$? @@ -103,10 +106,11 @@ speed() { while IFS= read -r f; do grep -q '"failures": 0,' "$f" && grep -q '"candidate_bound": true,' "$f" && grep -q "\"$word\": \"NOT_RUN\"" "$f" || bad=1 + if grep -q '"not_run_reason": "leg_skew"' "$f"; then BUSY_REASON=leg_skew; fi done <<< "$r" fi if [ "$bad" = 0 ]; then - echo "run.sh: $target: machine too busy to time (cpu_busy); not judged, the rest of the step runs" >&2 + echo "run.sh: $target: refused to time ($BUSY_REASON; the test's NOT RUN lines say why); not judged, the rest of the step runs" >&2 printf '%s\n' "$r" | xargs sha256sum BUSY=1 return 0 @@ -289,7 +293,7 @@ case "$step" in tools/rx_host_receipts.sh heartbeat "$r" tools/rx_host_receipts.sh native "$native" "$OMEGA_CANDIDATE_COMMIT" tools/rx_host_receipts.sh generation "$generation" "$OMEGA_CANDIDATE_COMMIT" - if [ "$BUSY" = 1 ]; then obs not_run_reason '"cpu_busy"'; exit 77; fi + if [ "$BUSY" = 1 ]; then obs not_run_reason "\"$BUSY_REASON\""; exit 77; fi ;; faculty-arm) pin physics-src-6d7cf0d physics 6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf diff --git a/tests/runtime/.crumb b/tests/runtime/.crumb index 857a0d8e8..9bc69ac7d 100644 --- a/tests/runtime/.crumb +++ b/tests/runtime/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-31T15:59:27Z", + "compiled_at": "2026-10-31T16:13:55Z", "compiler": "crumb-compile/1", - "digest": "sha256:b2c2b1e9935a1e5043268b0a58aa384378dfefe617243d443fdf1e88267e2dac", + "digest": "sha256:bcb53f4b937ac70130b76922af36da6f9efd27709c0c3060f715b50f8405df48", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 71, - "generated_at_commit": "829cf68321a46418e039a70f48ae538505c37a0e", - "source_tree": "sha256:ef2f92f8da09e0f6fc562211df556cccf9de5c68a39187a9ceb9c6aa14db3aae" + "generated_at_commit": "664c16893d6b2ad3ec307b4c4f809007e0e75e4e", + "source_tree": "sha256:9faae7d1accc14519be4fa456a26ee2e64390530cbd062e0feed496c3aca3daa" }, "owner_lane": "", "provenance": { diff --git a/tests/runtime/rx_quiet_reps.h b/tests/runtime/rx_quiet_reps.h index 2ab310abd..0e86aabc1 100644 --- a/tests/runtime/rx_quiet_reps.h +++ b/tests/runtime/rx_quiet_reps.h @@ -17,6 +17,30 @@ * undisturbed within the attempt budget the check is refused and says why * (rx_busy_refuse below: NOT_RUN cpu_busy, never a pass). Where schedstat is missing every * repetition counts (the old behaviour) and the output says so. + * + * The delay is summed over the whole process, so it cannot tell the + * machine's load from contention the code under test makes itself. A leg + * that intermittently makes its own threads wait (one run in three, say) + * would have exactly those slow runs set aside, and its slowdown would pass + * unseen. So each leg's disturbed repetitions are counted, and the check is + * refused (NOT_RUN leg_skew, never a pass) when the leg the check claims is + * the faster one was disturbed significantly more often than the other leg + * (rx_pairs_skew_p below) and the claim holds on the kept runs. A claim + * that fails on them is judged as it would be without the test: the skew + * only set aside more of the claimed-faster leg's runs, which favours the + * claim. Set-aside runs of the other leg only make that leg look faster, + * which works against the claim, so the test is one-sided. + * + * Known limit: the test assumes both legs offer the machine's load the same + * number of threads to delay. Where one leg keeps several workers on cores + * and the other one (a parallel graph against its serialized fusion), load + * alone disturbs the wider leg more often: on the loaded Spark the 4-worker + * leg was refused for skew in runs where nothing but load was at work, and + * dividing each repetition's delay by its mean number of threads on a core + * still left 7 of 25 such runs refused. Checks whose legs differ in + * parallelism therefore skip the skew test and say so in their output and + * receipt; for them, contention a leg makes itself only intermittently can + * still hide in its set-aside runs, as before this test existed. */ #ifndef RX_QUIET_REPS_H #define RX_QUIET_REPS_H @@ -64,13 +88,75 @@ static inline int rx_quiet_rep(int64_t delay_ns, uint64_t wall_ns) { return (uint64_t)delay_ns <= RX_QUIET_FLOOR_NS + wall_ns * RX_QUIET_PERMILLE / 1000ull; } +/* Leg skew. Under "the machine, not the leg, disturbs runs" a leg's + * disturbed repetitions are no more frequent than the other leg's. Legs are + * paired (each attempt times both legs back to back, as in + * rx_workflow_fusion.c), so the test is McNemar's exact test, one-sided at + * RX_SKEW_ALPHA: among the attempts where exactly one leg was disturbed, the + * count where it was the claimed-faster leg is Binomial(n, 1/2) under the + * null; p = P(X >= that count). + * + * A false refusal is a NOT_RUN, never a false FAIL. At RX_SKEW_ALPHA = 1/1000 + * the paired test cannot refuse with fewer than 10 one-leg-disturbed + * attempts, so a quiet machine (a handful of disturbed attempts) is never + * refused. Thresholds (WolframLanguageEvaluator, 2026-10-31, with + * up[n_, k_] := 1 - CDF[BinomialDistribution[n, 1/2], k - 1]): + * Min[Select[Range[1, 40], up[#, #] <= 1/1000 &]] -> 10 + * up[10, 10] -> 1/1024 (0.000977), up[10, 9] -> 0.0107 + * smallest refused count for n = 20, 50, 100, 300, 600, 2460: + * 18, 37, 66, 178, 339, 1308 + * rx_sign_upper is checked against these in rx_workflow_fusion.c + * (t_skew_math). */ +#define RX_SKEW_ALPHA 0.001 + +/* The tail sums pmf weights scaled to 1 at the mode, built by the pmf ratio + * of neighbours, so nothing overflows and no libm is needed; weights that + * underflow are below 1e-300 of the total. */ + +/* P(X >= k) for X ~ Binomial(n, 1/2). */ +static inline double rx_sign_upper(uint32_t n, uint32_t k) { + if (k == 0) return 1.0; + if (k > n) return 0.0; + uint32_t m = n / 2; + double w = 1.0, total = 1.0, tail = m >= k ? 1.0 : 0.0; + for (uint32_t i = m + 1; i <= n; i++) { /* w(i) = w(i-1) (n-i+1) / i */ + w *= (double)(n - i + 1) / (double)i; + total += w; + if (i >= k) tail += w; + } + w = 1.0; + for (uint32_t i = m; i-- > 0;) { /* w(i) = w(i+1) (i+1) / (n-i) */ + w *= (double)(i + 1) / (double)(n - i); + total += w; + if (i >= k) tail += w; + } + return tail / total; +} + +/* Paired legs: attempts where exactly one leg was disturbed, by leg. */ +typedef struct { + uint32_t only[2]; +} RxPairs; + +static inline void rx_pairs_note(RxPairs *s, int quiet0, int quiet1) { + if (quiet0 != quiet1) s->only[quiet0 ? 1 : 0]++; +} + +/* One-sided p that leg `fast` (the one the check claims is faster) was + * disturbed more often than the other leg. */ +static inline double rx_pairs_skew_p(const RxPairs *s, int fast) { + return rx_sign_upper(s->only[0] + s->only[1], s->only[fast ? 1 : 0]); +} + /* A check that found the machine too busy to time is a refusal, not a * failure: nothing was measured, so nothing is judged, and the checks that * need that measurement are not judged either. The program then ends with * the local judge's "could not run" contract (aien-test SELF_NOT_RUN_EXIT): - * stdout line `AIEN-OBS not_run_reason "cpu_busy"` and exit 77, a retryable + * stdout line `AIEN-OBS not_run_reason "<reason>"` and exit 77, a retryable * NOT_RUN, never a pass. Any real failure anywhere in the run wins: the exit - * is then 1, whatever was refused. */ + * is then 1, whatever was refused. The reason is "cpu_busy", or "leg_skew" + * when a leg-skew refusal (rx_skew_refuse) happened: then the timing could + * not be trusted because of the code under test, not the machine. */ #define RX_NOT_RUN_EXIT 77 static inline unsigned *rx_busy_refusals(void) { @@ -78,19 +164,42 @@ static inline unsigned *rx_busy_refusals(void) { return &n; } +static inline unsigned *rx_skew_refusals(void) { + static unsigned n; + return &n; +} + /* Record one refusal; `what` names the measurement that was not taken. */ static inline void rx_busy_refuse(const char *what) { (*rx_busy_refusals())++; fprintf(stderr, " NOT RUN %s (cpu_busy): checks that need this measurement are not judged\n", what); } +/* Record a leg-skew refusal: the leg the check claims is faster was disturbed + * in `fast_disturbed` attempts, the other leg in `other_disturbed`, one-sided + * p = `p` <= RX_SKEW_ALPHA. */ +static inline void rx_skew_refuse(const char *what, uint32_t fast_disturbed, uint32_t other_disturbed, double p) { + (*rx_busy_refusals())++; + (*rx_skew_refusals())++; + fprintf(stderr, + " NOT RUN %s (leg_skew): the leg claimed faster was disturbed in %u attempts, the other leg in %u " + "(one-sided p %.3g <= %g): its set-aside runs may hide a slowdown it causes itself; checks that need " + "this measurement are not judged\n", + what, fast_disturbed, other_disturbed, p, RX_SKEW_ALPHA); +} + +/* The not_run_reason of this run's refusals. */ +static inline const char *rx_busy_reason(void) { + return *rx_skew_refusals() ? "leg_skew" : "cpu_busy"; +} + /* The program's exit status from its failure count and `pass`, everything * else its receipt judges: a refusal never covers a check judged false. */ static inline int rx_busy_exit(int failures, int pass) { if (failures) return 1; if (*rx_busy_refusals()) { if (!pass) return 1; - printf("AIEN-OBS not_run_reason \"cpu_busy\"\n"); + printf("AIEN-OBS not_run_reason \"%s\"\n", rx_busy_reason()); fflush(stdout); return RX_NOT_RUN_EXIT; } diff --git a/tests/runtime/rx_workflow_fusion.c b/tests/runtime/rx_workflow_fusion.c index bb7db2d5d..6d53ce09a 100644 --- a/tests/runtime/rx_workflow_fusion.c +++ b/tests/runtime/rx_workflow_fusion.c @@ -84,9 +84,19 @@ enum { MS_COMPILED = 101, MS_HYBRID, MS_LEARNED, MS_HARDWARE, MS_POISONED, MS_PA static int g_checks; static int g_fail; -/* Measurements refused as too busy to time (rx_quiet_reps.h). */ +/* Measurements refused as too busy to time, or for leg skew (rx_quiet_reps.h). */ static int g_untimed_compiled, g_untimed_parallel, g_untimed_poisoned; +/* One measurement's disturbance: attempts, undisturbed pairs, attempts where + * only one leg was disturbed, whether the leg-skew test applied, and its + * one-sided p for the leg the check claims is faster. */ +typedef struct { + RxPairs legs; + uint32_t tried, kept; + int known, fast, skew; + double p; +} Quiet; + #define CHECK(cond, ...) do { \ g_checks++; \ if (!(cond)) { \ @@ -126,6 +136,7 @@ static struct { uint32_t unpublished_refusals, unpublished_digest_equal; /* measurement */ AgFusionMeasure m_compiled, m_hybrid, m_parallel; + Quiet q_compiled, q_hybrid, q_parallel; uint32_t parallel_state, hybrid_state; /* canary */ uint32_t canary_runs, canary_divergences, poisoned_state, poisoned_verified, poisoned_promote_refused; @@ -1052,9 +1063,16 @@ static int cmp_u64(const void *a, const void *b) { /* 41 interleaved runs per leg at 4 workers: reactions that computed per * run, crumbs per run, median latency, CPU time, outcomes. */ -/* 1 when measured; 0 when the machine was too busy to time it (a refusal, - * rx_quiet_reps.h): nothing was measured and nothing that needs it is judged. */ -static int measure(AgMetaSkill *m, uint32_t goal, AgFusionMeasure *ms, int with_energy, const char *what) { +/* 1 when measured; 0 when the machine was too busy to time it, or the leg + * the check claims is faster (`fast`: 0 original, 1 fused) was disturbed + * significantly more often than the other and the claim holds on the kept + * runs (a refusal, rx_quiet_reps.h): + * nothing was measured and nothing that needs it is judged. `q` gets the + * disturbance counts either way. `skew` 0 skips the leg-skew test: only for + * legs that keep different numbers of threads on cores, where load alone + * disturbs the wider leg more often (the known limit in rx_quiet_reps.h). */ +static int measure(AgMetaSkill *m, uint32_t goal, AgFusionMeasure *ms, int with_energy, const char *what, int fast, + int skew, Quiet *q) { Pair *p = &g_pair; CHECK(pair_start(p, goal, m, 4) == 0, "%s: pair", what); memset(ms, 0, sizeof *ms); @@ -1068,6 +1086,9 @@ static int measure(AgMetaSkill *m, uint32_t goal, AgFusionMeasure *ms, int with_ uint64_t ns_o[RUNS], ns_f[RUNS], cpu_o = 0, cpu_f = 0, cr_o = 0, cr_f = 0, cm_o = 0, cm_f = 0; uint32_t kept = 0, tried = 0; int delay_known = 1; + memset(q, 0, sizeof *q); + q->fast = fast; + q->skew = skew; for (uint64_t i = 0; i < ATTEMPTS && kept < RUNS; i++) { uint64_t id = 10 + i, a = a_value(id), t_o = 0, t_f = 0; set_inputs(&p->o, a, id); @@ -1088,8 +1109,10 @@ static int measure(AgMetaSkill *m, uint32_t goal, AgFusionMeasure *ms, int with_ tried++; CHECK(ro.outcome == rf.outcome, "%s: attempt %u: outcomes differ", what, tried); if (d0 < 0 || d1 < 0 || d2 < 0 || d3 < 0) delay_known = 0; - if (!rx_quiet_rep(delay_known ? d1 - d0 : -1, t_o) || - !rx_quiet_rep(delay_known ? d3 - d2 : -1, t_f)) + int quiet_o = rx_quiet_rep(delay_known ? d1 - d0 : -1, t_o); + int quiet_f = rx_quiet_rep(delay_known ? d3 - d2 : -1, t_f); + rx_pairs_note(&q->legs, quiet_o, quiet_f); + if (!quiet_o || !quiet_f) continue; ns_o[kept] = t_o; ns_f[kept] = t_f; @@ -1105,8 +1128,26 @@ static int measure(AgMetaSkill *m, uint32_t goal, AgFusionMeasure *ms, int with_ ms->ok_after += rf.outcome == AG_RUN_SUCCESS; ms->failed_after += rf.outcome == AG_RUN_FAILURE; } - printf(" %s: undisturbed pairs %u of %u (%s)\n", what, kept, tried, - delay_known ? "run-queue delay from schedstat" : "schedstat missing: every pair counts"); + q->tried = tried; + q->kept = kept; + q->known = delay_known; + q->p = rx_pairs_skew_p(&q->legs, fast); + printf(" %s: undisturbed pairs %u of %u (%s); only original disturbed %u, only fused disturbed %u, ", what, + kept, tried, delay_known ? "run-queue delay from schedstat" : "schedstat missing: every pair counts", + q->legs.only[0], q->legs.only[1]); + if (skew) + printf("one-sided p that the %s leg was disturbed more %.3g\n", fast ? "fused" : "original", q->p); + else + printf("leg-skew test not applied: the legs keep different numbers of threads on cores\n"); + /* Skew sets aside more of the claimed-faster leg's runs, which only + * favours the claim: a claim that fails on the kept runs is still judged + * (FAIL, as on main); one that holds is refused below. */ + int skewed = skew && delay_known && q->p <= RX_SKEW_ALPHA; + if (skewed && kept < RUNS) { + rx_skew_refuse(what, q->legs.only[fast ? 1 : 0], q->legs.only[fast ? 0 : 1], q->p); + pair_stop(p); + return 0; + } if (kept < RUNS) { fprintf(stderr, " %s: machine too busy to time: %u of %u undisturbed pairs in %u attempts\n", what, kept, RUNS, (unsigned)ATTEMPTS); @@ -1131,6 +1172,17 @@ static int measure(AgMetaSkill *m, uint32_t goal, AgFusionMeasure *ms, int with_ ms->reactions_after = p->gf.n_nodes; ms->objects_before = p->go.n_nodes + 1; ms->objects_after = p->gf.n_nodes + 1; + if (skewed) { + static AgMetaSkill probe; /* accept reads only state and the measure */ + probe.state = AG_MS_VERIFIED; + int accepted = rx_fusion_accept_measure(&probe, ms, 50) == 0; + if (fast ? accepted : !accepted) { + rx_skew_refuse(what, q->legs.only[fast ? 1 : 0], q->legs.only[fast ? 0 : 1], q->p); + pair_stop(p); + return 0; + } + printf(" %s: leg skew, but the claim fails even on the kept runs: judged\n", what); + } if (with_energy) measure_energy(p, ms); pair_stop(p); printf(" %s: reactions computing per run %.1f -> %.1f, crumbs %.1f -> %.1f, median %.1f -> %.1f us, " @@ -1145,25 +1197,64 @@ static int measure(AgMetaSkill *m, uint32_t goal, AgFusionMeasure *ms, int with_ return 1; } +/* The leg-skew tail (rx_quiet_reps.h) against WolframLanguageEvaluator, + * 2026-10-31: up[n_, k_] := 1 - CDF[BinomialDistribution[n, 1/2], k - 1]; + * crit[n_] := Min[Select[Range[0, n + 1], up[n, #] <= 1/1000 &]]. */ +static void t_skew_math(void) { + printf("[*] leg-skew tails against exact values\n"); + static const struct { uint32_t n, k; double want; } sign[] = { + { 10, 10, 0.0009765625 }, /* up[10, 10] -> 1/1024 */ + { 10, 9, 0.0107421875 }, /* up[10, 9] */ + { 21, 21, 4.76837158203125e-7 }, /* up[21, 21] */ + { 40, 30, 0.00111071688661468 }, /* up[40, 30] */ + { 40, 29, 0.00321328804784571 }, /* up[40, 29] */ + { 600, 340, 0.000620253095612713 }, /* up[600, 340] */ + { 2460, 1300, 0.00253021285261641 }, /* up[2460, 1300] */ + { 7, 0, 1.0 }, { 7, 8, 0.0 }, + }; + for (size_t i = 0; i < sizeof sign / sizeof sign[0]; i++) { + double got = rx_sign_upper(sign[i].n, sign[i].k); + CHECK(fabs(got - sign[i].want) <= 1e-9 * sign[i].want + 1e-300, "P(Bin(%u, 1/2) >= %u) = %.12g, want %.12g", + sign[i].n, sign[i].k, got, sign[i].want); + } + /* crit[n] for n = 10, 20, 30, 50, 100, 300, 600, 1000, 2460 */ + static const uint32_t crit[][2] = { { 10, 10 }, { 20, 18 }, { 30, 24 }, { 50, 37 }, { 100, 66 }, + { 300, 178 }, { 600, 339 }, { 1000, 550 }, { 2460, 1308 } }; + for (size_t i = 0; i < sizeof crit / sizeof crit[0]; i++) { + RxPairs s = { { crit[i][0] - crit[i][1], crit[i][1] } }; + RxPairs t = { { crit[i][0] - crit[i][1] + 1, crit[i][1] - 1 } }; + CHECK(rx_pairs_skew_p(&s, 1) <= RX_SKEW_ALPHA && rx_pairs_skew_p(&t, 1) > RX_SKEW_ALPHA, + "n %u: smallest refused count %u", crit[i][0], crit[i][1]); + } + RxPairs nine = { { 0, 9 } }; + CHECK(rx_pairs_skew_p(&nine, 1) > RX_SKEW_ALPHA, "nine one-leg disturbances alone are never refused"); +} + static void t_measure(void) { printf("[*] measurement: original and fused side by side\n"); if (MC.state != AG_MS_VERIFIED) return; unpublished_refused(&MC, "verified"); - /* A refused measurement (machine too busy to time) leaves its MetaSkill - * verified and unmeasured: the acceptance below, and for the compiled one - * the canary, promotion and use that follow it, are not judged. */ - g_untimed_compiled = !measure(&MC, GOAL_EFFECT, &R.m_compiled, 1, "compiled"); + /* A refused measurement (machine too busy to time, or leg skew) leaves its + * MetaSkill verified and unmeasured: the acceptance below, and for the + * compiled one the canary, promotion and use that follow it, are not + * judged. The leg each check claims is faster is the one tested for skew: + * the fused leg where it must be accepted, the original where the + * parallel fragment must be refused as slower. The parallel check runs no + * skew test: its original leg keeps up to four workers on cores and the + * fused leg one, so load alone disturbs the original more often (known + * limit, rx_quiet_reps.h). */ + g_untimed_compiled = !measure(&MC, GOAL_EFFECT, &R.m_compiled, 1, "compiled", 1, 1, &R.q_compiled); if (!g_untimed_compiled) CHECK(rx_fusion_accept_measure(&MC, &R.m_compiled, 50) == 0 && MC.state == AG_MS_MEASURED, "compiled accepted: fewer reactions, not slower, same outcomes"); R.m_compiled = MC.measure; - if (measure(&MH, GOAL_EFFECT, &R.m_hybrid, 0, "hybrid")) { + if (measure(&MH, GOAL_EFFECT, &R.m_hybrid, 0, "hybrid", 1, 1, &R.q_hybrid)) { rx_fusion_accept_measure(&MH, &R.m_hybrid, 50); CHECK(MH.state == AG_MS_MEASURED, "hybrid accepted"); } R.m_hybrid = MH.measure; R.hybrid_state = MH.state; - g_untimed_parallel = !measure(&MP, GOAL_PARALLEL, &R.m_parallel, 0, "parallel"); + g_untimed_parallel = !measure(&MP, GOAL_PARALLEL, &R.m_parallel, 0, "parallel", 0, 0, &R.q_parallel); if (!g_untimed_parallel) { CHECK(rx_fusion_accept_measure(&MP, &R.m_parallel, 50) != 0 && MP.state == AG_MS_SLOWER, "parallel fragment refused: fusing it serializes independent work (%.0f -> %.0f us)", @@ -1215,7 +1306,8 @@ static void t_canary(void) { R.poisoned_verified = MQ.state == AG_MS_VERIFIED; CHECK(MQ.state == AG_MS_VERIFIED, "poisoned hybrid passes verification (the entry is never generated)"); AgFusionMeasure mq; - g_untimed_poisoned = !measure(&MQ, GOAL_EFFECT, &mq, 0, "poisoned hybrid"); + Quiet qq; + g_untimed_poisoned = !measure(&MQ, GOAL_EFFECT, &mq, 0, "poisoned hybrid", 1, 1, &qq); if (g_untimed_poisoned) { /* unmeasured: its canary and quarantine are not judged */ unpublished_refused(&MC, "canary-passed"); return; @@ -1260,7 +1352,7 @@ static char g_store_dir[64]; static void t_promote(void) { printf("[*] promotion through the generation barrier, then publication\n"); if (g_untimed_compiled) { /* never measured, so never canary-passed */ - printf(" not judged: the compiled MetaSkill was not measured (cpu_busy)\n"); + printf(" not judged: the compiled MetaSkill was not measured (refused, see NOT RUN above)\n"); return; } static Env e; @@ -1545,7 +1637,7 @@ static void binary_digest(char out[65]) { hex(d, out); } -static void measure_json(FILE *fp, const char *name, const AgFusionMeasure *m, int last) { +static void measure_json(FILE *fp, const char *name, const AgFusionMeasure *m, const Quiet *q, int last) { fprintf(fp, " \"%s\": {\"runs_per_leg\": %u, \"reactions_computing_per_run_before\": %.2f, " "\"reactions_computing_per_run_after\": %.2f,\n" @@ -1564,6 +1656,16 @@ static void measure_json(FILE *fp, const char *name, const AgFusionMeasure *m, i (unsigned long long)m->cpu_ns_after, m->reactions_before, m->reactions_after, m->objects_before, m->objects_after, m->ok_before, m->failed_before, m->ok_after, m->failed_after); + fprintf(fp, + ",\n \"disturbance\": {\"run_queue_delay_known\": %s, \"attempts\": %u, \"undisturbed_pairs\": %u, " + "\"only_original_disturbed\": %u, \"only_fused_disturbed\": %u, \"claimed_faster_leg\": \"%s\", ", + q->known ? "true" : "false", q->tried, q->kept, q->legs.only[0], q->legs.only[1], + q->fast ? "fused" : "original"); + if (q->skew) + fprintf(fp, "\"skew_test\": \"applied\", \"skew_p_one_sided\": %.6g, \"skew_alpha\": %g}", q->p, + RX_SKEW_ALPHA); + else + fprintf(fp, "\"skew_test\": \"not_applied_legs_differ_in_parallelism\"}"); if (m->energy_available) { double dp = fabs(m->energy_uj_before - m->energy_uj_after), dc = fabs(cpu_mean(0) - cpu_mean(1)); fprintf(fp, @@ -1654,9 +1756,9 @@ static void write_receipt(void) { " \"measurement\": {\n", R.tamper_cases, R.tamper_caught, R.tamper_names, R.coherent_rewrite_sites, R.unpublished_refusals, R.unpublished_digest_equal, R.refused_after_publish); - measure_json(fp, "compiled", &R.m_compiled, 0); - measure_json(fp, "hybrid", &R.m_hybrid, 0); - measure_json(fp, "parallel_fragment", &R.m_parallel, 1); + measure_json(fp, "compiled", &R.m_compiled, &R.q_compiled, 0); + measure_json(fp, "hybrid", &R.m_hybrid, &R.q_hybrid, 0); + measure_json(fp, "parallel_fragment", &R.m_parallel, &R.q_parallel, 1); fprintf(fp, " },\n" " \"promotion\": {\"parallel_fragment\": \"%s\", \"hybrid\": \"%s\",\n" @@ -1677,6 +1779,7 @@ static void write_receipt(void) { " \"fused_authority_exactly_steps\": %u},\n" " \"gates\": {\n" " \"OMEGA_WORKFLOW_FUSION_PASS\": \"%s\",\n" + " \"not_run_reason\": \"%s\",\n" " \"not_claimed\": [\"a hardware realization (the kind is in the contract; none is built)\", " "\"a neural learned module (the learned realization is a table of verified observations)\", " "\"machine code (the compiled realization is a typed step program run in one reaction)\", " @@ -1694,7 +1797,8 @@ static void write_receipt(void) { R.fused_nodes_before, R.fused_nodes_after, R.eq_runs, R.eq_nodes, R.eq_mismatch, R.cross_runs, R.cross_mismatch, R.steps_checked, R.steps_mismatch, R.evidence_checked, R.evidence_missing, R.ancestry_nodes, R.ancestry_mismatch, R.det_mismatch, R.bypass, R.n3_blocked_original, - R.n3_blocked_fused, R.n3_meta_auth_exact, rx_busy_verdict(judged_pass())); + R.n3_blocked_fused, R.n3_meta_auth_exact, rx_busy_verdict(judged_pass()), + *rx_busy_refusals() ? rx_busy_reason() : "none"); fclose(fp); printf("receipt: %s\n", path); } @@ -1706,6 +1810,7 @@ int main(void) { build_templates(); t_observe(); t_verify(); + t_skew_math(); t_measure(); t_canary(); t_promote();