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
omega-mv / aienux / crates / aienos-explain / explain_test.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note aienux/crates/aienos-explain/explain_test.om: Behavioral self-test for aienos-explain. |
| 3 | note Ports all behavioral tests from tests/explain.rs and tests/rsi_and_cli.rs. |
| 4 | note Compose with: si/directives/om2.om om/tls/sha2.om aienux/crates/aienos-explain/explain.om aienux/crates/aienos-explain/explain_test.om |
| 5 | |
| 6 | note Common test texts |
| 7 | text t_prod "test" |
| 8 | text t_sys "test" |
| 9 | text t_art "Node" |
| 10 | text t_dig64 "abababababababababababababababababababababababababababababababab" |
| 11 | |
| 12 | note Linear chain texts |
| 13 | text t_lc_obs_s "allocator queue depth 900" |
| 14 | text t_lc_obs_p "telemetry:kv" |
| 15 | text t_lc_obs_e "900" |
| 16 | text t_lc_i1_s "allocator is saturated" |
| 17 | text t_lc_i1_p "rule:queue>512" |
| 18 | text t_lc_i2_s "p95 latency is allocator bound" |
| 19 | text t_lc_i2_p "rule:join" |
| 20 | |
| 21 | note Branching / diamond / cycle / missing / unsupported texts |
| 22 | text t_id_a "a" |
| 23 | text t_id_c "c" |
| 24 | text t_id_m "m" |
| 25 | text t_id_z "z" |
| 26 | text t_id_A "A" |
| 27 | text t_id_B "B" |
| 28 | text t_id_C "C" |
| 29 | text t_id_concl "concl" |
| 30 | text t_id_i1 "i1" |
| 31 | text t_id_i2 "i2" |
| 32 | text t_id_obs "obs" |
| 33 | text t_id_ghost "ghost" |
| 34 | text t_id_lonely "lonely" |
| 35 | text t_id_zz "zz" |
| 36 | text t_st_concl "statement of concl" |
| 37 | text t_st_i1 "statement of i1" |
| 38 | text t_st_i2 "statement of i2" |
| 39 | text t_st_obs "statement of obs" |
| 40 | text t_st_a "statement of a" |
| 41 | text t_st_c "statement of c" |
| 42 | text t_st_m "statement of m" |
| 43 | text t_st_z "statement of z" |
| 44 | text t_st_A "statement of A" |
| 45 | text t_st_B "statement of B" |
| 46 | text t_st_C "statement of C" |
| 47 | text t_st_lonely "statement of lonely" |
| 48 | text t_w_circular "circular" |
| 49 | text t_w_noev "no evidence for that link" |
| 50 | |
| 51 | note Imported cycle texts |
| 52 | text t_cy1 "claim 1" |
| 53 | text t_cy2 "claim 2" |
| 54 | text t_cy3 "claim 3" |
| 55 | |
| 56 | note Contradiction texts |
| 57 | text t_co_o1_s "sensor A says 70C" |
| 58 | text t_co_o1_p "sensor:a" |
| 59 | text t_co_o1_e "70" |
| 60 | text t_co_o2_s "sensor B says 40C" |
| 61 | text t_co_o2_p "sensor:b" |
| 62 | text t_co_o2_e "40" |
| 63 | text t_co_fl_s "A and B disagree" |
| 64 | text t_co_in_s "die is hot" |
| 65 | text t_co_in_p "rule:max" |
| 66 | text t_w_conflicts "Conflicts:" |
| 67 | text t_w_munc "Main uncertainty" |
| 68 | text t_w_contra "contradiction" |
| 69 | |
| 70 | note Hypothesis texts |
| 71 | text t_hy_o_s "cache misses up 40%" |
| 72 | text t_hy_o_p "perf:llc" |
| 73 | text t_hy_o_e "40" |
| 74 | text t_hy_h_s "prefetcher is mis-trained" |
| 75 | text t_hy_h_p "agent:rsi" |
| 76 | text t_hy_i_s "retune prefetcher" |
| 77 | text t_hy_i_p "planner" |
| 78 | text t_w_chkfact "checked fact" |
| 79 | text t_w_verfact "VerifiedFact" |
| 80 | text t_w_obsbr "observed]" |
| 81 | text t_w_notest "not yet established" |
| 82 | |
| 83 | note Branch scope texts |
| 84 | text t_br_u_s "link 3 dropped 2% packets" |
| 85 | text t_br_u_p "nic:3" |
| 86 | text t_br_u_e "2" |
| 87 | text t_br_d_s "link 3 is flaky" |
| 88 | text t_br_d_p "rule:loss>1" |
| 89 | text t_br_un_s "firmware 1.2 is signed" |
| 90 | text t_br_un_p "boot" |
| 91 | text t_br_un_v "sha256" |
| 92 | text t_br_un_e "sig" |
| 93 | |
| 94 | note Analogy & determinism texts |
| 95 | text t_an_o_s "x" |
| 96 | text t_an_o_p "s" |
| 97 | text t_an_h_s "y" |
| 98 | text t_an_h_p "agent" |
| 99 | text t_w_illus "illustration only, not evidence" |
| 100 | text t_w_evself "The evidence itself:" |
| 101 | text t_w_mech "mechanic" |
| 102 | text t_dt_o "o" |
| 103 | text t_dt_i "i" |
| 104 | text t_dt_m "m" |
| 105 | |
| 106 | note Limits & malformed texts |
| 107 | text t_bad_json "{not json" |
| 108 | text t_good_json "{\"format\":\"aien.explain.evidence-graph\",\"version\":1}" |
| 109 | text t_bad_fmt "wrong.format" |
| 110 | text t_id_top "top" |
| 111 | text t_id_m0 "m0" |
| 112 | text t_id_m1 "m1" |
| 113 | text t_id_m2 "m2" |
| 114 | text t_id_n49 "n49" |
| 115 | text t_id_n1 "n1" |
| 116 | |
| 117 | note Session clarification texts |
| 118 | text t_w_rests1 "rests on step 1" |
| 119 | text t_w_startpt "starting point" |
| 120 | text t_w_testnode "test (Node)" |
| 121 | text t_w_step1obs "step 1 id=obs" |
| 122 | text t_w_concl "Conclusion:" |
| 123 | text t_w_inferred "inferred" |
| 124 | text t_w_noalt "No alternative" |
| 125 | |
| 126 | note Bidirectional contradiction texts |
| 127 | text t_bi_obs "t:obs" |
| 128 | text t_bi_riv "t:rival" |
| 129 | text t_bi_clm "t:claim" |
| 130 | text t_bi_oth "t:other" |
| 131 | |
| 132 | note RSI KV-cache cycle fixture texts (tests/fixtures/rsi_kv_cycle.evidence.json) |
| 133 | text r_prod "spark-rsi/explain" |
| 134 | text r_sys "spark-rsi" |
| 135 | text r_art_cap "CapabilityNode" |
| 136 | text r_art_bn "BottleneckRank" |
| 137 | text r_art_hc "HypothesisContract" |
| 138 | text r_art_dc "DiagnosticContext" |
| 139 | text r_art_er "EvaluationReceipt" |
| 140 | text r_art_rr "RatificationRecord" |
| 141 | text r_art_rc "RsiCycle" |
| 142 | text r_id_kv "rsi:capability:kv_allocator" |
| 143 | text r_id_mk "rsi:capability:mojo_kernel" |
| 144 | text r_id_rg "rsi:capability:req_gateway" |
| 145 | text r_id_sp "rsi:capability:sampler" |
| 146 | text r_id_sc "rsi:capability:scheduler" |
| 147 | text r_id_bn "rsi:bottleneck:cycle-kv-0001" |
| 148 | text r_id_a1 "rsi:alternative:cycle-kv-0001:mojo_kernel" |
| 149 | text r_id_a2 "rsi:alternative:cycle-kv-0001:scheduler" |
| 150 | text r_id_a3 "rsi:alternative:cycle-kv-0001:sampler" |
| 151 | text r_id_hy "rsi:hypothesis:hypo-kv-0001" |
| 152 | text r_id_pr "rsi:hypothesis:hypo-kv-0001:prediction" |
| 153 | text r_id_fa "rsi:hypothesis:hypo-kv-0001:falsification" |
| 154 | text r_id_di "rsi:diagnostic:cycle-kv-0001" |
| 155 | text r_id_re "rsi:receipt:cycle-kv-0001:cand-kv-0001" |
| 156 | text r_id_rs "rsi:receipt:cycle-kv-0001:cand-kv-0001:summary" |
| 157 | text r_id_ra "rsi:ratification:cand-kv-0001" |
| 158 | text r_id_co "rsi:conclusion:cycle-kv-0001" |
| 159 | text r_st_kv "'Unified LPDDR5x KV Allocator' (memory) has measured median latency 4200.0 us over 20 samples" |
| 160 | text r_st_mk "'Mojo Blackwell GEMM Kernel' (compute) has measured median latency 1800.0 us over 5 samples" |
| 161 | text r_st_rg "'Request Gateway' (network) has measured median latency 120.0 us over 5 samples" |
| 162 | text r_st_sp "'Greedy Token Sampler' (inference) has measured median latency 150.0 us over 5 samples" |
| 163 | text r_st_sc "'Batch Scheduler' (scheduling) has measured median latency 340.0 us over 5 samples" |
| 164 | text r_st_bn "The capability graph ranks 'Unified LPDDR5x KV Allocator' (memory) as bottleneck #1 of 5" |
| 165 | text r_st_a1 "Alternative bottleneck candidate #2: 'Mojo Blackwell GEMM Kernel' (compute), score 0.6546" |
| 166 | text r_st_a2 "Alternative bottleneck candidate #3: 'Batch Scheduler' (scheduling), score 0.2029" |
| 167 | text r_st_a3 "Alternative bottleneck candidate #4: 'Greedy Token Sampler' (inference), score 0.0454" |
| 168 | text r_st_hy "Suspected root cause: High latency on 'Unified LPDDR5x KV Allocator'" |
| 169 | text r_st_pr "Predicts latency_median_us improves by 5.0% from baseline 4200.000" |
| 170 | text r_st_fa "Refuted if this check fails: assert!(receipt.passed_all_hard_invariants)" |
| 171 | text r_st_di "Diagnosis for src/kv_allocator.rs: primary defect PerformanceRegression" |
| 172 | text r_st_re "Evaluation of candidate cand-kv-0001 (parent parent): admitted=true, 2 evaluation layer result(s)" |
| 173 | text r_st_rs "The evaluator reports: hard invariants passed=true, statistical gates passed=true" |
| 174 | text r_st_ra "Ratification record for proposal cand-kv-0001: status Ratified (test record)" |
| 175 | text r_st_co "RSI proposes changing src/kv_allocator.rs to address PerformanceRegression (cycle cycle-kv-0001)" |
| 176 | text r_ref_kv "kv_allocator" |
| 177 | text r_ref_cy "cycle-kv-0001" |
| 178 | text r_ref_hy "hypo-kv-0001" |
| 179 | text r_ref_ca "cand-kv-0001" |
| 180 | text r_dig_re "c0cae9f3e257ef2f7b46f5cd3770f9fe1c21f8b6dfb2ee2e2449714b0c7e99d0" |
| 181 | text r_m_lat "latency_median_us" |
| 182 | text r_m_4200 "4200.000" |
| 183 | text r_m_us "us" |
| 184 | text r_cbas "declared in the HypothesisContract, not measured" |
| 185 | text r_miss_e "an artifact linking candidate cand-kv-0001 to hypothesis hypo-kv-0001" |
| 186 | text r_miss_r "no RSI artifact records that the candidate was generated from this hypothesis" |
| 187 | text r_note_co "this explanation is observational; it does not authorize promotion or any change" |
| 188 | text r_note_rs "these fields are not covered by the receipt digest, so they are reported, not verified" |
| 189 | |
| 190 | note CLI parse test texts |
| 191 | text t_cli_hex_raw "0102030405060708090a0b0c0d0e0f10" |
| 192 | text t_cli_hex_pfx "cortex:0102030405060708090a0b0c0d0e0f10" |
| 193 | text t_cli_hex_bad "no:such" |
| 194 | text t_cli_aud_se "systems-engineer" |
| 195 | text t_cli_aud_bad "alien" |
| 196 | |
| 197 | note Scratch buffers for comparing saved renders / journals |
| 198 | global t_buf_a uchar 16384 |
| 199 | global t_buf_b uchar 16384 |
| 200 | global t_jbuf uchar 8192 |
| 201 | |
| 202 | fn t_bytes_eq a view uchar * b view uchar * to bool |
| 203 | if ne len a len b |
| 204 | ret false |
| 205 | end |
| 206 | for i ulong len a bound 16384 |
| 207 | if ne get a i get b i |
| 208 | ret false |
| 209 | end |
| 210 | end |
| 211 | ret true |
| 212 | end |
| 213 | |
| 214 | fn t_add_std_node id view uchar * kd ulong st ulong stmt view uchar * to ulong |
| 215 | nid = exp_g_add_node id kd st stmt |
| 216 | exp_g_set_source_sa nid t_sys t_art |
| 217 | exp_g_set_source_ref nid id |
| 218 | ret nid |
| 219 | end |
| 220 | |
| 221 | fn t_add_simple_node id view uchar * kd ulong st ulong to ulong |
| 222 | io = exp_str_add_view id |
| 223 | nid = exp_g_add_node_raw io len id kd st |
| 224 | put exp_gn_stmt_off nid io |
| 225 | put exp_gn_stmt_len nid len id |
| 226 | exp_g_set_source_sa nid t_sys t_art |
| 227 | exp_g_set_source_ref nid id |
| 228 | ret nid |
| 229 | end |
| 230 | |
| 231 | fn t_cx_node_id_eq step1 ulong rec_idx ulong to bool |
| 232 | id = new uchar 16 0 |
| 233 | exp_cx_get_id rec_idx id |
| 234 | nid = get exp_bs_nid sub step1 1 |
| 235 | want_o = exp_cx_node_id_str id |
| 236 | ret exp_str_eq get exp_gn_id_off nid get exp_gn_id_len nid want_o 39 |
| 237 | end |
| 238 | |
| 239 | note 1. linear_chain_is_ordered_parents_first |
| 240 | fn t_01_linear_chain to int |
| 241 | exp_cx_reset |
| 242 | obs = exp_cx_add_rec EXP_ST_DIRECT_OBS t_lc_obs_s t_lc_obs_p |
| 243 | exp_cx_set_ev obs t_lc_obs_e |
| 244 | exp_cx_set_meta obs 10 0 0 |
| 245 | obs_id = new uchar 16 0 |
| 246 | exp_cx_get_id obs obs_id |
| 247 | i1 = exp_cx_add_rec EXP_ST_INFERENCE t_lc_i1_s t_lc_i1_p |
| 248 | exp_cx_set_meta i1 20 1 900 |
| 249 | exp_cx_add_parent i1 obs_id |
| 250 | i1_id = new uchar 16 0 |
| 251 | exp_cx_get_id i1 i1_id |
| 252 | i2 = exp_cx_add_rec EXP_ST_INFERENCE t_lc_i2_s t_lc_i2_p |
| 253 | exp_cx_set_meta i2 30 1 800 |
| 254 | exp_cx_add_parent i2 i1_id |
| 255 | i2_id = new uchar 16 0 |
| 256 | exp_cx_get_id i2 i2_id |
| 257 | rc = exp_cx_graph_for_record i2_id EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 258 | if ne rc EXP_OK |
| 259 | ret 1 |
| 260 | end |
| 261 | tgt_o = exp_cx_node_id_str i2_id |
| 262 | rc = exp_build_bundle_raw tgt_o 39 EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 263 | if ne rc EXP_OK |
| 264 | ret 2 |
| 265 | end |
| 266 | if ne get exp_b_scnt 0 3 |
| 267 | ret 3 |
| 268 | end |
| 269 | if not t_cx_node_id_eq 1 obs |
| 270 | ret 4 |
| 271 | end |
| 272 | if not t_cx_node_id_eq 2 i1 |
| 273 | ret 5 |
| 274 | end |
| 275 | if not t_cx_node_id_eq 3 i2 |
| 276 | ret 6 |
| 277 | end |
| 278 | if ne get exp_bs_sup_step get exp_bs_sup_off 1 1 |
| 279 | ret 7 |
| 280 | end |
| 281 | if ne get exp_bs_sup_step get exp_bs_sup_off 2 2 |
| 282 | ret 8 |
| 283 | end |
| 284 | if eq get exp_bs_gnd 0 0 |
| 285 | ret 9 |
| 286 | end |
| 287 | if ne get exp_bs_role 0 EXP_ROLE_OBSERVED |
| 288 | ret 10 |
| 289 | end |
| 290 | if exp_bundle_has_unc EXP_UK_MISSING_PARENT |
| 291 | ret 11 |
| 292 | end |
| 293 | if not exp_bundle_verify_digest |
| 294 | ret 12 |
| 295 | end |
| 296 | ret 0 |
| 297 | end |
| 298 | |
| 299 | note 2. branching_support_is_deterministic_regardless_of_input_order |
| 300 | fn t_02_branching_determinism to int |
| 301 | exp_g_reset_prod t_prod |
| 302 | nc = t_add_std_node t_id_c EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE t_st_c |
| 303 | exp_g_add_edge nc t_id_z EXP_REL_SUPPORTED_BY |
| 304 | exp_g_add_edge nc t_id_a EXP_REL_SUPPORTED_BY |
| 305 | exp_g_add_edge nc t_id_m EXP_REL_SUPPORTED_BY |
| 306 | nz = t_add_std_node t_id_z EXP_KD_CORTEX_RECORD EXP_ST_DIRECT_OBS t_st_z |
| 307 | na = t_add_std_node t_id_a EXP_KD_CORTEX_RECORD EXP_ST_VERIFIED_FACT t_st_a |
| 308 | nm = t_add_std_node t_id_m EXP_KD_CORTEX_RECORD EXP_ST_OPERATOR_DECISION t_st_m |
| 309 | rc = exp_build_bundle t_id_c EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 310 | if ne rc EXP_OK |
| 311 | ret 13 |
| 312 | end |
| 313 | if ne get exp_b_scnt 0 4 |
| 314 | ret 14 |
| 315 | end |
| 316 | if not exp_bundle_step_eq 1 t_id_a |
| 317 | ret 15 |
| 318 | end |
| 319 | if not exp_bundle_step_eq 2 t_id_z |
| 320 | ret 16 |
| 321 | end |
| 322 | if not exp_bundle_step_eq 3 t_id_m |
| 323 | ret 17 |
| 324 | end |
| 325 | if not exp_bundle_step_eq 4 t_id_c |
| 326 | ret 18 |
| 327 | end |
| 328 | note Reversed input order produces identical step sequence |
| 329 | exp_g_reset_prod t_prod |
| 330 | nm2 = t_add_std_node t_id_m EXP_KD_CORTEX_RECORD EXP_ST_OPERATOR_DECISION t_st_m |
| 331 | na2 = t_add_std_node t_id_a EXP_KD_CORTEX_RECORD EXP_ST_VERIFIED_FACT t_st_a |
| 332 | nz2 = t_add_std_node t_id_z EXP_KD_CORTEX_RECORD EXP_ST_DIRECT_OBS t_st_z |
| 333 | nc2 = t_add_std_node t_id_c EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE t_st_c |
| 334 | exp_g_add_edge nc2 t_id_m EXP_REL_SUPPORTED_BY |
| 335 | exp_g_add_edge nc2 t_id_a EXP_REL_SUPPORTED_BY |
| 336 | exp_g_add_edge nc2 t_id_z EXP_REL_SUPPORTED_BY |
| 337 | rc = exp_build_bundle t_id_c EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 338 | if ne rc EXP_OK |
| 339 | ret 19 |
| 340 | end |
| 341 | if not exp_bundle_step_eq 1 t_id_a |
| 342 | ret 20 |
| 343 | end |
| 344 | if not exp_bundle_step_eq 2 t_id_z |
| 345 | ret 21 |
| 346 | end |
| 347 | if not exp_bundle_step_eq 3 t_id_m |
| 348 | ret 22 |
| 349 | end |
| 350 | if not exp_bundle_step_eq 4 t_id_c |
| 351 | ret 23 |
| 352 | end |
| 353 | ret 0 |
| 354 | end |
| 355 | |
| 356 | note 3. shared_parent_appears_once |
| 357 | fn t_03_shared_parent to int |
| 358 | exp_g_reset_prod t_prod |
| 359 | n0 = t_add_std_node t_id_concl EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE t_st_concl |
| 360 | exp_g_add_edge n0 t_id_i1 EXP_REL_SUPPORTED_BY |
| 361 | exp_g_add_edge n0 t_id_i2 EXP_REL_SUPPORTED_BY |
| 362 | n1 = t_add_std_node t_id_i1 EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE t_st_i1 |
| 363 | exp_g_add_edge n1 t_id_obs EXP_REL_SUPPORTED_BY |
| 364 | n2 = t_add_std_node t_id_i2 EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE t_st_i2 |
| 365 | exp_g_add_edge n2 t_id_obs EXP_REL_SUPPORTED_BY |
| 366 | n3 = t_add_std_node t_id_obs EXP_KD_CORTEX_RECORD EXP_ST_DIRECT_OBS t_st_obs |
| 367 | exp_g_set_digest n3 t_dig64 |
| 368 | rc = exp_build_bundle t_id_concl EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 369 | if ne rc EXP_OK |
| 370 | ret 24 |
| 371 | end |
| 372 | if ne get exp_b_scnt 0 4 |
| 373 | ret 25 |
| 374 | end |
| 375 | if ne get exp_be_cnt 0 1 |
| 376 | ret 26 |
| 377 | end |
| 378 | if not exp_bundle_step_eq 1 t_id_obs |
| 379 | ret 27 |
| 380 | end |
| 381 | ret 0 |
| 382 | end |
| 383 | |
| 384 | note 4. cycle_terminates_and_is_reported |
| 385 | fn t_04_cycle_direct to int |
| 386 | exp_g_reset_prod t_prod |
| 387 | na = t_add_std_node t_id_A EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE t_st_A |
| 388 | exp_g_add_edge na t_id_B EXP_REL_SUPPORTED_BY |
| 389 | nb = t_add_std_node t_id_B EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE t_st_B |
| 390 | exp_g_add_edge nb t_id_C EXP_REL_SUPPORTED_BY |
| 391 | nc = t_add_std_node t_id_C EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE t_st_C |
| 392 | exp_g_add_edge nc t_id_A EXP_REL_SUPPORTED_BY |
| 393 | rc = exp_build_bundle t_id_A EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 394 | if ne rc EXP_OK |
| 395 | ret 28 |
| 396 | end |
| 397 | if ne get exp_b_scnt 0 3 |
| 398 | ret 29 |
| 399 | end |
| 400 | if not exp_bundle_step_eq 3 t_id_A |
| 401 | ret 30 |
| 402 | end |
| 403 | ccnt = ulong 0 |
| 404 | cidx = EXP_NONE |
| 405 | uc = get exp_bu_cnt 0 |
| 406 | for i ulong uc bound 512 |
| 407 | if eq get exp_bu_kind i EXP_UK_CYCLE |
| 408 | ccnt = add ccnt 1 |
| 409 | cidx = i |
| 410 | end |
| 411 | end |
| 412 | if ne ccnt 1 |
| 413 | ret 31 |
| 414 | end |
| 415 | if not exp_str_eq_view get exp_bu_nid_off cidx get exp_bu_nid_len cidx t_id_C |
| 416 | ret 32 |
| 417 | end |
| 418 | if not exp_str_eq_view get exp_bu_rel_off cidx get exp_bu_rel_len cidx t_id_A |
| 419 | ret 33 |
| 420 | end |
| 421 | ol = exp_render EXP_MODE_STEP_BY_STEP EXP_LEVEL_DEFAULT EXP_AUD_OPERATOR |
| 422 | if not exp_out_contains t_w_circular |
| 423 | ret 34 |
| 424 | end |
| 425 | ret 0 |
| 426 | end |
| 427 | |
| 428 | note 5. cycle_through_imported_cortex_journal_terminates |
| 429 | fn t_05_cycle_cortex to int |
| 430 | exp_cx_reset |
| 431 | id1 = new uchar 16 1 |
| 432 | id2 = new uchar 16 2 |
| 433 | id3 = new uchar 16 3 |
| 434 | r1 = exp_cx_add_rec EXP_ST_INFERENCE t_cy1 t_prod |
| 435 | exp_cx_set_id r1 id1 |
| 436 | exp_cx_add_parent r1 id2 |
| 437 | r2 = exp_cx_add_rec EXP_ST_INFERENCE t_cy2 t_prod |
| 438 | exp_cx_set_id r2 id2 |
| 439 | exp_cx_add_parent r2 id3 |
| 440 | r3 = exp_cx_add_rec EXP_ST_INFERENCE t_cy3 t_prod |
| 441 | exp_cx_set_id r3 id3 |
| 442 | exp_cx_add_parent r3 id1 |
| 443 | rc = exp_cx_graph_for_record id1 EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 444 | if ne rc EXP_OK |
| 445 | ret 35 |
| 446 | end |
| 447 | tgt_o = exp_cx_node_id_str id1 |
| 448 | rc = exp_build_bundle_raw tgt_o 39 EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 449 | if ne rc EXP_OK |
| 450 | ret 36 |
| 451 | end |
| 452 | if ne get exp_b_scnt 0 3 |
| 453 | ret 37 |
| 454 | end |
| 455 | if not exp_bundle_has_unc EXP_UK_CYCLE |
| 456 | ret 38 |
| 457 | end |
| 458 | ret 0 |
| 459 | end |
| 460 | |
| 461 | note 6 & 7. missing_parent_stays_missing and unsupported_claim_is_flagged |
| 462 | fn t_06_07_missing_and_unsupported to int |
| 463 | exp_g_reset_prod t_prod |
| 464 | nc = t_add_std_node t_id_concl EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE t_st_concl |
| 465 | exp_g_add_edge nc t_id_obs EXP_REL_SUPPORTED_BY |
| 466 | exp_g_add_edge nc t_id_ghost EXP_REL_SUPPORTED_BY |
| 467 | no = t_add_std_node t_id_obs EXP_KD_CORTEX_RECORD EXP_ST_DIRECT_OBS t_st_obs |
| 468 | rc = exp_build_bundle t_id_concl EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 469 | if ne rc EXP_OK |
| 470 | ret 39 |
| 471 | end |
| 472 | if ne get exp_b_scnt 0 2 |
| 473 | ret 40 |
| 474 | end |
| 475 | if not exp_bundle_step_eq 1 t_id_obs |
| 476 | ret 41 |
| 477 | end |
| 478 | if not exp_bundle_step_eq 2 t_id_concl |
| 479 | ret 42 |
| 480 | end |
| 481 | found_ghost = false |
| 482 | uc = get exp_bu_cnt 0 |
| 483 | for i ulong uc bound 512 |
| 484 | if eq get exp_bu_kind i EXP_UK_MISSING_PARENT |
| 485 | if exp_str_eq_view get exp_bu_rel_off i get exp_bu_rel_len i t_id_ghost |
| 486 | found_ghost = true |
| 487 | end |
| 488 | end |
| 489 | end |
| 490 | if not found_ghost |
| 491 | ret 43 |
| 492 | end |
| 493 | ol = exp_render EXP_MODE_SUMMARY EXP_LEVEL_DEFAULT EXP_AUD_OPERATOR |
| 494 | if not exp_out_contains t_w_noev |
| 495 | ret 44 |
| 496 | end |
| 497 | note Unsupported claim |
| 498 | exp_g_reset_prod t_prod |
| 499 | nl = t_add_std_node t_id_lonely EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE t_st_lonely |
| 500 | rc = exp_build_bundle t_id_lonely EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 501 | if ne rc EXP_OK |
| 502 | ret 45 |
| 503 | end |
| 504 | if not exp_bundle_has_unc EXP_UK_UNSUPPORTED |
| 505 | ret 46 |
| 506 | end |
| 507 | ret 0 |
| 508 | end |
| 509 | |
| 510 | note 8. contradiction_remains_visible |
| 511 | fn t_08_contradiction to int |
| 512 | exp_cx_reset |
| 513 | o1 = exp_cx_add_rec EXP_ST_DIRECT_OBS t_co_o1_s t_co_o1_p |
| 514 | exp_cx_set_ev o1 t_co_o1_e |
| 515 | o1_id = new uchar 16 0 |
| 516 | exp_cx_get_id o1 o1_id |
| 517 | o2 = exp_cx_add_rec EXP_ST_DIRECT_OBS t_co_o2_s t_co_o2_p |
| 518 | exp_cx_set_ev o2 t_co_o2_e |
| 519 | o2_id = new uchar 16 0 |
| 520 | exp_cx_get_id o2 o2_id |
| 521 | fl = exp_cx_add_rec EXP_ST_CONTRADICTION t_co_fl_s t_prod |
| 522 | exp_cx_add_parent fl o1_id |
| 523 | exp_cx_add_parent fl o2_id |
| 524 | inf = exp_cx_add_rec EXP_ST_INFERENCE t_co_in_s t_co_in_p |
| 525 | exp_cx_set_meta inf 4 1 700 |
| 526 | exp_cx_add_parent inf o1_id |
| 527 | inf_id = new uchar 16 0 |
| 528 | exp_cx_get_id inf inf_id |
| 529 | rc = exp_cx_graph_for_record inf_id EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 530 | if ne rc EXP_OK |
| 531 | ret 47 |
| 532 | end |
| 533 | tgt_o = exp_cx_node_id_str inf_id |
| 534 | rc = exp_build_bundle_raw tgt_o 39 EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 535 | if ne rc EXP_OK |
| 536 | ret 48 |
| 537 | end |
| 538 | if ne get exp_bc_cnt 0 1 |
| 539 | ret 49 |
| 540 | end |
| 541 | if ne get exp_bc_inv_cnt 0 1 |
| 542 | ret 50 |
| 543 | end |
| 544 | if not exp_bundle_has_unc EXP_UK_CONFLICT |
| 545 | ret 51 |
| 546 | end |
| 547 | if ne get exp_b_scnt 0 2 |
| 548 | ret 52 |
| 549 | end |
| 550 | ol = exp_render EXP_MODE_STEP_BY_STEP EXP_LEVEL_DEFAULT EXP_AUD_OPERATOR |
| 551 | if not exp_out_contains t_w_conflicts |
| 552 | ret 53 |
| 553 | end |
| 554 | if not exp_out_contains t_co_fl_s |
| 555 | ret 54 |
| 556 | end |
| 557 | ol = exp_render EXP_MODE_SUMMARY EXP_LEVEL_DEFAULT EXP_AUD_OPERATOR |
| 558 | if not exp_out_contains t_w_munc |
| 559 | ret 55 |
| 560 | end |
| 561 | if not exp_out_contains t_w_contra |
| 562 | ret 56 |
| 563 | end |
| 564 | ret 0 |
| 565 | end |
| 566 | |
| 567 | note 9. hypothesis_is_never_rendered_as_fact |
| 568 | fn t_09_hypothesis_never_fact to int |
| 569 | exp_cx_reset |
| 570 | o = exp_cx_add_rec EXP_ST_DIRECT_OBS t_hy_o_s t_hy_o_p |
| 571 | exp_cx_set_ev o t_hy_o_e |
| 572 | o_id = new uchar 16 0 |
| 573 | exp_cx_get_id o o_id |
| 574 | h = exp_cx_add_rec EXP_ST_HYPOTHESIS t_hy_h_s t_hy_h_p |
| 575 | exp_cx_add_parent h o_id |
| 576 | h_id = new uchar 16 0 |
| 577 | exp_cx_get_id h h_id |
| 578 | inf = exp_cx_add_rec EXP_ST_INFERENCE t_hy_i_s t_hy_i_p |
| 579 | exp_cx_set_meta inf 3 1 600 |
| 580 | exp_cx_add_parent inf h_id |
| 581 | inf_id = new uchar 16 0 |
| 582 | exp_cx_get_id inf inf_id |
| 583 | rc = exp_cx_graph_for_record inf_id EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 584 | if ne rc EXP_OK |
| 585 | ret 57 |
| 586 | end |
| 587 | tgt_o = exp_cx_node_id_str inf_id |
| 588 | rc = exp_build_bundle_raw tgt_o 39 EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 589 | if ne rc EXP_OK |
| 590 | ret 58 |
| 591 | end |
| 592 | if not exp_bundle_has_unc EXP_UK_HYPO_NOT_FALSIFIED |
| 593 | ret 59 |
| 594 | end |
| 595 | for md ulong 4 |
| 596 | for a_i ulong 2 |
| 597 | aud = EXP_AUD_GENERAL |
| 598 | if eq a_i 1 |
| 599 | aud = EXP_AUD_DEVELOPER |
| 600 | end |
| 601 | ol = exp_render md 4 aud |
| 602 | if exp_out_any_line_has_both t_hy_h_s t_w_chkfact |
| 603 | ret 60 |
| 604 | end |
| 605 | if exp_out_any_line_has_both t_hy_h_s t_w_verfact |
| 606 | ret 61 |
| 607 | end |
| 608 | if exp_out_any_line_has_both t_hy_h_s t_w_obsbr |
| 609 | ret 62 |
| 610 | end |
| 611 | end |
| 612 | end |
| 613 | exp_out_reset |
| 614 | exp_out_status_words EXP_ST_HYPOTHESIS |
| 615 | if not exp_out_contains t_w_notest |
| 616 | ret 63 |
| 617 | end |
| 618 | ret 0 |
| 619 | end |
| 620 | |
| 621 | fn t_10_check_steps u ulong d ulong un ulong to int |
| 622 | found_u = false |
| 623 | found_d = false |
| 624 | found_un = false |
| 625 | sc = get exp_b_scnt 0 |
| 626 | for i ulong sc bound 320 |
| 627 | if t_cx_node_id_eq add i 1 u |
| 628 | found_u = true |
| 629 | if ne get exp_bs_bref i 0 |
| 630 | ret 67 |
| 631 | end |
| 632 | end |
| 633 | if t_cx_node_id_eq add i 1 d |
| 634 | found_d = true |
| 635 | if eq get exp_bs_bref i 0 |
| 636 | ret 68 |
| 637 | end |
| 638 | end |
| 639 | if t_cx_node_id_eq add i 1 un |
| 640 | found_un = true |
| 641 | end |
| 642 | end |
| 643 | if not found_u |
| 644 | ret 69 |
| 645 | end |
| 646 | if not found_d |
| 647 | ret 70 |
| 648 | end |
| 649 | if found_un |
| 650 | ret 71 |
| 651 | end |
| 652 | ret 0 |
| 653 | end |
| 654 | |
| 655 | fn t_10_setup to ulong |
| 656 | exp_cx_reset |
| 657 | exp_br_reset |
| 658 | id = new uchar 16 0 |
| 659 | u = exp_cx_add_rec EXP_ST_DIRECT_OBS t_br_u_s t_br_u_p |
| 660 | exp_cx_set_ev u t_br_u_e |
| 661 | exp_cx_get_id u id |
| 662 | d = exp_cx_add_rec EXP_ST_INFERENCE t_br_d_s t_br_d_p |
| 663 | exp_cx_set_meta d 2 1 700 |
| 664 | exp_cx_add_parent d id |
| 665 | exp_cx_get_id d id |
| 666 | un = exp_cx_add_rec EXP_ST_VERIFIED_FACT t_br_un_s t_br_un_p |
| 667 | exp_cx_set_ev un t_br_un_e |
| 668 | exp_cx_set_verified_by un t_br_un_v |
| 669 | bid = new uchar 16 0x42 |
| 670 | br = exp_br_create bid 1 10 |
| 671 | exp_br_add_ref br id |
| 672 | ret br |
| 673 | end |
| 674 | |
| 675 | fn t_10_11_tokens_and_scope br ulong to int |
| 676 | dig_before = new uchar 32 0 |
| 677 | dig_after = new uchar 32 0 |
| 678 | exp_bundle_get_digest dig_before |
| 679 | exp_br_append_token br 11 |
| 680 | exp_br_append_token br 22 |
| 681 | exp_br_append_token br 33 |
| 682 | exp_br_append_token br 44 |
| 683 | bnid = exp_br_build_graph br EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 684 | rc = exp_build_bundle_raw get exp_gn_id_off bnid get exp_gn_id_len bnid EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 685 | if ne rc EXP_OK |
| 686 | ret 72 |
| 687 | end |
| 688 | exp_bundle_get_digest dig_after |
| 689 | if not t_bytes_eq dig_before dig_after |
| 690 | ret 73 |
| 691 | end |
| 692 | id = new uchar 16 0 |
| 693 | exp_cx_get_id 2 id |
| 694 | rc = exp_br_graph_for_record br id EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 695 | if ne rc EXP_ERR_NOT_IN_BRANCH_SCOPE |
| 696 | ret 74 |
| 697 | end |
| 698 | exp_cx_get_id 0 id |
| 699 | rc = exp_br_graph_for_record br id EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 700 | if ne rc EXP_OK |
| 701 | ret 75 |
| 702 | end |
| 703 | ret 0 |
| 704 | end |
| 705 | |
| 706 | note 10 & 11. branch_explanation_uses_only_what_branch_depended_on + token_history_never_enters |
| 707 | fn t_10_11_branch_scope_and_tokens to int |
| 708 | br = t_10_setup |
| 709 | bnid = exp_br_build_graph br EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 710 | rc = exp_build_bundle_raw get exp_gn_id_off bnid get exp_gn_id_len bnid EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 711 | if ne rc EXP_OK |
| 712 | ret 64 |
| 713 | end |
| 714 | if ne get exp_b_scnt 0 3 |
| 715 | ret 65 |
| 716 | end |
| 717 | if ne get exp_gn_kind get exp_bs_nid sub get exp_b_concl_step 0 1 EXP_KD_AGENT_BRANCH |
| 718 | ret 66 |
| 719 | end |
| 720 | rc = t_10_check_steps 0 1 2 |
| 721 | if ne rc 0 |
| 722 | ret rc |
| 723 | end |
| 724 | ret t_10_11_tokens_and_scope br |
| 725 | end |
| 726 | |
| 727 | fn t_12_check_analogy_renders to int |
| 728 | ol = exp_render EXP_MODE_ANALOGY EXP_LEVEL_DEFAULT EXP_AUD_OPERATOR |
| 729 | if not exp_out_contains t_w_illus |
| 730 | ret 79 |
| 731 | end |
| 732 | if not exp_out_contains t_w_evself |
| 733 | ret 80 |
| 734 | end |
| 735 | if not exp_out_contains t_w_mech |
| 736 | ret 81 |
| 737 | end |
| 738 | if not exp_out_contains t_an_o_s |
| 739 | ret 82 |
| 740 | end |
| 741 | if not exp_out_contains t_an_h_s |
| 742 | ret 83 |
| 743 | end |
| 744 | ol = exp_render EXP_MODE_TECHNICAL 4 EXP_AUD_OPERATOR |
| 745 | if exp_out_contains t_w_mech |
| 746 | ret 84 |
| 747 | end |
| 748 | if not exp_bundle_verify_digest |
| 749 | ret 85 |
| 750 | end |
| 751 | ret 0 |
| 752 | end |
| 753 | |
| 754 | note 12. analogy_is_isolated_from_evidence |
| 755 | fn t_12_analogy_isolated to int |
| 756 | exp_cx_reset |
| 757 | id = new uchar 16 0 |
| 758 | r = exp_cx_add_rec EXP_ST_DIRECT_OBS t_an_o_s t_an_o_p |
| 759 | exp_cx_set_ev r t_an_o_s |
| 760 | exp_cx_get_id r id |
| 761 | r = exp_cx_add_rec EXP_ST_HYPOTHESIS t_an_h_s t_an_h_p |
| 762 | exp_cx_add_parent r id |
| 763 | exp_cx_get_id r id |
| 764 | j1 = new uchar 1024 0 |
| 765 | jl1 = exp_cx_export_journal j1 |
| 766 | if eq jl1 0 |
| 767 | ret 76 |
| 768 | end |
| 769 | rc = exp_cx_graph_for_record id EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 770 | if ne rc EXP_OK |
| 771 | ret 77 |
| 772 | end |
| 773 | tgt_o = exp_cx_node_id_str id |
| 774 | rc = exp_build_bundle_raw tgt_o 39 EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 775 | if ne rc EXP_OK |
| 776 | ret 78 |
| 777 | end |
| 778 | dig1 = new uchar 32 0 |
| 779 | exp_bundle_get_digest dig1 |
| 780 | rc = t_12_check_analogy_renders |
| 781 | if ne rc 0 |
| 782 | ret rc |
| 783 | end |
| 784 | dig2 = new uchar 32 0 |
| 785 | exp_bundle_get_digest dig2 |
| 786 | if not t_bytes_eq dig1 dig2 |
| 787 | ret 86 |
| 788 | end |
| 789 | j2 = new uchar 1024 0 |
| 790 | jl2 = exp_cx_export_journal j2 |
| 791 | if ne jl1 jl2 |
| 792 | ret 87 |
| 793 | end |
| 794 | if not t_bytes_eq part j1 0 jl1 part j2 0 jl2 |
| 795 | ret 88 |
| 796 | end |
| 797 | if ne get exp_cx_cnt 0 2 |
| 798 | ret 89 |
| 799 | end |
| 800 | ret 0 |
| 801 | end |
| 802 | |
| 803 | fn t_13_build_and_render rec_id view uchar * dig edit uchar * txt edit uchar * to ulong |
| 804 | rc = exp_cx_graph_for_record rec_id EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 805 | if ne rc EXP_OK |
| 806 | ret EXP_NONE |
| 807 | end |
| 808 | tgt_o = exp_cx_node_id_str rec_id |
| 809 | rc = exp_build_bundle_raw tgt_o 39 EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 810 | if ne rc EXP_OK |
| 811 | ret EXP_NONE |
| 812 | end |
| 813 | exp_bundle_get_digest dig |
| 814 | ol = exp_render EXP_MODE_TECHNICAL 4 EXP_AUD_OPERATOR |
| 815 | ret exp_out_copy txt |
| 816 | end |
| 817 | |
| 818 | fn t_13_setup id edit uchar * to void |
| 819 | exp_cx_reset |
| 820 | r = exp_cx_add_rec EXP_ST_DIRECT_OBS t_dt_o t_an_o_p |
| 821 | exp_cx_set_ev r t_dt_o |
| 822 | exp_cx_get_id r id |
| 823 | r = exp_cx_add_rec EXP_ST_INFERENCE t_dt_i t_dt_m |
| 824 | exp_cx_set_meta r 2 1 500 |
| 825 | exp_cx_add_parent r id |
| 826 | exp_cx_get_id r id |
| 827 | end |
| 828 | |
| 829 | note 13. identical_input_gives_identical_bundle_and_text (via sealed journal round-trip) |
| 830 | fn t_13_identical_roundtrip to int |
| 831 | id = new uchar 16 0 |
| 832 | t_13_setup id |
| 833 | jbuf = new uchar 2048 0 |
| 834 | jlen = exp_cx_export_journal jbuf |
| 835 | if eq jlen 0 |
| 836 | ret 90 |
| 837 | end |
| 838 | d1 = new uchar 32 0 |
| 839 | r1 = new uchar 2048 0 |
| 840 | c1 = t_13_build_and_render id d1 r1 |
| 841 | if eq c1 EXP_NONE |
| 842 | ret 91 |
| 843 | end |
| 844 | if ne exp_cx_import_journal part jbuf 0 jlen EXP_OK |
| 845 | ret 93 |
| 846 | end |
| 847 | d2 = new uchar 32 0 |
| 848 | r2 = new uchar 2048 0 |
| 849 | c2 = t_13_build_and_render id d2 r2 |
| 850 | if eq c2 EXP_NONE |
| 851 | ret 94 |
| 852 | end |
| 853 | if not t_bytes_eq d1 d2 |
| 854 | ret 96 |
| 855 | end |
| 856 | if ne c1 c2 |
| 857 | ret 97 |
| 858 | end |
| 859 | for i ulong c1 bound 2048 |
| 860 | if ne get r1 i get r2 i |
| 861 | ret 98 |
| 862 | end |
| 863 | end |
| 864 | ret 0 |
| 865 | end |
| 866 | |
| 867 | fn t_14_wide_fanin to int |
| 868 | exp_g_reset_prod t_prod |
| 869 | top = t_add_simple_node t_id_top EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE |
| 870 | exp_g_add_edge top t_id_m0 EXP_REL_SUPPORTED_BY |
| 871 | exp_g_add_edge top t_id_m1 EXP_REL_SUPPORTED_BY |
| 872 | exp_g_add_edge top t_id_m2 EXP_REL_SUPPORTED_BY |
| 873 | m0 = t_add_simple_node t_id_m0 EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE |
| 874 | m1 = t_add_simple_node t_id_m1 EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE |
| 875 | m2 = t_add_simple_node t_id_m2 EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE |
| 876 | for k ulong 180 |
| 877 | po = exp_str_mark |
| 878 | exp_str_put_b uchar 112 |
| 879 | exp_str_add_u64 k |
| 880 | pl = sub exp_str_mark po |
| 881 | pn = exp_g_add_node_raw po pl EXP_KD_CORTEX_RECORD EXP_ST_DIRECT_OBS |
| 882 | put exp_gn_stmt_off pn po |
| 883 | put exp_gn_stmt_len pn pl |
| 884 | if lt k 60 |
| 885 | exp_g_add_edge_raw m0 po pl EXP_REL_SUPPORTED_BY |
| 886 | else |
| 887 | if lt k 120 |
| 888 | exp_g_add_edge_raw m1 po pl EXP_REL_SUPPORTED_BY |
| 889 | else |
| 890 | exp_g_add_edge_raw m2 po pl EXP_REL_SUPPORTED_BY |
| 891 | end |
| 892 | end |
| 893 | end |
| 894 | rc = exp_build_bundle t_id_top 32 100 |
| 895 | if ne rc EXP_OK |
| 896 | ret 104 |
| 897 | end |
| 898 | if gt get exp_b_scnt 0 100 |
| 899 | ret 105 |
| 900 | end |
| 901 | if not exp_bundle_has_unc EXP_UK_TRUNCATED |
| 902 | ret 106 |
| 903 | end |
| 904 | ret 0 |
| 905 | end |
| 906 | |
| 907 | note 14. depth_and_node_limits_bound_the_walk |
| 908 | fn t_14_limits_bound_walk to int |
| 909 | note 50-node linear chain n0..n49 |
| 910 | exp_g_reset_prod t_prod |
| 911 | for k ulong 50 |
| 912 | io = exp_str_mark |
| 913 | exp_str_put_b uchar 110 |
| 914 | exp_str_add_u64 k |
| 915 | il = sub exp_str_mark io |
| 916 | st = EXP_ST_INFERENCE |
| 917 | if eq k 0 |
| 918 | st = EXP_ST_DIRECT_OBS |
| 919 | end |
| 920 | nid = exp_g_add_node_raw io il EXP_KD_CORTEX_RECORD st |
| 921 | put exp_gn_stmt_off nid io |
| 922 | put exp_gn_stmt_len nid il |
| 923 | if gt k 0 |
| 924 | po = exp_str_mark |
| 925 | exp_str_put_b uchar 110 |
| 926 | exp_str_add_u64 sub k 1 |
| 927 | pl = sub exp_str_mark po |
| 928 | exp_g_add_edge_raw nid po pl EXP_REL_SUPPORTED_BY |
| 929 | end |
| 930 | end |
| 931 | rc = exp_build_bundle t_id_n49 3 256 |
| 932 | if ne rc EXP_OK |
| 933 | ret 99 |
| 934 | end |
| 935 | if ne get exp_b_scnt 0 4 |
| 936 | ret 100 |
| 937 | end |
| 938 | if not exp_bundle_has_unc EXP_UK_TRUNCATED |
| 939 | ret 101 |
| 940 | end |
| 941 | rc = exp_build_bundle t_id_n1 0 1 |
| 942 | if ne rc EXP_ERR_INVALID_LIMITS |
| 943 | ret 102 |
| 944 | end |
| 945 | rc = exp_build_bundle t_id_n1 1 1000000 |
| 946 | if ne rc EXP_ERR_INVALID_LIMITS |
| 947 | ret 103 |
| 948 | end |
| 949 | ret t_14_wide_fanin |
| 950 | end |
| 951 | |
| 952 | note 15. malformed_input_fails_safely |
| 953 | fn t_15_malformed_inputs to int |
| 954 | if ne exp_json_check t_bad_json EXP_ERR_BAD_FORMAT |
| 955 | ret 107 |
| 956 | end |
| 957 | if ne exp_json_check t_good_json EXP_OK |
| 958 | ret 108 |
| 959 | end |
| 960 | exp_g_reset_prod t_prod |
| 961 | na = t_add_std_node t_id_a EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE t_st_a |
| 962 | exp_g_set_version 2 |
| 963 | if ne exp_g_validate EXP_ERR_UNSUPPORTED_VERSION |
| 964 | ret 109 |
| 965 | end |
| 966 | exp_g_set_version 1 |
| 967 | exp_g_set_format t_bad_fmt |
| 968 | if ne exp_g_validate EXP_ERR_UNSUPPORTED_VERSION |
| 969 | ret 110 |
| 970 | end |
| 971 | exp_g_reset_prod t_prod |
| 972 | na = t_add_std_node t_id_a EXP_KD_CORTEX_RECORD 9 t_st_a |
| 973 | if ne exp_build_bundle t_id_a EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES EXP_ERR_UNKNOWN_CODE |
| 974 | ret 111 |
| 975 | end |
| 976 | exp_g_reset_prod t_prod |
| 977 | na = t_add_std_node t_id_a EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE t_st_a |
| 978 | exp_g_set_conf na 1001 t_prod |
| 979 | if ne exp_g_validate EXP_ERR_UNKNOWN_CODE |
| 980 | ret 112 |
| 981 | end |
| 982 | exp_g_reset_prod t_prod |
| 983 | na = t_add_std_node t_id_a EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE t_st_a |
| 984 | nb = t_add_std_node t_id_a EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE t_st_a |
| 985 | if ne exp_build_bundle t_id_a EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES EXP_ERR_DUPLICATE_NODE_ID |
| 986 | ret 113 |
| 987 | end |
| 988 | exp_g_reset_prod t_prod |
| 989 | na = t_add_std_node t_id_a EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE t_st_a |
| 990 | if ne exp_build_bundle t_id_zz EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES EXP_ERR_TARGET_NOT_FOUND |
| 991 | ret 114 |
| 992 | end |
| 993 | put exp_g_decl_ncnt 0 65537 |
| 994 | if ne exp_g_validate EXP_ERR_GRAPH_TOO_LARGE |
| 995 | ret 115 |
| 996 | end |
| 997 | note Tampered sealed journal fails with E9 |
| 998 | exp_cx_reset |
| 999 | o = exp_cx_add_rec EXP_ST_DIRECT_OBS t_dt_o t_an_o_p |
| 1000 | exp_cx_set_ev o t_dt_o |
| 1001 | jbuf = new uchar 1024 0 |
| 1002 | jl = exp_cx_export_journal jbuf |
| 1003 | if eq jl 0 |
| 1004 | ret 116 |
| 1005 | end |
| 1006 | mid = div jl 2 |
| 1007 | put jbuf mid xor get jbuf mid uchar 1 |
| 1008 | if ne exp_cx_import_journal part jbuf 0 jl EXP_ERR_JOURNAL |
| 1009 | ret 117 |
| 1010 | end |
| 1011 | ret 0 |
| 1012 | end |
| 1013 | |
| 1014 | note 16. clarification_reads_the_same_bundle |
| 1015 | fn t_16_clarification_session to int |
| 1016 | exp_g_reset_prod t_prod |
| 1017 | nc = t_add_std_node t_id_concl EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE t_st_concl |
| 1018 | exp_g_add_edge nc t_id_i1 EXP_REL_SUPPORTED_BY |
| 1019 | ni = t_add_std_node t_id_i1 EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE t_st_i1 |
| 1020 | exp_g_add_edge ni t_id_obs EXP_REL_SUPPORTED_BY |
| 1021 | no = t_add_std_node t_id_obs EXP_KD_CORTEX_RECORD EXP_ST_DIRECT_OBS t_st_obs |
| 1022 | rc = exp_build_bundle t_id_concl EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 1023 | if ne rc EXP_OK |
| 1024 | ret 118 |
| 1025 | end |
| 1026 | dig1 = new uchar 32 0 |
| 1027 | exp_bundle_get_digest dig1 |
| 1028 | exp_sess_init EXP_AUD_OPERATOR |
| 1029 | ol = exp_sess_explain |
| 1030 | if not exp_out_contains t_st_concl |
| 1031 | ret 119 |
| 1032 | end |
| 1033 | if exp_out_contains t_st_obs |
| 1034 | ret 120 |
| 1035 | end |
| 1036 | ol = exp_sess_deeper |
| 1037 | if not exp_out_contains t_st_i1 |
| 1038 | ret 121 |
| 1039 | end |
| 1040 | if exp_out_contains t_st_obs |
| 1041 | ret 122 |
| 1042 | end |
| 1043 | ol = exp_sess_deeper |
| 1044 | if not exp_out_contains t_st_obs |
| 1045 | ret 123 |
| 1046 | end |
| 1047 | if ne exp_sess_level 2 |
| 1048 | ret 124 |
| 1049 | end |
| 1050 | ol = exp_sess_shallower |
| 1051 | if ne exp_sess_level 1 |
| 1052 | ret 125 |
| 1053 | end |
| 1054 | rc = exp_sess_step 2 |
| 1055 | if ne rc EXP_OK |
| 1056 | ret 126 |
| 1057 | end |
| 1058 | if not exp_out_contains t_w_rests1 |
| 1059 | ret 127 |
| 1060 | end |
| 1061 | rc = exp_sess_step 1 |
| 1062 | if ne rc EXP_OK |
| 1063 | ret 128 |
| 1064 | end |
| 1065 | if not exp_out_contains t_w_startpt |
| 1066 | ret 129 |
| 1067 | end |
| 1068 | rc = exp_sess_source 1 |
| 1069 | if ne rc EXP_OK |
| 1070 | ret 130 |
| 1071 | end |
| 1072 | if not exp_out_contains t_w_testnode |
| 1073 | ret 131 |
| 1074 | end |
| 1075 | rc = exp_sess_step 9 |
| 1076 | if ne rc EXP_ERR_STEP_OUT_OF_RANGE |
| 1077 | ret 132 |
| 1078 | end |
| 1079 | ol = exp_sess_technical |
| 1080 | if not exp_out_contains t_w_step1obs |
| 1081 | ret 133 |
| 1082 | end |
| 1083 | ol = exp_sess_simple |
| 1084 | if not exp_out_contains t_w_concl |
| 1085 | ret 134 |
| 1086 | end |
| 1087 | ol = exp_sess_analogy |
| 1088 | if not exp_out_contains t_w_evself |
| 1089 | ret 135 |
| 1090 | end |
| 1091 | ol = exp_sess_uncertainties |
| 1092 | if not exp_out_contains t_w_inferred |
| 1093 | ret 136 |
| 1094 | end |
| 1095 | ol = exp_sess_alternatives |
| 1096 | if not exp_out_contains t_w_noalt |
| 1097 | ret 137 |
| 1098 | end |
| 1099 | dig2 = new uchar 32 0 |
| 1100 | exp_bundle_get_digest dig2 |
| 1101 | if not t_bytes_eq dig1 dig2 |
| 1102 | ret 138 |
| 1103 | end |
| 1104 | ret 0 |
| 1105 | end |
| 1106 | |
| 1107 | note 17. rsi_cycle_explains_in_causal_order (tests/rsi_and_cli.rs) |
| 1108 | fn t_build_rsi_fixture to void |
| 1109 | exp_g_reset_prod r_prod |
| 1110 | nid = exp_g_add_node r_id_kv EXP_KD_CAP_METRIC EXP_ST_DIRECT_OBS r_st_kv |
| 1111 | exp_g_set_source_sa nid r_sys r_art_cap |
| 1112 | exp_g_set_source_ref nid r_ref_kv |
| 1113 | m0 = exp_g_add_meas nid r_m_lat r_m_4200 |
| 1114 | exp_g_meas_set_unit m0 r_m_us |
| 1115 | nid = exp_g_add_node r_id_mk EXP_KD_CAP_METRIC EXP_ST_DIRECT_OBS r_st_mk |
| 1116 | exp_g_set_source_sa nid r_sys r_art_cap |
| 1117 | nid = exp_g_add_node r_id_rg EXP_KD_CAP_METRIC EXP_ST_DIRECT_OBS r_st_rg |
| 1118 | exp_g_set_source_sa nid r_sys r_art_cap |
| 1119 | nid = exp_g_add_node r_id_sp EXP_KD_CAP_METRIC EXP_ST_DIRECT_OBS r_st_sp |
| 1120 | exp_g_set_source_sa nid r_sys r_art_cap |
| 1121 | nid = exp_g_add_node r_id_sc EXP_KD_CAP_METRIC EXP_ST_DIRECT_OBS r_st_sc |
| 1122 | exp_g_set_source_sa nid r_sys r_art_cap |
| 1123 | nid = exp_g_add_node r_id_bn EXP_KD_CAP_ANALYSIS EXP_ST_INFERENCE r_st_bn |
| 1124 | exp_g_set_source_sa nid r_sys r_art_bn |
| 1125 | exp_g_add_edge nid r_id_kv EXP_REL_SUPPORTED_BY |
| 1126 | exp_g_add_edge nid r_id_mk EXP_REL_SUPPORTED_BY |
| 1127 | exp_g_add_edge nid r_id_rg EXP_REL_SUPPORTED_BY |
| 1128 | exp_g_add_edge nid r_id_sp EXP_REL_SUPPORTED_BY |
| 1129 | exp_g_add_edge nid r_id_sc EXP_REL_SUPPORTED_BY |
| 1130 | nid = exp_g_add_node r_id_a1 EXP_KD_ALTERNATIVE EXP_ST_INFERENCE r_st_a1 |
| 1131 | exp_g_set_source_sa nid r_sys r_art_bn |
| 1132 | exp_g_add_edge nid r_id_bn EXP_REL_ALTERNATIVE_TO |
| 1133 | nid = exp_g_add_node r_id_a2 EXP_KD_ALTERNATIVE EXP_ST_INFERENCE r_st_a2 |
| 1134 | exp_g_set_source_sa nid r_sys r_art_bn |
| 1135 | exp_g_add_edge nid r_id_bn EXP_REL_ALTERNATIVE_TO |
| 1136 | nid = exp_g_add_node r_id_a3 EXP_KD_ALTERNATIVE EXP_ST_INFERENCE r_st_a3 |
| 1137 | exp_g_set_source_sa nid r_sys r_art_bn |
| 1138 | exp_g_add_edge nid r_id_bn EXP_REL_ALTERNATIVE_TO |
| 1139 | nid = exp_g_add_node r_id_hy EXP_KD_HYPOTHESIS EXP_ST_HYPOTHESIS r_st_hy |
| 1140 | exp_g_set_source_sa nid r_sys r_art_hc |
| 1141 | exp_g_set_source_ref nid r_ref_hy |
| 1142 | exp_g_set_conf nid 850 r_cbas |
| 1143 | exp_g_add_edge nid r_id_bn EXP_REL_REFERENCES |
| 1144 | nid = exp_g_add_node r_id_pr EXP_KD_PREDICTION EXP_ST_HYPOTHESIS r_st_pr |
| 1145 | exp_g_set_source_sa nid r_sys r_art_hc |
| 1146 | exp_g_add_edge nid r_id_hy EXP_REL_PART_OF |
| 1147 | nid = exp_g_add_node r_id_fa EXP_KD_FALSIFICATION EXP_ST_HYPOTHESIS r_st_fa |
| 1148 | exp_g_set_source_sa nid r_sys r_art_hc |
| 1149 | exp_g_add_edge nid r_id_hy EXP_REL_PART_OF |
| 1150 | nid = exp_g_add_node r_id_di EXP_KD_DIAGNOSTIC EXP_ST_INFERENCE r_st_di |
| 1151 | exp_g_set_source_sa nid r_sys r_art_dc |
| 1152 | exp_g_add_edge nid r_id_hy EXP_REL_SUPPORTED_BY |
| 1153 | nid = exp_g_add_node r_id_re EXP_KD_EVAL_RECEIPT EXP_ST_VERIFIED_FACT r_st_re |
| 1154 | exp_g_set_source_sa nid r_sys r_art_er |
| 1155 | exp_g_set_source_ref nid r_ref_ca |
| 1156 | exp_g_set_digest nid r_dig_re |
| 1157 | nid = exp_g_add_node r_id_rs EXP_KD_EVAL_RECEIPT EXP_ST_UNCLASSIFIED r_st_rs |
| 1158 | exp_g_set_source_sa nid r_sys r_art_er |
| 1159 | exp_g_add_edge nid r_id_re EXP_REL_PART_OF |
| 1160 | exp_g_add_note nid r_note_rs |
| 1161 | nid = exp_g_add_node r_id_ra EXP_KD_PROMOTION_STATE EXP_ST_DIRECT_OBS r_st_ra |
| 1162 | exp_g_set_source_sa nid r_sys r_art_rr |
| 1163 | exp_g_add_edge nid r_id_re EXP_REL_SUPPORTED_BY |
| 1164 | nid = exp_g_add_node r_id_co EXP_KD_CONCLUSION EXP_ST_INFERENCE r_st_co |
| 1165 | exp_g_set_source_sa nid r_sys r_art_rc |
| 1166 | exp_g_set_source_ref nid r_ref_cy |
| 1167 | exp_g_add_edge nid r_id_di EXP_REL_SUPPORTED_BY |
| 1168 | exp_g_add_edge nid r_id_pr EXP_REL_SUPPORTED_BY |
| 1169 | exp_g_add_edge nid r_id_fa EXP_REL_SUPPORTED_BY |
| 1170 | exp_g_add_edge nid r_id_re EXP_REL_SUPPORTED_BY |
| 1171 | exp_g_add_edge nid r_id_rs EXP_REL_SUPPORTED_BY |
| 1172 | exp_g_add_edge nid r_id_ra EXP_REL_SUPPORTED_BY |
| 1173 | exp_g_add_missing nid r_miss_e r_miss_r |
| 1174 | exp_g_add_note nid r_note_co |
| 1175 | end |
| 1176 | |
| 1177 | fn t_first_role_pos rl ulong to ulong |
| 1178 | sc = get exp_b_scnt 0 |
| 1179 | for i ulong sc bound 320 |
| 1180 | if eq get exp_bs_role i rl |
| 1181 | ret i |
| 1182 | end |
| 1183 | end |
| 1184 | ret EXP_NONE |
| 1185 | end |
| 1186 | |
| 1187 | fn t_17_check_roles ci ulong to int |
| 1188 | prev = t_first_role_pos EXP_ROLE_OBSERVED |
| 1189 | cur = t_first_role_pos EXP_ROLE_ANALYSIS |
| 1190 | if ge prev cur |
| 1191 | ret 141 |
| 1192 | end |
| 1193 | prev = cur |
| 1194 | cur = t_first_role_pos EXP_ROLE_HYPOTHESIS |
| 1195 | if ge prev cur |
| 1196 | ret 141 |
| 1197 | end |
| 1198 | prev = cur |
| 1199 | cur = t_first_role_pos EXP_ROLE_PREDICTION |
| 1200 | if ge prev cur |
| 1201 | ret 142 |
| 1202 | end |
| 1203 | prev = cur |
| 1204 | cur = t_first_role_pos EXP_ROLE_FALSIFICATION |
| 1205 | if ge prev cur |
| 1206 | ret 142 |
| 1207 | end |
| 1208 | prev = cur |
| 1209 | cur = t_first_role_pos EXP_ROLE_EVALUATION |
| 1210 | if ge prev cur |
| 1211 | ret 143 |
| 1212 | end |
| 1213 | prev = cur |
| 1214 | cur = t_first_role_pos EXP_ROLE_DECISION |
| 1215 | if ge prev cur |
| 1216 | ret 143 |
| 1217 | end |
| 1218 | cur = t_first_role_pos EXP_ROLE_CONCLUSION |
| 1219 | if ne cur ci |
| 1220 | ret 144 |
| 1221 | end |
| 1222 | ret 0 |
| 1223 | end |
| 1224 | |
| 1225 | fn t_17_rsi_cycle to int |
| 1226 | t_build_rsi_fixture |
| 1227 | rc = exp_build_bundle r_id_co EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 1228 | if ne rc EXP_OK |
| 1229 | ret 139 |
| 1230 | end |
| 1231 | ci = sub get exp_b_concl_step 0 1 |
| 1232 | if not exp_bundle_step_eq add ci 1 r_id_co |
| 1233 | ret 140 |
| 1234 | end |
| 1235 | rc = t_17_check_roles ci |
| 1236 | if ne rc 0 |
| 1237 | ret rc |
| 1238 | end |
| 1239 | if not exp_bundle_has_unc EXP_UK_MISSING_LINK |
| 1240 | ret 145 |
| 1241 | end |
| 1242 | if not exp_bundle_has_unc EXP_UK_HYPO_NOT_FALSIFIED |
| 1243 | ret 146 |
| 1244 | end |
| 1245 | if not exp_bundle_has_unc EXP_UK_UNKNOWN |
| 1246 | ret 147 |
| 1247 | end |
| 1248 | if ne get exp_ba_cnt 0 3 |
| 1249 | ret 148 |
| 1250 | end |
| 1251 | st = exp_bundle_find_step r_id_re |
| 1252 | if eq st 0 |
| 1253 | ret 149 |
| 1254 | end |
| 1255 | if ne get exp_gn_status get exp_bs_nid sub st 1 EXP_ST_VERIFIED_FACT |
| 1256 | ret 150 |
| 1257 | end |
| 1258 | st = exp_bundle_find_step r_id_rs |
| 1259 | if eq st 0 |
| 1260 | ret 151 |
| 1261 | end |
| 1262 | if ne get exp_gn_status get exp_bs_nid sub st 1 EXP_ST_UNCLASSIFIED |
| 1263 | ret 152 |
| 1264 | end |
| 1265 | st = exp_bundle_find_step r_id_hy |
| 1266 | if eq st 0 |
| 1267 | ret 153 |
| 1268 | end |
| 1269 | if ne get exp_gn_status get exp_bs_nid sub st 1 EXP_ST_HYPOTHESIS |
| 1270 | ret 154 |
| 1271 | end |
| 1272 | ol = exp_render EXP_MODE_STEP_BY_STEP EXP_LEVEL_DEFAULT EXP_AUD_OPERATOR |
| 1273 | if not exp_out_contains exp_rh_0 |
| 1274 | ret 155 |
| 1275 | end |
| 1276 | if not exp_out_contains exp_rh_1 |
| 1277 | ret 156 |
| 1278 | end |
| 1279 | if not exp_out_contains exp_rh_2 |
| 1280 | ret 157 |
| 1281 | end |
| 1282 | if not exp_out_contains exp_rh_3 |
| 1283 | ret 158 |
| 1284 | end |
| 1285 | if not exp_out_contains exp_rh_4 |
| 1286 | ret 159 |
| 1287 | end |
| 1288 | if not exp_out_contains exp_rh_5 |
| 1289 | ret 160 |
| 1290 | end |
| 1291 | if not exp_out_contains exp_rh_6 |
| 1292 | ret 161 |
| 1293 | end |
| 1294 | if not exp_out_contains exp_rh_7 |
| 1295 | ret 162 |
| 1296 | end |
| 1297 | d1 = new uchar 32 0 |
| 1298 | exp_bundle_get_digest d1 |
| 1299 | t_build_rsi_fixture |
| 1300 | rc = exp_build_bundle r_id_co EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 1301 | if ne rc EXP_OK |
| 1302 | ret 163 |
| 1303 | end |
| 1304 | d2 = new uchar 32 0 |
| 1305 | exp_bundle_get_digest d2 |
| 1306 | if not t_bytes_eq d1 d2 |
| 1307 | ret 164 |
| 1308 | end |
| 1309 | ret 0 |
| 1310 | end |
| 1311 | |
| 1312 | note 18. contradiction_disclosed_in_both_directions |
| 1313 | fn t_18_bidirectional_contra to int |
| 1314 | exp_g_reset_prod t_prod |
| 1315 | n0 = t_add_simple_node t_bi_obs EXP_KD_CORTEX_RECORD EXP_ST_DIRECT_OBS |
| 1316 | n1 = t_add_simple_node t_bi_riv EXP_KD_CORTEX_RECORD EXP_ST_DIRECT_OBS |
| 1317 | exp_g_add_edge n1 t_bi_obs EXP_REL_CONTRADICTS |
| 1318 | n2 = t_add_simple_node t_bi_clm EXP_KD_CORTEX_RECORD EXP_ST_INFERENCE |
| 1319 | exp_g_add_edge n2 t_bi_obs EXP_REL_SUPPORTED_BY |
| 1320 | exp_g_add_edge n2 t_bi_oth EXP_REL_CONTRADICTS |
| 1321 | n3 = t_add_simple_node t_bi_oth EXP_KD_CORTEX_RECORD EXP_ST_DIRECT_OBS |
| 1322 | rc = exp_build_bundle t_bi_clm EXP_DEFAULT_MAX_DEPTH EXP_DEFAULT_MAX_NODES |
| 1323 | if ne rc EXP_OK |
| 1324 | ret 165 |
| 1325 | end |
| 1326 | has_riv = false |
| 1327 | has_clm = false |
| 1328 | cc = get exp_bc_cnt 0 |
| 1329 | for i ulong cc bound 128 |
| 1330 | nid = get exp_bc_nid i |
| 1331 | if exp_str_eq_view get exp_gn_id_off nid get exp_gn_id_len nid t_bi_riv |
| 1332 | has_riv = true |
| 1333 | end |
| 1334 | if exp_str_eq_view get exp_gn_id_off nid get exp_gn_id_len nid t_bi_clm |
| 1335 | has_clm = true |
| 1336 | end |
| 1337 | end |
| 1338 | if not has_riv |
| 1339 | ret 166 |
| 1340 | end |
| 1341 | if not has_clm |
| 1342 | ret 167 |
| 1343 | end |
| 1344 | if ne exp_bundle_find_step t_bi_riv 0 |
| 1345 | ret 168 |
| 1346 | end |
| 1347 | if ne exp_bundle_find_step t_bi_oth 0 |
| 1348 | ret 169 |
| 1349 | end |
| 1350 | ret 0 |
| 1351 | end |
| 1352 | |
| 1353 | note 19 & 20. CLI helpers + tampered bundle digest rejection |
| 1354 | fn t_19_20_cli_and_tamper to int |
| 1355 | if ne exp_cli_exit_code EXP_OK 0 |
| 1356 | ret 170 |
| 1357 | end |
| 1358 | if ne exp_cli_exit_code EXP_ERR_TARGET_NOT_FOUND 15 |
| 1359 | ret 171 |
| 1360 | end |
| 1361 | if ne exp_parse_audience t_cli_aud_se EXP_AUD_SYSTEMS_ENG |
| 1362 | ret 172 |
| 1363 | end |
| 1364 | if ne exp_parse_audience t_cli_aud_bad EXP_AUD_INVALID |
| 1365 | ret 173 |
| 1366 | end |
| 1367 | cid1 = new uchar 16 0 |
| 1368 | cid2 = new uchar 16 0 |
| 1369 | if ne exp_parse_cortex_id t_cli_hex_raw cid1 EXP_OK |
| 1370 | ret 174 |
| 1371 | end |
| 1372 | if ne exp_parse_cortex_id t_cli_hex_pfx cid2 EXP_OK |
| 1373 | ret 175 |
| 1374 | end |
| 1375 | if not t_bytes_eq cid1 cid2 |
| 1376 | ret 176 |
| 1377 | end |
| 1378 | if ne get cid1 0 1 |
| 1379 | ret 177 |
| 1380 | end |
| 1381 | if ne get cid1 15 16 |
| 1382 | ret 178 |
| 1383 | end |
| 1384 | if ne exp_parse_cortex_id t_cli_hex_bad cid1 EXP_ERR_TARGET_NOT_FOUND |
| 1385 | ret 179 |
| 1386 | end |
| 1387 | note Tampering a built bundle breaks digest verification |
| 1388 | if not exp_bundle_verify_digest |
| 1389 | ret 180 |
| 1390 | end |
| 1391 | put exp_bs_depth 0 add get exp_bs_depth 0 1 |
| 1392 | if exp_bundle_verify_digest |
| 1393 | ret 181 |
| 1394 | end |
| 1395 | ret 0 |
| 1396 | end |
| 1397 | |
| 1398 | fn main to int |
| 1399 | rc = t_01_linear_chain |
| 1400 | if ne rc 0 |
| 1401 | ret rc |
| 1402 | end |
| 1403 | rc = t_02_branching_determinism |
| 1404 | if ne rc 0 |
| 1405 | ret rc |
| 1406 | end |
| 1407 | rc = t_03_shared_parent |
| 1408 | if ne rc 0 |
| 1409 | ret rc |
| 1410 | end |
| 1411 | rc = t_04_cycle_direct |
| 1412 | if ne rc 0 |
| 1413 | ret rc |
| 1414 | end |
| 1415 | rc = t_05_cycle_cortex |
| 1416 | if ne rc 0 |
| 1417 | ret rc |
| 1418 | end |
| 1419 | rc = t_06_07_missing_and_unsupported |
| 1420 | if ne rc 0 |
| 1421 | ret rc |
| 1422 | end |
| 1423 | rc = t_08_contradiction |
| 1424 | if ne rc 0 |
| 1425 | ret rc |
| 1426 | end |
| 1427 | rc = t_09_hypothesis_never_fact |
| 1428 | if ne rc 0 |
| 1429 | ret rc |
| 1430 | end |
| 1431 | rc = t_10_11_branch_scope_and_tokens |
| 1432 | if ne rc 0 |
| 1433 | ret rc |
| 1434 | end |
| 1435 | rc = t_12_analogy_isolated |
| 1436 | if ne rc 0 |
| 1437 | ret rc |
| 1438 | end |
| 1439 | rc = t_13_identical_roundtrip |
| 1440 | if ne rc 0 |
| 1441 | ret rc |
| 1442 | end |
| 1443 | rc = t_14_limits_bound_walk |
| 1444 | if ne rc 0 |
| 1445 | ret rc |
| 1446 | end |
| 1447 | rc = t_15_malformed_inputs |
| 1448 | if ne rc 0 |
| 1449 | ret rc |
| 1450 | end |
| 1451 | rc = t_16_clarification_session |
| 1452 | if ne rc 0 |
| 1453 | ret rc |
| 1454 | end |
| 1455 | rc = t_17_rsi_cycle |
| 1456 | if ne rc 0 |
| 1457 | ret rc |
| 1458 | end |
| 1459 | rc = t_18_bidirectional_contra |
| 1460 | if ne rc 0 |
| 1461 | ret rc |
| 1462 | end |
| 1463 | rc = t_19_20_cli_and_tamper |
| 1464 | if ne rc 0 |
| 1465 | ret rc |
| 1466 | end |
| 1467 | ret 0 |
| 1468 | end |