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 / aienux / crates / aienos-cortex / cortex_test.om

256 lines · 6078 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note aienux/crates/aienos-cortex/cortex_test.om: Behavioral self-test for aienos-cortex.
3note Compose with: si/directives/om2.om om/tls/sha2.om aienux/crates/aienos-cortex/cortex.om aienux/crates/aienos-cortex/cortex_test.om
4
5text ct_s_obs "UART0 base physical address is 0x09000000"
6text ct_p_dt "device_tree"
7text ct_r_uart "phys_uart0_reg"
8text ct_s_inf1 "Driver can safely bind to UART0 MMIO"
9text ct_m_llama "llama3-spark"
10text ct_s_inf2 "Early console can initialize without Linux driver"
11text ct_s_hall "The system has 1024 GB10 GPUs connected"
12text ct_m_spec "speculative_model"
13text ct_s_ca "Claim A is true because Claim B is true"
14text ct_s_cb "Claim B is true because Claim A is true"
15text ct_m_circ "model_hallucination"
16text ct_s_forged "Secret backdoors exist in kernel"
17text ct_m_adv "adversarial_prompt"
18text ct_s_fab "Fabricated premise with zero grounding"
19text ct_m_mal "malicious_model"
20text ct_s_mix "Hybrid inference based on observation AND fabrication"
21text ct_m_hyb "hybrid_model"
22text ct_s_hyp "Hypothesis derived from valid observation"
23text ct_a_exp "explorer_agent"
24text ct_s_tr "Inference deduced from verified hypothesis"
25text ct_m_rsn "reasoning_model"
26text ct_reason "Hardware sensor disagrees with fabricated premise"
27
28text ct_p_obs "Boot completed at tick 42"
29text ct_p_klog "kernel_log"
30text ct_p_fact "SHA256 test vector passes FIPS 180-4"
31text ct_p_tsuite "test_suite"
32text ct_p_vtool "cargo_test"
33text ct_p_proof "proof"
34text ct_p_op "Promote Phase 3 to canonical state"
35text ct_p_opsig "operator_ed25519_key"
36
37fn ct_test_grounding to int
38cx_init
39obs_id = new uchar 16 0
40inf_id = new uchar 16 0
41inf2_id = new uchar 16 0
42tmp_id = new uchar 16 0
43
44note 1. Record raw hardware observation
45cx_stage_reset
46rc = cx_stage_set_payload ct_r_uart
47rc = cx_record_observation ct_s_obs ct_p_dt 100 obs_id
48if ne rc CORTEX_OK
49ret 1
50end
51
52note 2. Valid inference derived from observation
53cx_stage_reset
54rc = cx_stage_add_parent view obs_id
55if ne rc CORTEX_OK
56ret 2
57end
58cx_stage_set_conf 0.95f32
59rc = cx_record_inference ct_s_inf1 ct_m_llama 101 inf_id
60if ne rc CORTEX_OK
61ret 3
62end
63
64note Deep grounded inference: inf2 -> inf -> obs
65cx_stage_reset
66rc = cx_stage_add_parent view inf_id
67if ne rc CORTEX_OK
68ret 4
69end
70cx_stage_set_conf 0.90f32
71rc = cx_record_inference ct_s_inf2 ct_m_llama 102 inf2_id
72if ne rc CORTEX_OK
73ret 5
74end
75
76note 3. Hallucination test: ungrounded inference (no parents)
77cx_stage_reset
78cx_stage_set_conf 0.99f32
79rc = cx_record_inference ct_s_hall ct_m_spec 103 tmp_id
80if ne rc CORTEX_ERR_UNGROUNDED
81ret 6
82end
83
84note 4. Circular inference with no ground truth (A <-> B)
85cx_stage_reset
86cx_stage_set_conf 0.8f32
87rc = cx_stage_build CORTEX_INFERENCE ct_s_ca ct_m_circ 104
88if ne rc CORTEX_OK
89ret 7
90end
91id_a = new uchar 16 0
92for i ulong 16
93put id_a i get cx_st_id i
94end
95slot_a = cx_insert_staged
96if lt slot_a 0
97ret 8
98end
99cx_stage_reset
100rc = cx_stage_add_parent view id_a
101cx_stage_set_conf 0.8f32
102rc = cx_stage_build CORTEX_INFERENCE ct_s_cb ct_m_circ 104
103id_b = new uchar 16 0
104for i ulong 16
105put id_b i get cx_st_id i
106end
107slot_b = cx_insert_staged
108if lt slot_b 0
109ret 9
110end
111put cx_pcnt ulong slot_a 1
112base_a = mul ulong slot_a mul CORTEX_MAX_PARENTS CORTEX_ID_LEN
113for i ulong 16
114put cx_parents add base_a i get id_b i
115end
116if ne cx_verify_slot ulong slot_a CORTEX_ERR_CIRCULAR
117ret 10
118end
119
120note 5. Hallucination referencing non-existent parent
121forged = new uchar 16 0xaa
122cx_stage_reset
123rc = cx_stage_add_parent view forged
124cx_stage_set_conf 0.8f32
125rc = cx_record_inference ct_s_forged ct_m_adv 105 tmp_id
126if ne rc CORTEX_ERR_NOT_FOUND
127ret 11
128end
129
130note 6. Mixed parent grounding rejection (obs + ungrounded premise)
131cx_stage_reset
132cx_stage_set_conf 0.9f32
133rc = cx_stage_build CORTEX_INFERENCE ct_s_fab ct_m_mal 106
134id_ungr = new uchar 16 0
135for i ulong 16
136put id_ungr i get cx_st_id i
137end
138slot_u = cx_insert_staged
139if lt slot_u 0
140ret 12
141end
142cx_stage_reset
143rc = cx_stage_add_parent view obs_id
144rc = cx_stage_add_parent view id_ungr
145cx_stage_set_conf 0.85f32
146rc = cx_record_inference ct_s_mix ct_m_hyb 107 tmp_id
147if ne rc CORTEX_ERR_UNGROUNDED
148ret 13
149end
150
151note 7. Transitive grounding: Observation -> Hypothesis -> Inference
152cx_stage_reset
153rc = cx_stage_add_parent view obs_id
154rc = cx_record_hypothesis ct_s_hyp ct_a_exp 108 tmp_id
155if ne rc CORTEX_OK
156ret 14
157end
158cx_stage_reset
159rc = cx_stage_add_parent view tmp_id
160cx_stage_set_conf 0.95f32
161rc = cx_record_inference ct_s_tr ct_m_rsn 109 inf_id
162if ne rc CORTEX_OK
163ret 15
164end
165
166note 8. Flag contradiction between opposing records
167rc = cx_flag_contradiction view obs_id view id_ungr ct_reason 110 tmp_id
168if ne rc CORTEX_OK
169ret 16
170end
171slot_u = cx_find_by_id view tmp_id
172if lt slot_u 0
173ret 17
174end
175if ne get cx_status ulong slot_u CORTEX_CONTRADICTION
176ret 18
177end
178ret 0
179end
180
181fn ct_test_persistence to int
182cx_init
183obs_id = new uchar 16 0
184fact_id = new uchar 16 0
185op_id = new uchar 16 0
186
187cx_stage_reset
188rc = cx_record_observation ct_p_obs ct_p_klog 100 obs_id
189if ne rc CORTEX_OK
190ret 20
191end
192cx_stage_reset
193rc = cx_stage_add_parent view obs_id
194rc = cx_stage_set_verifier ct_p_vtool
195rc = cx_stage_set_payload ct_p_proof
196rc = cx_record_verified_fact ct_p_fact ct_p_tsuite 101 fact_id
197if ne rc CORTEX_OK
198ret 21
199end
200rc = cx_record_operator_decision ct_p_op ct_p_opsig 102 op_id
201if ne rc CORTEX_OK
202ret 22
203end
204
205if ne cx_count_by_status CORTEX_DIRECT_OBSERVATION 1
206ret 23
207end
208if ne cx_count_by_status CORTEX_VERIFIED_FACT 1
209ret 24
210end
211if ne cx_count_by_status CORTEX_OPERATOR_DECISION 1
212ret 25
213end
214
215jbuf = new uchar 4096 0
216jlen = cx_export_journal jbuf
217if le jlen 38
218ret 26
219end
220cx_init
221if ne get cx_cnt 0 0
222ret 27
223end
224imported = cx_import_journal view jbuf ulong jlen
225if ne imported 3
226ret 28
227end
228if lt cx_find_by_id view obs_id 0
229ret 29
230end
231if lt cx_find_by_id view fact_id 0
232ret 30
233end
234if lt cx_find_by_id view op_id 0
235ret 31
236end
237
238put jbuf 10 xor get jbuf 10 0xff
239cx_init
240if ne cx_import_journal view jbuf ulong jlen long CORTEX_ERR_CHECKSUM
241ret 32
242end
243ret 0
244end
245
246fn main to int
247rc = ct_test_grounding
248if ne rc 0
249ret rc
250end
251rc = ct_test_persistence
252if ne rc 0
253ret rc
254end
255ret 0
256end