aien
aien-dev/aien
Brought by drakestapleton
aien / src / goal_microjobs / shadow.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-or-later |
| 2 | note NL5 synthetic shadow proposal producer, not an executor or authority. |
| 3 | note Opt-in exact CLI: --private-local-shadow A|B|C SCENARIO |
| 4 | note stdout is the existing Allen-local plan+journal adapter, stderr metadata. |
| 5 | note No input traces, filesystem writes, sockets, models, Cortex or effect calls. |
| 6 | note C is unavailable pending NL3 CONTENT binding and NL4 consumer integration. |
| 7 | note Unsupported C proposals fall back to B before admission, never to effects. |
| 8 | text opt "--private-local-shadow" |
| 9 | text meta "NL5 HOST_ONLY synthetic Allen identity=9 owner=7 effects=0\n" |
| 10 | text cf "C NOT_RUN adapter_unavailable fallback=B\n" |
| 11 | text af "A deterministic_text_stub tokens=NOT_RUN\n" |
| 12 | text bf "B deterministic_typed_stub tokens=0\n" |
| 13 | global Arg uchar 64 |
| 14 | global Buf uchar 16384 |
| 15 | global Pos ulong 1 |
| 16 | global Seq ulong 1 |
| 17 | global Val ulong 12 |
| 18 | global Gen ulong 12 |
| 19 | global Ref ulong 24 |
| 20 | global Cfg ulong 3 |
| 21 | global Msg uchar 128 |
| 22 | global Mp ulong 2 |
| 23 | global Bytes ulong 1 |
| 24 | |
| 25 | fn out v ulong to void |
| 26 | if gt v 9 |
| 27 | out div v 10 |
| 28 | end |
| 29 | put Buf get Pos 0 uchar add rem v 10 48 |
| 30 | put Pos 0 add get Pos 0 1 |
| 31 | end |
| 32 | fn word v ulong to void |
| 33 | out v |
| 34 | put Buf get Pos 0 32 |
| 35 | put Pos 0 add get Pos 0 1 |
| 36 | end |
| 37 | fn line to void |
| 38 | put Buf sub get Pos 0 1 10 |
| 39 | end |
| 40 | fn flushout to int |
| 41 | p = ulong 0 |
| 42 | while lt p get Pos 0 bound 16384 |
| 43 | w = write 1 Buf p sub get Pos 0 p |
| 44 | if le w 0 |
| 45 | ret 74 |
| 46 | end |
| 47 | p = add p ulong w |
| 48 | end |
| 49 | ret 0 |
| 50 | end |
| 51 | fn args to bool |
| 52 | if ne argcnt 4 |
| 53 | ret false |
| 54 | end |
| 55 | n = argread 1 Arg 0 64 |
| 56 | if ne n long len opt |
| 57 | ret false |
| 58 | end |
| 59 | for i ulong len opt |
| 60 | if ne get Arg i get opt i |
| 61 | ret false |
| 62 | end |
| 63 | end |
| 64 | n = argread 2 Arg 0 64 |
| 65 | if ne n 1 |
| 66 | ret false |
| 67 | end |
| 68 | a = get Arg 0 |
| 69 | if or lt a 65 gt a 67 |
| 70 | ret false |
| 71 | end |
| 72 | put Cfg 0 ulong a |
| 73 | n = argread 3 Arg 0 64 |
| 74 | if ne n 1 |
| 75 | ret false |
| 76 | end |
| 77 | s = get Arg 0 |
| 78 | if or lt s 48 gt s 57 |
| 79 | ret false |
| 80 | end |
| 81 | put Cfg 1 sub ulong s 48 |
| 82 | ret true |
| 83 | end |
| 84 | fn headerout to void |
| 85 | word 1 |
| 86 | word 1 |
| 87 | word 19 |
| 88 | word 0 |
| 89 | word 0 |
| 90 | word 0 |
| 91 | word 7 |
| 92 | word 9 |
| 93 | word 0 |
| 94 | word 12 |
| 95 | word 11 |
| 96 | word 32 |
| 97 | if eq get Cfg 1 7 |
| 98 | word 0 |
| 99 | else |
| 100 | word 8 |
| 101 | end |
| 102 | word 640 |
| 103 | word 64 |
| 104 | word 16 |
| 105 | word 1200 |
| 106 | line |
| 107 | end |
| 108 | fn nodeout i ulong to void |
| 109 | word 2 |
| 110 | word i |
| 111 | if eq i 4 |
| 112 | word 2 |
| 113 | word 1 |
| 114 | word 1 |
| 115 | word 1 |
| 116 | else |
| 117 | word 1 |
| 118 | word 1 |
| 119 | word 0 |
| 120 | word 0 |
| 121 | end |
| 122 | word 0 |
| 123 | if eq i 4 |
| 124 | word 64 |
| 125 | word 16 |
| 126 | word 1 |
| 127 | word 1 |
| 128 | else |
| 129 | word 0 |
| 130 | word 0 |
| 131 | word 0 |
| 132 | word 0 |
| 133 | end |
| 134 | word 1 |
| 135 | word 5 |
| 136 | word 2 |
| 137 | word 2 |
| 138 | word 7 |
| 139 | word 100 |
| 140 | if eq i 12 |
| 141 | word 0 |
| 142 | else |
| 143 | word 1 |
| 144 | end |
| 145 | word i |
| 146 | word 0 |
| 147 | word 0 |
| 148 | word 0 |
| 149 | if eq i 5 |
| 150 | word 4 |
| 151 | word 1 |
| 152 | word 2 |
| 153 | word 3 |
| 154 | word 4 |
| 155 | else |
| 156 | if gt i 5 |
| 157 | word 1 |
| 158 | word sub i 1 |
| 159 | else |
| 160 | word 0 |
| 161 | end |
| 162 | end |
| 163 | line |
| 164 | end |
| 165 | fn emit kind ulong node ulong who ulong value ulong verdict ulong to void |
| 166 | put Seq 0 add get Seq 0 1 |
| 167 | word 3 |
| 168 | word get Seq 0 |
| 169 | word kind |
| 170 | word node |
| 171 | if or eq kind 7 or eq kind 6 eq kind 5 |
| 172 | word 0 |
| 173 | else |
| 174 | word 1 |
| 175 | end |
| 176 | word get Gen sub node 1 |
| 177 | word who |
| 178 | word verdict |
| 179 | word value |
| 180 | word 0 |
| 181 | word 0 |
| 182 | word 0 |
| 183 | word 0 |
| 184 | word 0 |
| 185 | line |
| 186 | end |
| 187 | note Two deterministic specialist transports; all operands are serialized and decoded. |
| 188 | note No language model or continuous latent transport is represented by these stubs. |
| 189 | fn mdigit v ulong to void |
| 190 | if gt v 9 |
| 191 | mdigit div v 10 |
| 192 | end |
| 193 | put Msg get Mp 0 uchar add rem v 10 48 |
| 194 | put Mp 0 add get Mp 0 1 |
| 195 | end |
| 196 | fn mread to ulong |
| 197 | v = ulong 0 |
| 198 | while lt get Mp 1 get Mp 0 bound 128 |
| 199 | c = get Msg get Mp 1 |
| 200 | put Mp 1 add get Mp 1 1 |
| 201 | if eq c 32 |
| 202 | ret v |
| 203 | end |
| 204 | if or lt c 48 gt c 57 |
| 205 | exit 66 |
| 206 | end |
| 207 | v = add mul v 10 sub ulong c 48 |
| 208 | end |
| 209 | ret v |
| 210 | end |
| 211 | fn mstore off ulong v ulong to void |
| 212 | for j ulong 8 |
| 213 | put Msg add off j uchar and shr v mul j 8 255 |
| 214 | end |
| 215 | end |
| 216 | fn mload off ulong to ulong |
| 217 | v = ulong 0 |
| 218 | for j ulong 8 |
| 219 | v = or v shl ulong get Msg add off j mul j 8 |
| 220 | end |
| 221 | ret v |
| 222 | end |
| 223 | fn specialist x ulong y ulong to ulong |
| 224 | note Shared work budget counts every specialist attempt, including fallback. |
| 225 | if ge get Cfg 2 32 |
| 226 | exit 68 |
| 227 | end |
| 228 | put Cfg 2 add get Cfg 2 1 |
| 229 | if or gt x 100 gt y 100 |
| 230 | exit 66 |
| 231 | end |
| 232 | if eq get Cfg 0 65 |
| 233 | put Msg 0 97 |
| 234 | put Msg 1 100 |
| 235 | put Msg 2 100 |
| 236 | put Msg 3 32 |
| 237 | put Mp 0 4 |
| 238 | mdigit x |
| 239 | put Msg get Mp 0 32 |
| 240 | put Mp 0 add get Mp 0 1 |
| 241 | mdigit y |
| 242 | put Bytes 0 add get Bytes 0 get Mp 0 |
| 243 | if or ne get Msg 0 97 or ne get Msg 1 100 ne get Msg 2 100 |
| 244 | exit 66 |
| 245 | end |
| 246 | put Mp 1 4 |
| 247 | a = mread |
| 248 | b = mread |
| 249 | ret add a b |
| 250 | end |
| 251 | mstore 0 1 |
| 252 | mstore 8 x |
| 253 | mstore 16 y |
| 254 | put Bytes 0 add get Bytes 0 24 |
| 255 | if ne mload 0 1 |
| 256 | exit 66 |
| 257 | end |
| 258 | ret add mload 8 mload 16 |
| 259 | end |
| 260 | fn compute i ulong corr bool to ulong |
| 261 | if eq i 1 |
| 262 | ret specialist 3 5 |
| 263 | end |
| 264 | if eq i 2 |
| 265 | ret specialist 4 7 |
| 266 | end |
| 267 | if eq i 3 |
| 268 | if corr |
| 269 | ret specialist 6 9 |
| 270 | end |
| 271 | ret specialist 6 8 |
| 272 | end |
| 273 | if eq i 4 |
| 274 | ret specialist 9 2 |
| 275 | end |
| 276 | if eq i 5 |
| 277 | v = add get Val 0 get Val 1 |
| 278 | v = add v get Val 2 |
| 279 | ret specialist v get Val 3 |
| 280 | end |
| 281 | ret specialist get Val sub i 2 sub i 5 |
| 282 | end |
| 283 | fn errbyte c uchar to void |
| 284 | put Arg 0 c |
| 285 | w = write 2 Arg 0 1 |
| 286 | if ne w 1 |
| 287 | exit 74 |
| 288 | end |
| 289 | end |
| 290 | fn errnum v ulong to void |
| 291 | if gt v 9 |
| 292 | errnum div v 10 |
| 293 | end |
| 294 | errbyte uchar add rem v 10 48 |
| 295 | end |
| 296 | fn hop i ulong bytes ulong to void |
| 297 | errnum 201 |
| 298 | errbyte 32 |
| 299 | errnum i |
| 300 | errbyte 32 |
| 301 | errnum get Cfg 0 |
| 302 | errbyte 32 |
| 303 | errnum bytes |
| 304 | errbyte 10 |
| 305 | end |
| 306 | fn runnode i ulong corr bool to bool |
| 307 | before = get Bytes 0 |
| 308 | v = compute i corr |
| 309 | if and eq get Cfg 1 4 eq i 4 |
| 310 | v = add v 1 |
| 311 | if eq get Cfg 0 67 |
| 312 | note Deterministic bad-proposal stub, not a learned latent message. |
| 313 | note Independent oracle must refuse it before typed fallback recomputation. |
| 314 | if eq v get Ref 3 |
| 315 | exit 67 |
| 316 | end |
| 317 | errnum 202 |
| 318 | errbyte 32 |
| 319 | errnum 4 |
| 320 | errbyte 10 |
| 321 | v = compute i corr |
| 322 | end |
| 323 | end |
| 324 | hop i sub get Bytes 0 before |
| 325 | emit 1 i 20 0 0 |
| 326 | emit 2 i 20 v 0 |
| 327 | idx = sub i 1 |
| 328 | if corr |
| 329 | idx = add idx 12 |
| 330 | end |
| 331 | if ne v get Ref idx |
| 332 | emit 3 i 5 v 0 |
| 333 | ret false |
| 334 | end |
| 335 | emit 3 i 5 v 1 |
| 336 | put Val sub i 1 v |
| 337 | ret true |
| 338 | end |
| 339 | fn main to int |
| 340 | if eq args false |
| 341 | ret 64 |
| 342 | end |
| 343 | w = write 2 meta 0 len meta |
| 344 | if ne w long len meta |
| 345 | ret 74 |
| 346 | end |
| 347 | if eq get Cfg 0 67 |
| 348 | w = write 2 cf 0 len cf |
| 349 | if ne w long len cf |
| 350 | ret 74 |
| 351 | end |
| 352 | else |
| 353 | if eq get Cfg 0 65 |
| 354 | w = write 2 af 0 len af |
| 355 | if ne w long len af |
| 356 | ret 74 |
| 357 | end |
| 358 | else |
| 359 | w = write 2 bf 0 len bf |
| 360 | if ne w long len bf |
| 361 | ret 74 |
| 362 | end |
| 363 | end |
| 364 | end |
| 365 | oracle |
| 366 | headerout |
| 367 | for j ulong 12 |
| 368 | nodeout add j 1 |
| 369 | put Gen j 1 |
| 370 | end |
| 371 | if eq get Cfg 1 5 |
| 372 | emit 1 5 20 0 0 |
| 373 | ret flushout |
| 374 | end |
| 375 | if eq get Cfg 1 2 |
| 376 | emit 5 5 7 0 0 |
| 377 | ret flushout |
| 378 | end |
| 379 | for j ulong 11 |
| 380 | if eq runnode add j 1 false false |
| 381 | r = flushout |
| 382 | if ne r 0 |
| 383 | ret r |
| 384 | end |
| 385 | ret 65 |
| 386 | end |
| 387 | if and eq get Cfg 1 3 eq j 3 |
| 388 | ret flushout |
| 389 | end |
| 390 | end |
| 391 | emit 7 12 9 0 0 |
| 392 | if eq get Cfg 1 1 |
| 393 | emit 6 3 7 99 0 |
| 394 | put Gen 2 2 |
| 395 | for j ulong 7 |
| 396 | put Gen add j 4 2 |
| 397 | end |
| 398 | ok = runnode 3 true |
| 399 | if eq ok false |
| 400 | ret 65 |
| 401 | end |
| 402 | for j ulong 7 |
| 403 | ok = runnode add j 5 true |
| 404 | if eq ok false |
| 405 | ret 65 |
| 406 | end |
| 407 | end |
| 408 | end |
| 409 | if eq get Cfg 1 6 |
| 410 | emit 6 3 20 99 0 |
| 411 | end |
| 412 | if eq get Cfg 1 8 |
| 413 | emit 8 11 9 777 0 |
| 414 | end |
| 415 | if eq get Cfg 1 9 |
| 416 | emit 2 11 20 get Val 10 0 |
| 417 | end |
| 418 | ret flushout |
| 419 | end |