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 / tests / orig4 / shadow-test.om

284 lines · 6215 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note omega-mv#731 ORIG-4 in-process tests of native/orig4/shadow.om (same unit, this caller
3note in place of main). stdin: the candidate MLP image (11560 bytes), then the candidate
4note affine image (1816 bytes). Records: the SYNTHETIC
5note fixture sxgen 7 780 (allow-list hash 626048380840256264). Groups: tadmit (the real
6note candidate is admitted, bound_matches=no, and the advice equals selmain E-mode's slpick
7note after slbest for 20 records), trefuse (every refusal class through the same functions
8note the advisor calls, state unchanged), tpred (non-finite score, out-of-distribution and
9note budget predicates), tnarrow (50 records: the advised arm always satisfies oxcand and
10note costs no less than the oracle), tnaff (the same over 780 records with the affine image).
11global HT ulong 2
12global HI uchar 11560
13text TALW "626048380840256264 SYNTHETIC fixture-seed7-780-records\n"
14text TREV "626048380840256264 REVOKED fixture-seed7-780-records\n"
15text TABS "1 SYNTHETIC not-this-fixture\n"
16text TPASS "ORIG4_SHADOW_TEST_PASS checks="
17text TFAIL "ORIG4_SHADOW_TEST_FAIL check="
18text TNL "\n"
19
20fn tck ok bool to void
21put HT 0 add get HT 0 1
22if not ok
23w = write 1 TFAIL 0 len TFAIL
24wnum get HT 0
25w = write 1 TNL 0 1
26exit 1
27end
28end
29
30fn timg to void
31note The candidate image from stdin into SI and a pristine copy into HI.
32tck eq hvrdimg 11560 11560
33for i ulong 11560
34put HI i get SI i
35end
36end
37
38fn trestore to void
39for i ulong 11560
40put SI i get HI i
41end
42end
43
44fn tlb n ulong to void
45note Allow-list text n: 0 the fixture SYNTHETIC line, 1 the same hash REVOKED, 2 absent.
46for i ulong 4096
47put LB i 0
48end
49if eq n 0
50for i ulong len TALW
51put LB i get TALW i
52end
53end
54if eq n 1
55for i ulong len TREV
56put LB i get TREV i
57end
58end
59if eq n 2
60for i ulong len TABS
61put LB i get TABS i
62end
63end
64end
65
66fn tlbn to ulong
67n = ulong 0
68for i ulong 4096
69if ne get LB i 0
70n = add i 1
71end
72end
73ret n
74end
75
76fn tfix to ulong
77note Regenerate and admit the fixture; returns the byte count.
78n = sxgen 7 780
79tck eq oxfnv n 626048380840256264
80tck eq oxload n 0
81tck eq get RC 0 780
82ret n
83end
84
85fn trbput r ulong i ulong v ulong to void
86note Word i of raw record r in RB (little-endian), for the record refusal tests.
87p = add mul r 256 mul i 8
88for k ulong 8
89put RB add p k uchar and shr v mul k 8 255
90end
91end
92
93fn tadmit to void
94note The real candidate: admitted, bound_matches=no (trained on the owner records, not the
95note fixture), and for 20 records the advice is slpick's choice with the same score bits.
96tlb 0
97tck eq oxallow tlbn oxfnv get RC 1 2
98tck eq hvimage 11560 0
99tck not slbound 0
100tck eq get SS 0 2
101tck eq get SS 15 705
102tck eq get SS 11 16622604375676129865
103tck ne get SS 11 get RC 2
104tck eq siget 11552 9232652764948363499
105slbest
106for r ulong 20
107c = hvscore r
108tck ge c 0
109tck eq ulong c slpick r
110tck eq get HV 0 slfwd r ulong c
111end
112end
113
114fn tref1 to void
115note Image refusals through the advisor's admission (sladmit) with the current params left
116note untouched; the resume-mode slload additionally refuses the unbound candidate (-8).
117f = slfnvp 705
118put SI 300 xor get SI 300 1
119tck eq hvimage 11560 -5
120trestore
121tck eq hvimage 11559 -1
122tck eq hvimage 1816 -4
123put SI 0 xor get SI 0 1
124tck eq hvimage 11560 -2
125trestore
126put SI 8 2
127tck eq hvimage 11560 -3
128trestore
129tck eq slload 0 11560 -8
130tck eq slfnvp 705 f
131tck eq hvimage 11560 0
132tck not slbound 0
133end
134
135fn tref2 to void
136note Record refusals through oxload: wrong profile (cache bytes), forged outcome word,
137note unknown arm bits; each refusal leaves nothing admitted (RC[0] = 0).
138n = get RC 1
139trbput 0 10 1048576
140tck eq oxload n -9
141tck eq get RC 0 0
142n = tfix
143trbput 3 31 1
144tck eq oxload n -7
145tck eq get RC 0 0
146n = tfix
147trbput 5 12 159
148tck eq oxload n -5
149tck eq get RC 0 0
150n = tfix
151end
152
153fn tref3 to void
154note Allow-list: REVOKED and absent refuse; SYNTHETIC admits.
155h = oxfnv get RC 1
156tlb 1
157tck eq oxallow tlbn h -12
158tlb 2
159tck eq oxallow tlbn h -13
160tlb 0
161tck eq oxallow tlbn h 2
162end
163
164fn tpred to void
165note A non-finite parameter makes the score non-finite and the advice a fallback; core
166note class 2 or pressure 2 is out of distribution; the budget predicate.
167slbest
168tck ge hvscore 0 0
169put SP 704 2139095040
170tck eq hvscore 0 -3
171tck not affinite get HV 0
172slbest
173tck ge hvscore 0 0
174tck not hvood 0
175put RW 3 2
176tck hvood 0
177tck eq hvscore 0 -1
178put RW 3 0
179put RW 4 2
180tck hvood 0
181tck eq hvscore 0 -1
182put RW 4 1
183tck not hvood 0
184put RW 4 0
185put HV 6 10
186tck hvbudget 10
187tck not hvbudget 9
188tck hvbudget 2047
189end
190
191fn tsingle to void
192note With only the reference arm admissible there is nothing to rank.
193e = get RW 12
194put RW 12 1
195tck eq hvnarms 0 1
196tck eq hvscore 0 -2
197put RW 12 e
198tck eq hvnarms 0 5
199end
200
201fn tnarrow to void
202note The advice never widens the candidate set: the advised arm satisfies oxcand, and its
203note recorded cost is never below the oracle's.
204slbest
205for r ulong 50
206c = hvscore r
207tck ge c 0
208tck oxcand r ulong c
209tck lt ulong c oxword r 13
210tck ge oxcost r ulong c oxcost r oxbest r
211end
212end
213
214fn tnaff to void
215note tnarrow on the affine candidate (the next 1816 stdin bytes) over all 780 fixture
216note records under v1 admission: every record is scored, the advised arm satisfies oxcand,
217note is one of the fixture's measured arms 0..4, and costs no less than the oracle.
218n = tfix
219tck eq hvrdimg 1816 1816
220tck eq hvimage 1816 0
221tck eq get SS 0 1
222tck eq get SS 15 96
223slbest
224for r ulong 780
225c = hvscore r
226tck ge c 0
227tck oxcand r ulong c
228tck le ulong c 4
229tck ge oxcost r ulong c oxcost r oxbest r
230end
231end
232
233fn tv2 to void
234note v2 admission (oxadm2) and the retrieval advisor kind: refused records are in no split
235note (oxpart 3); retrieval advice is select.om's slnear; the image scorer is still slpick.
236n = sxgen 7 780
237tck eq oxadm2 n 0
238tck eq get RC 10 468
239k = ulong 0
240for r ulong 780
241if eq oxpart r 3
242k = add k 1
243end
244end
245tck eq k 312
246put HV 7 1
247k = ulong 0
248for r ulong 200
249if lt oxpart r 3
250c = hvscore r
251tck ge c 0
252tck eq ulong c slnear r
253tck eq get HV 0 0
254k = add k 1
255end
256end
257tck gt k 0
258put HV 7 0
259slbest
260for r ulong 200
261if lt oxpart r 3
262c = hvscore r
263tck eq ulong c slpick r
264end
265end
266end
267
268fn main to int
269timg
270n = tfix
271tadmit
272tref1
273tref2
274tref3
275tpred
276tsingle
277tnarrow
278tv2
279tnaff
280w = write 1 TPASS 0 len TPASS
281wnum get HT 0
282w = write 1 TNL 0 1
283ret 0
284end