Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sovereign-intelligence/blob/main/compiler/links.om # sovereign-intelligence Front door to Drake Stapleton's sovereign stack. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `sovereign-intelligence / compiler / links.om` 558 lines ยท 12329 bytes Raw Blame History 1 om2 2 note compiler/links.om: the link check of sovereign-intelligence, in pure seeded Omega. 3 note 4 note Build with the pinned seeded compiler (compiler/README.md names the pin): 5 note omc < compiler/links.om > links && chmod +x links 6 note Run, from anywhere: 7 note links ROOT 8 note ROOT is a checkout of this repository. links checks two things and writes nothing: 9 note 1. every row of ROOT/repos.tsv, the link table, is a project that is only linked: a 10 note name, a valid Radicle ID ("rad:z" then 27 or 28 base58 characters that decode to a 11 note 20-byte id), a 40-digit head and a tier of core or rest. The withdrawn crypto 12 note projects (any name containing pearl or crypto, in any case, and any RID that starts 13 note rad:z2ft64) are refused; 14 note 2. no new project source is vendored into SI. The entries of ROOT, ROOT/compiler and 15 note ROOT/gpu must each be on the lists below, with the kind named there; .git is 16 note skipped. ROOT may hold the regular files README.md, repos.tsv, CITATION.cff, 17 note LICENSE, .gitignore and build.sh, README.zh-CN.md (the Simplified Chinese README, exactly 18 note that name and only at ROOT; Drake, 2026-11-11, "approved for all"), the untracked build 19 note outputs si, si.sh and links (files) and out (build.sh's directory), and the 20 note directories .claude, compiler, docs, 21 note evidence, gpu, harness, seed, stack, tests and tools: the GitHub line's existing 22 note directories, grandfathered as they are, contents unchecked (Drake, 2026-11-07). 23 note ROOT/gpu may hold only the directory cuda-crack. ROOT/compiler 24 note may hold only the regular files README.md, si.om, gate.om, links.om, inventory.tsv, 25 note order.tsv, state.tsv and gate-`3c37e6fb`.tsv. Any other file, directory or symbolic 26 note link there is refused: a project is linked by its RID, never copied in. 27 note It prints "links: pass" and the row count, exit 0; or "links: " and the first refusal on 28 note stderr, exit 1. Usage errors exit 2. 29 30 text tlk "links: " 31 text tnl "\n" 32 text tusage "usage: links ROOT\n" 33 text tpass "pass: " 34 text tpass2 " link rows, every RID valid; root, compiler/ and gpu/ hold only SI entries\n" 35 text targ "cannot read the command-line argument" 36 text topen "cannot open " 37 text tread "cannot read " 38 text tbig "file over the 1 MiB buffer: " 39 text tlong "path over 4000 bytes: " 40 text thdr "repos.tsv header is not name TAB rid TAB head TAB tier TAB description: " 41 text tcols "repos.tsv line needs 5 tab-separated fields: " 42 text tbname "bad project name (letters, digits, . _ - only): " 43 text tbrid "RID is not rad:z then 27 or 28 base58 characters of a 20-byte id: " 44 text tcrypt "withdrawn crypto project is never linked: " 45 text tbhead "head is not a 40-digit lowercase hex commit: " 46 text tbtier "tier is not core or rest: " 47 text tnone "repos.tsv lists no project" 48 text tvend "not an SI file; project source lives on Radicle, never in SI: " 49 text trepos "/repos.tsv" 50 text tcomp "/compiler" 51 text tgpu "/gpu" 52 text hdr "name\trid\thead\ttier\tdescription" 53 text tradz "rad:z" 54 text tbad "rad:z2ft64" 55 text tpearl "pearl" 56 text tcrypto "crypto" 57 text tcore "core" 58 text trest "rest" 59 text b58 "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" 60 text tdot "." 61 text tdotdot ".." 62 text tgit ".git" 63 text tcdir "compiler" 64 text a1 "README.md" 65 text a2 "repos.tsv" 66 text a3 "CITATION.cff" 67 text a4 "LICENSE" 68 text a5 ".gitignore" 69 text a6 "si" 70 text a7 "si.sh" 71 text a8 "links" 72 text a9 "build.sh" 73 text a10 "README.zh-CN.md" 74 text a11 "layers.tsv" 75 text d1 ".claude" 76 text d2 "docs" 77 text d3 "evidence" 78 text d4 "gpu" 79 text d5 "harness" 80 text d6 "seed" 81 text d7 "stack" 82 text d8 "tests" 83 text d9 "tools" 84 text g1 "cuda-crack" 85 text tout "out" 86 text c1 "si.om" 87 text c2 "gate.om" 88 text c3 "links.om" 89 text c4 "inventory.tsv" 90 text c5 "order.tsv" 91 text c6 "state.tsv" 92 text c7 "gate-`3c37e6fb`.tsv" 93 text c8 "rebuild.om" 94 95 note src: repos.tsv; pb: the path being checked; rt: ROOT; db: getdents64 records; sb: stat 96 global src uchar `1048576` 97 global pb uchar 4096 98 global pbn ulong 1 99 global rt uchar 4096 100 global rtn ulong 1 101 global db uchar 32768 102 global sb uchar 128 103 note bn: a base58 RID decoded big-endian into 21 bytes; byte 0 must stay 0 104 global bn uchar 21 105 106 note die: "links: " m, then n bytes of src from o (at most 200), on stderr; exit 1 107 fn die m view uchar * o ulong n ulong to void 108 k = n 109 if gt k 200 110 k = 200 111 end 112 w = write 2 tlk 0 len tlk 113 w = write 2 m 0 len m 114 if gt k 0 115 w = write 2 src o k 116 end 117 w = write 2 tnl 0 len tnl 118 exit 1 119 end 120 121 note dief: "links: " m and the path pb on stderr; exit 1 122 fn dief m view uchar * to void 123 w = write 2 tlk 0 len tlk 124 w = write 2 m 0 len m 125 w = write 2 pb 0 get pbn 0 126 w = write 2 tnl 0 len tnl 127 exit 1 128 end 129 130 note proot: pb becomes ROOT 131 fn proot to void 132 n = get rtn 0 133 for i ulong n 134 put pb i get rt i 135 end 136 put pbn 0 n 137 end 138 139 note padd: append a text to pb 140 fn padd t view uchar * to void 141 p = get pbn 0 142 n = len t 143 if gt add p n 4000 144 dief tlong 145 end 146 for i ulong n 147 put pb add p i get t i 148 end 149 put pbn 0 add p n 150 end 151 152 note eqt: do the n bytes of src at o equal the text t 153 fn eqt o ulong n ulong t view uchar * to bool 154 if ne n len t 155 ret false 156 end 157 for i ulong n 158 if ne get src add o i get t i 159 ret false 160 end 161 end 162 ret true 163 end 164 165 note eqd: do the n bytes of db at o equal the text t 166 fn eqd o ulong n ulong t view uchar * to bool 167 if ne n len t 168 ret false 169 end 170 for i ulong n 171 if ne get db add o i get t i 172 ret false 173 end 174 end 175 ret true 176 end 177 178 fn isaln c uchar to bool 179 ret or or and ge c 48 le c 57 and ge c 65 le c 90 and ge c 97 le c 122 180 end 181 182 note okname: 1..64 bytes of letters, digits, dot, dash, underscore; not ".", "..", or a leading dash 183 fn okname o ulong n ulong to bool 184 if or eq n 0 gt n 64 185 ret false 186 end 187 if eq get src o 45 188 ret false 189 end 190 for i ulong n 191 c = get src add o i 192 if not or isaln c or eq c 46 or eq c 45 eq c 95 193 ret false 194 end 195 end 196 if eqt o n tdot 197 ret false 198 end 199 ret not eqt o n tdotdot 200 end 201 202 note b58v: the base58 value of c, or 58 when c is not a base58 character 203 fn b58v c uchar to ulong 204 for k ulong 58 205 if eq c get b58 k 206 ret k 207 end 208 end 209 ret 58 210 end 211 212 note okrid: "rad:z" then 27 or 28 base58 characters whose value fits in 20 bytes 213 fn okrid o ulong n ulong to bool 214 if or lt n 32 gt n 33 215 ret false 216 end 217 if not eqt o 5 tradz 218 ret false 219 end 220 for j ulong 21 221 put bn j 0 222 end 223 for i ulong sub n 5 224 v = b58v get src add add o 5 i 225 if eq v 58 226 ret false 227 end 228 cy = v 229 for j ulong 21 230 q = sub 20 j 231 x = add mul ulong get bn q 58 cy 232 put bn q uchar and x 255 233 cy = shr x 8 234 end 235 if ne cy 0 236 ret false 237 end 238 end 239 ret eq get bn 0 0 240 end 241 242 note okhex: exactly 40 lowercase hex digits 243 fn okhex o ulong n ulong to bool 244 if ne n 40 245 ret false 246 end 247 for i ulong n 248 c = get src add o i 249 if not or and ge c 48 le c 57 and ge c 97 le c 102 250 ret false 251 end 252 end 253 ret true 254 end 255 256 note lowc: byte i of src, an ASCII capital folded to lowercase 257 fn lowc i ulong to ulong 258 c = ulong get src i 259 if and ge c 65 le c 90 260 ret add c 32 261 end 262 ret c 263 end 264 265 note atci: do the bytes of src at o equal the lowercase text t, ignoring ASCII case 266 fn atci o ulong t view uchar * to bool 267 for i ulong len t 268 if ne lowc add o i ulong get t i 269 ret false 270 end 271 end 272 ret true 273 end 274 275 note hasci: does [o, o+n) of src contain the lowercase text t, ignoring ASCII case 276 fn hasci o ulong n ulong t view uchar * to bool 277 if lt n len t 278 ret false 279 end 280 for i ulong add sub n len t 1 281 if atci add o i t 282 ret true 283 end 284 end 285 ret false 286 end 287 288 note crypto: is this row a withdrawn crypto project: a name containing pearl or crypto in any 289 note case, or a RID that starts rad:z2ft64 290 fn crypto no ulong nn ulong ro ulong rn ulong to bool 291 if hasci no nn tpearl 292 ret true 293 end 294 if hasci no nn tcrypto 295 ret true 296 end 297 if lt rn len tbad 298 ret false 299 end 300 ret eqt ro len tbad tbad 301 end 302 303 note fo, fe: start and end of the five fields of the current repos.tsv line; fln: field k's length 304 global fo ulong 5 305 global fe ulong 5 306 307 fn fln k ulong to ulong 308 ret sub get fe k get fo k 309 end 310 311 note row: check one repos.tsv line [p, q) 312 fn row p ulong q ulong to void 313 k = ulong 0 314 put fo 0 p 315 c = p 316 while lt c q bound `1048577` 317 if eq get src c 9 318 if ge k 4 319 die tcols p sub q p 320 end 321 put fe k c 322 k = add k 1 323 put fo k add c 1 324 end 325 c = add c 1 326 end 327 if ne k 4 328 die tcols p sub q p 329 end 330 put fe 4 q 331 if not okname get fo 0 fln 0 332 die tbname p sub q p 333 end 334 if crypto get fo 0 fln 0 get fo 1 fln 1 335 die tcrypt p sub q p 336 end 337 if not okrid get fo 1 fln 1 338 die tbrid p sub q p 339 end 340 if not okhex get fo 2 fln 2 341 die tbhead p sub q p 342 end 343 if not or eqt get fo 3 fln 3 tcore eqt get fo 3 fln 3 trest 344 die tbtier p sub q p 345 end 346 end 347 348 note rows: read ROOT/repos.tsv, check its header and every row; the row count 349 fn rows to ulong 350 proot 351 padd trepos 352 fd = fopen pb 0 get pbn 0 524288 0 353 if lt fd 0 354 dief topen 355 end 356 p = ulong 0 357 while lt p `1048576` bound `1048577` 358 k = read int fd src p sub `1048576` p 359 if lt k 0 360 dief tread 361 end 362 if eq k 0 363 break 364 end 365 p = add p ulong k 366 end 367 c = fclose int fd 368 if ge p `1048576` 369 dief tbig 370 end 371 e = p 372 q = ulong 0 373 while lt q e bound `1048577` 374 if eq get src q 10 375 break 376 end 377 q = add q 1 378 end 379 if not eqt 0 q hdr 380 die thdr 0 q 381 end 382 nr = ulong 0 383 s = add q 1 384 while lt s e bound `1048577` 385 t = s 386 while lt t e bound `1048577` 387 if eq get src t 10 388 break 389 end 390 t = add t 1 391 end 392 row s t 393 nr = add nr 1 394 s = add t 1 395 end 396 if eq nr 0 397 die tnone 0 0 398 end 399 ret nr 400 end 401 402 note rootf, rootd: may [o, o+n) of db stand in ROOT as a regular file, as a directory 403 fn rootf o ulong n ulong to bool 404 if eqd o n a11 405 ret true 406 end 407 if or or or or eqd o n a1 eqd o n a2 eqd o n a3 eqd o n a4 eqd o n a5 408 ret true 409 end 410 ret or or or or eqd o n a6 eqd o n a7 eqd o n a8 eqd o n a9 eqd o n a10 411 end 412 413 fn rootd o ulong n ulong to bool 414 if or or or or or eqd o n tcdir eqd o n d1 eqd o n d2 eqd o n d3 eqd o n d4 eqd o n d5 415 ret true 416 end 417 ret or or or or eqd o n d6 eqd o n d7 eqd o n d8 eqd o n d9 eqd o n tout 418 end 419 420 note allowed: may the entry [o, o+n) of db, of file type m, stand in directory set w 421 note (1 ROOT, 2 compiler, 3 gpu) 422 fn allowed w ulong o ulong n ulong m ulong to bool 423 reg = eq m 32768 424 dir = eq m 16384 425 if eq w 1 426 ret or and reg rootf o n and dir rootd o n 427 end 428 if eq w 3 429 ret and dir eqd o n g1 430 end 431 if not reg 432 ret false 433 end 434 if eqd o n c8 435 ret true 436 end 437 if or or or eqd o n a1 eqd o n c1 eqd o n c2 eqd o n c3 438 ret true 439 end 440 ret or or or eqd o n c4 eqd o n c5 eqd o n c6 eqd o n c7 441 end 442 443 note entry: check the getdents64 record at p of db in directory pb[0, base) of set w; its length. 444 note The entry's type is the record's d_type (byte 18: 4 directory, 8 regular file), whose layout 445 note is the same on AArch64 and x86-64 (an lstat buffer is not). Any other d_type, including a 446 note symbolic link or DT_UNKNOWN, is not allowed: the check fails closed. compiler/gate.om plants 447 note stray files, symbolic links and a stray directory in ROOT, ROOT/compiler and ROOT/gpu; it cannot 448 note plant DT_UNKNOWN, which ext4 and tmpfs never return, so a mutant that read DT_UNKNOWN as a 449 note directory would pass the gate there. 450 fn entry w ulong base ulong p ulong to ulong 451 rl = add ulong get db add p 16 mul ulong get db add p 17 256 452 if eq rl 0 453 dief tread 454 end 455 o = add p 19 456 n = ulong 0 457 while lt add o n add p rl bound 32769 458 if eq get db add o n 0 459 break 460 end 461 n = add n 1 462 end 463 if or eqd o n tdot eqd o n tdotdot 464 ret rl 465 end 466 if and eq w 1 eqd o n tgit 467 ret rl 468 end 469 put pb base 47 470 if gt add add base 1 n 4000 471 dief tlong 472 end 473 for i ulong n 474 put pb add add base 1 i get db add o i 475 end 476 put pbn 0 add add base 1 n 477 t = get db add p 18 478 m = ulong 0 479 if eq t 8 480 m = ulong 32768 481 end 482 if eq t 4 483 m = ulong 16384 484 end 485 good = allowed w o n m 486 if not good 487 dief tvend 488 end 489 put pbn 0 base 490 ret rl 491 end 492 493 note walk: check every entry of the directory pb (set w); pb is restored on return 494 fn walk w ulong to void 495 base = get pbn 0 496 fd = fopen pb 0 base 524288 0 497 if lt fd 0 498 dief topen 499 end 500 while true bound `1048577` 501 k = getdnts int fd db 0 32768 502 if lt k 0 503 dief tread 504 end 505 if eq k 0 506 break 507 end 508 p = ulong 0 509 while lt p ulong k bound 32769 510 p = add p entry w base p 511 end 512 end 513 c = fclose int fd 514 end 515 516 fn main to int 517 if ne argcnt 2 518 w = write 2 tusage 0 len tusage 519 ret 2 520 end 521 n = argread 1 rt 0 3900 522 if le n 0 523 w = write 2 tusage 0 len tusage 524 ret 2 525 end 526 put rtn 0 ulong n 527 nr = rows 528 proot 529 walk 1 530 proot 531 padd tcomp 532 walk 2 533 proot 534 padd tgpu 535 r = lstat pb 0 get pbn 0 sb 0 128 536 if eq r 0 537 walk 3 538 end 539 w = write 1 tlk 0 len tlk 540 w = write 1 tpass 0 len tpass 541 d = new uchar 20 0 542 x = nr 543 k = ulong 0 544 while true bound 21 545 put d k uchar add rem x 10 48 546 k = add k 1 547 x = div x 10 548 if eq x 0 549 break 550 end 551 end 552 while gt k 0 bound 21 553 k = sub k 1 554 w = write 1 d k 1 555 end 556 w = write 1 tpass2 0 len tpass2 557 ret 0 558 end