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#257 (code only)
Apply it
git checkout -b patch-8c832e57ee120d35 5790b1b11b74080cdc6df36888b2d7dd8910caa7 curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/8c832e57ee120d35.patch | git am
Provenance
github-import 1
aien-dev/omega-mv
257
7638888046f96c499e2da30812a8a5f42bd1867f
{"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":257,"url":"https://github.com/aien-dev/omega-mv/pull/257","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:37:00Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/docs/physics0/LEARNER.md b/docs/physics0/LEARNER.md index 767fdc92d..ff406134e 100644 --- a/docs/physics0/LEARNER.md +++ b/docs/physics0/LEARNER.md @@ -11,7 +11,10 @@ Spec: aien-dev/physics `docs/PD0_HIDDEN_EQUATION_BENCHMARK.md` rev 2 (2f881b1); world parameters follow rev 3 (omega #248, merged); the rev 5 rules (requested-reset preregistration hash, no T2 self pairs) and the rev 6 rules (rollout error over the pooled FIT sd, EPISODE_END records count as -observations) are implemented in the checker and the learner. +observations) and the rev 7 rule (a TRIAL or REP episode ended OUT_OF_BOUNDS +before the horizon is void, replaced from the same stream, never in p or f; +a fourth void in a batch voids the batch) are implemented in the checker +and the harness. ## Layout @@ -73,7 +76,7 @@ learner refits (at most three attempts). The checker runs after each stage; the harness never proceeds to trials without a HYPOTHESIS state. The scorer runs on 20 noise-free truth episodes (10 in the reset box, 10 at 1.5x). -## Development results (seeds 1..5, rev 3 world, rev 6 checker rules) +## Development results (seeds 1..5, rev 3 world, rev 7 checker rules) Learner never saw HOLDOUT/TRIAL/REP. "state" is the checker's verdict; "scorer" is `pd0_score` against the truth. Earlier receipts (rev 2 world; @@ -81,7 +84,7 @@ rev 5 rules) are kept beside the new one. | level | state reached (seeds) | scorer | size / bound | bits | notes | |---|---|---|---|---|---| -| L0 | PROVISIONAL_LAW 4/5, INTERVENED 1/5 | PASS 5/5 (exact) | 2 / 4 | 96 | seed 5: one replication episode left the box, batch short by one (code 261) | +| L0 | PROVISIONAL_LAW 5/5 | PASS 5/5 (exact) | 2 / 4 | 96 | seed 5: one replication episode left the box, void and replaced (rev 7) | | L1 | PROVISIONAL_LAW 5/5 | PASS 5/5 | 3 / 5 | 144 | exact, one-step error 0 | | L2 | PROVISIONAL_LAW 5/5 | PASS 5/5 | 4 / 6 | 192 | exact | | L3 | PROVISIONAL_LAW 5/5 | PASS 5/5 | 8 / 10 | 576 | four variables, two channels, exact | @@ -121,13 +124,11 @@ Numbers per instance: `evidence/physics0/learner/pd0-learner-dev-<commit>.txt`. levels the checker binds the reset through the PD0EXP1 entry and the steps only; the trial error bound covers a mismatched reset. A reset record that carries the requested values would close this. -3. **Replication batches and out-of-bounds episodes.** A random replication - schedule can leave the box; the episode then has fewer than 20 outcomes - and the batch falls short (L0 seed 5). The spec should say whether the - harness may run a replacement episode in the same batch. - -Resolved by rev 5 and rev 6: noisy-reset preregistration hash, T2 self -pairs, within-trial error normalisation, EPISODE_END outcomes. +Resolved by rev 5, rev 6 and rev 7: noisy-reset preregistration hash, T2 +self pairs, within-trial error normalisation, EPISODE_END outcomes, void +out-of-bounds trial and replication episodes (replaced from the same +stream; at most three voids per batch, a fourth voids and redraws the +batch; voids never count toward p or f). ## Not implemented diff --git a/evidence/physics0/learner/pd0-learner-dev-8c5324f8483d.txt b/evidence/physics0/learner/pd0-learner-dev-8c5324f8483d.txt new file mode 100644 index 000000000..92efe910a --- /dev/null +++ b/evidence/physics0/learner/pd0-learner-dev-8c5324f8483d.txt @@ -0,0 +1,48 @@ +receipt: PD0_LEARNER_DEV +commit: 8c5324f8483def6d38ebe9be18c7bfd055e1dfc2 +date_utc: 2026-10-04T00:57:38Z +levels: 0 1 2 3 4 5 6 null +seeds: 1 2 3 4 5 (development seeds; HOLDOUT/TRIAL/REP withheld by the harness) +--- isolation +PHYSICS0_ISOLATION: PASS (3 learner-side objects clean) +--- results +PD0L level=L0 seed=1 desc=v2 episodes=145 steps=2900 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=2 cand_bits=96 size_bound=4 fit_nrmse=0 select_nrmse=0 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=0 extrap=0 onestep=0 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L0 seed=2 desc=v2 episodes=145 steps=2898 fit=1317 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=2 cand_bits=96 size_bound=4 fit_nrmse=0 select_nrmse=0 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=0 extrap=0 onestep=0 ref=0 score_eps=20 law=0 checker_rc=0 oob=1 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L0 seed=3 desc=v2 episodes=145 steps=2899 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=2 cand_bits=96 size_bound=4 fit_nrmse=0 select_nrmse=0 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=0 extrap=0 onestep=0 ref=0 score_eps=20 law=0 checker_rc=0 oob=1 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L0 seed=4 desc=v2 episodes=145 steps=2899 fit=1320 select=437 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=2 cand_bits=96 size_bound=4 fit_nrmse=0 select_nrmse=0 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=0 extrap=0 onestep=0 ref=0 score_eps=20 law=0 checker_rc=0 oob=2 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L0 seed=5 desc=v2 episodes=146 steps=2919 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=2 cand_bits=96 size_bound=4 fit_nrmse=0 select_nrmse=0 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=0 extrap=0 onestep=0 ref=0 score_eps=20 law=0 checker_rc=0 oob=1 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=1 void_batch=0 +PD0L level=L1 seed=1 desc=v2 episodes=145 steps=2900 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=3 cand_bits=144 size_bound=5 fit_nrmse=0 select_nrmse=0 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=1 extrap=1 onestep=0 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L1 seed=2 desc=v2 episodes=145 steps=2900 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=3 cand_bits=144 size_bound=5 fit_nrmse=0 select_nrmse=0 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=2 extrap=2 onestep=0 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L1 seed=3 desc=v2 episodes=145 steps=2900 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=3 cand_bits=144 size_bound=5 fit_nrmse=0 select_nrmse=0 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=6 extrap=6 onestep=0 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L1 seed=4 desc=v2 episodes=145 steps=2900 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=3 cand_bits=144 size_bound=5 fit_nrmse=0 select_nrmse=0 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=1 extrap=1 onestep=0 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L1 seed=5 desc=v2 episodes=145 steps=2900 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=3 cand_bits=144 size_bound=5 fit_nrmse=0 select_nrmse=0 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=8 extrap=4 onestep=0 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L2 seed=1 desc=v2 episodes=145 steps=2900 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=4 cand_bits=192 size_bound=6 fit_nrmse=0 select_nrmse=1 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=2 extrap=2 onestep=0 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L2 seed=2 desc=v2 episodes=145 steps=2900 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=4 cand_bits=192 size_bound=6 fit_nrmse=0 select_nrmse=0 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=1 extrap=1 onestep=0 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L2 seed=3 desc=v2 episodes=145 steps=2900 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=4 cand_bits=192 size_bound=6 fit_nrmse=0 select_nrmse=0 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=1 extrap=2 onestep=0 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L2 seed=4 desc=v2 episodes=145 steps=2900 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=4 cand_bits=192 size_bound=6 fit_nrmse=0 select_nrmse=0 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=4 extrap=3 onestep=0 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L2 seed=5 desc=v2 episodes=145 steps=2900 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=4 cand_bits=192 size_bound=6 fit_nrmse=1 select_nrmse=1 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=5 extrap=3 onestep=0 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L3 seed=1 desc=v2 episodes=145 steps=2900 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=8 cand_bits=576 size_bound=10 fit_nrmse=0 select_nrmse=0 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=4 extrap=3 onestep=0 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L3 seed=2 desc=v2 episodes=145 steps=2900 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=8 cand_bits=576 size_bound=10 fit_nrmse=0 select_nrmse=0 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=1 extrap=1 onestep=0 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L3 seed=3 desc=v2 episodes=145 steps=2900 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=8 cand_bits=576 size_bound=10 fit_nrmse=0 select_nrmse=0 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=3 extrap=4 onestep=0 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L3 seed=4 desc=v2 episodes=145 steps=2900 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=8 cand_bits=576 size_bound=10 fit_nrmse=0 select_nrmse=0 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=4 extrap=3 onestep=0 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L3 seed=5 desc=v2 episodes=145 steps=2900 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=8 cand_bits=576 size_bound=10 fit_nrmse=0 select_nrmse=0 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=3 extrap=2 onestep=0 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L4 seed=1 desc=v2 episodes=145 steps=2900 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=4 cand_bits=192 size_bound=6 fit_nrmse=1 select_nrmse=2 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=23 extrap=28 onestep=2 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L4 seed=2 desc=v2 episodes=145 steps=2900 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=4 cand_bits=192 size_bound=6 fit_nrmse=1 select_nrmse=1 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=9 extrap=8 onestep=1 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L4 seed=3 desc=v2 episodes=145 steps=2900 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=4 cand_bits=192 size_bound=6 fit_nrmse=1 select_nrmse=1 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=8 extrap=6 onestep=1 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L4 seed=4 desc=v2 episodes=145 steps=2900 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=4 cand_bits=192 size_bound=6 fit_nrmse=1 select_nrmse=1 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=9 extrap=6 onestep=0 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L4 seed=5 desc=v2 episodes=145 steps=2900 fit=1320 select=440 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=4 cand_bits=192 size_bound=6 fit_nrmse=1 select_nrmse=1 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=15 extrap=6 onestep=1 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L5 seed=1 desc=v2 episodes=295 steps=5900 fit=3120 select=1040 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=4 cand_bits=192 size_bound=6 fit_nrmse=30248 select_nrmse=32375 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=3903 extrap=4164 onestep=497 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L5 seed=2 desc=v2 episodes=295 steps=5900 fit=3120 select=1040 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=4 cand_bits=192 size_bound=6 fit_nrmse=38039 select_nrmse=42991 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=10846 extrap=9891 onestep=1088 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L5 seed=3 desc=v2 episodes=295 steps=5900 fit=3120 select=1040 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=4 cand_bits=192 size_bound=6 fit_nrmse=32341 select_nrmse=34964 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=17789 extrap=18118 onestep=2176 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L5 seed=4 desc=v2 episodes=295 steps=5900 fit=3120 select=1040 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=4 cand_bits=192 size_bound=6 fit_nrmse=33607 select_nrmse=33926 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=9881 extrap=10085 onestep=1294 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L5 seed=5 desc=v2 episodes=295 steps=5900 fit=3120 select=1040 state=REPLICATED code=0 stall=0 refutations=0 attempts=1 cand_size=4 cand_bits=192 size_bound=6 fit_nrmse=31997 select_nrmse=32532 hidden_state=0 score=PASS score_code=0 mask=0x0 inbox=6186 extrap=6864 onestep=685 ref=0 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L6 seed=1 desc=v2 episodes=275 steps=5500 fit=3420 select=1040 state=CANDIDATE code=251 stall=250 refutations=3 attempts=3 cand_size=6 cand_bits=288 size_bound=9 fit_nrmse=10622 select_nrmse=10781 hidden_state=1 score=FAIL score_code=307 mask=0x183 inbox=83238 extrap=170182 onestep=0 ref=66472 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L6 seed=2 desc=v2 episodes=275 steps=5500 fit=3420 select=1040 state=CANDIDATE code=251 stall=250 refutations=3 attempts=3 cand_size=5 cand_bits=240 size_bound=9 fit_nrmse=6758 select_nrmse=6819 hidden_state=1 score=FAIL score_code=307 mask=0x181 inbox=67405 extrap=74489 onestep=0 ref=63828 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L6 seed=3 desc=v2 episodes=275 steps=5500 fit=3420 select=1040 state=CANDIDATE code=251 stall=250 refutations=3 attempts=3 cand_size=5 cand_bits=240 size_bound=9 fit_nrmse=8389 select_nrmse=8490 hidden_state=1 score=FAIL score_code=307 mask=0x181 inbox=60855 extrap=75487 onestep=0 ref=58964 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L6 seed=4 desc=v2 episodes=275 steps=5500 fit=3420 select=1040 state=CANDIDATE code=251 stall=250 refutations=3 attempts=3 cand_size=5 cand_bits=240 size_bound=9 fit_nrmse=6525 select_nrmse=6878 hidden_state=1 score=FAIL score_code=307 mask=0x181 inbox=54335 extrap=73008 onestep=0 ref=59366 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=L6 seed=5 desc=v2 episodes=275 steps=5500 fit=3420 select=1040 state=CANDIDATE code=251 stall=250 refutations=3 attempts=3 cand_size=5 cand_bits=240 size_bound=9 fit_nrmse=7792 select_nrmse=7646 hidden_state=1 score=FAIL score_code=307 mask=0x181 inbox=72836 extrap=69814 onestep=0 ref=68627 score_eps=20 law=0 checker_rc=0 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=null seed=1 desc=v2 episodes=110 steps=2200 fit=1320 select=440 state=OBSERVATION code=270 stall=211 refutations=0 attempts=1 cand_size=2 cand_bits=96 size_bound=6 fit_nrmse=1000700 select_nrmse=1000751 hidden_state=0 score=NOT_SCORED score_code=-1 mask=0x0 inbox=0 extrap=0 onestep=0 ref=0 score_eps=0 law=-1 checker_rc=270 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=null seed=2 desc=v2 episodes=110 steps=2200 fit=1320 select=440 state=OBSERVATION code=270 stall=211 refutations=0 attempts=1 cand_size=2 cand_bits=96 size_bound=6 fit_nrmse=1000709 select_nrmse=1001724 hidden_state=0 score=NOT_SCORED score_code=-1 mask=0x0 inbox=0 extrap=0 onestep=0 ref=0 score_eps=0 law=-1 checker_rc=270 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=null seed=3 desc=v2 episodes=110 steps=2200 fit=1320 select=440 state=OBSERVATION code=270 stall=211 refutations=0 attempts=1 cand_size=2 cand_bits=96 size_bound=6 fit_nrmse=999896 select_nrmse=1007210 hidden_state=0 score=NOT_SCORED score_code=-1 mask=0x0 inbox=0 extrap=0 onestep=0 ref=0 score_eps=0 law=-1 checker_rc=270 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=null seed=4 desc=v2 episodes=110 steps=2200 fit=1320 select=440 state=OBSERVATION code=270 stall=211 refutations=0 attempts=1 cand_size=2 cand_bits=96 size_bound=6 fit_nrmse=1000521 select_nrmse=1000384 hidden_state=0 score=NOT_SCORED score_code=-1 mask=0x0 inbox=0 extrap=0 onestep=0 ref=0 score_eps=0 law=-1 checker_rc=270 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 +PD0L level=null seed=5 desc=v2 episodes=110 steps=2200 fit=1320 select=440 state=OBSERVATION code=270 stall=211 refutations=0 attempts=1 cand_size=2 cand_bits=96 size_bound=6 fit_nrmse=1000243 select_nrmse=1000843 hidden_state=0 score=NOT_SCORED score_code=-1 mask=0x0 inbox=0 extrap=0 onestep=0 ref=0 score_eps=0 law=-1 checker_rc=270 oob=0 refused=0 budget_hits=0 propose_fail=0 trial_random=0 void_ep=0 void_batch=0 diff --git a/src/physics0/ladder/pd0_ladder.c b/src/physics0/ladder/pd0_ladder.c index 86c425dda..fa0fb0c69 100644 --- a/src/physics0/ladder/pd0_ladder.c +++ b/src/physics0/ladder/pd0_ladder.c @@ -262,6 +262,30 @@ static int try_t4(ctx *c, const pd0_falsifier *f, const uint8_t *entry_hash) c->have_fals = 1; c->fals = *f; memcpy(c->fals_hash, entry_hash, PD0_HASH); c->R->eps_micro = f->eps_micro; c->R->state = LS_HYPOTHESIS; set_code(c, 4, PD0V_OK); return 0; } +/* spec rev 7: a TRIAL or REP episode the world ends with OUT_OF_BOUNDS before the rollout horizon is void: + * not a failed prediction, never counted toward p or f, replaced from the same fresh stream. */ +static int ep_void(const ctx *c, const episode *e) +{ + if (!e->has_tag || (e->tag != TAG_TRIAL && e->tag != TAG_REP) || ep_ok_steps(c, e) >= c->P->rollout_steps) return 0; + for (uint32_t i = 0; i < e->n; i++) if (c->rec[e->first + i].kind == PD0_KIND_STEP && c->rec[e->first + i].status == PD0_ST_OUT_OF_BOUNDS) return 1; + return 0; +} +/* a void episode matches a preregistration on the requested reset and the applied steps it did run */ +static int ep_matches_prereg_prefix(const ctx *c, const episode *ep, const pd0_exp *e) +{ + const pd0_rec *r0 = &c->rec[ep->first]; if (r0->kind != PD0_KIND_RESET || r0->n_obs != e->n_obs) return 0; + if (!c->P->noisy) for (int j = 0; j < e->n_obs; j++) if (r0->after[j] != e->reset[j]) return 0; + uint8_t k = 0; + for (uint32_t i = 1; i < ep->n && k < e->n_steps; i++) { const pd0_rec *r = &c->rec[ep->first + i]; if (r->kind != PD0_KIND_STEP || r->status == PD0_ST_REFUSED_RANGE) continue; + if (r->channel != e->steps[k].channel || r->applied != e->steps[k].value) return 0; k++; } + return k > 0; +} +/* voids in a replication batch; more than 3 void the batch itself (spec rev 7) */ +static uint32_t batch_voids(const ctx *c, uint32_t b) +{ + uint32_t v = 0; for (uint32_t i = 0; i < c->nep; i++) { const episode *ep = &c->ep[i]; if (ep->has_tag && ep->tag == TAG_REP && ep->batch_id == c->bat[b].b.batch_id && ep_void(c, ep)) v++; } + return v; +} /* ---------- T5 ---------- */ static int try_t5(ctx *c, const pd0_exp *e, const uint8_t *entry_hash) { @@ -284,15 +308,20 @@ static int try_t6(ctx *c) { const pd0_ladder_params *P = c->P; uint8_t no = P->n_obs; uint32_t n = P->rollout_steps; /* match complete TRIAL episodes to preregistrations */ + uint32_t voided = 0; for (uint32_t i = 0; i < c->nep; i++) { episode *ep = &c->ep[i]; if (!ep->has_tag || ep->tag != TAG_TRIAL || ep->n == 0) continue; + if (ep_void(c, ep)) { for (uint32_t k = 0; k < c->npre; k++) if (c->pre[k].matched_ep == -1 && c->pre[k].entry < ep->first_entry && ep_matches_prereg_prefix(c, ep, &c->pre[k].e)) { c->pre[k].matched_ep = -2; break; } continue; } if (ep_ok_steps(c, ep) < n) continue; int found = 0; for (uint32_t k = 0; k < c->npre; k++) if (c->pre[k].entry < ep->first_entry && ep_matches_prereg(c, ep, &c->pre[k].e)) { c->pre[k].matched_ep = (int)i; found = 1; break; } if (!found) { set_code(c, 6, PD0V_T6_TRIAL_NOT_PREREGISTERED); return PD0V_T6_TRIAL_NOT_PREREGISTERED; } } - for (uint32_t k = 0; k < c->npre; k++) if (c->pre[k].matched_ep < 0) { set_code(c, 6, PD0V_T6_TRIAL_MISSING); return 0; } + for (uint32_t k = 0; k < c->npre; k++) if (c->pre[k].matched_ep == -2) voided++; /* void marks persist across passes */ + { uint32_t need = c->fals.min_trials > P->min_prereg ? c->fals.min_trials : P->min_prereg; + for (uint32_t k = 0; k < c->npre; k++) if (c->pre[k].matched_ep == -1) { set_code(c, 6, PD0V_T6_TRIAL_MISSING); return 0; } + if (c->npre - voided < need) { set_code(c, 6, PD0V_T6_TRIAL_MISSING); return 0; } } /* evaluate every trial against the committed prediction (hypothesis index 0) */ int64_t obs[PD0_MAX_STEPS * PD0_MAX_OBS], pk[PD0_MAX_STEPS * PD0_MAX_OBS]; - for (uint32_t k = 0; k < c->npre; k++) { prereg *p = &c->pre[k]; const episode *ep = &c->ep[p->matched_ep]; uint32_t m = 0; const pd0_rec *last = NULL, *worst_rec = NULL; int64_t wp = 0, wo = 0, wd = -1; + for (uint32_t k = 0; k < c->npre; k++) { prereg *p = &c->pre[k]; if (p->matched_ep < 0) continue; const episode *ep = &c->ep[p->matched_ep]; uint32_t m = 0; const pd0_rec *last = NULL, *worst_rec = NULL; int64_t wp = 0, wo = 0, wd = -1; for (uint32_t i = 1; i < ep->n && m < n; i++) { const pd0_rec *r = &c->rec[ep->first + i]; if (r->kind != PD0_KIND_STEP || !rec_has_outcome(r)) continue; for (int j = 0; j < no; j++) { obs[m * no + j] = r->after[j]; int64_t d = llabs(p->e.expected[0][m][j] - r->after[j]); if (d > wd) { wd = d; worst_rec = r; wp = p->e.expected[0][m][j]; wo = r->after[j]; } } m++; last = r; } @@ -308,12 +337,12 @@ static int try_t7(ctx *c) { const pd0_ladder_params *P = c->P; uint8_t no = P->n_obs; uint32_t n = P->rollout_steps; uint32_t ready = 0; int64_t pred[PD0_MAX_STEPS * PD0_MAX_OBS], obs[PD0_MAX_STEPS * PD0_MAX_OBS]; - for (uint32_t b = 0; b < c->nbat; b++) { uint32_t cnt = 0, planner = 0, random = 0; for (uint32_t i = 0; i < c->nep; i++) { const episode *ep = &c->ep[i]; if (ep->has_tag && ep->tag == TAG_REP && ep->batch_id == c->bat[b].b.batch_id && ep_ok_steps(c, ep) >= n) { cnt++; if (ep->origin == ORIGIN_PLANNER) planner++; else random++; } } + for (uint32_t b = 0; b < c->nbat; b++) { uint32_t cnt = 0, planner = 0, random = 0; if (batch_voids(c, b) > 3) continue; for (uint32_t i = 0; i < c->nep; i++) { const episode *ep = &c->ep[i]; if (ep->has_tag && ep->tag == TAG_REP && ep->batch_id == c->bat[b].b.batch_id && ep_ok_steps(c, ep) >= n) { cnt++; if (ep->origin == ORIGIN_PLANNER) planner++; else random++; } } if (cnt < P->min_batch_episodes || cnt < c->bat[b].b.n_episodes) continue; if (planner + 1 < random || random + 1 < planner) { set_code(c, 7, PD0V_T7_ORIGIN_IMBALANCE); return PD0V_T7_ORIGIN_IMBALANCE; } ready++; } if (ready < P->min_batches) { set_code(c, 7, ready || c->nbat ? PD0V_T7_BATCH_TOO_SMALL : PD0V_T7_TOO_FEW_BATCHES); return 0; } - for (uint32_t b = 0; b < c->nbat; b++) { nrmse_acc a; memset(&a, 0, sizeof a); const pd0_rec *first = NULL, *last = NULL; + for (uint32_t b = 0; b < c->nbat; b++) { nrmse_acc a; memset(&a, 0, sizeof a); const pd0_rec *first = NULL, *last = NULL; if (batch_voids(c, b) > 3) continue; for (uint32_t i = 0; i < c->nep; i++) { const episode *ep = &c->ep[i]; if (!(ep->has_tag && ep->tag == TAG_REP && ep->batch_id == c->bat[b].b.batch_id && ep_ok_steps(c, ep) >= n)) continue; /* freshness: schedule must not equal any other episode's schedule */ uint8_t h1[PD0_HASH], h2[PD0_HASH]; ep_schedule_hash(c, ep, (uint8_t)n, h1); @@ -418,6 +447,9 @@ int pd0_ladder_check(const uint8_t *ledger, size_t len, const pd0_ladder_params if (!rc && R->state == LS_INTERVENED) { int r2 = try_t7(c); if (r2) rc = r2; } compute_domain(c); R->confidence_ppm = pd0_confidence_ppm(R->p, R->f); + R->n_void_episodes = 0; R->n_void_batches = 0; /* spec rev 7 diagnostics, counted once */ + for (uint32_t i = 0; i < c->nep; i++) if (ep_void(c, &c->ep[i])) R->n_void_episodes++; + for (uint32_t b = 0; b < c->nbat; b++) if (batch_voids(c, b) > 3) R->n_void_batches++; if (rc) R->code = rc; free(c->rec); free(c); return rc; diff --git a/src/physics0/ladder/pd0_ladder.h b/src/physics0/ladder/pd0_ladder.h index fefb8e950..db8a40c2a 100644 --- a/src/physics0/ladder/pd0_ladder.h +++ b/src/physics0/ladder/pd0_ladder.h @@ -30,6 +30,7 @@ typedef struct { uint8_t chain_root[PD0_HASH]; uint64_t n_entries, n_records; int64_t last_nrmse_micro; /* diagnostics */ + uint32_t n_void_episodes, n_void_batches; /* spec rev 7: void TRIAL/REP episodes and batches (never in p or f) */ double last_r, last_p; } pd0_ladder_report; diff --git a/tests/physics0/learner/pd0_harness.c b/tests/physics0/learner/pd0_harness.c index c760981e7..547b29e0b 100644 --- a/tests/physics0/learner/pd0_harness.c +++ b/tests/physics0/learner/pd0_harness.c @@ -63,13 +63,13 @@ typedef struct { pd0_ladder_params P; uint32_t next_episode, n_episodes, steps_used, episodes_used; /* per episode bookkeeping: tag, schedule hash, record range */ - uint8_t ep_tag[MAX_EP]; uint8_t ep_hash[MAX_EP][PD0_HASH]; uint32_t ep_first[MAX_EP], ep_n[MAX_EP]; int ep_ok[MAX_EP]; + uint8_t ep_tag[MAX_EP]; uint8_t ep_hash[MAX_EP][PD0_HASH]; uint32_t ep_first[MAX_EP], ep_n[MAX_EP]; int ep_ok[MAX_EP]; int ep_void[MAX_EP]; /* spec rev 7: TRIAL/REP ended OUT_OF_BOUNDS before the horizon */ pd0_rec *recs; uint32_t nrec; pd0_transition *fit; uint32_t nfit; /* truth */ pd0_rel truth_rel; int truth_size, truth_n_latent; int have_truth; /* counters for the report */ - uint32_t n_oob, n_refused, n_propose_fail, n_trial_random, n_attempts, n_budget; + uint32_t n_oob, n_refused, n_propose_fail, n_trial_random, n_attempts, n_budget, n_void_ep, n_void_batch; } run; static void append(run *R, uint8_t kind, const uint8_t *p, uint32_t n) { R->llen = pd0_ledg_append(R->ledger, R->llen, LCAP, kind, p, n, R->last); } @@ -88,7 +88,7 @@ static int episode(run *R, uint8_t t, uint32_t batch, uint8_t origin, const int6 if (r.status == PD0_ST_BUDGET_EXHAUSTED) { R->n_budget++; return -1; } if (r.episode != ep) { fprintf(stderr, "harness: episode numbering drift (%u vs %u)\n", r.episode, ep); exit(3); } R->next_episode = ep + 1; R->episodes_used++; - R->ep_tag[slot] = t; R->ep_first[slot] = R->nrec; R->ep_n[slot] = 0; R->ep_ok[slot] = 0; R->n_episodes++; + R->ep_tag[slot] = t; R->ep_first[slot] = R->nrec; R->ep_n[slot] = 0; R->ep_ok[slot] = 0; R->ep_void[slot] = 0; R->n_episodes++; append(R, LEDG_OBS, resp, (uint32_t)rn); R->recs[R->nrec++] = r; R->ep_n[slot]++; if (t == TAG_FIT || t == TAG_SELECT) pd0_learner_observe(R->L, &r, t); if (r.status != PD0_ST_OK) { R->n_refused++; memset(R->ep_hash[slot], 0, PD0_HASH); return (int)slot; } @@ -103,7 +103,7 @@ static int episode(run *R, uint8_t t, uint32_t batch, uint8_t origin, const int6 R->steps_used++; if (r.status == PD0_ST_OK || r.status == PD0_ST_EPISODE_END) { if (n_ok < PD0_MAX_STEPS) { applied[n_ok].channel = r.channel; applied[n_ok].value = r.applied; } n_ok++; if (t == TAG_FIT && R->nfit < 65536) { pd0_transition *f = &R->fit[R->nfit++]; memcpy(f->before, r.before, sizeof f->before); f->chan = r.channel; f->value = r.applied; memcpy(f->after, r.after, sizeof f->after); } } - if (r.status == PD0_ST_OUT_OF_BOUNDS) { R->n_oob++; break; } + if (r.status == PD0_ST_OUT_OF_BOUNDS) { R->n_oob++; if (t == TAG_TRIAL || t == TAG_REP) { R->ep_void[slot] = 1; R->n_void_ep++; } break; } if (r.status == PD0_ST_REFUSED_RANGE) { R->n_refused++; continue; } if (r.status == PD0_ST_EPISODE_END) break; } @@ -179,14 +179,15 @@ int main(int argc, char **argv) append(&R, LEDG_FALSIFIER, pl, (uint32_t)pd0_fals_write(&f, pl)); checker_rc = pd0_ladder_check(R.ledger, R.llen, &R.P, &rep); if (rep.state < LS_HYPOTHESIS) break; /* no admissible candidate: no trials */ n_forb = 0; for (uint32_t s = 0; s < R.n_episodes && n_forb < PD0L_MAX_FORBID; s++) memcpy(forbidden[n_forb++], R.ep_hash[s], PD0_HASH); - for (int t = 0; t < 5; t++) { static pd0_exp x; memset(&x, 0, sizeof x); + for (int t = 0, voids = 0; t < 5 + voids; t++) { static pd0_exp x; memset(&x, 0, sizeof x); int64_t div = pd0_learner_propose(R.L, hyps, n_hyp, R.seed * 1000 + a * 10 + (uint64_t)t, 256, (const uint8_t (*)[PD0_HASH])forbidden, n_forb, &x); if (div < 0) { R.n_propose_fail++; R.n_trial_random++; x.n_obs = d->n_obs; x.n_hyp = (uint8_t)n_hyp; x.n_steps = PD0_MAX_STEPS; pd0_learner_random_schedule(d, R.seed * 7919 + a, "trial", (uint32_t)t, x.reset, x.steps, PD0_MAX_STEPS); for (int h = 0; h < n_hyp; h++) { int64_t tmp[PD0_MAX_STEPS * PD0_MAX_OBS]; pd0_learner_rollout(&hyps[h], x.reset, x.steps, PD0_MAX_STEPS, tmp); for (int s = 0; s < PD0_MAX_STEPS; s++) for (int j = 0; j < d->n_obs; j++) x.expected[h][s][j] = tmp[s * d->n_obs + j]; } x.divergence_micro = 0; } size_t xn = pd0_exp_write(&x, pl, sizeof pl); append(&R, LEDG_PREREG, pl, (uint32_t)xn); - int slot = episode(&R, TAG_TRIAL, 0, 0, x.reset, x.steps, PD0_MAX_STEPS); if (slot >= 0 && n_forb < PD0L_MAX_FORBID) memcpy(forbidden[n_forb++], R.ep_hash[slot], PD0_HASH); } + int slot = episode(&R, TAG_TRIAL, 0, 0, x.reset, x.steps, PD0_MAX_STEPS); if (slot >= 0 && n_forb < PD0L_MAX_FORBID) memcpy(forbidden[n_forb++], R.ep_hash[slot], PD0_HASH); + if (slot >= 0 && R.ep_void[slot] && voids < 3) voids++; } checker_rc = pd0_ladder_check(R.ledger, R.llen, &R.P, &rep); if (rep.state >= LS_INTERVENED) break; if (rep.code == PD0V_T6_TRIAL_FAILED) { /* refuted: the trial records are FIT from now on */ @@ -196,11 +197,15 @@ int main(int argc, char **argv) } /* 3. replication: three batches of ten episodes, planner and random halves */ if (rep.state >= LS_INTERVENED) { - for (uint32_t bt = 0; bt < 3; bt++) { pd0_batch bb = { bt + 1, R.seed * 100 + bt + 1, 10 }; append(&R, LEDG_BATCH, pl, (uint32_t)pd0_batch_write(&bb, pl)); - for (uint32_t e = 0; e < 10; e++) { uint8_t origin = (e & 1) ? ORIGIN_RANDOM : ORIGIN_PLANNER; static pd0_exp x; + for (uint32_t bt = 0; bt < 3; bt++) for (uint32_t redraw = 0; redraw <= 3; redraw++) { pd0_batch bb = { bt + 1 + 10 * redraw, R.seed * 100 + bt + 1 + 50 * redraw, 10 }; append(&R, LEDG_BATCH, pl, (uint32_t)pd0_batch_write(&bb, pl)); + uint32_t good = 0, voids = 0; + for (uint32_t e = 0; good < 10 && voids <= 3; e++) { uint8_t origin = (good & 1) ? ORIGIN_RANDOM : ORIGIN_PLANNER; static pd0_exp x; if (origin == ORIGIN_PLANNER && pd0_learner_propose(R.L, hyps, n_hyp, bb.stream_seed * 31 + e, 128, (const uint8_t (*)[PD0_HASH])forbidden, n_forb, &x) >= 0) { memcpy(reset, x.reset, sizeof reset); memcpy(steps, x.steps, sizeof steps); } else { if (origin == ORIGIN_PLANNER) R.n_propose_fail++; pd0_learner_random_schedule(d, bb.stream_seed, "rep", e, reset, steps, PD0_MAX_STEPS); } - int slot = episode(&R, TAG_REP, bb.batch_id, origin, reset, steps, PD0_MAX_STEPS); if (slot >= 0 && n_forb < PD0L_MAX_FORBID) memcpy(forbidden[n_forb++], R.ep_hash[slot], PD0_HASH); } } + int slot = episode(&R, TAG_REP, bb.batch_id, origin, reset, steps, PD0_MAX_STEPS); if (slot >= 0 && n_forb < PD0L_MAX_FORBID) memcpy(forbidden[n_forb++], R.ep_hash[slot], PD0_HASH); + if (slot >= 0 && R.ep_void[slot]) voids++; else good++; } + if (voids <= 3) break; /* batch complete */ + R.n_void_batch++; } checker_rc = pd0_ladder_check(R.ledger, R.llen, &R.P, &rep); } /* 4. law record + independent re-verification */ @@ -228,12 +233,12 @@ int main(int argc, char **argv) printf("PD0L level=%s seed=%llu desc=v%d episodes=%u steps=%u fit=%u select=%u state=%s code=%d stall=%d refutations=%u attempts=%u " "cand_size=%u cand_bits=%u size_bound=%u fit_nrmse=%lld select_nrmse=%lld hidden_state=%d " "score=%s score_code=%d mask=0x%x inbox=%lld extrap=%lld onestep=%lld ref=%lld score_eps=%d law=%d checker_rc=%d " - "oob=%u refused=%u budget_hits=%u propose_fail=%u trial_random=%u\n", + "oob=%u refused=%u budget_hits=%u propose_fail=%u trial_random=%u void_ep=%u void_batch=%u\n", lvl_name(R.level), (unsigned long long)R.seed, R.D.version, R.n_episodes, R.steps_used, pd0_learner_n_transitions(R.L, TAG_FIT), pd0_learner_n_transitions(R.L, TAG_SELECT), pd0_ladder_state_name(rep.state), rep.code, rep.stall_code, rep.n_refutations, R.n_attempts, csize, cbits, R.P.size_bound, (long long)(best ? best->fit_nrmse_micro : -1), (long long)(best ? best->select_nrmse_micro : -1), hidden, !scored ? "NO_CANDIDATE" : S.code == 0 ? "PASS" : S.code < 0 ? "NOT_SCORED" : "FAIL", S.code, S.fail_mask, (long long)S.inbox_nrmse, (long long)S.extrap_nrmse, (long long)S.onestep_nrmse, (long long)S.ref_nrmse, n_score_eps, law_rc, checker_rc, - R.n_oob, R.n_refused, R.n_budget, R.n_propose_fail, R.n_trial_random); + R.n_oob, R.n_refused, R.n_budget, R.n_propose_fail, R.n_trial_random, R.n_void_ep, R.n_void_batch); fprintf(R.truth.wr, "quit\n"); fflush(R.truth.wr); fclose(R.world.wr); fclose(R.truth.wr); waitpid(R.world.pid, NULL, 0); waitpid(R.truth.pid, NULL, 0); pd0_learner_free(R.L); free(R.ledger); free(R.recs); free(R.fit); return 0; diff --git a/tests/physics0/verify/bundle.h b/tests/physics0/verify/bundle.h index 8ec0f99b8..cebe63369 100644 --- a/tests/physics0/verify/bundle.h +++ b/tests/physics0/verify/bundle.h @@ -13,13 +13,14 @@ typedef struct { int end_last; /* rev 6 (b): the last step of every episode is EPISODE_END */ int quiet_trials; /* rev 6 (a): trials start near rest with tiny pushes */ int64_t obs_noise; /* observation noise sd (micro) on every recorded value */ + int void_rep, void_rep_four, void_trial; /* rev 7: void episodes with replacements */ } bundle_opts; typedef struct { uint8_t *buf; size_t len; uint8_t last[PD0_HASH]; uint8_t rec_prev[PD0_HASH]; uint64_t seq; uint32_t episode; truth_world w; pd0_ladder_params P; pd0_rng g; pd0_rec *recs; uint32_t nrec; - int end_last; int64_t obs_noise; pd0_rng nz; + int end_last; int64_t obs_noise; pd0_rng nz; uint32_t oob_at; /* oob_at > 0: step index at which the world reports OUT_OF_BOUNDS */ } bundle; static inline void b_append(bundle *b, uint8_t kind, const uint8_t *p, uint32_t n) { b->len = pd0_ledg_append(b->buf, b->len, LCAP, kind, p, n, b->last); } static inline void b_record(bundle *b, pd0_rec *r) @@ -37,6 +38,7 @@ static inline uint32_t b_episode(bundle *b, const int64_t *reset, const pd0_step r.kind = PD0_KIND_RESET; r.channel = PD0_CHAN_NONE; r.episode = ep; for (int j = 0; j < 2; j++) { st[j] = reset[j]; ob[j] = b_obs(b, reset[j]); r.before[j] = r.after[j] = ob[j]; } b_record(b, &r); for (uint32_t s = 0; s < n; s++) { memset(&r, 0, sizeof r); r.kind = PD0_KIND_STEP; r.episode = ep; r.step_in_episode = s + 1; r.time_micro = (int64_t)(s + 1) * b->P.dt_micro; r.channel = steps[s].channel; r.requested = r.applied = steps[s].value; r.before[0] = b_obs(b, st[0]); r.before[1] = b_obs(b, st[1]); /* fresh observation of the state, as pd0_world_step does */ truth_step(w, st, steps[s].value, nx); memcpy(st, nx, sizeof st); ob[0] = b_obs(b, st[0]); ob[1] = b_obs(b, st[1]); r.after[0] = ob[0]; r.after[1] = ob[1]; + if (b->oob_at && s + 1 == b->oob_at) { r.status = PD0_ST_OUT_OF_BOUNDS; r.after[0] = r.before[0]; r.after[1] = r.before[1]; b_record(b, &r); break; } if (b->end_last && s + 1 == n) r.status = PD0_ST_EPISODE_END; b_record(b, &r); } return ep; } @@ -78,7 +80,8 @@ static inline int b_build(bundle *b, const bundle_opts *o, pd0_ladder_report *R) b_append(b, LEDG_FALSIFIER, pl, (uint32_t)pd0_fals_write(&f, pl)); /* 6. five preregistered experiments, each followed by its trial */ pd0_exp *x = calloc(1, sizeof *x); uint8_t *xb = malloc(16384); - for (int t = 0; t < 5; t++) { memset(x, 0, sizeof *x); x->n_obs = 2; x->n_hyp = 2; x->n_steps = 20; + int n_trials = o->void_trial ? 6 : 5; + for (int t = 0; t < n_trials; t++) { memset(x, 0, sizeof *x); x->n_obs = 2; x->n_hyp = 2; x->n_steps = 20; b->oob_at = (o->void_trial && t == 2) ? 5 : 0; if (o->reuse_schedule && t == 0) { const pd0_rec *r0 = &b->recs[0]; x->reset[0] = r0->after[0]; x->reset[1] = r0->after[1]; for (int s = 0; s < 20; s++) { x->steps[s].channel = b->recs[1 + s].channel; x->steps[s].value = b->recs[1 + s].applied; } } else if (o->quiet_trials) { for (int j = 0; j < 2; j++) x->reset[j] = draw_const(&b->g, -50000, 50000); for (int s = 0; s < 20; s++) { x->steps[s].channel = 0; x->steps[s].value = draw_const(&b->g, -50000, 50000); } } else b_random_schedule(b, x->reset, x->steps, 20); @@ -87,11 +90,14 @@ static inline int b_build(bundle *b, const bundle_opts *o, pd0_ladder_report *R) if (!(o->trial_without_prereg && t == 4)) b_append(b, LEDG_PREREG, xb, (uint32_t)xn); if (o->stop_after_prereg) continue; b_tag(b, b->episode, TAG_TRIAL, 0, 0); b_episode(b, x->reset, x->steps, 20, w); } - free(x); free(xb); + free(x); free(xb); b->oob_at = 0; if (o->stop_after_prereg || o->stop_after_trials) goto done; /* 7. three replication batches of 10 episodes */ - for (uint32_t bt = 0; bt < 3; bt++) { pd0_batch bb = { bt + 1, o->batch_seed_reuse ? 1000u : 1000u + bt, 10 }; b_append(b, LEDG_BATCH, pl, (uint32_t)pd0_batch_write(&bb, pl)); - for (int e = 0; e < 10; e++) { b_tag(b, b->episode, TAG_REP, bt + 1, o->all_planner ? ORIGIN_PLANNER : (e & 1) ? ORIGIN_RANDOM : ORIGIN_PLANNER); b_random_schedule(b, reset, steps, 20); b_episode(b, reset, steps, 20, w); } } + uint32_t n_batches = o->void_rep_four ? 4 : 3; + for (uint32_t bt = 0; bt < n_batches; bt++) { pd0_batch bb = { bt + 1, o->batch_seed_reuse ? 1000u : 1000u + bt, 10 }; b_append(b, LEDG_BATCH, pl, (uint32_t)pd0_batch_write(&bb, pl)); + int n_void = (bt == 0) ? (o->void_rep ? 1 : o->void_rep_four ? 4 : 0) : 0; int n_run = 10 + n_void; if (o->void_rep_four && bt == 0) n_run = n_void; /* a voided batch: nothing but voids */ + for (int e = 0, good = 0; e < n_run; e++) { int is_void = e < n_void; b->oob_at = is_void ? 5 : 0; int idx = is_void ? e : good; b_tag(b, b->episode, TAG_REP, bt + 1, o->all_planner ? ORIGIN_PLANNER : (idx & 1) ? ORIGIN_RANDOM : ORIGIN_PLANNER); b_random_schedule(b, reset, steps, 20); b_episode(b, reset, steps, 20, w); if (!is_void) good++; } + b->oob_at = 0; } if (o->demote_after_law) { null_w.k = w->k * 2; pd0_batch bb = { 9, 7777, 1 }; b_append(b, LEDG_BATCH, pl, (uint32_t)pd0_batch_write(&bb, pl)); b_tag(b, b->episode, TAG_REP, 9, ORIGIN_RANDOM); b_random_schedule(b, reset, steps, 20); b_episode(b, reset, steps, 20, &null_w); } done: return pd0_ladder_check(b->buf, b->len, &b->P, R); diff --git a/tests/physics0/verify/test_pd0_ladder.c b/tests/physics0/verify/test_pd0_ladder.c index 51e578d93..6f651d74c 100644 --- a/tests/physics0/verify/test_pd0_ladder.c +++ b/tests/physics0/verify/test_pd0_ladder.c @@ -65,6 +65,10 @@ int main(void) CHECK(pd0_nrmse_micro(pred, obs, 3, 2) > 10000000); /* within-trial spread 0.0008: error reads as 12 sd */ CHECK(pd0_nrmse_pooled_micro(pred, obs, 3, 2, sd) == 10000); /* pooled sd 1.0: the same error is 0.01 */ int64_t sd0[2] = { 0, 0 }; CHECK(pd0_nrmse_pooled_micro(pred, obs, 3, 2, sd0) == 10000); } /* sd 0 falls back to the RMSE */ + /* spec rev 7: void TRIAL/REP episodes (OUT_OF_BOUNDS before the horizon) are replaced and never count toward p or f */ + memset(&o, 0, sizeof o); o.void_rep = 1; rc = run(1, 1, &o, &R, law, &ln, "ladder-void-rep"); CHECK(rc == 0 && R.state == LS_REPLICATED && R.n_void_episodes == 1 && R.n_void_batches == 0 && R.p == 35 && R.f == 0); + memset(&o, 0, sizeof o); o.void_rep_four = 1; rc = run(1, 1, &o, &R, law, &ln, "ladder-void-batch"); CHECK(rc == 0 && R.state == LS_REPLICATED && R.n_void_batches == 1 && R.n_void_episodes == 4 && R.p == 35 && R.f == 0); + memset(&o, 0, sizeof o); o.void_trial = 1; rc = run(1, 1, &o, &R, law, &ln, "ladder-void-trial"); CHECK(rc == 0 && R.state == LS_REPLICATED && R.n_void_episodes == 1 && R.p == 35 && R.f == 0 && R.n_experiments == 8); memset(&o, 0, sizeof o); o.demote_after_law = 1; rc = run(1, 1, &o, &R, law, &ln, "ladder-demotion"); CHECK(rc == 0 && R.demoted && R.state == LS_HYPOTHESIS && R.n_refutations == 1); { bundle b; b_init(&b, 1, 1); bundle_opts h; memset(&h, 0, sizeof h); pd0_ladder_report Rh; b_build(&b, &h, &Rh); size_t n = pd0_ladder_emit_law(&Rh, &b.P, law2, sizeof law2); b_free(&b); CHECK(pd0_ladder_verify_law(&R, &P, law2, n) == PD0V_LAW_DEMOTED); }