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 / si / inquisitor / main.om

106 lines · 1889 bytes Raw Blame History
1note si/inquisitor/main.om: CLI entrypoint for pure-Omega spark-inquisitor gatekeeper
2note Composed after si/directives/om2.om and si/inquisitor/lib.om.
3note Reads patch/audit records on stdin, emits structured JSON verdict receipt on stdout.
4note Exit 0 on PASS (or advisory WARN); exit 1 on BLOCK (or WARN with --strict); exit 2 on I/O error.
5
6text cli_strict "--strict"
7text cli_io_err "inquisitor: stdin read error\n"
8text cli_ovf_err "inquisitor: stdin exceeds 131072 byte limit\n"
9text cli_wr_err "inquisitor: stdout write error\n"
10text cli_arg_err "inquisitor: too many arguments (max 64)\n"
11
12fn cli_is_strict to bool
13ac = argcnt
14if or le ac 1 gt ac 64
15ret false
16end
17abuf = new uchar 64 0
18for i ulong ulong ac bound 64
19if gt i 0
20r = argread i abuf 0 64
21if eq r long len cli_strict
22ok = true
23for j ulong len cli_strict bound 64
24if ne get abuf j get cli_strict j
25ok = false
26break
27end
28end
29if ok
30ret true
31end
32end
33end
34end
35ret false
36end
37
38fn cli_read_stdin to long
39probe = new uchar 1 0
40total = ulong 0
41while lt total INQ_MAX_IN bound 131072
42k = read 0 inq_in total sub INQ_MAX_IN total
43if lt k 0
44ret k
45end
46if eq k 0
47break
48end
49total = add total ulong k
50end
51if eq total INQ_MAX_IN
52more = read 0 probe 0 1
53if lt more 0
54ret more
55end
56if gt more 0
57ret long -1000
58end
59end
60put inq_in_len 0 total
61ret long total
62end
63
64fn main to int
65ac = argcnt
66if or lt ac 0 gt ac 64
67ea = write 2 cli_arg_err 0 len cli_arg_err
68if lt ea 0
69ret 2
70end
71ret 2
72end
73strict = cli_is_strict
74got = cli_read_stdin
75if eq got long -1000
76eov = write 2 cli_ovf_err 0 len cli_ovf_err
77if lt eov 0
78ret 2
79end
80ret 2
81end
82if lt got 0
83ew = write 2 cli_io_err 0 len cli_io_err
84if lt ew 0
85ret 2
86end
87ret 2
88end
89v = inq_scan_input
90rlen = inq_format_receipt
91ok = inq_write_all 1 rlen
92if not ok
93ew2 = write 2 cli_wr_err 0 len cli_wr_err
94if lt ew2 0
95ret 2
96end
97ret 2
98end
99if eq v SEV_BLOCK
100ret 1
101end
102if and strict eq v SEV_WARN
103ret 1
104end
105ret 0
106end