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 / src / searchtrace / st_tool.om

371 lines · 7402 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note Copyright 2026 Drake Stapleton (AIEN / aien-dev)
3note src/searchtrace/st_tool.om: Pure seeded OM-2 CLI for `searchtrace`:
4note searchtrace run <taskset> <out_corpus>
5note searchtrace verify <corpus> [<taskset>]
6note searchtrace replay <taskset> <corpus>
7note searchtrace hookcheck <taskset>
8note searchtrace holdout <commit|reveal|verify|sign> ...
9
10text stt_c_run "run"
11text stt_c_replay "replay"
12text stt_c_verify "verify"
13text stt_c_hook "hookcheck"
14text stt_c_hold "holdout"
15text stt_usage "usage: searchtrace run <taskset> <out> | verify <corpus> [<taskset>] | replay <taskset> <corpus>\n searchtrace hookcheck <taskset> | holdout <commit|reveal|verify|sign> ...\n"
16text stt_m_corp "corpus digest="
17text stt_m_steps " steps="
18text stt_m_tasks " tasks="
19text stt_m_bytes " bytes="
20text stt_m_path " path="
21text stt_m_rpass "replay PASS digest="
22text stt_m_rfail "replay FAIL digest="
23text stt_m_vpass "verify PASS digest="
24text stt_m_vref "verify REFUSED\n"
25text stt_m_hpass "hookcheck PASS tasks="
26text stt_m_hfail "hookcheck FAIL tasks="
27text stt_tmp_suf ".tmp"
28text stt_nl "\n"
29
30global stt_fbuf uchar 2097152
31global stt_flen ulong 1
32global stt_tsbuf uchar 65536
33global stt_tslen ulong 1
34
35fn stt_wr_u64 v ulong to void
36 b = new uchar 24 0
37 p = ulong 24
38 x = v
39 while true bound 24
40 p = sub p 1
41 put b p uchar add 48 rem x 10
42 x = div x 10
43 if eq x 0
44 break
45 end
46 end
47 r = write 1 b p sub 24 p
48end
49
50fn stt_wr_hex32 d view uchar 32 to void
51 hx = new uchar 64 0
52 for i ulong 32
53 bv = ulong get d i
54 put hx mul i 2 sth_hex_nib shr bv 4
55 put hx add mul i 2 1 sth_hex_nib and bv 15
56 end
57 r = write 1 hx 0 64
58end
59
60fn stt_read_arg_str idx ulong dst edit uchar 512 to long
61 r = argread idx dst 0 510
62 ret r
63end
64
65fn stt_arg_eq idx ulong s view uchar * to bool
66 b = new uchar 512 0
67 n = argread idx b 0 510
68 if ne n long len s
69 ret false
70 end
71 for i ulong ulong n bound 64
72 if ne get b i get s i
73 ret false
74 end
75 end
76 ret true
77end
78
79fn stt_read_file_to_ts pth view uchar 512 plen ulong to long
80 fd = fopen pth 0 plen 0 0
81 if lt fd 0
82 ret -1
83 end
84 tot = ulong 0
85 while lt tot 65536 bound 65536
86 r = read int fd stt_tsbuf tot sub 65536 tot
87 if lt r 0
88 if eq r -4
89 continue
90 end
91 c = fclose int fd
92 ret -1
93 end
94 if eq r 0
95 break
96 end
97 tot = add tot ulong r
98 end
99 c = fclose int fd
100 put stt_tslen 0 tot
101 ret long tot
102end
103
104fn stt_read_file_to_fbuf pth view uchar 512 plen ulong to long
105 fd = fopen pth 0 plen 0 0
106 if lt fd 0
107 ret -1
108 end
109 tot = ulong 0
110 while lt tot 2097152 bound 2097152
111 r = read int fd stt_fbuf tot sub 2097152 tot
112 if lt r 0
113 if eq r -4
114 continue
115 end
116 c = fclose int fd
117 ret -1
118 end
119 if eq r 0
120 break
121 end
122 tot = add tot ulong r
123 end
124 c = fclose int fd
125 put stt_flen 0 tot
126 ret long tot
127end
128
129fn stt_load_taskset idx ulong to long
130 pth = new uchar 512 0
131 pl = stt_read_arg_str idx pth
132 if lt pl 1
133 ret -1
134 end
135 tl = stt_read_file_to_ts pth ulong pl
136 if lt tl 0
137 ret -1
138 end
139 ts = new uchar 65536 0
140 for i ulong ulong tl bound 65536
141 put ts i get stt_tsbuf i
142 end
143 ret stc_taskset_parse ts ulong tl
144end
145
146fn stt_write_exact pth view uchar 512 plen ulong to long
147 ol = get stc_out_len 0
148 old = stt_read_file_to_fbuf pth plen
149 if ge old 0
150 if ne ulong old ol
151 ret -1
152 end
153 for i ulong ol bound 2097152
154 if ne get stt_fbuf i get stc_out i
155 ret -1
156 end
157 end
158 ret 0
159 end
160 tmp = new uchar 512 0
161 for i ulong plen bound 500
162 put tmp i get pth i
163 end
164 for i ulong 4
165 put tmp add plen i get stt_tmp_suf i
166 end
167 tl = add plen 4
168 fd = fopen tmp 0 tl 577 420
169 if lt fd 0
170 ret -1
171 end
172 w = ulong 0
173 while lt w ol bound 2097152
174 r = write int fd stc_out w sub ol w
175 if le r 0
176 c = fclose int fd
177 u = unlink tmp 0 tl
178 ret -1
179 end
180 w = add w ulong r
181 end
182 c = fclose int fd
183 if ne c 0
184 u = unlink tmp 0 tl
185 ret -1
186 end
187 pk = new uchar 1040 0
188 pkl = sth_pack_two tmp tl pth plen pk
189 rr = renames pk 0 pkl 0
190 if ne rr 0
191 u = unlink tmp 0 tl
192 ret -1
193 end
194 ret 0
195end
196
197fn stt_verify_stc_out check_ts ulong to long
198 ol = get stc_out_len 0
199 buf = new uchar 2097152 0
200 for i ulong ol bound 2097152
201 put buf i get stc_out i
202 end
203 ret stc_corpus_verify buf ol check_ts
204end
205
206fn stt_cmd_run replay ulong to int
207 if ne stt_load_taskset 2 0
208 ret 2
209 end
210 if ne stc_corpus_generate 0
211 ret 2
212 end
213 if ne stt_verify_stc_out 1 0
214 ret 2
215 end
216 pth = new uchar 512 0
217 pl = stt_read_arg_str 3 pth
218 if lt pl 1
219 ret 2
220 end
221 dg = new uchar 32 0
222 for i ulong 32
223 put dg i get stc_v_dig i
224 end
225 ol = get stc_out_len 0
226 if ne replay 0
227 rl = stt_read_file_to_fbuf pth ulong pl
228 if lt rl 0
229 ret 2
230 end
231 same = eq ulong rl ol
232 if same
233 for i ulong ol bound 2097152
234 if ne get stt_fbuf i get stc_out i
235 same = false
236 break
237 end
238 end
239 end
240 if same
241 sth_wr 1 stt_m_rpass
242 else
243 sth_wr 1 stt_m_rfail
244 end
245 stt_wr_hex32 dg
246 sth_wr 1 stt_m_steps
247 stt_wr_u64 get stc_v_steps 0
248 sth_wr 1 stt_m_bytes
249 stt_wr_u64 ol
250 sth_wr 1 stt_nl
251 if same
252 ret 0
253 end
254 ret 2
255 end
256 if ne stt_write_exact pth ulong pl 0
257 ret 2
258 end
259 sth_wr 1 stt_m_corp
260 stt_wr_hex32 dg
261 sth_wr 1 stt_m_steps
262 stt_wr_u64 get stc_v_steps 0
263 sth_wr 1 stt_m_tasks
264 stt_wr_u64 get stc_ts_n 0
265 sth_wr 1 stt_m_bytes
266 stt_wr_u64 ol
267 sth_wr 1 stt_m_path
268 w1 = write 1 pth 0 ulong pl
269 sth_wr 1 stt_nl
270 ret 0
271end
272
273fn stt_cmd_verify has_ts ulong to int
274 if ne has_ts 0
275 if ne stt_load_taskset 3 0
276 ret 2
277 end
278 end
279 pth = new uchar 512 0
280 pl = stt_read_arg_str 2 pth
281 if lt pl 1
282 ret 2
283 end
284 rl = stt_read_file_to_fbuf pth ulong pl
285 if lt rl 0
286 ret 2
287 end
288 buf = new uchar 2097152 0
289 for i ulong ulong rl bound 2097152
290 put buf i get stt_fbuf i
291 end
292 if ne stc_corpus_verify buf ulong rl has_ts 0
293 sth_wr 1 stt_m_vref
294 ret 2
295 end
296 dg = new uchar 32 0
297 for i ulong 32
298 put dg i get stc_v_dig i
299 end
300 sth_wr 1 stt_m_vpass
301 stt_wr_hex32 dg
302 sth_wr 1 stt_m_steps
303 stt_wr_u64 get stc_v_steps 0
304 sth_wr 1 stt_nl
305 ret 0
306end
307
308fn stt_cmd_hookcheck to int
309 if ne stt_load_taskset 2 0
310 ret 2
311 end
312 rc = stc_hook_equivalence
313 if eq rc 0
314 sth_wr 1 stt_m_hpass
315 else
316 sth_wr 1 stt_m_hfail
317 end
318 stt_wr_u64 get stc_ts_n 0
319 sth_wr 1 stt_nl
320 if eq rc 0
321 ret 0
322 end
323 ret 2
324end
325
326fn stt_cmd_holdout ac ulong to int
327 n = sub ac 2
328 if gt n 8
329 ret 1
330 end
331 put sth_argc 0 n
332 b = new uchar 512 0
333 for i ulong n bound 8
334 al = argread add i 2 b 0 510
335 if lt al 0
336 ret 1
337 end
338 sth_arg_set i b ulong al
339 end
340 ret sth_cli_run
341end
342
343fn main to int
344 ac = ulong argcnt
345 if lt ac 2
346 sth_wr 2 stt_usage
347 ret 1
348 end
349 if and stt_arg_eq 1 stt_c_run eq ac 4
350 ret stt_cmd_run 0
351 end
352 if and stt_arg_eq 1 stt_c_replay eq ac 4
353 ret stt_cmd_run 1
354 end
355 if stt_arg_eq 1 stt_c_verify
356 if eq ac 3
357 ret stt_cmd_verify 0
358 end
359 if eq ac 4
360 ret stt_cmd_verify 1
361 end
362 end
363 if and stt_arg_eq 1 stt_c_hook eq ac 3
364 ret stt_cmd_hookcheck
365 end
366 if and stt_arg_eq 1 stt_c_hold ge ac 3
367 ret stt_cmd_holdout ac
368 end
369 sth_wr 2 stt_usage
370 ret 1
371end