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#350 (code only)
Apply it
git checkout -b patch-edc90b399b6ce375 7683eaaa66e40067d08214115d1e2bf354b8fdfb curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/edc90b399b6ce375.patch | git am
Provenance
github-import 1
aien-dev/omega-mv
350
6af342da7bed319280e45d4f2d606affe5b1d6f6
{"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":350,"url":"https://github.com/aien-dev/omega-mv/pull/350","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:37:27Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/.crumb b/.crumb index 3a714f0c7..45bc0c274 100644 --- a/.crumb +++ b/.crumb @@ -46,37 +46,37 @@ "children": [ { "digest": "fb7cc6e608fdbe68a9735a1313285782b9717ff12bde17343f8ce635de3644f6", - "last_commit": "190ff89", + "last_commit": "a9b9d0d", "name": "calibration", "purpose": "Directory calibration. Purpose not yet described by a human." }, { - "digest": "c101f5f4b04a91af4f3e15c0fd8c7b4328ba3444364fc1a68556352e03e245d0", - "last_commit": "e2e08e9", + "digest": "206b9c1ef7b4b3472b916b5ad9c435e6997512bb95f8a6d9633df12a14b491b0", + "last_commit": "84ec3f3", "name": "docs", "purpose": "Directory docs. Purpose not yet described by a human." }, { "digest": "536f7b8db9a92a1f586bad4379d47544a30d1b8e83c2d799c18e66cf8660c9ae", - "last_commit": "30bb116", + "last_commit": "a9b9d0d", "name": "doctrine", "purpose": "Directory doctrine. Purpose not yet described by a human." }, { - "digest": "0e5e438de09d26650bc575b50b19d2ac89e453a29d61872dcd830b2b431beebd", - "last_commit": "da7bbd2", + "digest": "4dff9dca56ae6ee7c61c117f9a54b161e1eb8223075fd1fec70cda4bb15e1eba", + "last_commit": "84ec3f3", "name": "mk", "purpose": "Directory mk. Purpose not yet described by a human." }, { "digest": "69cbb8ef13ccce47ccc21f159e95f1eac58679319e2cc25937065f95c4eb9207", - "last_commit": "ae8c7c5", + "last_commit": "a9b9d0d", "name": "polyglot", "purpose": "Directory polyglot. Purpose not yet described by a human." }, { "digest": "8178197a3e956890d6194e5b4fcc0e0b5c4ec67b0749f0d257f2ed17c8ca7465", - "last_commit": "559f6e5", + "last_commit": "a9b9d0d", "name": "research", "purpose": "Directory research. Purpose not yet described by a human." }, @@ -93,27 +93,27 @@ "purpose": "Directory src. Purpose not yet described by a human." }, { - "digest": "3c34368255315b76534c31a3ce30d3f0723718601247894e45bfae30006364a3", - "last_commit": "cae7bd7", + "digest": "3d7c5bcf7d44a931f6def8354e1cebdfac6178a9fbc6fcc8a149d10287e68102", + "last_commit": "4be83d1", "name": "tests", "purpose": "Directory tests. Purpose not yet described by a human." }, { "digest": "acd42de9387a133f34b4b6afca962c82d340fba67c6a770a74852406769b4186", - "last_commit": "c07ee6b", + "last_commit": "7683eaa", "name": "tools", "purpose": "Directory tools. Purpose not yet described by a human." } ], - "children_root": "sha256:b8b803c0aa6b77065f2ccf50c3a4f56a9f0549bfd1dc78d2c0112e742ff3862f", - "compiled_at": "2026-10-09T15:55:39Z", + "children_root": "sha256:12af60fec0fdf5c8cfb1f116c80a9b03ad51fa5405fbe9bac39fd9ae840adf76", + "compiled_at": "2026-10-09T16:23:46Z", "compiler": "crumb-compile/1", - "digest": "sha256:7898c97bad9dccf986c59ccf72f707e98470605ec4d002076d683b2e47a8b82c", - "evidence_files": 4836, - "evidence_root": "sha256:e445a46bcc90a9b6dcc3675714a42e1815156e1a78b8d09f85ef3d0eca3ee1d8", - "files": 6843, - "generated_at_commit": "e2e08e9adb27b7f7bd7d69d554000f859c2862c2", - "source_tree": "sha256:74d5ff41c70aba6c279d4b1f3efc32b1dc9201497efc303e9edfd5d1e6068a98" + "digest": "sha256:7cfa6db2b118b299af2a4100df501f2feac6ddd890816586e891ea28bc5b264c", + "evidence_files": 4838, + "evidence_root": "sha256:5c7bceae14859a35c304178e1f8c627558f7b61e122fbc0d04b2199aea7c5e82", + "files": 6848, + "generated_at_commit": "84ec3f3e0914fad457ce7f6d7580536d4a931b10", + "source_tree": "sha256:9ed2da3cb0e9138ba8909f8d784239e40d2b0b0f26ab1310166fa7816065779c" }, "owner_lane": "", "provenance": { diff --git a/docs/.crumb b/docs/.crumb index b184f3276..c60a63a11 100644 --- a/docs/.crumb +++ b/docs/.crumb @@ -46,31 +46,31 @@ "children": [ { "digest": "640f6b7b818c769ab0dcd91437d58dd3251044084d2ae3785f000d30d2bb768a", - "last_commit": "a927bd6", + "last_commit": "a9b9d0d", "name": "adr", "purpose": "Directory docs/adr. Purpose not yet described by a human." }, { "digest": "e7ac2460455a35b96b01dab649dcdc2cdf5bb4657bf230b91272c64fe1bf82cf", - "last_commit": "d48ab89", + "last_commit": "a9b9d0d", "name": "autodiff", "purpose": "M21 OMEGA_AUTODIFF scope, op and error-contract table, status (not qualified)" }, { "digest": "d6212e49d394eddb0ee2df40bc9d203dcdb02072526bc6aa14e361b895874011", - "last_commit": "a6ba245", + "last_commit": "a9b9d0d", "name": "brownian", "purpose": "Directory docs/brownian. Purpose not yet described by a human." }, { "digest": "bffa3f51dd1982c179ba28f52971c38cb9592c795be0e93b958005e55190be5e", - "last_commit": "a0e59f4", + "last_commit": "a9b9d0d", "name": "crumbs", "purpose": "Directory docs/crumbs. Purpose not yet described by a human." }, { "digest": "e9baaaeec04be41a57c4a2d6a540b01a682c70d4db96cb4af4e1a9912a133aa9", - "last_commit": "55d05d6", + "last_commit": "a9b9d0d", "name": "dual", "purpose": "DUAL (ARCH-0031) documents in omega: applicability experiment method and findings (APPLICABILITY" }, @@ -94,38 +94,38 @@ }, { "digest": "0d858e0a20456e8380c530e4c77f523985f95657bf66b7418f341e84c6e9ec49", - "last_commit": "32ad8a5", + "last_commit": "a9b9d0d", "name": "polyglot", "purpose": "Directory docs/polyglot. Purpose not yet described by a human." }, { "digest": "2ab37838f8694e5060a3789f08a16146996050af949fba329ed805429d85f695", - "last_commit": "f633e34", + "last_commit": "a9b9d0d", "name": "tensor", "purpose": "M20 OMEGA_TENSOR spec and qualification checklist" }, { "digest": "41ab5cf8617e9583dcda75292e1e851e1ec4187b69d5d00b5eb354f1ee55c9d5", - "last_commit": "54826a3", + "last_commit": "a9b9d0d", "name": "train", "purpose": "Directory docs/train. Purpose not yet described by a human." }, { - "digest": "e96878d9e530244ed2e8a8bfdc3293ece772457c8a66a201353854ac50e4925a", - "last_commit": "e2e08e9", + "digest": "ba181063e0532f849da7092223145ae7843659615f1c8534734f298544c8e2c9", + "last_commit": "84ec3f3", "name": "turing", "purpose": "Directory docs/turing. Purpose not yet described by a human." } ], - "children_root": "sha256:7e14885fcef96b34b596dc1314f49d660955642d7c5bcd31ec5952786ad691c0", - "compiled_at": "2026-10-09T15:55:39Z", + "children_root": "sha256:c6b56ffbccb2064234ea9091d8c0cb5ed5b4573d46643341558feddace8214f6", + "compiled_at": "2026-10-09T16:23:46Z", "compiler": "crumb-compile/1", - "digest": "sha256:c101f5f4b04a91af4f3e15c0fd8c7b4328ba3444364fc1a68556352e03e245d0", + "digest": "sha256:206b9c1ef7b4b3472b916b5ad9c435e6997512bb95f8a6d9633df12a14b491b0", "evidence_files": 34, "evidence_root": "sha256:589d8b3706e6d7a202ab20b278dac5fc5bafc973f1c2a867b2668aa7210b65cc", "files": 117, - "generated_at_commit": "e2e08e9adb27b7f7bd7d69d554000f859c2862c2", - "source_tree": "sha256:15a3dc284211106921ba8b7c8a9adbe1d9d78072f2f91be3f998fc630d4a083f" + "generated_at_commit": "84ec3f3e0914fad457ce7f6d7580536d4a931b10", + "source_tree": "sha256:2404856db7b9deb938fe0acf02eff616f3b50f08977130694b3c2e3e0791dfb7" }, "owner_lane": "", "provenance": { diff --git a/docs/turing/.crumb b/docs/turing/.crumb index 0240ceac4..087c2d61b 100644 --- a/docs/turing/.crumb +++ b/docs/turing/.crumb @@ -14,20 +14,20 @@ "children": [ { "digest": "b89d63e1e54100fab00e608e20b7c0de1497d64dcd28e2580046b9235b1d2782", - "last_commit": "2d52219", + "last_commit": "a9b9d0d", "name": "protocols", "purpose": "Directory docs/turing/protocols. Purpose not yet described by a human." } ], "children_root": "sha256:fe77bf98001350090630834e0d4555e4eab5fa4a20c67d8820b60be154eb7094", - "compiled_at": "2026-10-09T15:55:39Z", + "compiled_at": "2026-10-09T16:23:46Z", "compiler": "crumb-compile/1", - "digest": "sha256:e96878d9e530244ed2e8a8bfdc3293ece772457c8a66a201353854ac50e4925a", + "digest": "sha256:ba181063e0532f849da7092223145ae7843659615f1c8534734f298544c8e2c9", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 19, - "generated_at_commit": "e2e08e9adb27b7f7bd7d69d554000f859c2862c2", - "source_tree": "sha256:9dccf6f8aebf77120cdd21a47c8328932f1a5d52379df7fcbec75f25a15f9159" + "generated_at_commit": "84ec3f3e0914fad457ce7f6d7580536d4a931b10", + "source_tree": "sha256:1dcd99b36dfa2444a0c6705ec6a6f622e6b3a042c71756fca25d6f4fa8a3aaca" }, "owner_lane": "", "provenance": { diff --git a/docs/turing/BRW_ACT_RESULTS.md b/docs/turing/BRW_ACT_RESULTS.md index b3bb597bb..b3d0690b9 100644 --- a/docs/turing/BRW_ACT_RESULTS.md +++ b/docs/turing/BRW_ACT_RESULTS.md @@ -73,7 +73,7 @@ committed before DEV0's held-out output was read. The hypothesis classes are given. The worlds are simple and mostly Gaussian. The advantage is concentrated in mean-reversion worlds; on drift worlds active is level with random. Held-out prediction quality does not improve over random or cycle at the end of the budget: the benefit is faster discrimination, not better final prediction. -Known reporting issues (display only, no result affected): the Wilson coverage intervals treat the 60 held-out readings of a world as independent, so they are too narrow (P3 uses the point estimate); in DEV1 output the P4 noise line prints the combined noise-and-diffusion result (both passed on hold1; the separate diffusion line is correct). Left unchanged after results to keep the runner that produced the evidence. +Known reporting issues (display only, no result affected), as found at merge: the Wilson coverage intervals treated the 60 held-out readings of a world as independent, so they were too narrow (P3 uses the point estimate); in DEV1 output the P4 noise line printed the combined noise-and-nested-null verdict (both controls passed on hold1, so no printed verdict was wrong). Both fixed after merge, see section 7; the receipts above are unchanged. These are development results on a self-chosen world family by the same session that wrote the profile; an independent evaluator, sealing and EXP-003's contract are all still required. @@ -81,3 +81,34 @@ independent evaluator, sealing and EXP-003's contract are all still required. Not integrated. There is no consumer whose decision this would improve today (section 1). If one appears, the first connection must be observational: TURING measures and does not authorise actions. + +## 7. Follow-up 2026-10-09: report fixes and computation charged + +Added after the results above were read; nothing here changes a verdict and no world was re-run. + +- Report fixes (omega PR "BRW-ACT report fixes"): coverage intervals now use the world as the independent unit + (`tests/brownian/brw_act_report.h`), and the P4 noise line prints the noise verdict alone. Regression test + `test_brw_act_report` (in `make test-brownian-active`): 3 of 7 checks fail on the old code, 7 of 7 pass after. + The per-world table is byte-identical (DEV0 regress digest 373dc7d7... unchanged). +- Re-analysis of the committed held-out tables (`make brownian-active-reanalyse`, reads `table.tsv` only): + `evidence/BRW-ACT-DEV0/hold-reanalysis/` and `evidence/BRW-ACT-DEV1/hold1-reanalysis/`, each with source commit, + input and tool digests; generated twice, identical. Source commit kept reachable by tag + `brw-act-reanalysis-provenance-2026-10-09`. +- Corrected coverage, DEV1 hold1 active: 90% intervals held 0.8949 [0.8892, 0.9006] of held-out readings, 50% held + 0.4969 [0.4871, 0.5068]. Barely wider than the Wilson figures: the clustering was real but small. +- Computation charged. Extra evaluations (likelihood, quadrature and cdf counted alike) of active per discoverable + world, against the time it saved, give a break-even exchange rate: active is ahead only while one time unit of + measurement is worth more than this many evaluations. + +| run | vs | extra evaluations per world | time saved per world [normal 95%] | break-even evaluations per time unit (at the low end of the saving) | +|---|---|---|---|---| +| DEV1 hold1 | random | 1.12e8 | 115.9 [55.9, 176.0] | 9.7e5 (2.0e6) | +| DEV1 hold1 | cycle | 1.12e8 | 160.0 [98.7, 221.3] | 7.0e5 (1.1e6) | +| DEV1 hold1 | fixed8 | 1.12e8 | 387.9 [308.1, 467.8] | 2.9e5 (3.6e5) | +| DEV0 hold | random | 3.9e7 | 7.5 [2.7, 12.3] | 5.2e6 (1.5e7) | + + Reading: when a measurement is slow or costly (a lab reading, a long benchmark, a GPU hold), a few million cheap + arithmetic evaluations per time unit saved is a good trade; when measurements are as cheap as the arithmetic, the + active chooser does not pay for itself. No wall-clock or energy figure was measured, so no speed or energy claim + follows. Treating the three evaluation kinds as equal is a simplification (quadrature evaluations dominate). + diff --git a/docs/turing/TURING_SCIENTIFIC_QUALIFICATION_STATE.md b/docs/turing/TURING_SCIENTIFIC_QUALIFICATION_STATE.md index 4a3ebb040..7505d5c90 100644 --- a/docs/turing/TURING_SCIENTIFIC_QUALIFICATION_STATE.md +++ b/docs/turing/TURING_SCIENTIFIC_QUALIFICATION_STATE.md @@ -27,7 +27,7 @@ from the sealed Wave 1 records (section 2 row "EXP-002A to D", section 7). No ev | EXP-002D (Brownian) | INCOMPLETE | one hostile rule (row 28, mixture weights) was not evaluable with the Wave 1 prediction format; 0 wrong verdicts on the rules that were evaluated. Stage A (2026-10-04): PRD2 makes it evaluable, omega-side R28-v2 MATCH, receipts `evidence/EXP-002D/01..04`; sealed harness re-pointed at PRD2 and re-run under pin 2564f57 (aien-sealed PR #2): row 28 MATCH; still INCOMPLETE because the dev runner keeps 36 match 1 mismatch (HC-meas-lag1-control block 0 edge, 0.00313 vs null upper 0.00308). Diagnosis 2026-10-09 (evaluator side, aien-sealed draft PR #3, reproduced at aien-sealed 019c64d with omega 2564f57): no implementation fault; the mismatch is a null-control line landing just above its interval edge, which fresh independent null blocks show happens at roughly the expected tail rate, so the expectation "inside on every block" was stated too strictly. Status stays INCOMPLETE: the original result is kept, and a successor development rule with a binomial allowance on control lines is proposed (draft, not adopted). The "stop-27 TPS1-adapter gate PENDING" note in the Stage A receipt is superseded: the evaluator receipt clarification records 30 passed, 0 failed at the current pin | | interventional replication (Brownian) | PASS | profile v1.3, fresh sealed worlds | | EXP-003 | BLOCKED | needs a separate Wave 2 contract (draft under review, not accepted, not frozen) and must seal after BRN-10 | -| BRW-ACT-DEV0 / DEV1 (development only, not EXP-003) | DEV0: dev FAIL (P1), held-out PASS; DEV1 (successor, design defects of DEV0 fixed): dev FAIL (P1 vs random, narrowly), held-out PASS | hand-coded reference candidate chooses the next noisy measurement by expected information; on DEV1 held-out it reaches the right explanation 116 / 160 / 388 time units sooner than random / cycle / fixed (horizon 2000), gain concentrated in mean-reversion worlds, final held-out prediction not better than random or cycle. Self-run by the profile author, no seal, no independent evaluator: it does not close EXP-003 or raise the level ceiling. `docs/turing/BRW_ACT_RESULTS.md` | +| BRW-ACT-DEV0 / DEV1 (development only, not EXP-003) | DEV0: dev FAIL (P1), held-out PASS; DEV1 (successor, design defects of DEV0 fixed): dev FAIL (P1 vs random, narrowly), held-out PASS | hand-coded reference candidate chooses the next noisy measurement by expected information; on DEV1 held-out it reaches the right explanation 116 / 160 / 388 time units sooner than random / cycle / fixed (horizon 2000), gain concentrated in mean-reversion worlds, final held-out prediction not better than random or cycle; with its extra computation charged it stays ahead of random only while one time unit of measurement is worth more than about 1e6 arithmetic evaluations, 2e6 at the low end of the saving (2026-10-09 re-analysis, no rerun). Self-run by the profile author, no seal, no independent evaluator: it does not close EXP-003 or raise the level ceiling. `docs/turing/BRW_ACT_RESULTS.md` | | R16 (orchestrator retirement) | CLOSED at candidate `850fc545`; living build IMPLEMENTED / NOT QUALIFIED | omega#112 merged (`3dd5eaa`), gates G1 to G8 PASS at that candidate (update 2026-09-30); merged with evidence-immutable FAILED, re-qualification owed (see the 2026-10-01 reconciliation section at the end) | | TURING wired into the live runtime | NOT STARTED | the runtime edit freeze was lifted (aien-architecture #70); no wiring work exists yet | diff --git a/evidence/BRW-ACT-DEV0/hold-reanalysis/reanalysis.txt b/evidence/BRW-ACT-DEV0/hold-reanalysis/reanalysis.txt new file mode 100644 index 000000000..985715431 --- /dev/null +++ b/evidence/BRW-ACT-DEV0/hold-reanalysis/reanalysis.txt @@ -0,0 +1,17 @@ +source commit: 4be83d129999caa041720b0028c4752301412fdb +input: evidence/BRW-ACT-DEV0/hold/table.tsv sha256 588b87a04e3dd42eeb0155df1423e65e4a8aebc21076606940cd8046bff59793 +tool: tests/brownian/brw_act_reanalyse.c sha256 7742439b3e5ba150cd0cbd4afb9bd57f70dbb199fdbc23580588060b706ad7d8 +flags: -std=c11 -Wall -Wextra -Werror -pedantic -O2 -D_POSIX_C_SOURCE=200809L -Isrc -Itools -ffp-contract=off -fno-fast-math +BRW-ACT re-analysis (dev0), 2000 table rows, 300 discoverable worlds per strategy + +Held-out coverage, per-world 95% interval (replaces the pooled Wilson interval): + active cov50 0.4938 [0.4843,0.5034] cov90 0.8949 [0.8884,0.9014] + random cov50 0.4950 [0.4855,0.5045] cov90 0.9001 [0.8938,0.9064] + fixed8 cov50 0.4933 [0.4842,0.5023] cov90 0.9004 [0.8946,0.9063] + cycle cov50 0.4906 [0.4814,0.4997] cov90 0.8969 [0.8906,0.9032] + +Computation charged (active minus baseline, per discoverable world): + vs extra evals time saved [95%] break-even evals/time + random 3.876e+07 7.5 [ 2.7, 12.3] 5.19e+06 (1.46e+07 at the low end of the saving) + fixed8 3.875e+07 7.5 [ 3.3, 11.7] 5.18e+06 (1.19e+07 at the low end of the saving) + cycle 3.876e+07 7.3 [ 2.8, 11.9] 5.29e+06 (1.41e+07 at the low end of the saving) diff --git a/evidence/BRW-ACT-DEV1/hold1-reanalysis/reanalysis.txt b/evidence/BRW-ACT-DEV1/hold1-reanalysis/reanalysis.txt new file mode 100644 index 000000000..2cb7fc7e2 --- /dev/null +++ b/evidence/BRW-ACT-DEV1/hold1-reanalysis/reanalysis.txt @@ -0,0 +1,17 @@ +source commit: 4be83d129999caa041720b0028c4752301412fdb +input: evidence/BRW-ACT-DEV1/hold1/table.tsv sha256 3365c8e84b10dffa07daf3e98d090a6d0fdab0ccfc1f3903b65b0919a3026fd7 +tool: tests/brownian/brw_act_reanalyse.c sha256 7742439b3e5ba150cd0cbd4afb9bd57f70dbb199fdbc23580588060b706ad7d8 +flags: -std=c11 -Wall -Wextra -Werror -pedantic -O2 -D_POSIX_C_SOURCE=200809L -Isrc -Itools -ffp-contract=off -fno-fast-math +BRW-ACT re-analysis (dev1), 2000 table rows, 200 discoverable worlds per strategy + +Held-out coverage, per-world 95% interval (replaces the pooled Wilson interval): + active cov50 0.4969 [0.4871,0.5068] cov90 0.8949 [0.8892,0.9006] + random cov50 0.5011 [0.4910,0.5111] cov90 0.8965 [0.8907,0.9023] + fixed8 cov50 0.5058 [0.4961,0.5156] cov90 0.9013 [0.8960,0.9067] + cycle cov50 0.4981 [0.4884,0.5077] cov90 0.8950 [0.8894,0.9006] + +Computation charged (active minus baseline, per discoverable world): + vs extra evals time saved [95%] break-even evals/time + random 1.118e+08 115.9 [ 55.9, 176.0] 9.65e+05 (2e+06 at the low end of the saving) + fixed8 1.118e+08 387.9 [ 308.1, 467.8] 2.88e+05 (3.63e+05 at the low end of the saving) + cycle 1.118e+08 160.0 [ 98.7, 221.3] 6.99e+05 (1.13e+06 at the low end of the saving) diff --git a/mk/.crumb b/mk/.crumb index 8335c0459..8cbf4f3d0 100644 --- a/mk/.crumb +++ b/mk/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-09T15:42:59Z", + "compiled_at": "2026-10-09T16:23:46Z", "compiler": "crumb-compile/1", - "digest": "sha256:0e5e438de09d26650bc575b50b19d2ac89e453a29d61872dcd830b2b431beebd", + "digest": "sha256:4dff9dca56ae6ee7c61c117f9a54b161e1eb8223075fd1fec70cda4bb15e1eba", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 63, - "generated_at_commit": "d83c1e207b3d3422601486a205644753e9d9a17c", - "source_tree": "sha256:265908703fcdbbc062f38a302f5928a85f0a4805f8e08c5e848a384aae1a7811" + "generated_at_commit": "84ec3f3e0914fad457ce7f6d7580536d4a931b10", + "source_tree": "sha256:52bff05a860cf020b372143f26490df2e2b7a6d16813440ab36bbf0684e2335a" }, "owner_lane": "", "provenance": { diff --git a/mk/brownian_active.mk b/mk/brownian_active.mk index 2617f585a..7053b94b3 100644 --- a/mk/brownian_active.mk +++ b/mk/brownian_active.mk @@ -7,7 +7,7 @@ # The `hold` worlds are run by hand once: build/brownian-active/brw_active_dev0 hold <fresh-dir> <commit> ifndef BROWNIAN_ACTIVE_MK BROWNIAN_ACTIVE_MK := 1 -.PHONY: test-brownian-active brownian-active-dev0 brwa-purity brwa-cli brownian-active-dev1-power brownian-active-dev1 brownian-active-dev0-regress +.PHONY: brownian-active-reanalyse test-brownian-active brownian-active-dev0 brwa-purity brwa-cli brownian-active-dev1-power brownian-active-dev1 brownian-active-dev0-regress BRWA_FLAGS = -std=c11 -Wall -Wextra -Werror -pedantic -O2 -D_POSIX_C_SOURCE=200809L -Isrc -Itools -ffp-contract=off -fno-fast-math BRWA_ASAN = -O1 -g -fsanitize=address,undefined -fno-sanitize-recover=all BRWA_LIB = tools/brownian/brw_active.c src/turing/ty_prd2.c src/turing/ty_qcont.c src/turing/ty_prd.c src/turing/ty_math.c @@ -42,7 +42,15 @@ brwa-cli: $(BRWA_DIR)/brw_active_dev0 @$(BRWA_DIR)/brw_active_dev0 bogus $(BRWA_DIR)/cli-x t >/dev/null 2>&1; [ $$? -eq 64 ] || { echo "unknown profile id must exit 64"; exit 1; } @echo "brwa-cli: runner argument contract holds" -test-brownian-active: brwa-purity brwa-cli $(BRWA_DIR)/test_brw_active $(BRWA_DIR)/test_brw_active_asan +$(BRWA_DIR)/test_brw_act_report: tests/brownian/test_brw_act_report.c tests/brownian/brw_act_report.h + @mkdir -p $(BRWA_DIR) + $(CC) $(BRWA_FLAGS) $(BRWA_ASAN) -o $@ tests/brownian/test_brw_act_report.c -lm +$(BRWA_DIR)/brw_act_reanalyse: tests/brownian/brw_act_reanalyse.c tests/brownian/brw_act_report.h + @mkdir -p $(BRWA_DIR) + $(CC) $(BRWA_FLAGS) -o $@ tests/brownian/brw_act_reanalyse.c -lm + +test-brownian-active: brwa-purity brwa-cli $(BRWA_DIR)/test_brw_active $(BRWA_DIR)/test_brw_active_asan $(BRWA_DIR)/test_brw_act_report + ./$(BRWA_DIR)/test_brw_act_report ./$(BRWA_DIR)/test_brw_active ./$(BRWA_DIR)/test_brw_active_asan @echo "test-brownian-active: candidate library unit tests pass in plain and ASan/UBSan builds; purity holds" @@ -84,4 +92,16 @@ brownian-active-dev1: $(BRWA1_DIR)/brw_active_dev0 a=$$(sha256sum < $(BRWA1_DIR)/dev1-a/table.tsv); b=$$(sha256sum < $(BRWA1_DIR)/dev1-b/table.tsv); \ if [ "$$a" != "$$b" ]; then echo "brownian-active-dev1: REPLAY MISMATCH"; exit 1; fi; \ echo "brownian-active-dev1: two dev1 runs produced identical tables ($$a)" +# Re-analysis of the committed held-out tables (reads table.tsv only, runs no world). Writes a new evidence file, +# never over an existing one: evidence/BRW-ACT-DEV<n>/<run>-reanalysis/reanalysis.txt. +brownian-active-reanalyse: $(BRWA_DIR)/brw_act_reanalyse + @for r in DEV0:hold:dev0 DEV1:hold1:dev1; do \ + d=$${r%%:*}; rest=$${r#*:}; run=$${rest%%:*}; p=$${rest#*:}; t=evidence/BRW-ACT-$$d/$$run/table.tsv; \ + o=evidence/BRW-ACT-$$d/$$run-reanalysis; test -e $$o/reanalysis.txt && { echo "$$o/reanalysis.txt exists, not overwritten"; continue; }; \ + mkdir -p $$o; { echo "source commit: $(BRWA_COMMIT)"; echo "input: $$t sha256 $$(sha256sum < $$t | cut -c1-64)"; \ + echo "tool: tests/brownian/brw_act_reanalyse.c sha256 $$(sha256sum < tests/brownian/brw_act_reanalyse.c | cut -c1-64)"; \ + echo "flags: $(BRWA_FLAGS)"; ./$(BRWA_DIR)/brw_act_reanalyse $$p $$t; } > $$o/reanalysis.txt.tmp || { rm -f $$o/reanalysis.txt.tmp; exit 1; }; \ + mv $$o/reanalysis.txt.tmp $$o/reanalysis.txt; \ + echo "wrote $$o/reanalysis.txt"; done + endif diff --git a/tests/.crumb b/tests/.crumb index 571bf602e..db9568521 100644 --- a/tests/.crumb +++ b/tests/.crumb @@ -110,25 +110,25 @@ "children": [ { "digest": "e7498eca87fe5ca8dc27d92f2d99be0de3e4c804711f9d8cba5bb1e47ca95f74", - "last_commit": "28911be", + "last_commit": "a9b9d0d", "name": "algebra", "purpose": "Directory tests/algebra. Purpose not yet described by a human." }, { "digest": "d484ca176e9932b098df5664d01bdd679c78f5b89f4d15a77eb30f43d235f570", - "last_commit": "834ee93", + "last_commit": "a9b9d0d", "name": "ans", "purpose": "Tests 1-10 for ANS (docs/ans/INERTIAL_ALIGNMENT_SPEC_V1.md): freeze/digest, hostile reference mu" }, { - "digest": "23d72ac4f53b2477a130ed808d6e5304a3f94a6a3ea023c68d8e341ff582c843", - "last_commit": "1f85669", + "digest": "42a7efc25b16d1ea7bd7a5cbc31be7e499c9bc64c9e7df179c7627121d7df637", + "last_commit": "4be83d1", "name": "brownian", "purpose": "Directory tests/brownian. Purpose not yet described by a human." }, { "digest": "1cbe9561b87b394e200f67996ce1407c377025d07ad033b27cdd542625e277d4", - "last_commit": "30bb116", + "last_commit": "a9b9d0d", "name": "canonicalization", "purpose": "Directory tests/canonicalization. Purpose not yet described by a human." }, @@ -140,61 +140,61 @@ }, { "digest": "47683e6a56ca8e14ee526004b2a90dd08498507e8d4b0b42c3d85d22afb07d28", - "last_commit": "28b8793", + "last_commit": "a9b9d0d", "name": "constraints", "purpose": "Directory tests/constraints. Purpose not yet described by a human." }, { "digest": "95b2041562face1ba7baa6c57456bf07d77a0f44e093b989ec18f559064e22d9", - "last_commit": "49abb02", + "last_commit": "a9b9d0d", "name": "crumbline", "purpose": "Directory tests/crumbline. Purpose not yet described by a human." }, { "digest": "d57833fb3f63ef6475cf25e2e16319d818a0a407b825d5b4c5cbdd3cc0e06492", - "last_commit": "00f54b6", + "last_commit": "a9b9d0d", "name": "dual_experiment", "purpose": "Tests for the DUAL applicability experiment: determinism (same seed, byte-identical results dige" }, { "digest": "fb0a9296a93d065d5e016ad0a950fc6b9691f8ddca12ad0111cee2e35791cdb4", - "last_commit": "c819b37", + "last_commit": "a9b9d0d", "name": "effect", "purpose": "Directory tests/effect. Purpose not yet described by a human." }, { "digest": "bc2473da101ba5a74c32021a9d27ecb2007897f07a9689ba50ccc99b9030bf0c", - "last_commit": "1a147e4", + "last_commit": "a9b9d0d", "name": "estimation", "purpose": "Directory tests/estimation. Purpose not yet described by a human." }, { "digest": "de2bc4e310a257dbd21cc5c9624641b137b1b4487d8876cb52469aea2af5b904", - "last_commit": "3108fc2", + "last_commit": "a9b9d0d", "name": "fabric", "purpose": "Directory tests/fabric. Purpose not yet described by a human." }, { "digest": "90418926706f827aafd72938aee1dea89222cb5e465fba06a8df5a83253e0412", - "last_commit": "28b8793", + "last_commit": "a9b9d0d", "name": "identity", "purpose": "Directory tests/identity. Purpose not yet described by a human." }, { "digest": "c653c851c8934ce9ac4eabaa32a9df65d858c9ac7a556e76b265b1ee81494443", - "last_commit": "4f55f45", + "last_commit": "a9b9d0d", "name": "language", "purpose": "Directory tests/language. Purpose not yet described by a human." }, { "digest": "e485aa0a00f0a588e22d55caa704db8581a5da1b53080b311086e6edd38f6044", - "last_commit": "30bb116", + "last_commit": "a9b9d0d", "name": "malformed", "purpose": "Directory tests/malformed. Purpose not yet described by a human." }, { "digest": "adba9b5ea1c000db36078fca7d1bfef0b2769b73c8fb474024d9409bd48bdbc1", - "last_commit": "40d1ea3", + "last_commit": "a9b9d0d", "name": "numeric_native", "purpose": "Simulated M16 driver for numeric resource-lifecycle tests. No device execution or numeric parity" }, @@ -206,31 +206,31 @@ }, { "digest": "a4d320b3203650a28c43ea954957d8902d1cc25cbdc8aecd15628c01a92f68f8", - "last_commit": "d550b70", + "last_commit": "a9b9d0d", "name": "path", "purpose": "Directory tests/path. Purpose not yet described by a human." }, { "digest": "1fd5f914f326a1a51fc343ab633ac411e86bea22beee718b1460db066807f292", - "last_commit": "8a2e268", + "last_commit": "a9b9d0d", "name": "physics0", "purpose": "PD-0 gates: world self-test, oracle calibration, learner L0/L1/NULL, mutations, OSC differential" }, { "digest": "4619a90a957e77cd3d5680132ab4d1a5ef65f43419ddcc089743ca5b7a7719ee", - "last_commit": "8f8babe", + "last_commit": "a9b9d0d", "name": "polyglot", "purpose": "Directory tests/polyglot. Purpose not yet described by a human." }, { "digest": "16bea65aa50f0b3ab8b90cb286de048639fa8e635ff84e517e138c6f9f26a059", - "last_commit": "3c82389", + "last_commit": "a9b9d0d", "name": "program", "purpose": "Directory tests/program. Purpose not yet described by a human." }, { "digest": "ba0c09f67d12b5d7de906129bdbe2f6e0a228e1a34236ecc4b779c523cb2061e", - "last_commit": "6fdc4c3", + "last_commit": "a9b9d0d", "name": "r16_inventory", "purpose": "Directory tests/r16_inventory. Purpose not yet described by a human." }, @@ -242,19 +242,19 @@ }, { "digest": "25cabf47d18353539db28146434d246a2f81bf9c323471566451aca56806f279", - "last_commit": "44d8c06", + "last_commit": "a9b9d0d", "name": "r16_surface", "purpose": "Directory tests/r16_surface. Purpose not yet described by a human." }, { "digest": "9106f2ea57e8f453322f0a988b61cfcbd06631573c9ff32a777903d27d7741e1", - "last_commit": "40d1ea3", + "last_commit": "a9b9d0d", "name": "realize", "purpose": "Directory tests/realize. Purpose not yet described by a human." }, { "digest": "381184e79b26920b256dd4a774fb11f17a92afa8ceda4813eada241bac4163a9", - "last_commit": "30bb116", + "last_commit": "a9b9d0d", "name": "relations", "purpose": "Directory tests/relations. Purpose not yet described by a human." }, @@ -266,38 +266,38 @@ }, { "digest": "b1311025a3bfd8dd7b5e07b1adf1d7ece502a15200f7207f515334f7083b8315", - "last_commit": "5ae192a", + "last_commit": "a9b9d0d", "name": "searchtrace", "purpose": "Directory tests/searchtrace. Purpose not yet described by a human." }, { "digest": "3ecf636e2923038708cafa062895b8d8f2664dc1865cdff38575911eaa9f1b2d", - "last_commit": "54826a3", + "last_commit": "a9b9d0d", "name": "train", "purpose": "Directory tests/train. Purpose not yet described by a human." }, { "digest": "75d5e576c38a0497a55e9f5ee79550cb94f9b75008f3e4e126312802704b3f86", - "last_commit": "2564f57", + "last_commit": "a9b9d0d", "name": "turing", "purpose": "Directory tests/turing. Purpose not yet described by a human." }, { "digest": "3f19e3034ff999211cb13ab8995ca6c38d0d8e1f5bfbbbd621caaa08412d3f1f", - "last_commit": "fed4f07", + "last_commit": "a9b9d0d", "name": "visor", "purpose": "Directory tests/visor. Purpose not yet described by a human." } ], - "children_root": "sha256:66b7759d007da734c0da420966ee77159fe71278f914244399f5da057110aa31", - "compiled_at": "2026-10-09T15:42:59Z", + "children_root": "sha256:849957367e24b73a434dc9545ac6ac9703692c859a6cad7b69c743a58db3da0e", + "compiled_at": "2026-10-09T16:22:14Z", "compiler": "crumb-compile/1", - "digest": "sha256:3c34368255315b76534c31a3ce30d3f0723718601247894e45bfae30006364a3", + "digest": "sha256:3d7c5bcf7d44a931f6def8354e1cebdfac6178a9fbc6fcc8a149d10287e68102", "evidence_files": 11, "evidence_root": "sha256:d5c1bceb4d57ef0eb42797c58801b5926509711614c3e38bb7105b6efa3942f2", - "files": 944, - "generated_at_commit": "d83c1e207b3d3422601486a205644753e9d9a17c", - "source_tree": "sha256:fc3adba27de6b0e21863a5c8d9730e229db4aa308a09d207238ccf349c41adc2" + "files": 947, + "generated_at_commit": "7a9a3a34a93df74e2a226db8de6ba8ea0cfad672", + "source_tree": "sha256:16b12dc2672127f8cad803289ab34aaad0bfe510124db1a437ff87286e686f0d" }, "owner_lane": "", "provenance": { diff --git a/tests/brownian/.crumb b/tests/brownian/.crumb index 7b026486d..49f863e2b 100644 --- a/tests/brownian/.crumb +++ b/tests/brownian/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-09T15:42:59Z", + "compiled_at": "2026-10-09T16:22:14Z", "compiler": "crumb-compile/1", - "digest": "sha256:23d72ac4f53b2477a130ed808d6e5304a3f94a6a3ea023c68d8e341ff582c843", + "digest": "sha256:42a7efc25b16d1ea7bd7a5cbc31be7e499c9bc64c9e7df179c7627121d7df637", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 3, - "generated_at_commit": "d83c1e207b3d3422601486a205644753e9d9a17c", - "source_tree": "sha256:7bbcd4ad69bfdf3eec7cee358ebd464b94d9ba65878961fd8de1ae215d8798c8" + "files": 6, + "generated_at_commit": "7a9a3a34a93df74e2a226db8de6ba8ea0cfad672", + "source_tree": "sha256:fe89cc7f41dbad1a9e2c6270accc46727bc40b66fb1c04e6616960a650f13cb4" }, "owner_lane": "", "provenance": { diff --git a/tests/brownian/brw_act_reanalyse.c b/tests/brownian/brw_act_reanalyse.c new file mode 100644 index 000000000..f2bfe7517 --- /dev/null +++ b/tests/brownian/brw_act_reanalyse.c @@ -0,0 +1,71 @@ +/* BRW-ACT re-analysis of a committed table.tsv (harness side). Reads only the per-world table; runs no world. + * Usage: brw_act_reanalyse dev0|dev1 <table.tsv> + * Prints, over the discoverable classes of that profile (DEV0: diffusion, drift, ou; DEV1: drift, ou): + * - held-out coverage 50% / 90% with the per-world 95% interval (brw_act_report.h); + * - computation charged: extra evaluations (likelihood + quadrature + cdf, counted alike) of active over each + * baseline, the paired time saving with a normal 95% interval, and the break-even exchange rate: active stays + * ahead only while one time unit of measurement is worth more than that many evaluations. + * Descriptive, written after the results were read: not a pass rule of any profile. */ +#include "brw_act_report.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +enum { NS = 4, NWMAX = 600 }; +static const char *sname[NS] = {"active", "random", "fixed8", "cycle"}; + +int main(int argc, char **argv) +{ + if (argc != 3 || (strcmp(argv[1], "dev0") && strcmp(argv[1], "dev1"))) { + fprintf(stderr, "usage: brw_act_reanalyse dev0|dev1 <table.tsv>\n"); + return 64; + } + const int dev1 = !strcmp(argv[1], "dev1"); + FILE *f = fopen(argv[2], "r"); + if (!f) { perror(argv[2]); return 1; } + static double cost[NS][NWMAX], ev[NS][NWMAX], k50[NS][NWMAX], k90[NS][NWMAX]; + int n[NS] = {0}, rows = 0; + char line[4096]; + if (!fgets(line, sizeof line, f) || strncmp(line, "world\tclass\t", 12)) { fprintf(stderr, "not a BRW-ACT table\n"); return 1; } + while (fgets(line, sizeof line, f)) { + char *col[24]; + int nc = 0; + for (char *p = strtok(line, "\t\n"); p && nc < 24; p = strtok(NULL, "\t\n")) col[nc++] = p; + if (nc != 24) { fprintf(stderr, "row %d: %d columns, want 24\n", rows + 2, nc); return 1; } + rows++; + if (!strcmp(col[1], "noise") || !strcmp(col[1], "mismatch") || (dev1 && !strcmp(col[1], "diffusion"))) continue; + int s = -1; + for (int i = 0; i < NS; i++) if (!strcmp(col[4], sname[i])) s = i; + if (s < 0 || n[s] >= NWMAX) { fprintf(stderr, "row %d: bad strategy or too many worlds\n", rows + 1); return 1; } + cost[s][n[s]] = atof(col[8]); + k50[s][n[s]] = atof(col[18]); + k90[s][n[s]] = atof(col[19]); + ev[s][n[s]] = atof(col[21]) + atof(col[22]) + atof(col[23]); + n[s]++; + } + fclose(f); + for (int s = 1; s < NS; s++) if (n[s] != n[0]) { fprintf(stderr, "unpaired: %d vs %d worlds\n", n[s], n[0]); return 1; } + const int nd = n[0]; + printf("BRW-ACT re-analysis (%s), %d table rows, %d discoverable worlds per strategy\n", argv[1], rows, nd); + printf("\nHeld-out coverage, per-world 95%% interval (replaces the pooled Wilson interval):\n"); + for (int s = 0; s < NS; s++) { + double m50, l50, h50, m90, l90, h90; + brwr_coverage(k50[s], nd, 60, &m50, &l50, &h50); + brwr_coverage(k90[s], nd, 60, &m90, &l90, &h90); + printf(" %-7s cov50 %.4f [%.4f,%.4f] cov90 %.4f [%.4f,%.4f]\n", sname[s], m50, l50, h50, m90, l90, h90); + } + printf("\nComputation charged (active minus baseline, per discoverable world):\n"); + printf(" %-7s %14s %22s %26s\n", "vs", "extra evals", "time saved [95%]", "break-even evals/time"); + for (int b = 1; b < NS; b++) { + double ds = 0, dss = 0, de = 0; + for (int i = 0; i < nd; i++) ds += cost[b][i] - cost[0][i], de += ev[0][i] - ev[b][i]; + ds /= nd; de /= nd; + for (int i = 0; i < nd; i++) { double d = cost[b][i] - cost[0][i] - ds; dss += d * d; } + double h = 1.959964 * sqrt(dss / (nd - 1) / nd); + printf(" %-7s %14.4g %8.1f [%6.1f,%6.1f] ", sname[b], de, ds, ds - h, ds + h); + if (ds - h > 0 && de > 0) printf("%11.3g (%.3g at the low end of the saving)\n", de / ds, de / (ds - h)); + else printf("%26s\n", "no saving established"); + } + return 0; +} diff --git a/tests/brownian/brw_act_report.h b/tests/brownian/brw_act_report.h new file mode 100644 index 000000000..4d94d0a52 --- /dev/null +++ b/tests/brownian/brw_act_report.h @@ -0,0 +1,32 @@ +/* Report statistics for the BRW-ACT runner and its re-analysis tool (harness side, not candidate code). + * Kept apart from brw_active_dev0.c so the unit test can check them. */ +#ifndef BRW_ACT_REPORT_H +#define BRW_ACT_REPORT_H + +#include <math.h> + +/* Coverage over n worlds, k[i] of m held-out readings covered in world i. Mean and 95% interval. + * The world is the independent unit (its readings share one fit), so the interval is the normal interval of + * the n per-world proportions, clipped to [0, 1]. */ +static inline void brwr_coverage(const double *k, int n, int m, double *mean, double *lo, double *hi) +{ + double s = 0, ss = 0; + for (int i = 0; i < n; i++) s += k[i] / m; + double p = s / n; + for (int i = 0; i < n; i++) ss += (k[i] / m - p) * (k[i] / m - p); + double h = n > 1 ? 1.959964 * sqrt(ss / (n - 1) / n) : 1.0; + *mean = p; + *lo = p - h < 0.0 ? 0.0 : p - h; + *hi = p + h > 1.0 ? 1.0 : p + h; +} + +/* P4 control verdicts: noise worlds always; diffusion (nested null) worlds only under DEV1. Returns both. */ +static inline int brwr_p4(int claims_noise, int claims_diff, int nper, int dev1, int *noise_ok, int *diff_ok) +{ + int all = (double)claims_noise <= 0.05 * nper && (!dev1 || (double)claims_diff <= 0.05 * nper); + *noise_ok = (double)claims_noise <= 0.05 * nper; + *diff_ok = !dev1 || (double)claims_diff <= 0.05 * nper; + return all; +} + +#endif diff --git a/tests/brownian/brw_active_dev0.c b/tests/brownian/brw_active_dev0.c index b3dd53406..4b9c38e3e 100644 --- a/tests/brownian/brw_active_dev0.c +++ b/tests/brownian/brw_active_dev0.c @@ -8,6 +8,7 @@ #include "sha256.h" #include "turing/ty_prd2.h" #include "turing/ty_qcont.h" +#include "brw_act_report.h" #include <errno.h> #include <fcntl.h> @@ -29,6 +30,7 @@ static int budget = 400; /* DEV0: 400; DEV1: B from the power receipt */ #define NHELD_PER_TAU 10 #define NHELD (BRW_NT * NHELD_PER_TAU) +#define NPER_MAX 100 /* worlds per class in the largest profile run (hold, hold1) */ #define NBOOT 10000 #define BOOT_SEED 0x0B5E55ED00000001ull enum { C_DIFF, C_DRIFT, C_OU, C_NOISE, C_MIS, NCLS }; @@ -251,14 +253,6 @@ static void boot(const double *d, size_t n, double *mean, double *lo, double *hi free(m); } -static void wilson(double k, double n, double *lo, double *hi) -{ - const double z = 1.959964; - double p = k / n, d = 1.0 + z * z / n, c = p + z * z / (2 * n), h = z * sqrt(p * (1 - p) / n + z * z / (4 * n * n)); - *lo = (c - h) / d; - *hi = (c + h) / d; -} - /* ---- growing text buffer ---- */ typedef struct { char *p; size_t n, cap; } buf_t; static void bprintf(buf_t *b, const char *fmt, ...) @@ -485,18 +479,16 @@ int main(int argc, char **argv) double lo50[NSTRAT], hi50[NSTRAT], lo90[NSTRAT], hi90[NSTRAT]; uint64_t lik[NSTRAT] = {0}, quad[NSTRAT] = {0}, cdf[NSTRAT] = {0}; for (int st = 0; st < NSTRAT; st++) { - double f[3] = {0, 0, 0}, mc = 0, nm = 0, mp = 0, mb = 0, k50 = 0, k90 = 0; + double f[3] = {0, 0, 0}, mc = 0, nm = 0, mp = 0, mb = 0, w50[NCLS * NPER_MAX], w90[NCLS * NPER_MAX]; for (int wi = 0; wi < nd; wi++) { const run_t *r = &R[di[wi] * NSTRAT + st]; f[r->outcome] += 1; - mc += r->cost_restr; nm += r->nmeas; mp += r->p_true; mb += r->bits; k50 += r->c50; k90 += r->c90; + mc += r->cost_restr; nm += r->nmeas; mp += r->p_true; mb += r->bits; w50[wi] = r->c50; w90[wi] = r->c90; } for (int o = 0; o < 3; o++) frac[st][o] = f[o] / nd; meancost[st] = mc / nd; meannm[st] = nm / nd; meanp[st] = mp / nd; meanbits[st] = mb / nd; - cov50[st] = k50 / ((double)nd * NHELD); - cov90[st] = k90 / ((double)nd * NHELD); - wilson(k50, (double)nd * NHELD, &lo50[st], &hi50[st]); - wilson(k90, (double)nd * NHELD, &lo90[st], &hi90[st]); + brwr_coverage(w50, nd, NHELD, &cov50[st], &lo50[st], &hi50[st]); + brwr_coverage(w90, nd, NHELD, &cov90[st], &lo90[st], &hi90[st]); for (int wi = 0; wi < nw; wi++) { lik[st] += R[wi * NSTRAT + st].lik; quad[st] += R[wi * NSTRAT + st].quad; @@ -505,7 +497,7 @@ int main(int argc, char **argv) } bprintf(&rep, "\nDiscoverable classes pooled (restricted mean cost, horizon %d):\n", budget); bprintf(&rep, "%-8s %7s %7s %7s %9s %6s %7s %9s %20s %20s\n", "strategy", "success", "wrong", "censor", "mean_cost", "n_meas", - "P(true)", "bits/read", "cov50 [Wilson95]", "cov90 [Wilson95]"); + "P(true)", "bits/read", "cov50 [world95]", "cov90 [world95]"); for (int st = 0; st < NSTRAT; st++) bprintf(&rep, "%-8s %7.4f %7.4f %7.4f %9.3f %6.2f %7.4f %9.4f %.4f [%.4f,%.4f] %.4f [%.4f,%.4f]\n", str_name[st], frac[st][0], frac[st][1], frac[st][2], meancost[st], meannm[st], meanp[st], meanbits[st], cov50[st], lo50[st], @@ -561,15 +553,15 @@ int main(int argc, char **argv) int v = R[(C_DIFF * nper + i) * NSTRAT + S_ACTIVE].verdict; claims_diff += (v == BRW_V_M1 || v == BRW_V_M2); } - int p4 = (double)claims <= 0.05 * nper && (!dev1 || (double)claims_diff <= 0.05 * nper); + int p4_noise, p4_diff, p4 = brwr_p4(claims, claims_diff, nper, dev1, &p4_noise, &p4_diff); int confident = ctl_mis[S_ACTIVE][BRW_V_M0] + ctl_mis[S_ACTIVE][BRW_V_M1] + ctl_mis[S_ACTIVE][BRW_V_M2]; int p5 = (double)confident <= 0.20 * nper; bprintf(&rep, "\nPass rules (%s worlds):\n", argv[1]); bprintf(&rep, " P1 active cost interval entirely below 0 vs random, fixed8, cycle: %s\n", p1 ? "PASS" : "FAIL"); bprintf(&rep, " P2 active wrong %.4f <= 0.05 and <= max baseline wrong %.4f + 0.02: %s\n", frac[S_ACTIVE][1], maxbase, p2 ? "PASS" : "FAIL"); bprintf(&rep, " P3 active coverage 90%% %.4f in [0.85,0.95], 50%% %.4f in [0.45,0.55]: %s\n", cov90[S_ACTIVE], cov50[S_ACTIVE], p3 ? "PASS" : "FAIL"); - bprintf(&rep, " P4 noise control: active claims M1 or M2 in %d of %d worlds (limit %.1f): %s\n", claims, nper, 0.05 * nper, p4 ? "PASS" : "FAIL"); - if (dev1) bprintf(&rep, " P4 (DEV1) nested-null control: active claims M1 or M2 in %d of %d diffusion worlds (limit %.1f): %s\n", claims_diff, nper, 0.05 * nper, (double)claims_diff <= 0.05 * nper ? "PASS" : "FAIL"); + bprintf(&rep, " P4 noise control: active claims M1 or M2 in %d of %d worlds (limit %.1f): %s\n", claims, nper, 0.05 * nper, p4_noise ? "PASS" : "FAIL"); + if (dev1) bprintf(&rep, " P4 (DEV1) nested-null control: active claims M1 or M2 in %d of %d diffusion worlds (limit %.1f): %s\n", claims_diff, nper, 0.05 * nper, p4_diff ? "PASS" : "FAIL"); bprintf(&rep, " P5 mismatch control: active confident model verdict in %d of %d worlds (limit %.1f): %s\n", confident, nper, 0.20 * nper, p5 ? "PASS" : "FAIL"); bprintf(&rep, "BRW_ACT_%s %s: %s\n", dev1 ? "DEV1" : "DEV0", argv[1], (p1 && p2 && p3 && p4 && p5 && !nfail) ? "PASS" : "FAIL"); bprintf(&rep, "failed runs (validation or scorer refusals): %d\n", nfail); diff --git a/tests/brownian/test_brw_act_report.c b/tests/brownian/test_brw_act_report.c new file mode 100644 index 000000000..08e5f8bd6 --- /dev/null +++ b/tests/brownian/test_brw_act_report.c @@ -0,0 +1,43 @@ +/* Regression tests for the BRW-ACT report statistics (tests/brownian/brw_act_report.h). + * Both defects were listed in docs/turing/BRW_ACT_RESULTS.md section 5 as known reporting issues. */ +#include "brw_act_report.h" + +#include <stdio.h> + +static int fails, checks; +#define CHECK(c) do { checks++; if (!(c)) { fails++; printf("FAIL line %d: %s\n", __LINE__, #c); } } while (0) + +int main(void) +{ + double k[200], mean, lo, hi; + + /* Readings in a world share that world's fit, so coverage clusters by world. 100 worlds cover all 60 + * readings and 100 cover none: pooled mean 0.5, but only 200 independent units. The interval must be about + * +-1.96*0.5/sqrt(200) = +-0.069 wide, not the +-0.009 of 12000 independent readings. */ + for (int i = 0; i < 200; i++) k[i] = i < 100 ? 60 : 0; + brwr_coverage(k, 200, 60, &mean, &lo, &hi); + CHECK(fabs(mean - 0.5) < 1e-12); + CHECK(hi - lo > 0.12 && hi - lo < 0.16); + + /* No spread between worlds: every world covers 54 of 60. Interval collapses onto 0.9. */ + for (int i = 0; i < 200; i++) k[i] = 54; + brwr_coverage(k, 200, 60, &mean, &lo, &hi); + CHECK(fabs(mean - 0.9) < 1e-12 && fabs(lo - 0.9) < 1e-12 && fabs(hi - 0.9) < 1e-12); + + /* Bounds stay inside [0, 1]. */ + for (int i = 0; i < 200; i++) k[i] = i < 2 ? 0 : 60; + brwr_coverage(k, 200, 60, &mean, &lo, &hi); + CHECK(lo >= 0.0 && hi <= 1.0 && lo <= mean && mean <= hi); + + /* P4: noise control passes (0 claims), DEV1 nested-null control fails (10 of 100). The noise line must say + * PASS; only the combined verdict fails. */ + int nok, dok, all = brwr_p4(0, 10, 100, 1, &nok, &dok); + CHECK(nok == 1 && dok == 0 && all == 0); + all = brwr_p4(6, 0, 100, 1, &nok, &dok); + CHECK(nok == 0 && dok == 1 && all == 0); + all = brwr_p4(5, 10, 100, 0, &nok, &dok); /* DEV0 has no nested-null control */ + CHECK(nok == 1 && dok == 1 && all == 1); + + printf("test_brw_act_report: %d checks, %d failures\n", checks, fails); + return fails != 0; +}