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 / seed / qualification / security673 / game / evidence / native-v3 / roundtrip.attempt1.om

231 lines · 4246 bytes Raw Blame History
1note SC1-G transport only. No transition or invariant code is shared.
2global wire uchar 4096
3global pos ulong 1
4global avail ulong 1
5global digits uchar 32
6global samples ulong 101
7text nl "\n"
8text sp " "
9text tags "construct_ns=\nsolve_ns=\ncheck_ns=\nstates=\nedges=\nwinning=\nrounds=\narray_bytes=\nPASS SC1-G-v3 finite model only\nFAIL QUANTIFIER_CLOSURE\nFAIL OMITTED_DISTURBANCE_CLOSURE\nFAIL FRESHNESS_AT_RENAME\nFAIL UNCERTAIN_REFUND\nFAIL SELECTED_NOT_SAFE\nFAIL EARLY_STOP_CLOSURE\nFAIL CERTIFICATE\nPASS certified serial witnesses empty-set costs\nFAIL PAIRED_PRODUCT\ndistinct_hidden_states=\ndistinct_hidden_edges=\nsample_ns=\np50_ns=\np95_ns=\np99_ns=\nidentical_zero_states=\nidentical_zero_edges=\nWITNESS source action disturbance raw effective\nFAIL TRANSITION_CONFORMANCE\nFAIL CLOSURE\nFAIL SOURCE_INVARIANT\nFAIL DISABLED_ACTION\nFAIL EXACTNESS\nFAIL SELECTION_COST\n"
10fn label id uint to void
11p = ulong 0
12n = uint 0
13for j ulong len tags
14if eq get tags j 10
15if eq n id
16r = write 2 tags p add sub j p 1
17if ne r long add sub j p 1
18exit 90
19end
20ret
21end
22n = add n 1
23p = add j 1
24end
25end
26exit 90
27end
28fn number n ulong to void
29p = ulong 0
30while ge n 10 bound 32
31put digits p uchar add rem n 10 48
32n = div n 10
33p = add p 1
34end
35put digits p uchar add n 48
36p = add p 1
37for j ulong p
38r = write 2 digits sub sub p j 1 1
39if ne r 1
40exit 90
41end
42end
43r = write 2 nl 0 1
44if ne r 1
45exit 90
46end
47end
48fn mode to uint
49if eq argcnt 1
50ret 0
51end
52if ne argcnt 2
53exit 90
54end
55if ne argread 1 wire 0 1 1
56exit 90
57end
58m = get wire 0
59if or lt m 48 gt m 56
60exit 90
61end
62ret sub uint m 48
63end
64fn flush to void
65n = get pos 0
66if ne write 1 wire 0 n long n
67exit 90
68end
69put pos 0 0
70end
71fn sendword x uint to void
72for i ulong 4
73p = get pos 0
74put wire p uchar and shr x mul uint i 8 255
75put pos 0 add p 1
76if eq get pos 0 4096
77flush
78end
79end
80end
81fn recvword to uint
82x = uint 0
83for i ulong 4
84if eq get pos 0 get avail 0
85n = read 0 wire 0 len wire
86if le n 0
87exit 90
88end
89put avail 0 ulong n
90put pos 0 0
91end
92p = get pos 0
93x = or x shl uint get wire p mul uint i 8
94put pos 0 add p 1
95end
96ret x
97end
98fn endinput to void
99if ne get pos 0 get avail 0
100exit 90
101end
102if ne read 0 wire 0 len wire 0
103exit 90
104end
105end
106fn percentiles to void
107for i ulong 101
108label 20
109number get samples i
110end
111for i ulong 101
112for j ulong 100
113if gt get samples j get samples add j 1
114t = get samples j
115put samples j get samples add j 1
116put samples add j 1 t
117end
118end
119end
120label 21
121number get samples 50
122label 22
123number get samples 95
124label 23
125number get samples 99
126end
127note Fixed two-child lifecycle measurement using gate669 fork/exec/wait pattern.
128note Not a general runner. Existing compiled solver/checker required; no model code here.
129text solver "build/security760-v3/solve0"
130text checker "build/security760-v3/check0"
131text spool "build/security760-v3/roundtrip.bin"
132text nullpath "/dev/null"
133global argv uchar 256
134global status uchar 4
135fn command c uint to ulong
136put argv 0 1
137put argv 1 0
138n = len solver
139if eq c 1
140n = len checker
141end
142put argv 2 uchar n
143put argv 3 0
144for i ulong n
145if eq c 0
146put argv add i 4 get solver i
147else
148put argv add i 4 get checker i
149end
150end
151ret add n 4
152end
153fn redir fd int dst int to void
154if ne fd dst
155if ne dupfd fd dst 0 long dst
156exit 90
157end
158end
159end
160fn reap pid long to void
161start = monons
162while true bound 60000
163r = waitpid int pid status 0 len status 1
164if eq r pid
165if or ne get status 0 0 ne get status 1 0
166exit 90
167end
168ret
169end
170if or lt r 0 gt sub monons start 30000000000
171r = killpid int pid 9
172r = waitpid int pid status 0 len status 0
173exit 90
174end
175if ne sleepns 1000000 0
176exit 90
177end
178end
179exit 90
180end
181fn child c uint fd int nullfd int to void
182n = command c
183pid = fork
184if lt pid 0
185exit 90
186end
187if eq pid 0
188redir nullfd 2
189if eq c 0
190redir nullfd 0
191redir fd 1
192else
193redir fd 0
194redir nullfd 1
195end
196r = execprog argv 0 n
197exit 90
198end
199reap pid
200end
201fn main to int
202fd = fopen spool 0 len spool 194 384
203if lt fd 0
204ret 90
205end
206nullfd = fopen nullpath 0 len nullpath 2 0
207if lt nullfd 0
208ret 90
209end
210for i ulong 101
211start = monons
212if ne fseek int fd 0 0 0
213ret 90
214end
215child 0 int fd int nullfd
216if ne fseek int fd 0 0 0
217ret 90
218end
219child 1 int fd int nullfd
220put samples i ulong sub monons start
221end
222percentiles
223if ne fclose int fd 0
224ret 90
225end
226if ne fclose int nullfd 0
227ret 90
228end
229label 8
230ret 0
231end