Files
LithosAnanake/experiments/std79-doe/std79-doe.fth
T
Robert Allan JamesandClaude Sonnet 5 66ba21adb4
Build / build-amd64-iso (push) Waiting to run
Build / build-aarch64-iso (push) Waiting to run
Build / build-riscv64-img (push) Waiting to run
Log fleet_k_q48/fleet_conserved; K holds exactly, 775/775 ticks (FABRIC-3.md §XVIII)
doe_log.c's per-heartbeat-tick CSV gains two columns: fleet_k_q48
(vm_physics_fleet_heat_sum() over ALL live VMs -- the genuine fleet-wide
conservation invariant K, not reconstructable from the 3 named-Tripod-
member heat columns already logged, which omit every identity VM's own
heat) and fleet_conserved (vm_physics_conserved() as 0/1). Requested
explicitly after the first heartbeat-telemetry analysis pass
(analysis-20260912/) omitted K entirely.

Kernel rebuilt on all three architectures, full 3x9x3 campaign rerun
(results-20260912-with-k/). K = 1.0000000000 (Q48.16 raw 65536) on every
one of 775 heartbeat-tick observations, sd(K) = 0, 100% fleet_conserved,
across amd64/aarch64/riscv64, nine identities, three replicates -- zero
deviation. Also a free regression check on both recent Stadium fixes
(§XVI/§XVII): neither disturbed the reservoir-transfer accounting K
depends on.

Found and fixed a tooling wrinkle along the way: fleet_conserved, being
the CSV row's very last field with nothing after it to bound a regex
match, can have a resumed trial digit merge into it with zero separator
on the wire -- combine.py now derives it from fleet_k_q48 directly (same
epsilon vm_physics_conserved() uses) instead of trusting the raw field.
fleet_k_q48 itself is unaffected either way.

Full analysis, discussion, and light/dark SVG->PDF figures written up as
a proper LaTeX report (report-20260912/report/std79_doe_report.pdf),
following experiments/bare_metal/analysis/report/bare_metal_doe_report.tex's
established style -- supersedes analysis-20260912/'s markdown-only first
pass as the primary deliverable for this dataset (kept, not discarded).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXieurDfDSsDFdnSyusuWo
2026-09-12 13:25:09 -04:00

199 lines
7.5 KiB
Forth

