aien-architecture-mv
Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.
Brought by drakestapleton
aien-architecture-mv / tools / ecosystem303 / cli.om
| 1 | note EC303 stream checker. Input is bounded unsigned decimal tokens, ASCII whitespace. |
| 2 | global Input uchar 65536 |
| 3 | global Position ulong 1 |
| 4 | global Size ulong 1 |
| 5 | global ParseErr ulong 1 |
| 6 | text ok "EC303 STRUCTURE_OK; evidence authenticity and release approval NOT_ESTABLISHED\n" |
| 7 | text bad "EC303 REFUSED\n" |
| 8 | |
| 9 | fn ecspace c uchar to bool |
| 10 | ret or eq c 32 or eq c 9 or eq c 10 eq c 13 |
| 11 | end |
| 12 | |
| 13 | fn ecnumber to ulong |
| 14 | p = get Position 0 |
| 15 | skip = true |
| 16 | while and lt p get Size 0 skip |
| 17 | if ecspace get Input p |
| 18 | p = add p 1 |
| 19 | else |
| 20 | skip = false |
| 21 | end |
| 22 | end |
| 23 | v = ulong 0 |
| 24 | digits = ulong 0 |
| 25 | more = true |
| 26 | while and lt p get Size 0 more |
| 27 | c = get Input p |
| 28 | if ecspace c |
| 29 | more = false |
| 30 | else |
| 31 | if or lt c 48 gt c 57 |
| 32 | put ParseErr 0 1 |
| 33 | ret 0 |
| 34 | end |
| 35 | d = sub ulong c 48 |
| 36 | if or gt v 1844674407370955161 and eq v 1844674407370955161 gt d 5 |
| 37 | put ParseErr 0 1 |
| 38 | ret 0 |
| 39 | end |
| 40 | v = add mul v 10 d |
| 41 | p = add p 1 |
| 42 | digits = add digits 1 |
| 43 | if gt digits 20 |
| 44 | put ParseErr 0 1 |
| 45 | ret 0 |
| 46 | end |
| 47 | end |
| 48 | end |
| 49 | put Position 0 p |
| 50 | if eq digits 0 |
| 51 | put ParseErr 0 1 |
| 52 | end |
| 53 | ret v |
| 54 | end |
| 55 | |
| 56 | fn main to int |
| 57 | reading = true |
| 58 | while reading |
| 59 | n = get Size 0 |
| 60 | if eq n 65536 |
| 61 | w = write 2 bad 0 len bad |
| 62 | ret 20 |
| 63 | end |
| 64 | r = read 0 Input n sub 65536 n |
| 65 | if lt r 0 |
| 66 | ret 21 |
| 67 | end |
| 68 | if eq r 0 |
| 69 | reading = false |
| 70 | else |
| 71 | put Size 0 add n ulong r |
| 72 | end |
| 73 | end |
| 74 | magic = ecnumber |
| 75 | version = ecnumber |
| 76 | count = ecnumber |
| 77 | for i ulong 800 |
| 78 | put EC i ecnumber |
| 79 | end |
| 80 | p = get Position 0 |
| 81 | while lt p get Size 0 |
| 82 | if eq ecspace get Input p false |
| 83 | put ParseErr 0 1 |
| 84 | end |
| 85 | p = add p 1 |
| 86 | end |
| 87 | if or ne magic 303 ne get ParseErr 0 0 |
| 88 | w = write 2 bad 0 len bad |
| 89 | ret 22 |
| 90 | end |
| 91 | s = ecvalidate version count |
| 92 | if ne s 0 |
| 93 | w = write 2 bad 0 len bad |
| 94 | ret int add 30 s |
| 95 | end |
| 96 | w = write 1 ok 0 len ok |
| 97 | if le w 0 |
| 98 | ret 23 |
| 99 | end |
| 100 | if ne ulong w len ok |
| 101 | ret 23 |
| 102 | end |
| 103 | ret 0 |
| 104 | end |