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 / tests / arboris / online-core.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note Host verification gate for the shared zero-global Arboris online core |
| 3 | note (`om/arboris_online.om`), covering looped-core wrap, multi-stream |
| 4 | note cross-batch expert deduplication + sum-over-paths ranking, and negative controls. |
| 5 | |
| 6 | fn ik_set_cfg cfg edit ulong 6 to void |
| 7 | put cfg 0 24 |
| 8 | put cfg 1 128 |
| 9 | put cfg 2 8 |
| 10 | put cfg 3 16 |
| 11 | put cfg 4 17 |
| 12 | put cfg 5 6 |
| 13 | end |
| 14 | |
| 15 | fn ds_set_cfg cfg edit ulong 6 to void |
| 16 | put cfg 0 4 |
| 17 | put cfg 1 384 |
| 18 | put cfg 2 6 |
| 19 | put cfg 3 16 |
| 20 | put cfg 4 AO_NONE |
| 21 | put cfg 5 AO_NONE |
| 22 | end |
| 23 | |
| 24 | fn fill_ids_offset buf edit uint * base uint to void |
| 25 | for k ulong len buf bound 64 |
| 26 | put buf k add base uint k |
| 27 | end |
| 28 | end |
| 29 | |
| 30 | fn ck_wrap_train cfg view ulong 6 edges edit uint * prev_state edit uint * to int |
| 31 | ids_a = new uint 8 0 |
| 32 | ids_b = new uint 8 0 |
| 33 | ids_c = new uint 8 0 |
| 34 | fill_ids_offset ids_a 10 |
| 35 | fill_ids_offset ids_b 20 |
| 36 | fill_ids_offset ids_c 30 |
| 37 | if not ao_stage_cur cfg prev_state ids_a |
| 38 | ret 6 |
| 39 | end |
| 40 | if not ao_observe cfg edges prev_state 0 |
| 41 | ret 7 |
| 42 | end |
| 43 | if not ao_stage_cur cfg prev_state ids_b |
| 44 | ret 8 |
| 45 | end |
| 46 | if not ao_observe cfg edges prev_state 1 |
| 47 | ret 9 |
| 48 | end |
| 49 | if not ao_reset_token cfg prev_state |
| 50 | ret 10 |
| 51 | end |
| 52 | if not ao_stage_cur cfg prev_state ids_a |
| 53 | ret 11 |
| 54 | end |
| 55 | if not ao_observe cfg edges prev_state 17 |
| 56 | ret 12 |
| 57 | end |
| 58 | if not ao_stage_cur cfg prev_state ids_c |
| 59 | ret 13 |
| 60 | end |
| 61 | if not ao_observe cfg edges prev_state 6 |
| 62 | ret 14 |
| 63 | end |
| 64 | if not ao_stage_cur cfg prev_state ids_b |
| 65 | ret 15 |
| 66 | end |
| 67 | if not ao_observe cfg edges prev_state 6 |
| 68 | ret 16 |
| 69 | end |
| 70 | ret 0 |
| 71 | end |
| 72 | |
| 73 | fn ck_wrap_score cfg view ulong 6 edges edit uint * to int |
| 74 | ids_a = new uint 8 0 |
| 75 | resident = new long 3072 -1 |
| 76 | scores_work = new ulong 135 0 |
| 77 | recs = new uint 8 0 |
| 78 | fill_ids_offset ids_a 10 |
| 79 | for k ulong 6 |
| 80 | put scores_work k get cfg k |
| 81 | end |
| 82 | put scores_work 6 23 |
| 83 | if not ao_score_batch edges ids_a scores_work |
| 84 | ret 17 |
| 85 | end |
| 86 | if ne get scores_work add ulong 7 30 8 |
| 87 | ret 18 |
| 88 | end |
| 89 | put scores_work 6 17 |
| 90 | if not ao_score_batch edges ids_a scores_work |
| 91 | ret 19 |
| 92 | end |
| 93 | if ne get scores_work add ulong 7 30 0 |
| 94 | ret 20 |
| 95 | end |
| 96 | put scores_work 6 23 |
| 97 | if not ao_score_batch edges ids_a scores_work |
| 98 | ret 21 |
| 99 | end |
| 100 | put resident add mul ulong 6 128 30 0 |
| 101 | if ne ao_mask_resident cfg 6 resident part scores_work 7 128 0 |
| 102 | ret 22 |
| 103 | end |
| 104 | if ne ao_pick_op3 cfg part scores_work 7 128 part recs 0 4 2 |
| 105 | ret 23 |
| 106 | end |
| 107 | if or ne get recs 0 3 ne get recs 1 31 |
| 108 | ret 24 |
| 109 | end |
| 110 | if or ne get recs 2 3 ne get recs 3 32 |
| 111 | ret 25 |
| 112 | end |
| 113 | ret 0 |
| 114 | end |
| 115 | |
| 116 | fn ck_single_and_loop to int |
| 117 | cfg = new ulong 6 0 |
| 118 | edges = new uint 49152 0 |
| 119 | prev_state = new uint 17 0 |
| 120 | ik_set_cfg cfg |
| 121 | if or not ao_cfg_valid cfg ne ao_table_words cfg 49152 |
| 122 | ret 1 |
| 123 | end |
| 124 | if not ao_reset_all cfg edges prev_state |
| 125 | ret 2 |
| 126 | end |
| 127 | if ne ao_resolve_trans cfg 17 6 23 |
| 128 | ret 3 |
| 129 | end |
| 130 | if ne ao_resolve_trans cfg 17 18 17 |
| 131 | ret 4 |
| 132 | end |
| 133 | if ne ao_resolve_trans cfg 23 0 24 |
| 134 | ret 5 |
| 135 | end |
| 136 | rc = ck_wrap_train cfg edges prev_state |
| 137 | if ne rc 0 |
| 138 | ret rc |
| 139 | end |
| 140 | rc = ck_wrap_score cfg edges |
| 141 | if ne rc 0 |
| 142 | ret rc |
| 143 | end |
| 144 | note Saturation halving test at AO_DECAY_AT (60000 -> 30000) |
| 145 | row_base = mul add mul ulong 6 128 4 16 |
| 146 | put edges row_base ao_pack 59999 77 |
| 147 | ao_bump_edge cfg edges 6 4 77 |
| 148 | if or ne ulong shr get edges row_base 16 30000 ne ulong and get edges row_base 65535 77 |
| 149 | ret 26 |
| 150 | end |
| 151 | ret 0 |
| 152 | end |
| 153 | |
| 154 | fn ck_ms_seed_edges cfg view ulong 6 edges edit uint * to void |
| 155 | ao_bump_edge cfg edges 1 10 100 |
| 156 | ao_bump_edge cfg edges 1 10 100 |
| 157 | ao_bump_edge cfg edges 1 20 200 |
| 158 | ao_bump_edge cfg edges 1 20 200 |
| 159 | ao_bump_edge cfg edges 1 20 200 |
| 160 | ao_bump_edge cfg edges 1 20 105 |
| 161 | ao_bump_edge cfg edges 1 70 55 |
| 162 | ao_bump_edge cfg edges 1 70 55 |
| 163 | ao_bump_edge cfg edges 1 70 55 |
| 164 | ao_bump_edge cfg edges 1 70 55 |
| 165 | end |
| 166 | |
| 167 | fn ck_ms_fill_batch batch_ids edit uint 24 to void |
| 168 | put batch_ids 0 10 |
| 169 | put batch_ids 1 20 |
| 170 | put batch_ids 2 30 |
| 171 | put batch_ids 6 20 |
| 172 | put batch_ids 7 30 |
| 173 | put batch_ids 8 70 |
| 174 | put batch_ids 12 10 |
| 175 | put batch_ids 13 70 |
| 176 | put batch_ids 14 110 |
| 177 | put batch_ids 18 20 |
| 178 | put batch_ids 19 110 |
| 179 | put batch_ids 20 120 |
| 180 | end |
| 181 | |
| 182 | fn ck_ms_pick cfg view ulong 6 scores_work edit ulong * to int |
| 183 | dummy_res = new long 1 0 |
| 184 | recs = new uint 8 0 |
| 185 | if ne ao_mask_resident cfg 2 part dummy_res 0 0 part scores_work 7 384 0 |
| 186 | ret 48 |
| 187 | end |
| 188 | if ne ao_pick_op3 cfg part scores_work 7 384 recs 4 |
| 189 | ret 49 |
| 190 | end |
| 191 | if or ne get recs 1 55 ne get recs 3 200 |
| 192 | ret 50 |
| 193 | end |
| 194 | if or ne get recs 5 100 ne get recs 7 105 |
| 195 | ret 51 |
| 196 | end |
| 197 | ret 0 |
| 198 | end |
| 199 | |
| 200 | fn ck_ms_rank cfg view ulong 6 edges view uint * dedup_out view uint * n_uniq ulong to int |
| 201 | scores_work = new ulong 391 0 |
| 202 | for k ulong 6 |
| 203 | put scores_work k get cfg k |
| 204 | end |
| 205 | put scores_work 6 1 |
| 206 | if not ao_score_batch edges part dedup_out 0 n_uniq scores_work |
| 207 | ret 47 |
| 208 | end |
| 209 | ret ck_ms_pick cfg scores_work |
| 210 | end |
| 211 | |
| 212 | fn ck_multistream_dedup_and_rank to int |
| 213 | cfg = new ulong 6 0 |
| 214 | edges = new uint 24576 0 |
| 215 | prev_state = new uint 13 0 |
| 216 | batch_ids = new uint 24 0xffffffff |
| 217 | meta = new ulong 4 0 |
| 218 | dedup_out = new uint 72 0 |
| 219 | ds_set_cfg cfg |
| 220 | if or not ao_cfg_valid cfg ne ao_table_words cfg 24576 |
| 221 | ret 40 |
| 222 | end |
| 223 | if not ao_reset_all cfg edges prev_state |
| 224 | ret 41 |
| 225 | end |
| 226 | ck_ms_seed_edges cfg edges |
| 227 | ck_ms_fill_batch batch_ids |
| 228 | put meta 0 384 |
| 229 | put meta 1 4 |
| 230 | put meta 2 6 |
| 231 | n_uniq = ao_dedup_batch meta batch_ids dedup_out |
| 232 | if ne n_uniq 6 |
| 233 | ret 42 |
| 234 | end |
| 235 | if or ne get dedup_out 0 10 ne get dedup_out 1 20 |
| 236 | ret 43 |
| 237 | end |
| 238 | if or ne get dedup_out 2 30 ne get dedup_out 3 70 |
| 239 | ret 44 |
| 240 | end |
| 241 | if or ne get dedup_out 4 110 ne get dedup_out 5 120 |
| 242 | ret 44 |
| 243 | end |
| 244 | if or ne get dedup_out 24 2 ne get dedup_out 25 3 |
| 245 | ret 45 |
| 246 | end |
| 247 | if ne get dedup_out 27 2 |
| 248 | ret 45 |
| 249 | end |
| 250 | if or ne get dedup_out 66 1 ne get dedup_out 51 uint AO_NONE |
| 251 | ret 46 |
| 252 | end |
| 253 | ret ck_ms_rank cfg edges dedup_out ulong n_uniq |
| 254 | end |
| 255 | |
| 256 | fn ck_neg_cfg to int |
| 257 | bad_cfg = new ulong 6 0 |
| 258 | cfg = new ulong 6 0 |
| 259 | short_state = new uint 8 0 |
| 260 | edges = new uint 49152 0 |
| 261 | ik_set_cfg bad_cfg |
| 262 | put bad_cfg 0 0 |
| 263 | if or ao_cfg_valid bad_cfg ne ao_table_words bad_cfg 0 |
| 264 | ret 70 |
| 265 | end |
| 266 | ik_set_cfg bad_cfg |
| 267 | put bad_cfg 1 65536 |
| 268 | if ao_cfg_valid bad_cfg |
| 269 | ret 71 |
| 270 | end |
| 271 | ik_set_cfg bad_cfg |
| 272 | put bad_cfg 2 200 |
| 273 | if ao_cfg_valid bad_cfg |
| 274 | ret 72 |
| 275 | end |
| 276 | ik_set_cfg bad_cfg |
| 277 | put bad_cfg 4 AO_NONE |
| 278 | if ao_cfg_valid bad_cfg |
| 279 | ret 73 |
| 280 | end |
| 281 | ik_set_cfg cfg |
| 282 | if ao_reset_token cfg short_state |
| 283 | ret 74 |
| 284 | end |
| 285 | if ao_reset_all bad_cfg edges short_state |
| 286 | ret 75 |
| 287 | end |
| 288 | ret 0 |
| 289 | end |
| 290 | |
| 291 | fn ck_neg_buffers to int |
| 292 | cfg = new ulong 6 0 |
| 293 | meta = new ulong 4 0 |
| 294 | batch_ids = new uint 8 0 |
| 295 | dedup_out = new uint 24 777 |
| 296 | scores = new ulong 128 0 |
| 297 | odd_recs = new uint 3 0 |
| 298 | short_res = new long 128 -1 |
| 299 | ik_set_cfg cfg |
| 300 | put meta 0 384 |
| 301 | put meta 1 2 |
| 302 | put meta 2 4 |
| 303 | put batch_ids 5 384 |
| 304 | if ne ao_dedup_batch meta batch_ids dedup_out -1 |
| 305 | ret 76 |
| 306 | end |
| 307 | if ne get dedup_out 0 777 |
| 308 | ret 77 |
| 309 | end |
| 310 | put batch_ids 5 12 |
| 311 | if ne ao_dedup_batch meta batch_ids part dedup_out 0 23 -1 |
| 312 | ret 78 |
| 313 | end |
| 314 | if ne ao_pick_op3 cfg scores odd_recs -1 |
| 315 | ret 79 |
| 316 | end |
| 317 | if ne ao_mask_resident cfg 1 short_res scores -1 |
| 318 | ret 80 |
| 319 | end |
| 320 | if ne ao_mask_resident cfg 24 short_res scores -1 |
| 321 | ret 81 |
| 322 | end |
| 323 | ret 0 |
| 324 | end |
| 325 | |
| 326 | fn main to int |
| 327 | rc = ck_single_and_loop |
| 328 | if ne rc 0 |
| 329 | ret rc |
| 330 | end |
| 331 | rc = ck_multistream_dedup_and_rank |
| 332 | if ne rc 0 |
| 333 | ret rc |
| 334 | end |
| 335 | rc = ck_neg_cfg |
| 336 | if ne rc 0 |
| 337 | ret rc |
| 338 | end |
| 339 | ret ck_neg_buffers |
| 340 | end |