( std79-doe.4th - 3(arch, fixed per boot) x 9(identity) x 3(rep) )
( randomized full-factorial DoE. Same 24-case content as )
( std79-exerciser.fth, driven via VM-EXEC into each identity's own )
( live VM (all 9 pre-attached before this runs); "zuse" dispatches )
( into "Hera" herself since her power is a session flag on Hera, )
( not a separate registered VM. Fisher-Yates shuffle matches )
( doe.4th's own algorithm/style; seed fixed for cross-architecture )
( reproducibility (same permutation applied on every arch). )
9 CONSTANT N-ID
3 CONSTANT N-REPS
27 CONSTANT N-RUNS
24 CONSTANT N-TESTS
: ID-NAME ( idx -- c-addr u )
CASE
0 OF S" Hera" ENDOF
1 OF S" rajames" ENDOF
2 OF S" 00" ENDOF
3 OF S" 01" ENDOF
4 OF S" 02" ENDOF
5 OF S" 03" ENDOF
6 OF S" 04" ENDOF
7 OF S" 05" ENDOF
8 OF S" 06" ENDOF
ENDCASE ;
: ID-LABEL ( idx -- c-addr u )
CASE
0 OF S" zuse" ENDOF
1 OF S" rajames" ENDOF
2 OF S" 00" ENDOF
3 OF S" 01" ENDOF
4 OF S" 02" ENDOF
5 OF S" 03" ENDOF
6 OF S" 04" ENDOF
7 OF S" 05" ENDOF
8 OF S" 06" ENDOF
ENDCASE ;
( idx 0 (zuse) runs natively on Hera -- never via VM-EXEC targeting )
( "Hera" herself: VM-EXEC's own vm_state_push/pop only saves )
( rsp/exit_colon/ecw_nesting, not input_buffer/input_pos, so a )
( self-targeting call while THIS capsule's own vm_interpret call is )
( still mid-line would risk clobbering the outer parse -- the exact )
( class of bug the idle-tick reentrancy guards (repl.c) exist for, )
( just not covered by VM-EXEC's own narrower state stack. Sidestepped )
( entirely by never dispatching a string back into the caller's own )
( VM; the same 24 cases are just directly-compiled code below. )
: RUN-TEST-NATIVE ( n -- )
CASE
0 OF 7 3 /MOD SWAP . . ENDOF
1 OF -7 3 /MOD SWAP . . ENDOF
2 OF 7 -3 /MOD SWAP . . ENDOF
3 OF -7 -3 /MOD SWAP . . ENDOF
4 OF 2147483647 1 + . ENDOF
5 OF -2147483648 NEGATE . ENDOF
6 OF -2147483648 ABS . ENDOF
7 OF -1 1 RSHIFT . ENDOF
8 OF -8 2 RSHIFT . ENDOF
9 OF 1 31 LSHIFT . ENDOF
10 OF -1 0 < . ENDOF
11 OF -1 0 U< . ENDOF
12 OF 123 456 M* SWAP D. ENDOF
13 OF -123 456 M* SWAP D. ENDOF
14 OF 100000 S>D SWAP 7 M/MOD . . ENDOF
15 OF 7 11 3 */ . ENDOF
16 OF 7 11 3 */MOD SWAP . . ENDOF
17 OF -5 S>D SWAP D. ENDOF
18 OF -5 S>D 3 S>D D+ SWAP D. ENDOF
19 OF -5 S>D DNEGATE SWAP D. ENDOF
20 OF -5 3 MIN . -5 3 MAX . ENDOF
21 OF 5 0 10 WITHIN . ENDOF
22 OF -1 0 AND . -1 0 OR . 5 3 XOR . ENDOF
23 OF -2147483648 2/ . ENDOF
ENDCASE ;
: TEST-CMD ( n -- c-addr u )
CASE
0 OF S" 7 3 /MOD SWAP . ." ENDOF
1 OF S" -7 3 /MOD SWAP . ." ENDOF
2 OF S" 7 -3 /MOD SWAP . ." ENDOF
3 OF S" -7 -3 /MOD SWAP . ." ENDOF
4 OF S" 2147483647 1 + ." ENDOF
5 OF S" -2147483648 NEGATE ." ENDOF
6 OF S" -2147483648 ABS ." ENDOF
7 OF S" -1 1 RSHIFT ." ENDOF
8 OF S" -8 2 RSHIFT ." ENDOF
9 OF S" 1 31 LSHIFT ." ENDOF
10 OF S" -1 0 < ." ENDOF
11 OF S" -1 0 U< ." ENDOF
12 OF S" 123 456 M* SWAP D." ENDOF
13 OF S" -123 456 M* SWAP D." ENDOF
14 OF S" 100000 S>D SWAP 7 M/MOD . ." ENDOF
15 OF S" 7 11 3 */ ." ENDOF
16 OF S" 7 11 3 */MOD SWAP . ." ENDOF
17 OF S" -5 S>D SWAP D." ENDOF
18 OF S" -5 S>D 3 S>D D+ SWAP D." ENDOF
19 OF S" -5 S>D DNEGATE SWAP D." ENDOF
20 OF S" -5 3 MIN . -5 3 MAX ." ENDOF
21 OF S" 5 0 10 WITHIN ." ENDOF
22 OF S" -1 0 AND . -1 0 OR . 5 3 XOR ." ENDOF
23 OF S" -2147483648 2/ ." ENDOF
ENDCASE ;
CREATE RUN-MATRIX N-RUNS CELLS ALLOT
: MATRIX! ( val idx -- ) CELLS RUN-MATRIX + ! ;
: MATRIX@ ( idx -- val ) CELLS RUN-MATRIX + @ ;
VARIABLE SW-I VARIABLE SW-J VARIABLE SW-VI VARIABLE SW-VJ
: SWAP-MTX ( i j -- )
SW-J ! SW-I !
SW-I @ MATRIX@ SW-VI !
SW-J @ MATRIX@ SW-VJ !
SW-VJ @ SW-I @ MATRIX!
SW-VI @ SW-J @ MATRIX! ;
: INIT-MATRIX ( -- ) N-RUNS 0 DO I I MATRIX! LOOP ;
: SHUFFLE-MATRIX ( -- )
N-RUNS 1 - 0 DO
I N-RUNS 1 - RANDOM
I SWAP-MTX
LOOP ;
VARIABLE CURR-ID
VARIABLE CURR-REP
( Boot-batching support, added 2026-09-11 (FABRIC-3.md SXV). Originally a )
( workaround for a real aarch64 Stadium/COOL scaling bug -- root-caused and )
( fixed 2026-09-11/12 (FABRIC-3.md SXVI, src/starkernel/vm/stadium.c): )
( stadium_grant_quota() halves the granting VM's own free list on every )
( birth with no floor, and stadium_admit()'s eviction fallback used to scan )
( the ENTIRE global cell array (stadium_ncells, in the hundreds of )
( thousands on aarch64's larger RAM-scaled Stadium) filtered by owner, )
( instead of walking just the calling VM's own resident cells as its own )
( doc comment already claimed -- fixed by threading a real per-VM resident )
( list. A single boot with all 9 identities simultaneously live now works )
( cleanly on all three architectures (see results-20260911-stadium-fix/), )
( so ACTIVE-LO/ACTIVE-HI is no longer load-bearing -- kept only as general )
( flexibility: every boot shares the SAME seed so INIT-MATRIX/SHUFFLE-MATRIX )
( produce the identical master 27-slot permutation regardless of how many )
( boots this runs across; only the ACTIVE-LO/ACTIVE-HI filter differs if )
( split. The recorded run_id is always I itself (the slot's true position )
( in the master shuffle), never a separately-incremented counter, so row )
( order stays meaningful and comparable across any number of boots. )
VARIABLE ACTIVE-LO
VARIABLE ACTIVE-HI
: ACTIVE? ( idx -- flag )
DUP ACTIVE-LO @ >=
SWAP ACTIVE-HI @ <=
AND ;
: RUN-TEST ( n -- )
CURR-ID @ 0= IF
RUN-TEST-NATIVE
ELSE
TEST-CMD CURR-ID @ ID-NAME VM-EXEC
THEN ;
VARIABLE CURR-RUN-ID
: RUN-TRIAL ( id-idx rep run-id -- )
CURR-RUN-ID !
CURR-REP ! CURR-ID !
." DOE-RUN," CURR-RUN-ID @ . ." ," CURR-ID @ . ." ,"
CURR-ID @ ID-LABEL TYPE ." ," CURR-REP @ . CR
N-TESTS 0 DO I RUN-TEST LOOP ;
( HB-ON/HB-OFF (doe_log.c) bracket the trial loop below so the per-tick )
( DoE-tagged physics/heartbeat CSV -- 20 columns: tick_number, elapsed_ns, )
( hot_word_count, avg_word_heat_q48, window_width, apic_ticks, )
( hera/hermes/artemis heat_q48, fleet_k_q48, fleet_conserved, etc. -- )
( covers exactly this run's window, not the whole boot. )
( g_doe_log_enabled defaults OFF (doe_log.c), so )
( every prior campaign run's extracted CSV (scripts/extract_doe.sh, run )
( automatically at the end of every `make qemu`) was silently empty; )
( without this bracket there is no per-tick data to analyze the 3x9x3 )
( factorial's physics behavior by, only the DOE-RUN/DOE-HEADER correctness )
( lines already printed below. NOTE: this comment deliberately never )
( spells out the literal tag string doe_log.c prefixes each row with -- )
( writing it here once already corrupted a real extracted CSV live )
( 2026-09-12, since scripts/extract_doe.sh greps the log for exactly that )
( substring and can't tell a real telemetry row from this comment's own )
( compile-time echo saying the same characters. )
: EXEC-STD79-DOE ( seed lo hi -- )
ACTIVE-HI ! ACTIVE-LO !
SEED
INIT-MATRIX SHUFFLE-MATRIX
." DOE-HEADER,run_id,id_idx,id_label,rep" CR
HB-ON
N-RUNS 0 DO
I MATRIX@
DUP N-REPS /
DUP ACTIVE? IF
SWAP N-REPS MOD I RUN-TRIAL
ELSE
DROP DROP
THEN
LOOP
HB-OFF
." STD79-DOE: complete" CR ;