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 / receipt-fields.om

464 lines · 8614 bytes Raw Blame History
1note units: sha256 stats turing receipt
2note SPDX-License-Identifier: Apache-2.0
3note receipt-fields: the receipt layout. Inputs: an index with known holdout words, three
4note acq-1-R.mansha files, a stats.sum with known words, a contract file. The receipt must equal
5note RTEXP byte for byte except the two 64-hex values marked ?: the evaluator binary digest
6note (checked against SHA-256 of /proc/self/exe computed here) and the receipt identity digest
7note (recomputed here from the documented length-prefixed field list). policy_sha256 and
8note stats_summary_sha256 are SHA-256 values computed independently (Python hashlib, development
9note only). Then the refusals: MANSHA differing from a rebuild (9), a missing rebuild file (8),
10note an uppercase commit (2), a stats.sum with a wrong magic (7), a summary whose holdout digest
11note differs from the index (11), a DEV summary (11), a DEV index (10), a summary with another
12note request count (11).
13note argv[1] = temporary directory (default /tmp/reuse-test-evalstats-rc-<pid>).
14note Exit 0 = pass; otherwise the failing check's code.
15
16text RTK "/tmp/reuse-test-evalstats-rc-\nsplit\nrun\nstats\ncontract.md\nreceipt.txt\nindex\nacq-1-0.mansha\nacq-1-1.mansha\nacq-1-2.mansha\nstats.sum\n/proc/self/exe\n"
17text RTCON "REUSE-1 test contract v1.0\n"
18text RTC "0123456789abcdef0123456789abcdef01234567"
19text RTCU "0123456789ABCDEF0123456789abcdef01234567"
20text RTM "5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a"
21text RTM2 "5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5b"
22text RTH "0102030405060708090a0b0c0d0e0f1011111111111111111918171615141312"
23text RTP "0e6940071a1f189c69a3faa6d9ca6dc78f92f8520c4548f2c6a878c89e4e9e98"
24text RTS "dd51cbe03f9a9c7e61a4d471f9312ee703b2910541daf12bbd7c9b5790dfe192"
25text RTD "spark-rsi.reuse1-receipt.v2-unsigned"
26text RTEXP "receipt=REUSE-1 format_version=2 kind=evaluation status=UNSIGNED\nsignature=UNSIGNED reason=no_om_p256_signer (REUSE-1 7.5, spark-rsi #67 signer is Rust)\nsubject_commit=0123456789abcdef0123456789abcdef01234567\nsubject_mansha=5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a\nholdout_set_sha256=0102030405060708090a0b0c0d0e0f1011111111111111111918171615141312\npolicy_sha256=0e6940071a1f189c69a3faa6d9ca6dc78f92f8520c4548f2c6a878c89e4e9e98\nevaluator_binary_sha256=????????????????????????????????????????????????????????????????\nstats_summary_sha256=dd51cbe03f9a9c7e61a4d471f9312ee703b2910541daf12bbd7c9b5790dfe192\nholdouts_total=189504 holdouts_passed=189500\ncounts groups=24 sessions=192 requests=18000 queries=9024 reps=3 arms=8 wrong_refusals=1\ndecision=INVESTIGATE reason_bits=512\nbudget split=FINAL runs_allowed=1 runs_used=1 seed=burned\nindependence=UNISOLATED\nreceipt_identity_sha256=????????????????????????????????????????????????????????????????\n"
27
28global RTRB uchar 4096
29global RTRL ulong 1
30global RTEV uchar 64
31global RTID uchar 64
32
33fn rtoff k ulong to ulong
34i = ulong 0
35c = ulong 0
36while lt c k bound 100000
37if eq get RTK i 10
38c = add c 1
39end
40i = add i 1
41end
42ret i
43end
44
45fn rtkp k ulong to void
46i = rtoff k
47while ne get RTK i 10 bound 4096
48stpc get RTK i
49i = add i 1
50end
51end
52
53fn rtroot to void
54put STPL 0 0
55for i ulong get RTRL 0
56stpc get RTRB i
57end
58end
59
60fn rtpath k ulong f ulong to void
61rtroot
62stpc 47
63rtkp k
64if gt f 0
65stpc 47
66rtkp f
67end
68end
69
70fn rtinit to int
71put RTRL 0 0
72if ge argcnt 2
73n = argread 1 RTRB 0 4000
74if gt n 0
75put RTRL 0 ulong n
76end
77end
78if eq get RTRL 0 0
79put STPL 0 0
80rtkp 0
81stpu ulong getpid
82for i ulong get STPL 0
83put RTRB i get STPB i
84end
85put RTRL 0 get STPL 0
86end
87rtroot
88r = makedir STPB 0 get STPL 0 448
89if and ne r 0 ne r -17
90ret 1
91end
92for k ulong 3
93rtpath add k 1 0
94r = makedir STPB 0 get STPL 0 448
95if and ne r 0 ne r -17
96ret 2
97end
98end
99ret 0
100end
101
102note the mansha text (m 0 = RTM, 1 = RTM2) and a newline into STOB
103fn rtmsh m ulong to void
104put STOP 0 0
105for i ulong 64
106if eq m 0
107stoc get RTM i
108else
109stoc get RTM2 i
110end
111end
112stoc 10
113end
114
115note the split index: split id sp, 24 groups of 750 requests, 192 sessions, 9024 QUERYs
116fn rtindex sp ulong to int
117put STOP 0 0
118stow 3544386032354079058
119stow 1
120stow sp
121stow 24
122stow 192
123stow 18000
124stow 9024
125stow 72623859790382856
126stow 651345242494996240
127stow 1229782938247303441
128stow 1808220633999610642
129for k ulong 5
130stow 0
131end
132for g ulong 24
133stow 750
134end
135rtpath 1 6
136if ne stwfile 0
137ret 3
138end
139ret 0
140end
141
142fn rtfiles to int
143r = rtindex 4
144if ne r 0
145ret r
146end
147for k ulong 3
148rtmsh 0
149rtpath 2 add 7 k
150if ne stwfile 0
151ret 4
152end
153end
154r = rtsum 3544386041195737426 4 0
155if ne r 0
156ret r
157end
158put STOP 0 0
159for i ulong len RTCON
160stoc get RTCON i
161end
162rtpath 4 0
163ret stwfile
164end
165
166note stats.sum with split id sp; hx is added to holdout word 7 (0 = the index's digest)
167fn rtsum magic ulong sp ulong hx ulong to int
168put STOP 0 0
169stow magic
170stow 1
171stow 2
172stow 512
173stow 24
174stow 192
175stow 18000
176stow 9024
177stow 3
178stow sp
179stow 0
180stow 10000
181stow 189504
182stow 189500
183stow 4
184stow 1
185stow 0
186stow 0
187stow add 72623859790382856 hx
188stow 651345242494996240
189stow 1229782938247303441
190stow 1808220633999610642
191for k ulong 234
192stow 0
193end
194rtpath 3 10
195if ne stwfile 0
196ret 5
197end
198ret 0
199end
200
201note slots for rcrun; commit from RTC (u = 0) or RTCU (u = 1)
202fn rtslots u ulong to void
203rtpath 1 0
204stbfromp 0
205rtpath 2 0
206stbfromp 1
207rtpath 3 0
208stbfromp 2
209rtpath 4 0
210stbfromp 3
211put STPL 0 0
212for i ulong 40
213if eq u 0
214stpc get RTC i
215else
216stpc get RTCU i
217end
218end
219stbfromp 4
220put STPL 0 0
221for i ulong 64
222stpc get RTM i
223end
224stbfromp 5
225rtpath 5 0
226stbfromp 6
227end
228
229note 64 hex of TUD into RTEV (e = 0) or RTID (e = 1)
230fn rthex e ulong to void
231h = stkoff SKDIG
232for j ulong 4
233v = get TUD j
234for k ulong 8
235b = and shr v mul k 8 255
236p = add mul j 16 mul k 2
237c1 = get STK add h shr b 4
238c2 = get STK add h and b 15
239if eq e 0
240put RTEV p c1
241put RTEV add p 1 c2
242else
243put RTID p c1
244put RTID add p 1 c2
245end
246end
247end
248end
249
250note appends u64 LE length n then the bytes of text t (0 RTD, 1 RTC, 2 RTM, 3 RTH, 4 RTP, 5 RTEV, 6 RTS)
251fn rtlp t ulong to void
252n = ulong 64
253if eq t 0
254n = len RTD
255end
256if eq t 1
257n = 40
258end
259tule n 8
260for i ulong n
261if eq t 0
262tub ulong get RTD i
263end
264if eq t 1
265tub ulong get RTC i
266end
267if eq t 2
268tub ulong get RTM i
269end
270if eq t 3
271tub ulong get RTH i
272end
273if eq t 4
274tub ulong get RTP i
275end
276if eq t 5
277tub ulong get RTEV i
278end
279if eq t 6
280tub ulong get RTS i
281end
282end
283end
284
285note the identity digest recomputed from the documented field list
286fn rtident to void
287put TUFL 0 0
288for t ulong 7
289rtlp t
290end
291tule 8 8
292tule 189504 8
293tule 8 8
294tule 189500 8
295tule 8 8
296tule 2 8
297tule 8 8
298tule 512 8
299tusha 1000 0 0 get TUFL 0
300rthex 1
301end
302
303note the receipt file equals RTEXP, with RTEV and RTID at the two ? runs
304fn rtcmp to int
305rtpath 5 0
306n = stload
307if ne n long len RTEXP
308ret 20
309end
310q = ulong 0
311for i ulong len RTEXP
312e = get RTEXP i
313g = get STFB i
314if eq e 63
315if lt q 64
316e = get RTEV q
317else
318e = get RTID sub q 64
319end
320q = add q 1
321end
322if ne e g
323ret 21
324end
325end
326if ne q 128
327ret 22
328end
329ret 0
330end
331
332fn rtrefuse to int
333rtmsh 1
334rtpath 2 8
335if ne stwfile 0
336ret 30
337end
338if ne rcrun 2
339ret 31
340end
341if ne get STOB 20 57
342ret 32
343end
344rtmsh 0
345rtpath 2 8
346r = stwfile
347rtpath 2 9
348u = unlink STPB 0 get STPL 0
349if ne rcrun 2
350ret 33
351end
352if ne get STOB 20 56
353ret 34
354end
355rtmsh 0
356rtpath 2 9
357r = stwfile
358rtslots 1
359if ne rcrun 2
360ret 35
361end
362if ne get STOB 20 50
363ret 36
364end
365rtslots 0
366r = rtsum 3544386041195737427 4 0
367if ne rcrun 2
368ret 37
369end
370if ne get STOB 20 55
371ret 38
372end
373ret rtfinal
374end
375
376note the refusal code printed by the last rcrun
377fn rtcode to ulong
378if ne get STOB 0 115
379ret 999
380end
381v = ulong 0
382for k ulong 4
383c = get STOB add 20 k
384if or lt c 48 gt c 57
385break
386end
387v = add mul v 10 ulong sub c 48
388end
389ret v
390end
391
392note split and summary identity: a mismatched holdout digest, a DEV summary, DEV index, and
393note a summary with another request count are refused (11, 11, 10, 11); restored = accepted
394fn rtfinal to int
395r = rtsum 3544386041195737426 4 1
396if or ne rcrun 2 ne rtcode 11
397ret 39
398end
399r = rtsum 3544386041195737426 3 0
400if or ne rcrun 2 ne rtcode 11
401ret 40
402end
403r = rtsum 3544386041195737426 4 0
404r = rtindex 3
405if or ne rcrun 2 ne rtcode 10
406ret 41
407end
408r = rtindex 4
409if ne rcrun 0
410ret 42
411end
412r = rtsumreq
413if or ne rcrun 2 ne rtcode 11
414ret 43
415end
416ret 0
417end
418
419note stats.sum as written by rtsum but with request count 17999 (word 6)
420fn rtsumreq to int
421r = rtsum 3544386041195737426 4 0
422rtpath 3 10
423n = stload
424put STOP 0 0
425for k ulong 256
426if eq k 6
427stow 17999
428else
429stow stw mul k 8
430end
431end
432rtpath 3 10
433ret stwfile
434end
435
436fn main to int
437r = rtinit
438if ne r 0
439ret r
440end
441r = rtfiles
442if ne r 0
443ret r
444end
445put STPL 0 0
446rtkp 11
447n = stload
448if lt n 0
449ret 10
450end
451tusha 1000 1 0 ulong n
452rthex 0
453rtident
454rtslots 0
455put STQT 0 1
456if ne rcrun 0
457ret 11
458end
459r = rtcmp
460if ne r 0
461ret r
462end
463ret rtrefuse
464end