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 / architecture / verify / test.om

235 lines · 6806 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note si/architecture/verify/test.om: positive & negative control test suite for
3note aien-architecture-mv authority, capability register, and invariant verification engine.
4note Compose with:
5note si/directives/om2.om om/tls/sha2.om si/architecture/verify/authority.om si/architecture/verify/test.om
6
7text t_pass "PASS "
8text t_fail "FAIL "
9text t_nl "\n"
10
11text t_c1 "adr_id_parsing_and_supersession_cycle_controls"
12text t_c2 "plan_authority_and_release_qualification_controls"
13text t_c3 "capability_register_language_and_dirty_tree_controls"
14text t_c4 "capability_register_emulator_vs_hardware_qualification"
15text t_c5 "layer_dependency_monotonicity_and_inversion_controls"
16text t_c6 "evidence_immutability_additions_only_controls"
17text t_c7 "authority_record_digest_determinism_and_sensitivity"
18text t_done "PASS aien-architecture-verify all 7 test suites passed\n"
19
20text t_adr_ok "ADR-0047"
21text t_adr_zero "ADR-0000"
22text t_adr_badpfx "RFC-0047"
23text t_adr_short "ADR-47"
24text t_adr_alpha "ADR-004a"
25
26text t_sha40_a "3a9fe6de80123456789abcdef0123456789abcde"
27text t_sha40_b "0811840af0123456789abcdef0123456789abcde"
28text t_sha40_bad "3a9fe6de8"
29text t_sha64_ok "34d611ca0415eab1728d3234911d90e74af17ba9ab0c581d559f48274d7ca6d3"
30text t_sha64_bad "zzzz11ca0415eab1728d3234911d90e74af17ba9ab0c581d559f48274d7ca6d3"
31
32fn report_case name view uchar * ok bool to int
33if ok
34w1 = arch_write_all int 1 t_pass
35w2 = arch_write_all int 1 name
36w3 = arch_write_all int 1 t_nl
37if and w1 and w2 w3
38ret int 0
39end
40ret int 1
41end
42w4 = arch_write_all int 1 t_fail
43w5 = arch_write_all int 1 name
44w6 = arch_write_all int 1 t_nl
45if and w4 and w5 w6
46ret int 1
47end
48ret int 1
49end
50
51fn test_adr_ids to bool
52if ne arch_parse_adr_id t_adr_ok long 47
53ret false
54end
55note Negative controls: ADR-0000, wrong prefix, short, non-digit
56if ne arch_parse_adr_id t_adr_zero long -1
57ret false
58end
59if ne arch_parse_adr_id t_adr_badpfx long -1
60ret false
61end
62if ne arch_parse_adr_id t_adr_short long -1
63ret false
64end
65if ne arch_parse_adr_id t_adr_alpha long -1
66ret false
67end
68note Valid ACCEPTED ADR and valid forward supersession (47 -> 52)
69if ne arch_validate_adr t_adr_ok AUTH_ACCEPTED ulong 0 ARCH_OK
70ret false
71end
72if ne arch_validate_adr t_adr_ok AUTH_SUPERSEDED ulong 52 ARCH_OK
73ret false
74end
75note Negative controls: self-supersession (47 -> 47), backward supersession (47 -> 10), nonzero superseded_by on ACCEPTED
76if ne arch_validate_adr t_adr_ok AUTH_SUPERSEDED ulong 47 ARCH_ERR_CYCLE_SUPERSEDE
77ret false
78end
79if ne arch_validate_adr t_adr_ok AUTH_SUPERSEDED ulong 10 ARCH_ERR_CYCLE_SUPERSEDE
80ret false
81end
82if ne arch_validate_adr t_adr_ok AUTH_ACCEPTED ulong 52 ARCH_ERR_CYCLE_SUPERSEDE
83ret false
84end
85ret true
86end
87
88fn test_release_authority to bool
89if not arch_adr_is_binding AUTH_ACCEPTED
90ret false
91end
92if arch_adr_is_binding AUTH_PROPOSED
93ret false
94end
95if arch_adr_is_binding AUTH_SUPERSEDED
96ret false
97end
98if ne arch_check_release_authority AUTH_ACCEPTED t_sha40_a false ARCH_OK
99ret false
100end
101note Negative controls: PROPOSED plan != qualified release, dirty tree refused, bad commit SHA refused
102if ne arch_check_release_authority AUTH_PROPOSED t_sha40_a false ARCH_ERR_UNQUALIFIED_REL
103ret false
104end
105if ne arch_check_release_authority AUTH_ACCEPTED t_sha40_a true ARCH_ERR_DIRTY_TREE
106ret false
107end
108if ne arch_check_release_authority AUTH_ACCEPTED t_sha40_bad false ARCH_ERR_BAD_SHA
109ret false
110end
111ret true
112end
113
114fn test_cap_lang_and_dirty to bool
115if ne arch_verify_cap_lang true LANG_OMEGA ARCH_OK
116ret false
117end
118note Negative controls: new C or Rust capability must be refused
119if ne arch_verify_cap_lang true LANG_C_LEGACY ARCH_ERR_NON_OMEGA_NEW
120ret false
121end
122if ne arch_verify_cap_lang true LANG_RUST_LEGACY ARCH_ERR_NON_OMEGA_NEW
123ret false
124end
125note Existing legacy capability tracked for migration is allowed
126if ne arch_verify_cap_lang false LANG_C_LEGACY ARCH_OK
127ret false
128end
129note Dirty tree refused even for PLANNED capability
130if ne arch_verify_cap_hw CAP_PLANNED HW_HOST_EMULATOR true ARCH_ERR_DIRTY_TREE
131ret false
132end
133ret true
134end
135
136fn test_cap_hw_qualification to bool
137note Host/emulator pass is valid for CAP_VERIFIED
138if ne arch_verify_cap_hw CAP_VERIFIED HW_HOST_EMULATOR false ARCH_OK
139ret false
140end
141if ne arch_verify_cap_receipts CAP_VERIFIED t_sha40_a t_sha64_ok ARCH_OK
142ret false
143end
144note GB10 and bare_metal are valid for CAP_QUALIFIED_HW
145if ne arch_verify_cap_hw CAP_QUALIFIED_HW HW_GB10 false ARCH_OK
146ret false
147end
148if ne arch_verify_cap_hw CAP_QUALIFIED_HW HW_BARE_METAL false ARCH_OK
149ret false
150end
151note Negative controls: emulator CANNOT claim CAP_QUALIFIED_HW; missing/bad receipt or SHA refused
152if ne arch_verify_cap_hw CAP_QUALIFIED_HW HW_HOST_EMULATOR false ARCH_ERR_EMULATOR_AS_HW
153ret false
154end
155if ne arch_verify_cap_receipts CAP_VERIFIED t_sha40_a t_sha64_bad ARCH_ERR_MISSING_RECEIPT
156ret false
157end
158if ne arch_verify_cap_receipts CAP_VERIFIED t_sha40_bad t_sha64_ok ARCH_ERR_BAD_SHA
159ret false
160end
161ret true
162end
163
164fn test_layer_deps to bool
165if ne arch_layer_dep_check LAYER_APPS LAYER_PROTOCOL ARCH_OK
166ret false
167end
168if ne arch_layer_dep_check LAYER_CORE LAYER_SEED ARCH_OK
169ret false
170end
171if ne arch_layer_dep_check LAYER_PROTOCOL LAYER_PROTOCOL ARCH_OK
172ret false
173end
174note Negative controls: lower layer depending on higher layer is a layer inversion
175if ne arch_layer_dep_check LAYER_SEED LAYER_PROTOCOL ARCH_ERR_LAYER_INVERSION
176ret false
177end
178if ne arch_layer_dep_check LAYER_AIENUX LAYER_APPS ARCH_ERR_LAYER_INVERSION
179ret false
180end
181if ne arch_layer_dep_check ulong 99 LAYER_SEED ARCH_ERR_BAD_LAYER
182ret false
183end
184ret true
185end
186
187fn test_evidence_immutability to bool
188if ne arch_evidence_op_check EV_OP_ADD ARCH_OK
189ret false
190end
191if ne arch_evidence_op_check EV_OP_MODIFY ARCH_ERR_EVIDENCE_MUTATION
192ret false
193end
194if ne arch_evidence_op_check EV_OP_RENAME ARCH_ERR_EVIDENCE_MUTATION
195ret false
196end
197if ne arch_evidence_op_check EV_OP_DELETE ARCH_ERR_EVIDENCE_MUTATION
198ret false
199end
200ret true
201end
202
203fn test_record_digest to bool
204d1 = new uchar 32 0
205d2 = new uchar 32 0
206arch_record_digest ulong 47 AUTH_ACCEPTED CAP_QUALIFIED_HW t_sha40_a d1
207arch_record_digest ulong 47 AUTH_ACCEPTED CAP_QUALIFIED_HW t_sha40_a d2
208if not arch_digest_eq d1 d2
209ret false
210end
211arch_record_digest ulong 47 AUTH_ACCEPTED CAP_QUALIFIED_HW t_sha40_b d2
212if arch_digest_eq d1 d2
213ret false
214end
215ret true
216end
217
218fn main to int
219fail = int 0
220fail = add fail report_case t_c1 test_adr_ids
221fail = add fail report_case t_c2 test_release_authority
222fail = add fail report_case t_c3 test_cap_lang_and_dirty
223fail = add fail report_case t_c4 test_cap_hw_qualification
224fail = add fail report_case t_c5 test_layer_deps
225fail = add fail report_case t_c6 test_evidence_immutability
226fail = add fail report_case t_c7 test_record_digest
227if ne fail int 0
228ret int 1
229end
230ok = arch_write_all int 1 t_done
231if not ok
232ret int 1
233end
234ret int 0
235end