aien-train
AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished.
Brought by drakestapleton
aien-train / tools / verified_examples / sources.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-or-later |
| 2 | note Composed after examples.om with its main renamed to vxmodelmain by the gate/build command. |
| 3 | text vsprep "prep" |
| 4 | text vstaskdir "/tasks/" |
| 5 | text vsrefs "references" |
| 6 | text vsharness "harness" |
| 7 | text vstask "task" |
| 8 | text vsref "/reference." |
| 9 | text vsstmt "/statement.txt" |
| 10 | text vsslash "/" |
| 11 | text vssource ",\"source\":" |
| 12 | text vstaskkey "{\"task\":" |
| 13 | text vsprogram ",\"program\":" |
| 14 | text vscontract ",\"referee_contract\":" |
| 15 | text vscompiler ",\"omc_sha256\":" |
| 16 | text vsdigest ",\"task_set_sha256\":" |
| 17 | text vsreceipt ",\"referee_output_sha256\":" |
| 18 | text vsend "}\n" |
| 19 | text vsarchive "archive" |
| 20 | text vsformat "--format=tar" |
| 21 | text vshead "HEAD" |
| 22 | text vsgit "/usr/bin/git" |
| 23 | text vsc "-C" |
| 24 | text vsdiff "diff" |
| 25 | text vsquiet "--quiet" |
| 26 | text vsgate "/examples/gate.sh" |
| 27 | text vsbash "/usr/bin/bash" |
| 28 | text vstar "/harness.tar" |
| 29 | text vsreceiptfile "/harness-receipt.txt" |
| 30 | text vsreceiptbad "/harness-receipt.err" |
| 31 | text vsexpect ".expect" |
| 32 | text vssuffix ".om" |
| 33 | text vspass "PASS" |
| 34 | text vsexit "(exit" |
| 35 | text vslicence ",\"licence_position\":" |
| 36 | text vsreflic "reference source retains its original licence; verification is not a relicensing grant" |
| 37 | global vscompilerhash uchar 64 |
| 38 | global vstaskhash uchar 64 |
| 39 | fn vscapturehash k ulong which ulong to void |
| 40 | h = new uchar 64 0 |
| 41 | vxhash k h |
| 42 | for i ulong 64 |
| 43 | if eq which 0 |
| 44 | put vscompilerhash i get h i |
| 45 | else |
| 46 | put vstaskhash i get h i |
| 47 | end |
| 48 | end |
| 49 | end |
| 50 | fn vswritehash which ulong to void |
| 51 | h = new uchar 64 0 |
| 52 | for i ulong 64 |
| 53 | if eq which 0 |
| 54 | put h i get vscompilerhash i |
| 55 | else |
| 56 | put h i get vstaskhash i |
| 57 | end |
| 58 | end |
| 59 | vxquote h |
| 60 | end |
| 61 | fn vssetup to void |
| 62 | for i ulong 5 |
| 63 | vxarg add i 1 i |
| 64 | end |
| 65 | vxenvinit |
| 66 | r = makedir vxp mul ulong 4 4096 get vxplen 4 448 |
| 67 | if ne r 0 |
| 68 | vxfail 3 |
| 69 | end |
| 70 | vxcopy 5 1 |
| 71 | vxadd 5 vxdriver |
| 72 | vxcopy 14 4 |
| 73 | vxadd 14 vxt56 |
| 74 | vxcopy 15 4 |
| 75 | vxadd 15 vxt57 |
| 76 | fd = vxopen 14 193 |
| 77 | put vxion 1 ulong fd |
| 78 | vscapturehash 2 0 |
| 79 | end |
| 80 | fn vsrecord name view uchar * rh view uchar 64 to void |
| 81 | b = new uchar 8 0 |
| 82 | vxout vstaskkey |
| 83 | vxquote name |
| 84 | vxout vssource |
| 85 | if eq get vxcounts 10 1 |
| 86 | vxquote vxrefsource |
| 87 | else |
| 88 | vxquote vxharsource |
| 89 | end |
| 90 | vxout vscontract |
| 91 | vxqfile 12 |
| 92 | vxout vsprogram |
| 93 | vxqfile 10 |
| 94 | vxout vscompiler |
| 95 | vswritehash 0 |
| 96 | vxout vsdigest |
| 97 | vswritehash 1 |
| 98 | vxout vsreceipt |
| 99 | vxquote rh |
| 100 | vxout vxt23 |
| 101 | if eq get vxcounts 10 1 |
| 102 | for i ulong get vxcounts 7 |
| 103 | put b i get vxp add mul ulong 11 4096 i |
| 104 | end |
| 105 | vxquote part b 0 get vxcounts 7 |
| 106 | else |
| 107 | vxquote vxt39 |
| 108 | end |
| 109 | vxout vxt26 |
| 110 | vxout vxarrnone |
| 111 | vxout vsend |
| 112 | end |
| 113 | fn vsrefone lang view uchar * task view uchar 16 idx ulong to void |
| 114 | h = new uchar 64 0 |
| 115 | l = new uchar 8 0 |
| 116 | for i ulong len lang |
| 117 | put l i get lang i |
| 118 | end |
| 119 | put vxcounts 7 len lang |
| 120 | vxset 11 lang |
| 121 | vxcopy 10 1 |
| 122 | vxadd 10 vstaskdir |
| 123 | vxadd 10 part task 0 6 |
| 124 | vxadd 10 vsref |
| 125 | vxadd 10 lang |
| 126 | vxcopy 12 1 |
| 127 | vxadd 12 vstaskdir |
| 128 | vxadd 12 part task 0 6 |
| 129 | vxadd 12 vsstmt |
| 130 | vxcopy 13 4 |
| 131 | vxadd 13 vxt46 |
| 132 | vxdecimal 13 get vxcounts 9 |
| 133 | put vxcounts 9 add get vxcounts 9 1 |
| 134 | r = vxreferee l task |
| 135 | if ne r 0 |
| 136 | vxfail 17 |
| 137 | end |
| 138 | vxcopy 6 13 |
| 139 | vxadd 6 vxevalout |
| 140 | vxhash 6 h |
| 141 | vsrecord part task 0 6 h |
| 142 | put vxcounts idx add get vxcounts idx 1 |
| 143 | put vxcounts 4 add get vxcounts 4 1 |
| 144 | end |
| 145 | fn vsreferences to void |
| 146 | b = new uchar 16 0 |
| 147 | h = new uchar 64 0 |
| 148 | vxchecktasks |
| 149 | vxhash 2 h |
| 150 | if not vxequal h vxsha |
| 151 | vxfail 10 |
| 152 | end |
| 153 | for i ulong 64 |
| 154 | put vstaskhash i get vxtasks i |
| 155 | end |
| 156 | put vxcounts 10 1 |
| 157 | for n ulong 20 |
| 158 | for i ulong 4 |
| 159 | put b i get vstask i |
| 160 | end |
| 161 | v = add n 1 |
| 162 | put b 4 uchar add div v 10 48 |
| 163 | put b 5 uchar add rem v 10 48 |
| 164 | vsrefone vxt39 b 0 |
| 165 | vsrefone vxt36 b 1 |
| 166 | vsrefone vxt37 b 2 |
| 167 | vsrefone vxt38 b 3 |
| 168 | end |
| 169 | end |
| 170 | fn vsgitcmd cmd view uchar * tail view uchar * to ulong |
| 171 | vxset 6 vxnull |
| 172 | vxcopy 7 4 |
| 173 | vxadd 7 vstar |
| 174 | vxcopy 8 4 |
| 175 | vxadd 8 vsreceiptbad |
| 176 | vxpkinit |
| 177 | vxpk vsgit |
| 178 | vxpk vsc |
| 179 | vxpkpath 1 |
| 180 | vxpk cmd |
| 181 | vxpk tail |
| 182 | vxpk vshead |
| 183 | ret vxspawn |
| 184 | end |
| 185 | fn vsharone line view uchar * to void |
| 186 | name = new uchar 4096 0 |
| 187 | h = new uchar 64 0 |
| 188 | n = vxword line 1 name |
| 189 | if lt n 4 |
| 190 | vxfail 2 |
| 191 | end |
| 192 | vxcopy 10 1 |
| 193 | vxadd 10 vsslash |
| 194 | vxadd 10 part name 0 n |
| 195 | vxadd 10 vssuffix |
| 196 | vxcopy 12 1 |
| 197 | vxadd 12 vsslash |
| 198 | vxadd 12 part name 0 n |
| 199 | vxadd 12 vsexpect |
| 200 | vxcopy 6 4 |
| 201 | vxadd 6 vsreceiptfile |
| 202 | vxhash 6 h |
| 203 | vsrecord part name 0 n h |
| 204 | put vxcounts 0 add get vxcounts 0 1 |
| 205 | put vxcounts 4 add get vxcounts 4 1 |
| 206 | end |
| 207 | fn vsharvest to void |
| 208 | b = new uchar 4096 0 |
| 209 | a = new uchar 4096 0 |
| 210 | put vxcounts 10 2 |
| 211 | r = vsgitcmd vsdiff vsquiet |
| 212 | if ne r 0 |
| 213 | vxfail 18 |
| 214 | end |
| 215 | r = vsgitcmd vsarchive vsformat |
| 216 | if ne r 0 |
| 217 | vxfail 18 |
| 218 | end |
| 219 | vxcopy 6 4 |
| 220 | vxadd 6 vstar |
| 221 | vscapturehash 6 1 |
| 222 | vxset 6 vxnull |
| 223 | vxcopy 7 4 |
| 224 | vxadd 7 vsreceiptfile |
| 225 | vxcopy 8 4 |
| 226 | vxadd 8 vsreceiptbad |
| 227 | vxcopy 5 1 |
| 228 | vxadd 5 vsgate |
| 229 | vxpkinit |
| 230 | vxpk vsbash |
| 231 | vxpkpath 5 |
| 232 | vxpkpath 2 |
| 233 | r = vxspawn |
| 234 | if ne r 0 |
| 235 | vxfail 19 |
| 236 | end |
| 237 | fd = vxopen 7 0 |
| 238 | while true bound 9223372036854775807 |
| 239 | n = vxline fd b |
| 240 | if eq n 0 |
| 241 | break |
| 242 | end |
| 243 | z = vxword part b 0 n 0 a |
| 244 | if vxequal part a 0 z vspass |
| 245 | z = vxword part b 0 n 2 a |
| 246 | if vxequal part a 0 z vsexit |
| 247 | vsharone part b 0 n |
| 248 | end |
| 249 | end |
| 250 | end |
| 251 | vxclose fd |
| 252 | end |
| 253 | fn vsmanifest to void |
| 254 | h = new uchar 64 0 |
| 255 | vxflush |
| 256 | vxclose int get vxion 1 |
| 257 | vxhash 14 h |
| 258 | fd = vxopen 15 193 |
| 259 | put vxion 1 ulong fd |
| 260 | vxout vxt48 |
| 261 | vxoutnum get vxcounts 4 |
| 262 | vxout vxt49 |
| 263 | vxoutnum get vxcounts 0 |
| 264 | vxout vxt50 |
| 265 | vxoutnum get vxcounts 1 |
| 266 | vxout vxt51 |
| 267 | vxoutnum get vxcounts 2 |
| 268 | vxout vxt52 |
| 269 | vxoutnum get vxcounts 3 |
| 270 | vxout vxt53 |
| 271 | vxoutnum get vxcounts 5 |
| 272 | vxout vxt54 |
| 273 | vxquote h |
| 274 | vxout vscompiler |
| 275 | vswritehash 0 |
| 276 | vxout vsdigest |
| 277 | vswritehash 1 |
| 278 | vxout vssource |
| 279 | if eq get vxcounts 10 1 |
| 280 | vxquote vxrefsource |
| 281 | else |
| 282 | vxquote vxharsource |
| 283 | end |
| 284 | vxout vslicence |
| 285 | vxquote vsreflic |
| 286 | vxout vsend |
| 287 | vxflush |
| 288 | vxclose fd |
| 289 | end |
| 290 | fn main to int |
| 291 | b = new uchar 4096 0 |
| 292 | if lt argcnt 7 |
| 293 | vxfail 2 |
| 294 | end |
| 295 | n = argread 1 b 0 len b |
| 296 | if lt n 0 |
| 297 | vxfail 2 |
| 298 | end |
| 299 | if vxequal part b 0 ulong n vsprep |
| 300 | put vxshift 0 1 |
| 301 | ret vxmodelmain |
| 302 | end |
| 303 | if vxequal part b 0 ulong n vsrefs |
| 304 | vssetup |
| 305 | vsreferences |
| 306 | vsmanifest |
| 307 | ret 0 |
| 308 | end |
| 309 | if vxequal part b 0 ulong n vsharness |
| 310 | vssetup |
| 311 | vsharvest |
| 312 | vsmanifest |
| 313 | ret 0 |
| 314 | end |
| 315 | ret vxmodelmain |
| 316 | end |