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 / train / aien-train / native / neuralese / nl1r-task / boundary.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note Verification adapter, not a receiver or authority. Reuses unchanged NL4 functions. |
| 3 | note Compose after host-proposal.om lines1..144, before pinned h/proposal/v/sha2. |
| 4 | note CLI context-file predicted-bits trusted-target-bits task abstain frame-output-fd. |
| 5 | note Trusted target is evaluator-owned and never flows back to sender or receiver. |
| 6 | global BARG uchar 5 |
| 7 | global BCFG ulong 5 |
| 8 | fn barg ix ulong to ulong |
| 9 | n = argread ix BARG 0 5 |
| 10 | if or le n 0 gt n 4 |
| 11 | exit 80 |
| 12 | end |
| 13 | v = ulong 0 |
| 14 | for i ulong ulong n |
| 15 | c = get BARG i |
| 16 | if or lt c 48 gt c 57 |
| 17 | exit 80 |
| 18 | end |
| 19 | v = add mul v 10 ulong sub c 48 |
| 20 | end |
| 21 | ret v |
| 22 | end |
| 23 | fn bargs to int |
| 24 | put BCFG 0 barg 2 |
| 25 | put BCFG 1 barg 3 |
| 26 | put BCFG 2 barg 4 |
| 27 | put BCFG 3 barg 6 |
| 28 | put BCFG 4 barg 5 |
| 29 | if or gt get BCFG 0 15 gt get BCFG 1 15 |
| 30 | ret 80 |
| 31 | end |
| 32 | if or gt get BCFG 2 2 gt get BCFG 4 1 |
| 33 | ret 80 |
| 34 | end |
| 35 | if or lt get BCFG 3 3 gt get BCFG 3 1023 |
| 36 | ret 80 |
| 37 | end |
| 38 | if eq get BCFG 2 1 |
| 39 | if or gt get BCFG 0 1 gt get BCFG 1 1 |
| 40 | ret 80 |
| 41 | end |
| 42 | end |
| 43 | if eq get BCFG 4 1 |
| 44 | ret 2 |
| 45 | end |
| 46 | if eq get BCFG 2 1 |
| 47 | put BCFG 2 1 |
| 48 | else |
| 49 | put BCFG 2 2 |
| 50 | end |
| 51 | ret 0 |
| 52 | end |
| 53 | fn bheader frame edit uchar 1056 ctx view uchar 1025 to void |
| 54 | for i ulong 1024 |
| 55 | put frame i get ctx i |
| 56 | end |
| 57 | note Fresh one-shot SYNTHETIC sequence, checked with existing lastseq0 rule. |
| 58 | for i ulong 8 |
| 59 | put frame add 80 i uchar 0 |
| 60 | end |
| 61 | put frame 87 uchar 1 |
| 62 | end |
| 63 | fn bexpect e edit uint 16 value uint to void |
| 64 | put e 0 3 |
| 65 | put e 1 value |
| 66 | put e 3 1 |
| 67 | put e 4 1 |
| 68 | put e 5 1 |
| 69 | put e 6 4 |
| 70 | put e 7 1 |
| 71 | put e 9 1 |
| 72 | end |
| 73 | fn bframe frame edit uchar 1056 value ulong to int |
| 74 | f = new f64 4 0.0f64 |
| 75 | put f 0 1.0f64 |
| 76 | put f 1 1.0f64 |
| 77 | put f 2 f64 and value 1 |
| 78 | put f 3 f64 and shr value 1 1 |
| 79 | wire = new uchar 32 0 |
| 80 | rc = nlencode f wire |
| 81 | if ne rc 0 |
| 82 | ret rc |
| 83 | end |
| 84 | for i ulong 32 |
| 85 | put frame add 1024 i get wire i |
| 86 | end |
| 87 | state = new ulong 40 0 |
| 88 | sha256_init state |
| 89 | sha256_update state part frame 0 992 |
| 90 | sha256_update state part frame 1024 32 |
| 91 | sha256_final state part frame 992 32 |
| 92 | note Raw actual envelope bytes are audit output, not an execution receipt. |
| 93 | z = write int get BCFG 3 frame 0 1056 |
| 94 | if ne z 1056 |
| 95 | ret 81 |
| 96 | end |
| 97 | ret 0 |
| 98 | end |
| 99 | fn bverify frame edit uchar 1056 ctx view uchar 1025 p edit uint 16 to int |
| 100 | value = and shr get BCFG 0 mul get BCFG 4 2 3 |
| 101 | rc = bframe frame value |
| 102 | if ne rc 0 |
| 103 | ret rc |
| 104 | end |
| 105 | now = lpbe64 ctx 64 |
| 106 | rc = lpvalid frame part ctx 0 1024 now 0 |
| 107 | if ne rc 0 |
| 108 | ret rc |
| 109 | end |
| 110 | rc = nlproposal frame p |
| 111 | if ne rc 0 |
| 112 | ret rc |
| 113 | end |
| 114 | e = new uint 16 0 |
| 115 | sh = mul get BCFG 4 2 |
| 116 | want = and shr get BCFG 1 sh 3 |
| 117 | bexpect e uint want |
| 118 | if not nlmatch p e |
| 119 | ret 49 |
| 120 | end |
| 121 | ret 0 |
| 122 | end |
| 123 | fn main to int |
| 124 | if ne argcnt 7 |
| 125 | ret nlfail 80 |
| 126 | end |
| 127 | rc = bargs |
| 128 | if ne rc 0 |
| 129 | ret nlfail rc |
| 130 | end |
| 131 | ctx = new uchar 1025 0 |
| 132 | frame = new uchar 1056 0 |
| 133 | props = new uint 32 0 |
| 134 | rc = nlcontext ctx |
| 135 | if ne rc 0 |
| 136 | ret nlfail rc |
| 137 | end |
| 138 | bheader frame ctx |
| 139 | p = new uint 16 0 |
| 140 | q = new uint 16 0 |
| 141 | for chunk ulong get BCFG 2 |
| 142 | put BCFG 4 chunk |
| 143 | for i ulong 16 |
| 144 | put p i uint 0 |
| 145 | end |
| 146 | rc = bverify frame ctx p |
| 147 | if ne rc 0 |
| 148 | ret nlfail rc |
| 149 | end |
| 150 | for i ulong 16 |
| 151 | put props add mul chunk 16 i get p i |
| 152 | end |
| 153 | end |
| 154 | note Every chunk must verify BEFORE any pure execution or execution receipt. |
| 155 | for chunk ulong get BCFG 2 |
| 156 | for i ulong 16 |
| 157 | put q i get props add mul chunk 16 i |
| 158 | end |
| 159 | nlexec q |
| 160 | end |
| 161 | ret 0 |
| 162 | end |