interplane.Get Omega
Read in your language

spark-rsi-mv

Native Rust recursive self-improvement engine with paired bootstrap evaluation and cryptographic ledger

Brought by drakestapleton

branch main Branches Tags History

spark-rsi-mv / tests / reuse-eval / stats-e2e.om

886 lines · 12569 bytes Raw Blame History
1note units: stats
2note SPDX-License-Identifier: Apache-2.0
3note stats-e2e: synthetic FINAL-shaped inputs (G groups of 2 sessions, 8 requests per group:
4note BEGIN, QUERY cold, SET, QUERY warm per session; 3 reps; 8 arms) written to a temporary
5note directory, then strun, then the summary words are checked. Costs per request:
6note base = 1000 + 100 g + 20 j, start-to-ready = base(j = 0) + 400, both times m / 4 where m is
7note the scenario's multiplier for (arm, group). Expected values:
8note s1 identical arms: every rho and ratio 1000000 with zero-width interval; STOP with reasons
9note rho_delta_lower_ge_1, upper bounds >= 1 (bits 4..7 = 240).
10note s2 delta costs exactly half: rho(delta) = delta/cache = delta/idelta = delta/method = 500000,
11note select/delta = 2000000, zero width; GO; payback(delta) = 0 QUERYs (acq 0).
12note s3 = s2 with acq 1000 ns per rep for lib 1: T(delta) = T(full) / 2 + 3000.
13note s4 24 groups (the FINAL group count), delta multiplier 1 + (5 g mod 7) quarters, acq 1000 per
14note rep, seed bytes 0123456789abcdef...: point, lo, hi of rho(delta) and the ratios as
15note computed by an independent reimplementation (Python, development only) of the
16note documented bootstrap; a changed splitmix64 constant or draw rule changes them.
17note s13: 4 groups, multipliers (2, 5, 3, 5): the same INVESTIGATE branch (224).
18note s5..s14: one decision branch each (see tsrun calls in main).
19note r1..r3: refusals (identity word, expectation word, missing proc record).
20note Exit 0 = pass; otherwise the failing check's code.
21
22text TSK "/tmp/reuse-test-evalstats-\nsplit\nrun\nctrl\nout\n-\n"
23text TSHEX "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
24
25global TSG ulong 1
26global TSSC ulong 1
27global TSAQ ulong 3
28global TSCO ulong 16
29global TSCF ulong 16
30global TSWA ulong 1
31global TSWR ulong 1
32global TSTR ulong 1
33global TSBAD ulong 1
34global TSNOC ulong 1
35global TSMISS ulong 1
36global TSEND ulong 1
37global TSEX ulong 1
38global TSRB uchar 4096
39global TSRL ulong 1
40
41fn tsoff k ulong to ulong
42i = ulong 0
43c = ulong 0
44while lt c k bound 100000
45if eq get TSK i 10
46c = add c 1
47end
48i = add i 1
49end
50ret i
51end
52
53fn tskp k ulong to void
54i = tsoff k
55while ne get TSK i 10 bound 4096
56stpc get TSK i
57i = add i 1
58end
59end
60
61note the test root as the path (no slash)
62fn tsroot to void
63put STPL 0 0
64for i ulong get TSRL 0
65stpc get TSRB i
66end
67end
68
69note root/sub as the path
70fn tssub k ulong to void
71tsroot
72stpc 47
73tskp k
74end
75
76fn tsmkdirs to int
77tsroot
78r = makedir STPB 0 get STPL 0 448
79if and ne r 0 ne r -17
80ret 1
81end
82for k ulong 4
83tssub add k 1
84r = makedir STPB 0 get STPL 0 448
85if and ne r 0 ne r -17
86ret 2
87end
88end
89ret 0
90end
91
92note multiplier in quarters for arm a, group g
93fn tsmul a ulong g ulong to ulong
94s = get TSSC 0
95if eq s 1
96ret 4
97end
98if eq s 4
99if eq a 4
100ret add 1 rem mul g 5 7
101end
102ret 4
103end
104if eq s 13
105if eq a 4
106if eq g 0
107ret 2
108end
109if eq g 1
110ret 5
111end
112if eq g 2
113ret 3
114end
115ret 5
116end
117ret 4
118end
119if eq s 11
120if or eq a 2 eq a 4
121ret 2
122end
123ret 4
124end
125if eq s 12
126if or eq a 5 eq a 4
127ret 2
128end
129ret 4
130end
131if eq a 4
132ret 2
133end
134ret 4
135end
136
137fn tscost a ulong g ulong j ulong to ulong
138b = add add 1000 mul 100 g mul 20 j
139ret div mul b tsmul a g 4
140end
141
142fn tsready a ulong g ulong to ulong
143ret add tscost a g 0 div mul 400 tsmul a g 4
144end
145
146fn tsop j ulong to ulong
147k = rem j 4
148if eq k 0
149ret 1
150end
151if eq k 2
152ret 3
153end
154ret 2
155end
156
157fn tscold j ulong to ulong
158if eq rem j 4 1
159ret 1
160end
161ret 0
162end
163
164fn tsroute a ulong j ulong to ulong
165if ne tsop j 2
166ret 0
167end
168if eq a 0
169ret 0
170end
171if eq a 1
172ret 1
173end
174if eq a 2
175ret 2
176end
177if eq a 3
178ret 3
179end
180if and eq a 4 lt j 4
181ret get TSTR 0
182end
183ret 4
184end
185
186fn tsindex to int
187g = get TSG 0
188put STOP 0 0
189stow 3544386032354079058
190stow 1
191stow 4
192stow g
193stow mul g 2
194stow mul g 8
195stow mul g 4
196stow 1311768467463790320
197stow 2
198stow 3
199stow 4
200for k ulong 5
201stow 0
202end
203for i ulong g
204stow 8
205end
206tssub 1
207stpc 47
208stpk SKINDEX
209ret stwfile
210end
211
212fn tssessions to int
213put STOP 0 0
214for s ulong mul get TSG 0 2
215l = rem s 2
216stow s
217stow div s 2
218stow add l 1
219stow sub 2 l
220stow add mul l 2 2
221stow l
222stow 64
223for k ulong 5
224stow 0
225end
226stow 4
227stow 2
228stow mul l 4
229stow 0
230end
231tssub 1
232stpc 47
233stpk SKSESS
234ret stwfile
235end
236
237fn tsexp g ulong to int
238put STOP 0 0
239for j ulong 8
240i = add mul g 8 j
241op = tsop j
242stow 0
243if eq op 2
244stow 3
245stow add 1000 i
246stow i
247else
248stow 0
249stow 0
250stow 0
251end
252stow op
253stow add mul g 2 div j 4
254stow tscold j
255stow 0
256end
257tssub 1
258stpc 47
259stpc 103
260stpu2 g
261stpk SKEXP
262ret stwfile
263end
264
265note knob predicates: identity corruption, wrong refusal, wrong answer, expectation corruption
266fn tsk1 a ulong g ulong j ulong to bool
267if ne get TSBAD 0 1
268ret false
269end
270ret and and eq a 3 eq g 1 eq j 5
271end
272
273fn tskwr a ulong g ulong j ulong to bool
274if ne get TSWR 0 1
275ret false
276end
277ret and and eq a 3 eq j 2 eq g 0
278end
279
280fn tskwa a ulong r ulong g ulong j ulong to bool
281if ne get TSWA 0 1
282ret false
283end
284ret and and eq a 7 eq g 0 and eq r 0 eq j 1
285end
286
287fn tsk2 a ulong g ulong j ulong to bool
288if ne get TSBAD 0 2
289ret false
290end
291ret and and eq a 5 eq g 0 eq j 3
292end
293
294note expected r0 (k = 0) or r1 (k = 1) of request j of group g
295fn tsrv g ulong j ulong k ulong to ulong
296if ne tsop j 2
297ret 0
298end
299i = add mul g 8 j
300if eq k 1
301ret i
302end
303ret add 1000 i
304end
305
306note one raw log record
307fn tsrec a ulong r ulong g ulong j ulong to void
308op = tsop j
309stow g
310stow r
311if tsk1 a g j
312stow 9
313else
314stow a
315end
316stow j
317stow op
318st = ulong 0
319if tskwr a g j
320st = 3
321end
322stow st
323c = ulong 2
324if tskwa a r g j
325stow add tsrv g j 0 1
326c = 0
327else
328if eq a 0
329stow 0
330else
331stow tsrv g j 0
332end
333end
334if eq a 0
335stow 0
336else
337stow tsrv g j 1
338end
339stow tsroute a j
340stow 0
341if tsk2 a g j
342stow add tsrv g j 0 7
343else
344stow tsrv g j 0
345end
346stow tsrv g j 1
347stow tscost a g j
348stow tscold j
349stow add mul g 2 div j 4
350if ne st 0
351c = 0
352end
353if and and ne a 0 eq op 2 eq c 2
354c = 1
355end
356if eq a 0
357c = 2
358end
359stow c
360end
361
362fn tslog a ulong r ulong g ulong to int
363put STOP 0 0
364for j ulong 8
365tsrec a r g j
366end
367tssub 2
368stpc 47
369stpk SKARMP
370stpc uchar add a 48
371stpk SKREPP
372stpc uchar add r 48
373stpk SKGP
374stpu2 g
375stpk SKLOG
376ret stwfile
377end
378
379note one proc.log record, left out for (6, 2, 1) when TSBAD is 3
380fn tsprec a ulong r ulong g ulong to void
381if and eq get TSBAD 0 3 and eq a 6 and eq r 2 eq g 1
382ret
383end
384stow a
385stow g
386stow r
387stow tsready a g
388stow 1
389stow 1
390stow 0
391stow 0
392stow add 1000 a
393stow add 900 a
394if and eq a 7 and eq r 1 eq g 2
395stow get TSEX 0
396else
397stow 0
398end
399stow 8
400stow 0
401stow 19
402stow 0
403if eq a 4
404stow get TSEND 0
405else
406stow 0
407end
408end
409
410fn tsproc to int
411put STOP 0 0
412for a ulong 8
413for r ulong 3
414for g ulong get TSG 0
415tsprec a r g
416end
417end
418end
419tssub 2
420stpc 47
421stpk SKPROC
422ret stwfile
423end
424
425fn tsacq to int
426put STOP 0 0
427for l ulong 2
428for r ulong 3
429stow add l 1
430stow r
431stow get TSAQ l
432stow 1
433stow 1
434stow 0
435stow 4096
436stow 0
437end
438end
439tssub 2
440stpc 47
441stpk SKACQ
442ret stwfile
443end
444
445note one record per required (control, sub-case) pair (stcreq), outcome TSCO[c], served flag
446note TSCF[c] on its lowest sub-case; TSMISS = c leaves out c's highest sub-case; TSBAD 4 repeats
447note the first record
448fn tsctl to int
449put STOP 0 0
450for c ulong 14
451m = stcreq add c 1
452if eq get TSMISS 0 add c 1
453m = tsdrophi m
454end
455f = get TSCF add c 1
456for s ulong 10
457if eq and shr m s 1 1
458tsctlrec add c 1 s get TSCO add c 1 f
459f = 0
460end
461end
462end
463if eq get TSBAD 0 4
464tsctlrec 1 0 1 0
465end
466tssub 3
467stpc 47
468stpk SKCTL
469ret stwfile
470end
471
472fn tsctlrec c ulong s ulong o ulong f ulong to void
473stow c
474stow s
475stow o
476stow f
477for k ulong 4
478stow 0
479end
480end
481
482note mask m without its highest set bit
483fn tsdrophi m ulong to ulong
484h = ulong 0
485for s ulong 10
486if eq and shr m s 1 1
487h = s
488end
489end
490ret xor m shl ulong 1 h
491end
492
493fn tsgen to int
494if ne tsindex 0
495ret 1
496end
497if ne tssessions 0
498ret 2
499end
500for g ulong get TSG 0
501if ne tsexp g 0
502ret 3
503end
504for a ulong 8
505for r ulong 3
506if ne tslog a r g 0
507ret 4
508end
509end
510end
511end
512if ne tsproc 0
513ret 5
514end
515if ne tsacq 0
516ret 6
517end
518ret tsctl
519end
520
521note default knobs, then scenario s
522fn tsset s ulong to void
523put TSSC 0 s
524put TSG 0 4
525put TSAQ 0 0
526put TSAQ 1 0
527put TSWA 0 0
528put TSWR 0 0
529put TSTR 0 4
530put TSBAD 0 0
531put TSNOC 0 0
532put TSMISS 0 0
533put TSEND 0 0
534put TSEX 0 0
535for c ulong 16
536put TSCO c 1
537put TSCF c 0
538end
539put TSCO 14 2
540end
541
542note writes the inputs, sets the bases and runs stats; returns strun's code (or 90+ on a setup error)
543fn tsrun to int
544e = tsgen
545if ne e 0
546ret add 90 e
547end
548tssub 1
549stbfromp 0
550tssub 2
551stbfromp 1
552if eq get TSNOC 0 1
553put STPL 0 0
554stpc 45
555else
556tssub 3
557end
558stbfromp 2
559tssub 4
560stbfromp 3
561put STQT 0 1
562ret strun
563end
564
565fn tsseed to void
566o = ulong 12288
567for i ulong 64
568put STBD add o i get TSHEX i
569end
570put STBL 3 64
571put STRF 3 0
572put STSEED 0 sthexw 3 0
573end
574
575note statistic s point/lo/hi equal to p, l, h
576fn tsstat s ulong p ulong l ulong h ulong to bool
577b = add 24 mul s 3
578if ne get STSUM b p
579ret false
580end
581if ne get STSUM add b 1 l
582ret false
583end
584ret eq get STSUM add b 2 h
585end
586
587fn tsdec d ulong bits ulong to bool
588if ne get STSUM 2 d
589ret false
590end
591ret eq get STSUM 3 bits
592end
593
594note reads stats.sum back and compares it with STSUM
595fn tsfile to bool
596tssub 4
597stpc 47
598stpk SKSUM
599n = stload
600if ne n 2048
601ret false
602end
603for k ulong 256
604if ne stw mul k 8 get STSUM k
605ret false
606end
607end
608ret true
609end
610
611fn tsroot0 to void
612put TSRL 0 0
613if ge argcnt 2
614n = argread 1 TSRB 0 4000
615if gt n 0
616put TSRL 0 ulong n
617ret
618end
619end
620put STPL 0 0
621tskp 0
622stpu ulong getpid
623for i ulong get STPL 0
624put TSRB i get STPB i
625end
626put TSRL 0 get STPL 0
627end
628
629fn main to int
630tsroot0
631if ne tsmkdirs 0
632ret 1
633end
634tsseed
635if ne get STSEED 0 17279655951921914625
636ret 2
637end
638tsset 1
639if ne tsrun 0
640ret 3
641end
642for s ulong 13
643if not tsstat s 1000000 1000000 1000000
644ret 4
645end
646end
647if not tsdec 3 240
648ret 5
649end
650if not tsfile
651ret 6
652end
653tsset 2
654if ne tsrun 0
655ret 10
656end
657if not tsstat 4 500000 500000 500000
658ret 11
659end
660if not tsstat 8 500000 500000 500000
661ret 12
662end
663if not tsstat 9 500000 500000 500000
664ret 13
665end
666if not tsstat 10 2000000 2000000 2000000
667ret 14
668end
669if not tsstat 11 500000 500000 500000
670ret 15
671end
672if not tsstat 12 1000000 1000000 1000000
673ret 16
674end
675if not tsdec 1 0
676ret 17
677end
678if ne get STSUM 92 0
679ret 18
680end
681if or ne get STSUM 16 24 ne get STSUM 17 24
682ret 19
683end
684if or ne get STSUM 12 336 ne get STSUM 13 336
685ret 20
686end
687tsset 3
688put TSAQ 0 1000
689if ne tsrun 0
690ret 21
691end
692if ne get STSUM 68 add div get STSUM 65 2 3000
693ret 22
694end
695if ne get STSUM 76 3000
696ret 23
697end
698if ne get STSUM 92 1
699ret 24
700end
701tsset 4
702put TSG 0 24
703put TSAQ 0 1000
704if ne tsrun 0
705ret 30
706end
707if not tsstat 4 998072 798314 1200645
708ret 31
709end
710if not tsstat 8 998072 798314 1200645
711ret 32
712end
713if not tsstat 10 1004229 834617 1255445
714ret 33
715end
716if not tsstat 11 995787 796468 1197803
717ret 35
718end
719if not tsdec 2 224
720ret 34
721end
722tsset 5
723put TSWA 0 1
724if ne tsrun 0
725ret 40
726end
727if not tsdec 3 1
728ret 41
729end
730if ne get STSUM 14 1
731ret 42
732end
733tsset 6
734put TSCO 4 0
735if ne tsrun 0
736ret 50
737end
738if not tsdec 3 4
739ret 51
740end
741tsset 7
742put TSCF 9 1
743if ne tsrun 0
744ret 60
745end
746if not tsdec 3 8
747ret 61
748end
749tsset 8
750put TSCO 5 3
751if ne tsrun 0
752ret 70
753end
754if not tsdec 2 512
755ret 71
756end
757tsset 9
758put TSNOC 0 1
759if ne tsrun 0
760ret 80
761end
762if not tsdec 2 512
763ret 81
764end
765tsset 10
766put TSTR 0 1
767if ne tsrun 0
768ret 82
769end
770if not tsdec 2 256
771ret 83
772end
773tsset 11
774if ne tsrun 0
775ret 84
776end
777if not tsdec 2 64
778ret 85
779end
780tsset 12
781if ne tsrun 0
782ret 86
783end
784if not tsdec 2 128
785ret 87
786end
787tsset 13
788put TSAQ 0 1000
789if ne tsrun 0
790ret 88
791end
792if not tsdec 2 224
793ret 89
794end
795tsset 14
796put TSWR 0 1
797if ne tsrun 0
798ret 100
799end
800if not tsdec 3 2
801ret 101
802end
803tsset 2
804put TSBAD 0 1
805if ne tsrun 2
806ret 110
807end
808if ne get STRF 0 8
809ret 111
810end
811tsset 2
812put TSBAD 0 2
813if ne tsrun 2
814ret 112
815end
816if ne get STRF 0 9
817ret 113
818end
819tsset 2
820put TSBAD 0 3
821if ne tsrun 2
822ret 114
823end
824if ne get STRF 0 11
825ret 115
826end
827ret tsk17
828end
829
830note K17 and control-pair scenarios: s15 END round trip 500 ns on every delta process (cost
831note grows by 500 x 3 reps x 4 groups); s16 one select process with END failed (word 10 1029):
832note STOP wrong_refusal, failed and END-failed counts 1; s17 a plain nonzero exit 3: STOP, END
833note count 0; s18 C8 missing its sub-case 9: INVESTIGATE control_not_run; r4 a repeated control
834note pair: refused 13 with detail 3
835fn tsk17 to int
836tsset 2
837put TSEND 0 500
838if ne tsrun 0
839ret 120
840end
841if ne get STSUM 68 add div get STSUM 65 2 6000
842ret 121
843end
844if or not tsdec 1 0 ne get STSUM 100 0
845ret 122
846end
847tsset 2
848put TSEX 0 1029
849if ne tsrun 0
850ret 123
851end
852if not tsdec 3 2
853ret 124
854end
855if or ne get STSUM 103 1 ne get STSUM 111 1
856ret 125
857end
858if ne get STSUM 15 1
859ret 126
860end
861tsset 2
862put TSEX 0 3
863if ne tsrun 0
864ret 127
865end
866if or not tsdec 3 2 ne get STSUM 111 0
867ret 128
868end
869tsset 2
870put TSMISS 0 10
871if ne tsrun 0
872ret 129
873end
874if not tsdec 2 512
875ret 130
876end
877tsset 2
878put TSBAD 0 4
879if ne tsrun 2
880ret 131
881end
882if or ne get STRF 0 13 ne get STRF 2 3
883ret 132
884end
885ret 0
886end