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 / train / aien-train / native / si19 / omexpmain.om

447 lines · 7228 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note aien-train#24 ORIG-1 driver. stdin: one mode byte, then the allow-list (4096 bytes),
3note then omexp-v1 records to end of input. Mode I: admit the file and print the
4note dataset identity, family counts and the deterministic baselines per partition and
5note core class (contract s.7). Mode G: generate the SYNTHETIC fixture (seed, count from
6note the next 16 bytes) to fd 3 and print its identity. No training, no model here.
7note Mode V (ORIG1-CONTRACT-v2.md): allow-list, records; v2 admission (oxadm2), refusal
8note counts by reason, admitted records and workload families per split and core class.
9note Mode A (leakage audit, no admission, local analysis only): 8 bytes na, then file A
10note (na records) and file B to end of input; prints the oxaudit counters.
11note Mode S: the frozen v2 split of every workload family (fm, fn), 0 <= fm, fn <= 13 and
12note fm + fn <= 19 (M, N <= 8192, M N <= 2^19): one line "fm fn split" each.
13note Exit: 64 bad mode, 66 dataset refused, 67 unauthorized or revoked, 74 I/O.
14global OM uchar 1
15global OB uchar 16
16global OE ulong 16
17text OKV "status="
18text OREC "records="
19text OFNV "data_fnv="
20text OALW "allow="
21text OFAM "family_"
22text OSTA "static_core"
23text OPT "part="
24text OCO " core="
25text OSEP " "
26text OEQ "="
27text ONL2 "\n"
28text ONM0 "n"
29text ONM1 "oracle"
30text ONM2 "rule"
31text ONM3 "reference"
32text ONM4 "static"
33text ONM5 "retrieval"
34text ONM6 "rule_top1"
35text ONM7 "retrieval_top1"
36text OREF "SELECT dataset refused status=-"
37text OUNA "SELECT dataset not authorized status=-"
38text OGEN "fixture_bytes="
39text OV2 "v2_"
40text OADM "admitted="
41text ORQ "refused_reason_"
42text OSPL "split_"
43text OFAMS "_families="
44text OAU "audit_"
45text OAN "a_records="
46text OBN "b_records="
47text OAF "a_fnv="
48text OBF "b_fnv="
49text OCU "_core_"
50
51fn onl to void
52w = write 1 ONL2 0 1
53end
54
55fn oread n ulong to ulong
56note Read exactly up to n bytes of records into RB; returns the count (stops at EOF).
57o = ulong 0
58while lt o n bound 999999
59r = read 0 RB o sub n o
60if lt r 0
61exit 74
62end
63if eq r 0
64ret o
65end
66o = add o ulong r
67end
68ret o
69end
70
71fn olist to ulong
72note The allow-list block: 4096 bytes, zero padded; returns the used length.
73o = ulong 0
74while lt o 4096 bound 4096
75r = read 0 LB o sub 4096 o
76if lt r 0
77exit 74
78end
79if eq r 0
80ret o
81end
82o = add o ulong r
83end
84n = ulong 0
85for i ulong 4096
86if ne get LB i 0
87n = add i 1
88end
89end
90ret n
91end
92
93fn okey k ulong to void
94if eq k 0
95w = write 1 ONM0 0 len ONM0
96end
97if eq k 1
98w = write 1 ONM1 0 len ONM1
99end
100if eq k 2
101w = write 1 ONM2 0 len ONM2
102end
103if eq k 3
104w = write 1 ONM3 0 len ONM3
105end
106if eq k 4
107w = write 1 ONM4 0 len ONM4
108end
109if eq k 5
110w = write 1 ONM5 0 len ONM5
111end
112if eq k 6
113w = write 1 ONM6 0 len ONM6
114end
115if eq k 7
116w = write 1 ONM7 0 len ONM7
117end
118end
119
120fn oacc k ulong v ulong to void
121put OE k add get OE k v
122end
123
124fn onearm r ulong to ulong
125a = oxbest oxnear r
126if oxcand r a
127ret a
128end
129ret 0
130end
131
132fn obaseone r ulong s ulong to void
133oacc 0 1
134b = oxbest r
135oacc 1 oxcost r b
136a = oxrule r
137oacc 2 oxcost r a
138if eq a b
139oacc 6 1
140end
141oacc 3 oxcost r 0
142oacc 4 oxcost r s
143a = onearm r
144oacc 5 oxcost r a
145if eq a b
146oacc 7 1
147end
148end
149
150fn obase part ulong core ulong to void
151note Baseline totals over one partition and core class into OE: 0 n, 1 oracle, 2 rule,
152note 3 reference, 4 best static, 5 retrieval, 6 rule top-1 hits, 7 retrieval top-1 hits.
153for i ulong 8
154put OE i 0
155end
156s = oxstatic core
157for r ulong get RC 0
158if and eq oxpart r part eq oxcore r core
159obaseone r s
160end
161end
162end
163
164fn oshow part ulong core ulong to void
165obase part core
166w = write 1 OPT 0 len OPT
167wnum part
168w = write 1 OCO 0 len OCO
169wnum core
170for k ulong 8
171w = write 1 OSEP 0 1
172okey k
173w = write 1 OEQ 0 1
174wnum get OE k
175end
176onl
177end
178
179fn oinspect to void
180n = olist
181c = oread 524288
182s = oxload c
183if lt s 0
184w = write 1 OREF 0 len OREF
185wnum ulong neg long s
186onl
187exit 66
188end
189a = oxallow n get RC 2
190if lt a 0
191w = write 1 OUNA 0 len OUNA
192wnum ulong neg long a
193onl
194exit 67
195end
196w = write 1 OKV 0 len OKV
197wnum 0
198onl
199w = write 1 OALW 0 len OALW
200wnum ulong a
201onl
202w = write 1 OREC 0 len OREC
203wnum get RC 0
204onl
205w = write 1 OFNV 0 len OFNV
206wnum get RC 2
207onl
208for f ulong 5
209w = write 1 OFAM 0 len OFAM
210wnum f
211w = write 1 OEQ 0 1
212wnum get RC add 4 f
213onl
214end
215for k ulong 2
216w = write 1 OSTA 0 len OSTA
217wnum k
218w = write 1 OEQ 0 1
219wnum oxstatic k
220onl
221end
222for p ulong 3
223for k ulong 2
224oshow p k
225end
226end
227end
228
229fn ogen to void
230o = ulong 0
231while lt o 16 bound 64
232r = read 0 OB o sub 16 o
233if le r 0
234exit 74
235end
236o = add o ulong r
237end
238seed = ulong 0
239cnt = ulong 0
240for i ulong 8
241seed = or seed shl ulong get OB i mul i 8
242cnt = or cnt shl ulong get OB add 8 i mul i 8
243end
244n = sxgen seed cnt
245o = ulong 0
246while lt o n bound 999999
247w = write 3 RB o sub n o
248if le w 0
249exit 74
250end
251o = add o ulong w
252end
253w = write 1 OGEN 0 len OGEN
254wnum n
255onl
256w = write 1 OFNV 0 len OFNV
257wnum oxfnv n
258onl
259end
260
261fn ofnvr a ulong n ulong to ulong
262note FNV-1a 64 over RB[a..a+n).
263h = ulong 14695981039346656037
264for i ulong n
265h = mul xor h ulong get RB add a i 1099511628211
266end
267ret h
268end
269
270fn ofams p ulong to ulong
271note Distinct workload families among the admitted records of split p.
272k = ulong 0
273for r ulong get RC 0
274if eq oxpart r p
275u = true
276for q ulong r
277if and eq oxpart q p eq oxcell q oxcell r
278u = false
279end
280end
281if u
282k = add k 1
283end
284end
285end
286ret k
287end
288
289fn ospcore p ulong c ulong to ulong
290k = ulong 0
291for r ulong get RC 0
292if and eq oxpart r p eq oxcore r c
293k = add k 1
294end
295end
296ret k
297end
298
299fn ov2show to void
300w = write 1 OADM 0 len OADM
301wnum get RQ 0
302onl
303for k ulong 16
304if gt k 0
305w = write 1 ORQ 0 len ORQ
306wnum k
307w = write 1 OEQ 0 1
308wnum get RQ k
309onl
310end
311end
312for p ulong 3
313w = write 1 OSPL 0 len OSPL
314wnum p
315w = write 1 OFAMS 0 len OFAMS
316wnum ofams p
317onl
318for c ulong 2
319w = write 1 OSPL 0 len OSPL
320wnum p
321w = write 1 OCU 0 len OCU
322wnum c
323w = write 1 OEQ 0 1
324wnum ospcore p c
325onl
326end
327end
328end
329
330fn ov2 to void
331n = olist
332c = oread 524288
333s = oxadm2 c
334if lt s 0
335w = write 1 OREF 0 len OREF
336wnum ulong neg long s
337onl
338exit 66
339end
340a = oxallow n get RC 2
341if lt a 0
342w = write 1 OUNA 0 len OUNA
343wnum ulong neg long a
344onl
345exit 67
346end
347w = write 1 OV2 0 len OV2
348w = write 1 OKV 0 len OKV
349wnum 0
350onl
351w = write 1 OALW 0 len OALW
352wnum ulong a
353onl
354w = write 1 OREC 0 len OREC
355wnum get RC 0
356onl
357w = write 1 OFNV 0 len OFNV
358wnum get RC 2
359onl
360ov2show
361end
362
363fn oaudit to void
364o = ulong 0
365while lt o 8 bound 64
366r = read 0 OB o sub 8 o
367if le r 0
368exit 74
369end
370o = add o ulong r
371end
372na = ulong 0
373for i ulong 8
374na = or na shl ulong get OB i mul i 8
375end
376c = oread 524288
377t = div c 256
378if or ne rem c 256 0 gt na t
379exit 66
380end
381nb = sub t na
382t = oxdec c
383oxaudit na nb
384w = write 1 OAN 0 len OAN
385wnum na
386onl
387w = write 1 OBN 0 len OBN
388wnum nb
389onl
390w = write 1 OAF 0 len OAF
391wnum ofnvr 0 mul na 256
392onl
393w = write 1 OBF 0 len OBF
394wnum ofnvr mul na 256 mul nb 256
395onl
396for k ulong 13
397w = write 1 OAU 0 len OAU
398wnum k
399w = write 1 OEQ 0 1
400wnum get AU k
401onl
402end
403end
404
405fn osplits to void
406for a ulong 14
407for b ulong 14
408if le add a b 19
409wnum a
410w = write 1 OSEP 0 1
411wnum b
412w = write 1 OSEP 0 1
413wnum oxhspl a b
414onl
415end
416end
417end
418end
419
420fn main to int
421r = read 0 OM 0 1
422if ne r 1
423exit 64
424end
425m = get OM 0
426if eq m 73
427oinspect
428ret 0
429end
430if eq m 71
431ogen
432ret 0
433end
434if eq m 86
435ov2
436ret 0
437end
438if eq m 65
439oaudit
440ret 0
441end
442if eq m 83
443osplits
444ret 0
445end
446exit 64
447end