interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / core / rsi / om / reuse-eval / receipt.om

413 lines · 9675 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note receipt.om (lane EvalStats, spark-rsi-mv #73): the REUSE-1 receipt of contract section 7.5 with
3note the identity fields of spark-rsi docs/RECEIPT-V2.md, an evaluation-budget record and an
4note explicit UNSIGNED status (no .om P-256 signer exists; the #67 signer is Rust). Needs the units
5note sha256, stats and turing (st* files and output, tusha, tub/tule). Names: rc*, RC*.
6note
7note CLI (argv[1] is the dispatcher's subcommand):
8note receipt SPLITDIR RUNDIR STATSDIR CONTRACT CANDCOMMIT MANSHA OUTFILE
9note SPLITDIR = the FINAL split (index); RUNDIR = the FINAL run (acq-1-R.mansha, R = 0..2, the
10note evaluator's rebuilds of the TRAIN library); STATSDIR holds stats.sum; CONTRACT = the REUSE-1
11note contract file (policy digest = SHA-256 of its bytes); CANDCOMMIT = the candidate-freeze commit
12note (40 lowercase hex); MANSHA = the frozen manifest SHA-256 (64 lowercase hex), which must equal
13note every acq-1-R.mansha (section 7.4: otherwise BLOCKED, not reproducible). OUTFILE receives
14note the receipt (also on stdout).
15note
16note Receipt lines, in this order (key=value):
17note receipt=REUSE-1 format_version=2 kind=evaluation status=UNSIGNED
18note signature=UNSIGNED reason=no_om_p256_signer (REUSE-1 7.5, spark-rsi #67 signer is Rust)
19note subject_commit=<40 hex> the candidate-freeze commit
20note subject_mansha=<64 hex> MANSHA (binding.subject_sha256 of RECEIPT-V2)
21note holdout_set_sha256=<64 hex> FINAL index words 7..10 (each word's bytes big endian)
22note policy_sha256=<64 hex> SHA-256 of the contract bytes
23note evaluator_binary_sha256=<64 hex> SHA-256 of /proc/self/exe (the running evaluator)
24note stats_summary_sha256=<64 hex> SHA-256 of stats.sum (the results this receipt states)
25note holdouts_total=<n> holdouts_passed=<n> scored QUERY responses of arms 1..7 over every
26note repetition, and the correct ones (stats.sum 12, 13)
27note counts groups= sessions= requests= queries= reps= arms=8 wrong_refusals=
28note decision=<GO|INVESTIGATE|STOP> reason_bits=<stats.sum word 3>
29note budget split=FINAL runs_allowed=1 runs_used=1 seed=burned (a void run burns the seed)
30note independence=UNISOLATED
31note receipt_identity_sha256=<64 hex>
32note receipt_identity_sha256 = SHA-256 over length-prefixed fields as RECEIPT-V2's digest writes
33note them (u64 LE byte length, then the bytes; numbers as 8-byte LE): the string
34note "spark-rsi.reuse1-receipt.v2-unsigned", the hex strings of subject_commit, subject_mansha,
35note holdout_set_sha256, policy_sha256, evaluator_binary_sha256, stats_summary_sha256, then
36note holdouts_total, holdouts_passed, decision (1 GO, 2 INVESTIGATE, 3 STOP), reason bits. It is
37note not a RECEIPT-V2 receipt_digest (that one covers fields R1 has no value for) and it is not a
38note signature.
39note Exit 0 = written; 2 = refused (status=REFUSED code=N): 1 usage, 2 commit not 40 lowercase
40note hex, 3 MANSHA not 64 lowercase hex, 4 index unreadable or invalid, 5 contract unreadable,
41note 6 evaluator binary unreadable, 7 stats.sum missing or invalid, 8 an acq-1-R.mansha missing,
42note 9 MANSHA differs from a rebuild (BLOCKED: not reproducible), 10 the index is not FINAL
43note (split id 4), 11 stats.sum is not the summary of this split (its split id is not 4, its
44note words 18..21 differ from index words 7..10, or its group, session, request or QUERY count
45note differs from the index); 15 output failure.
46
47text RCK "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=\nsubject_mansha=\nholdout_set_sha256=\npolicy_sha256=\nevaluator_binary_sha256=\nstats_summary_sha256=\nholdouts_total=\n holdouts_passed=\ncounts groups=\n sessions=\n requests=\n queries=\n reps=\n arms=8 wrong_refusals=\ndecision=\n reason_bits=\nbudget split=FINAL runs_allowed=1 runs_used=1 seed=burned\nindependence=UNISOLATED\nreceipt_identity_sha256=\nspark-rsi.reuse1-receipt.v2-unsigned\n/proc/self/exe\nacq-1-\n.mansha\nstatus=REFUSED code=\nGO\nINVESTIGATE\nSTOP\n"
48
49const RKHEAD ulong 0
50const RKSIG ulong 1
51const RKCOMM ulong 2
52const RKMANS ulong 3
53const RKHOLD ulong 4
54const RKPOL ulong 5
55const RKEVAL ulong 6
56const RKSTAT ulong 7
57const RKTOT ulong 8
58const RKPASS ulong 9
59const RKCNT ulong 10
60const RKSESS ulong 11
61const RKREQS ulong 12
62const RKQRYS ulong 13
63const RKREPS ulong 14
64const RKARMS ulong 15
65const RKDECI ulong 16
66const RKBITS ulong 17
67const RKBUDG ulong 18
68const RKINDEP ulong 19
69const RKIDENT ulong 20
70const RKDOM ulong 21
71const RKEXE ulong 22
72const RKACQ ulong 23
73const RKMSH ulong 24
74const RKREFU ulong 25
75const RKGO ulong 26
76
77global RCH ulong 24
78global RCS ulong 32
79
80fn rckoff k ulong to ulong
81i = ulong 0
82c = ulong 0
83while lt c k bound 999999
84if eq get RCK i 10
85c = add c 1
86end
87i = add i 1
88end
89ret i
90end
91
92fn rcks k ulong to void
93i = rckoff k
94while ne get RCK i 10 bound 4096
95stoc get RCK i
96i = add i 1
97end
98end
99
100fn rckp k ulong to void
101i = rckoff k
102while ne get RCK i 10 bound 4096
103stpc get RCK i
104i = add i 1
105end
106end
107
108note slot b holds exactly n lowercase hex characters
109fn rchex b ulong n ulong to bool
110if ne get STBL b n
111ret false
112end
113o = mul b 4096
114for i ulong n
115c = get STBD add o i
116if not or and ge c 48 le c 57 and ge c 97 le c 102
117ret false
118end
119end
120ret true
121end
122
123note TUD saved as digest d (0 holdout, 1 policy, 2 evaluator, 3 stats) in RCH
124fn rcsave d ulong to void
125for j ulong 4
126put RCH add mul d 4 j get TUD j
127end
128end
129
130note digest d as 64 hex (word j little-endian bytes, the TUD convention)
131fn rcohd d ulong to void
132for j ulong 4
133v = get RCH add mul d 4 j
134for k ulong 8
135stohb and shr v mul k 8 255
136end
137end
138end
139
140note the holdout digest words (big-endian bytes per word) into RCH 0..3 in the TUD convention
141fn rchold to void
142for j ulong 4
143v = get STHD j
144x = ulong 0
145for k ulong 8
146x = or x shl and shr v mul sub 7 k 8 255 mul k 8
147end
148put RCH j x
149end
150end
151
152note SHA-256 of the file at STPB into RCH d; false when unreadable
153fn rcfile d ulong to bool
154n = stload
155if lt n 0
156ret false
157end
158tusha 1000 1 0 ulong n
159rcsave d
160ret true
161end
162
163note every acq-1-R.mansha equals slot 5 (64 hex then a newline); 0 ok, 8 missing, 9 differs
164fn rcmansha to int
165for r ulong 3
166stpbase 1
167rckp RKACQ
168stpc uchar add r 48
169rckp RKMSH
170n = stload
171if lt n 64
172ret 8
173end
174for i ulong 64
175if ne get STFB i get STBD add 20480 i
176ret 9
177end
178end
179if gt n 64
180if or gt n 65 ne get STFB 64 10
181ret 9
182end
183end
184end
185ret 0
186end
187
188note stats.sum into RCS (words 0..31); false when missing or not R1STS001 version 1
189fn rcsum to bool
190stpbase 2
191stpk SKSUM
192n = stload
193if ne n 2048
194ret false
195end
196tusha 1000 1 0 2048
197rcsave 3
198for k ulong 32
199put RCS k stw mul k 8
200end
201if ne get RCS 0 3544386041195737426
202ret false
203end
204ret eq get RCS 1 1
205end
206
207note one length-prefixed field from slot b (its bytes) into TUFB
208fn rcfslot b ulong to void
209n = get STBL b
210tule n 8
211o = mul b 4096
212for i ulong n
213tub ulong get STBD add o i
214end
215end
216
217note one length-prefixed 64-hex field from digest d
218fn rcfdig d ulong to void
219tule 64 8
220h = stkoff SKDIG
221for j ulong 4
222v = get RCH add mul d 4 j
223for k ulong 8
224b = and shr v mul k 8 255
225tub ulong get STK add h shr b 4
226tub ulong get STK add h and b 15
227end
228end
229end
230
231fn rcfnum v ulong to void
232tule 8 8
233tule v 8
234end
235
236note receipt identity digest into RCH 16..19
237fn rcident to void
238put TUFL 0 0
239i = rckoff RKDOM
240n = sub rckoff add RKDOM 1 add i 1
241tule n 8
242for j ulong n
243tub ulong get RCK add i j
244end
245rcfslot 4
246rcfslot 5
247for d ulong 4
248rcfdig d
249end
250rcfnum get RCS 12
251rcfnum get RCS 13
252rcfnum get RCS 2
253rcfnum get RCS 3
254tusha 1000 0 0 get TUFL 0
255rcsave 4
256end
257
258note slot b's bytes to the output
259fn rcoslot b ulong to void
260o = mul b 4096
261for i ulong get STBL b
262stoc get STBD add o i
263end
264end
265
266fn rcreport to void
267rcks RKHEAD
268stnl
269rcks RKSIG
270stnl
271rcks RKCOMM
272rcoslot 4
273stnl
274rcks RKMANS
275rcoslot 5
276stnl
277rcks RKHOLD
278rcohd 0
279stnl
280rcks RKPOL
281rcohd 1
282stnl
283rcks RKEVAL
284rcohd 2
285stnl
286rcks RKSTAT
287rcohd 3
288stnl
289rcks RKTOT
290stou get RCS 12
291rcks RKPASS
292stou get RCS 13
293stnl
294rcks RKCNT
295stou get RCS 4
296rcks RKSESS
297stou get RCS 5
298rcks RKREQS
299stou get RCS 6
300rcks RKQRYS
301stou get RCS 7
302rcks RKREPS
303stou get RCS 8
304rcks RKARMS
305stou get RCS 15
306stnl
307rcks RKDECI
308d = get RCS 2
309if and ge d 1 le d 3
310rcks add RKGO sub d 1
311else
312stou d
313end
314rcks RKBITS
315stou get RCS 3
316stnl
317rcks RKBUDG
318stnl
319rcks RKINDEP
320stnl
321rcks RKIDENT
322rcohd 4
323stnl
324end
325
326fn rcfail code ulong to int
327put STOP 0 0
328rcks RKREFU
329stou code
330stnl
331if ne get STQT 0 1
332r = stflush 1
333end
334ret 2
335end
336
337note stats.sum describes this split: split id 4, words 18..21 = the index holdout words 7..10
338note (both as stored), and the group, session, request and QUERY counts equal the index's
339fn rcsame to bool
340if ne get RCS 9 4
341ret false
342end
343for j ulong 4
344if ne get RCS add 18 j get STHD j
345ret false
346end
347end
348if or ne get RCS 4 get STNG 0 ne get RCS 5 get STNS 0
349ret false
350end
351ret and eq get RCS 6 get STNR 0 eq get RCS 7 get STNQ 0
352end
353
354note the receipt on slots 0 split, 1 run, 2 stats dir, 3 contract, 4 commit, 5 MANSHA, 6 out
355note file; stdout unless STQT is 1
356fn rcrun to int
357streset
358if not rchex 4 40
359ret rcfail 2
360end
361if not rchex 5 64
362ret rcfail 3
363end
364if ne stidx 0
365ret rcfail 4
366end
367if ne get STSPL 0 4
368ret rcfail 10
369end
370rchold
371stpexact 3
372if not rcfile 1
373ret rcfail 5
374end
375put STPL 0 0
376rckp RKEXE
377if not rcfile 2
378ret rcfail 6
379end
380if not rcsum
381ret rcfail 7
382end
383if not rcsame
384ret rcfail 11
385end
386e = rcmansha
387if ne e 0
388ret rcfail ulong e
389end
390rcident
391put STOP 0 0
392rcreport
393if ne get STQT 0 1
394r = stflush 1
395end
396stpexact 6
397if ne stwfile 0
398ret 15
399end
400ret 0
401end
402
403fn rcmain to int
404if lt argcnt 9
405ret rcfail 1
406end
407for k ulong 7
408if eq stargb add k 2 k 0
409ret rcfail 1
410end
411end
412ret rcrun
413end