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/aien-architecture-mv/blob/main/tools/name-check/namecheck.om # aien-architecture-mv Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories. 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 `aien-architecture-mv / tools / name-check / namecheck.om` 779 lines ยท 14849 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note namecheck: refuse new uses of the retired project names (ADR 0038), seeded native Omega. 3 note usage: git -c core.quotePath=false diff --no-color --no-ext-diff -U0 BASE HEAD | namecheck 4 note Reads a git unified diff on stdin. A file's path is taken from its +++ line inside the header 5 note (after diff --git, before the first @@), so added text cannot name another path. 6 note Every ADDED line of a judged path is checked; a line FAILs 7 note when, with its quoted text removed, it names the project with a retired word: 8 note Aienix / AIENIX retired everywhere outside quoted text, also inside a word or identifier 9 note AIENOS / Aienos retired in prose (the kernel is Aienux, the whole system AienOS) 10 note A retired word counts only when it stands as a word: no letter, digit or _ beside it, nothing 11 note of - / . @ $ \ before it (a hyphen after a lowercase letter is prose: non-AIENOS), not followed 12 note by \ or by . and a letter or digit (a path part or file name), and not followed by - or / and a 13 note token of uppercase letters or digits that holds a digit or runs on to the next - / or _ (a label 14 note or path part). So 15 note lowercase names (paths, crates, URLs), identifiers (AIENOS_DISK, AienosCapRef) and labels (AIENOS-PKV-ENVID-KEY-V1, 16 note AIENOS/M5/CORTEX-V1) are code and pass, while AIENOS-based or AIENOS/kernel is prose. 17 note Quoted text keeps its words: `code spans` (a run of backticks closes at the next run of the same 18 note length; one left open runs to the end of the line, as a Markdown span may wrap), then 19 note "double quotes", then curly quotes (U+201C .. U+201D), removed in that order. 20 note Never judged (history is never rewritten): evidence/, */evidence/*, receipts/, */receipts/*, 21 note docs/history/, docs/archive/, CHANGELOG*, */CHANGELOG*, docs/adr/0038-names-aienux-kernel-aienos-system.md 22 note (that exact path), tools/name-check/*, and added 23 note lines that start with _Avoid_: (glossary lines naming the retired words on purpose). 24 note Output: one line per finding, then "name-check: FAIL" (exit 1) or "name-check: PASS" (exit 0); 25 note a refusal prints one line that names its reason (exit 2). 26 note Exit 2: stdin unreadable, an added line or hunk before any diff --git header, a +++ header 27 note that is neither +++ b/PATH nor +++ /dev/null (diff.noprefix, a C-quoted name), a path longer than 4096 bytes (PATH_MAX, a Linux boundary), or one 28 note diff line longer than `16777216` bytes (the largest array this compiler builds, OMEGESE 8). 29 30 text wtbl "Aienix\nAIENIX\nAIENOS\nAienos\n" 31 text atbl "evidence/\nreceipts/\ndocs/history/\ndocs/archive/\nCHANGELOG\ndocs/adr/0038-names-aienux-kernel-aienos-system.md\ntools/name-check/\n/evidence/\n/receipts/\n/CHANGELOG\n" 32 text tpre "name-check: " 33 text tret ": retired name '" 34 text tuse "' (use Aienux for the kernel, AienOS for the whole system)\n" 35 text tfail "name-check: FAIL\n" 36 text tpass1 "name-check: PASS (" 37 text tpass2 " added lines checked)\n" 38 text trf "name-check: refused, nothing judged (exit 2): " 39 text tr1 "a +++ header is neither +++ b/PATH nor +++ /dev/null (diff.noprefix, or a file name git C-quotes)\n" 40 text tr2 "an added line or a hunk comes before any diff --git header: the input is not a git diff\n" 41 text tr3 "a path is longer than 4096 bytes (PATH_MAX)\n" 42 text tr4 "a line is longer than `16777216` bytes (the largest array the compiler builds)\n" 43 text tr5 "standard input could not be read\n" 44 text tr6 "the input is longer than 999998^3 reads of 65536 bytes\n" 45 text tcol ":" 46 text tav "+_Avoid_:" 47 text thdr "+++ b/" 48 text tat "@@ " 49 text tdg "diff --git " 50 text tnul "+++ /dev/null" 51 52 global lb uchar `16777216` 53 global ub uchar `16777216` 54 global tb uchar `16777216` 55 global cb uchar 65536 56 global pb uchar 4096 57 global st ulong 9 58 59 note st: 0 line length, 1 path length (0 = no judged path), 2 new-side line number, 60 note 3 findings, 4 added lines checked, 5 word id of the last hit, 6 unquoted length, 7 refusal 61 note reason (0 none; 1..6 as the tr texts), 62 note 8 where we are: 2 before any diff --git (an added line there is exit 2), 1 inside a file 63 note header (after diff --git, before the first @@), 0 inside the hunks 64 65 fn wr a ulong to void 66 note write one decimal number to stdout 67 d = new uchar 24 0 68 n = ulong 0 69 v = a 70 while true bound 24 71 put d sub 23 n uchar add 48 rem v 10 72 n = add n 1 73 v = div v 10 74 if eq v 0 75 break 76 end 77 end 78 k = write 1 d sub 24 n n 79 end 80 81 fn isaln c ulong to bool 82 if and ge c 48 le c 57 83 ret true 84 end 85 if and ge c 65 le c 90 86 ret true 87 end 88 if and ge c 97 le c 122 89 ret true 90 end 91 ret false 92 end 93 94 fn iswc c ulong to bool 95 if isaln c 96 ret true 97 end 98 ret eq c 95 99 end 100 101 fn isleft c ulong to bool 102 note the bytes that may not stand before a retired word: [A-Za-z0-9_] and - / . @ $ \ 103 if iswc c 104 ret true 105 end 106 if eq c 92 107 ret true 108 end 109 if or eq c 45 eq c 47 110 ret true 111 end 112 if or eq c 46 eq c 64 113 ret true 114 end 115 ret eq c 36 116 end 117 118 fn tstart k ulong to ulong 119 note start of entry k of atbl 120 s = ulong 0 121 j = ulong 0 122 while lt j k bound 4096 123 if eq get atbl s 10 124 j = add j 1 125 end 126 s = add s 1 127 end 128 ret s 129 end 130 131 fn pfxat k ulong o ulong to bool 132 note entry k of atbl equals pb at offset at 133 s = tstart k 134 i = ulong 0 135 pl = get st 1 136 while ne get atbl add s i 10 bound 64 137 if ge add o i pl 138 ret false 139 end 140 if ne get pb add o i get atbl add s i 141 ret false 142 end 143 i = add i 1 144 end 145 ret true 146 end 147 148 fn allowed to bool 149 for k ulong 7 150 if pfxat k 0 151 if ne k 5 152 ret true 153 end 154 note entry 5 is ADR 0038's own file: exempt only under its exact path 155 if eq get st 1 sub sub tstart 6 tstart 5 1 156 ret true 157 end 158 end 159 end 160 pl = get st 1 161 o = ulong 0 162 while lt o pl bound 4096 163 for k2 ulong 3 164 if pfxat add k2 7 o 165 ret true 166 end 167 end 168 o = add o 1 169 end 170 ret false 171 end 172 173 fn wordid i ulong to ulong 174 note 1..4 when a retired word (wtbl entry) starts at ub[i], else 0 175 n = get st 6 176 if gt add i 6 n 177 ret 0 178 end 179 for k ulong 4 180 ok = true 181 for j ulong 6 182 if ne get ub add i j get wtbl add mul k 7 j 183 ok = false 184 end 185 end 186 if ok 187 ret add k 1 188 end 189 end 190 ret 0 191 end 192 193 fn prefix i ulong p ulong to bool 194 note a hyphen with a lowercase letter before it joins prose: non-AIENOS 195 if ne p 45 196 ret false 197 end 198 if lt i 2 199 ret false 200 end 201 q = ulong get ub sub i 2 202 ret and ge q 97 le q 122 203 end 204 205 fn isupd c ulong to bool 206 if and ge c 65 le c 90 207 ret true 208 end 209 ret and ge c 48 le c 57 210 end 211 212 fn islabel k ulong n ulong to bool 213 note ub[k..) is a token of [A-Z0-9] that holds a digit, or runs on to - / or _ (a token is read up 214 note to 4095 bytes; past that it is prose) 215 m = k 216 dg = false 217 while and lt m n lt sub m k 4095 bound 4096 218 c0 = ulong get ub m 219 if not isupd c0 220 break 221 end 222 if le c0 57 223 dg = true 224 end 225 m = add m 1 226 end 227 if eq m k 228 ret false 229 end 230 if dg 231 ret true 232 end 233 if ge m n 234 ret false 235 end 236 c = ulong get ub m 237 if or eq c 45 eq c 47 238 ret true 239 end 240 ret eq c 95 241 end 242 243 fn bounded i ulong to bool 244 note the word at ub[i..i+6) stands as a word 245 n = get st 6 246 if gt i 0 247 p = ulong get ub sub i 1 248 if isleft p 249 if not prefix i p 250 ret false 251 end 252 end 253 end 254 j = add i 6 255 if lt j n 256 c = ulong get ub j 257 if iswc c 258 ret false 259 end 260 if eq c 92 261 note a path part: \EFI\AIENOS\MODEL.MAP 262 ret false 263 end 264 if lt add j 1 n 265 d = ulong get ub add j 1 266 if eq c 46 267 note a file name or extension: AIENOS.md 268 if isaln d 269 ret false 270 end 271 end 272 if or eq c 45 eq c 47 273 note a label or path part: AIENOS-PKV-ENVID-..., AIENOS/M5/CORTEX-V1, AIENOS-PI5: a token of 274 note uppercase letters or digits that holds a digit or runs on to the next - / or _; anything else 275 note is prose (AIENOS-based, AIENOS-Omega, AIENOS/Aienux) 276 if islabel add j 1 n 277 ret false 278 end 279 end 280 end 281 end 282 ret true 283 end 284 285 fn lim i ulong n ulong to ulong 286 note end of one inner pass: min(n, i + 999998), so an inner loop never reaches its bound and the 287 note outer loop carries on; 17 outer passes x 999998 >= `16777216` bytes 288 m = add i 999998 289 if lt n m 290 ret n 291 end 292 ret m 293 end 294 295 fn hit to bool 296 note first retired word in ub[0..st6); word id in st5 297 n = get st 6 298 i = ulong 0 299 while lt i n bound 17 300 e = lim i n 301 while lt i e bound 999999 302 w = wordid i 303 if ne w 0 304 if le w 2 305 note Aienix and AIENIX are retired even inside a word or identifier 306 put st 5 w 307 ret true 308 end 309 if bounded i 310 put st 5 w 311 ret true 312 end 313 end 314 i = add i 1 315 end 316 end 317 ret false 318 end 319 320 fn nextlb i ulong n ulong ch ulong to ulong 321 note first j >= i with lb[j] = ch, else n 322 j = i 323 while lt j n bound 17 324 e = lim j n 325 while lt j e bound 999999 326 if eq ulong get lb j ch 327 ret j 328 end 329 j = add j 1 330 end 331 end 332 ret n 333 end 334 335 fn nexttb i ulong n ulong ch ulong to ulong 336 note first j >= i with tb[j] = ch, else n 337 j = i 338 while lt j n bound 17 339 e = lim j n 340 while lt j e bound 999999 341 if eq ulong get tb j ch 342 ret j 343 end 344 j = add j 1 345 end 346 end 347 ret n 348 end 349 350 fn iscq i ulong n ulong last ulong to bool 351 note U+201C (last 156) or U+201D (last 157) at ub[i] 352 if gt add i 3 n 353 ret false 354 end 355 if ne get ub i 226 356 ret false 357 end 358 if ne get ub add i 1 128 359 ret false 360 end 361 ret eq ulong get ub add i 2 last 362 end 363 364 fn nextcq i ulong n ulong to ulong 365 note first j >= i where U+201D starts in ub, else n 366 j = i 367 while lt j n bound 17 368 e = lim j n 369 while lt j e bound 999999 370 if iscq j n 157 371 ret j 372 end 373 j = add j 1 374 end 375 end 376 ret n 377 end 378 379 fn btend i ulong n ulong to ulong 380 note end of the run of backticks that starts at lb[i] 381 j = i 382 while lt j n bound 17 383 e = lim j n 384 while lt j e bound 999999 385 if ne ulong get lb j 96 386 ret j 387 end 388 j = add j 1 389 end 390 end 391 ret n 392 end 393 394 fn btclose i ulong n ulong ln ulong to ulong 395 note start of the first run of exactly ln backticks at or after lb[i], else n 396 j = i 397 while lt j n bound 17 398 e = lim j n 399 while lt j e bound 999999 400 if eq ulong get lb j 96 401 k = btend j n 402 if eq sub k j ln 403 ret j 404 end 405 j = k 406 continue 407 end 408 j = add j 1 409 end 410 end 411 ret n 412 end 413 414 fn unbt n ulong to ulong 415 note lb[1..n) -> tb with `code spans` removed: a run of backticks closes at the next run of the same 416 note length (``x`` and `x` are spans, as in Markdown); an unmatched run cuts the rest of the line, 417 note because a Markdown code span may wrap onto the next line 418 o = ulong 0 419 i = ulong 1 420 while lt i n bound 17 421 e = lim i n 422 while lt i e bound 999999 423 c = get lb i 424 if eq c 96 425 k = btend i n 426 j = btclose k n sub k i 427 if ge j n 428 ret o 429 end 430 i = add j sub k i 431 continue 432 end 433 put tb o c 434 o = add o 1 435 i = add i 1 436 end 437 end 438 ret o 439 end 440 441 fn undq n ulong to ulong 442 note tb[0..n) -> ub with "double quoted" spans removed; an unmatched quote stays 443 o = ulong 0 444 i = ulong 0 445 while lt i n bound 17 446 e = lim i n 447 while lt i e bound 999999 448 c = get tb i 449 if eq c 34 450 j = nexttb add i 1 n 34 451 if lt j n 452 i = add j 1 453 continue 454 end 455 end 456 put ub o c 457 o = add o 1 458 i = add i 1 459 end 460 end 461 ret o 462 end 463 464 fn cpback o ulong to void 465 note tb[0..o) -> ub 466 k = ulong 0 467 while lt k o bound 17 468 e = lim k o 469 while lt k e bound 999999 470 put ub k get tb k 471 k = add k 1 472 end 473 end 474 end 475 476 fn uncq n ulong to ulong 477 note ub[0..n) -> tb with curly quoted spans removed, then copied back to ub 478 o = ulong 0 479 i = ulong 0 480 nc = false 481 while lt i n bound 17 482 e = lim i n 483 while lt i e bound 999999 484 if not nc 485 if iscq i n 156 486 j = nextcq add i 3 n 487 if lt j n 488 i = add j 3 489 continue 490 end 491 note no closing quote after i, so none after any later opening quote: the scan stays linear 492 nc = true 493 end 494 end 495 put tb o get ub i 496 o = add o 1 497 i = add i 1 498 end 499 end 500 cpback o 501 ret o 502 end 503 504 fn isavoid n ulong to bool 505 note lb = "+_Avoid_:" ... 506 if lt n 9 507 ret false 508 end 509 for i ulong 9 510 if ne get lb i get tav i 511 ret false 512 end 513 end 514 ret true 515 end 516 517 fn startsw n ulong k ulong to bool 518 note lb starts with "+++ b/" (k 6) or "+++ " (k 4) or "@@ " (k 3, compared at its own text) 519 if lt n k 520 ret false 521 end 522 if eq k 3 523 for i ulong 3 524 if ne get lb i get tat i 525 ret false 526 end 527 end 528 ret true 529 end 530 i2 = ulong 0 531 while lt i2 k bound 6 532 if ne get lb i2 get thdr i2 533 ret false 534 end 535 i2 = add i2 1 536 end 537 ret true 538 end 539 540 fn hunk n ulong to void 541 note @@ -a,b +c,d @@: the new-side start c 542 i = nextlb 3 n 43 543 v = ulong 0 544 i = add i 1 545 while lt i n bound 32 546 c = ulong get lb i 547 if or lt c 48 gt c 57 548 break 549 end 550 v = add mul v 10 sub c 48 551 i = add i 1 552 end 553 put st 2 v 554 end 555 556 fn setpath n ulong to void 557 m = sub n 6 558 note git ends a +++ path that holds a space with a TAB; it is not part of the name 559 if gt m 0 560 if eq get lb sub n 1 9 561 m = sub m 1 562 end 563 end 564 if gt m 4096 565 put st 7 3 566 put st 1 0 567 ret 568 end 569 i = ulong 0 570 while lt i m bound 4096 571 put pb i get lb add i 6 572 i = add i 1 573 end 574 put st 1 m 575 if allowed 576 put st 1 0 577 end 578 end 579 580 fn report to void 581 k = write 1 tpre 0 len tpre 582 k = write 1 pb 0 get st 1 583 k = write 1 tcol 0 1 584 wr get st 2 585 k = write 1 tret 0 len tret 586 w = sub get st 5 1 587 k = write 1 wtbl mul w 7 6 588 k = write 1 tuse 0 len tuse 589 put st 3 add get st 3 1 590 end 591 592 fn added n ulong to void 593 if gt get st 1 0 594 put st 4 add get st 4 1 595 m = unbt n 596 m = undq m 597 put st 6 m 598 m = uncq m 599 put st 6 m 600 if hit 601 report 602 end 603 end 604 put st 2 add get st 2 1 605 end 606 607 fn isdg n ulong to bool 608 note lb starts with "diff --git " 609 if lt n 11 610 ret false 611 end 612 for i ulong 11 613 if ne get lb i get tdg i 614 ret false 615 end 616 end 617 ret true 618 end 619 620 fn isnull n ulong to bool 621 note lb = "+++ /dev/null" 622 if ne n 13 623 ret false 624 end 625 for i ulong 13 626 if ne get lb i get tnul i 627 ret false 628 end 629 end 630 ret true 631 end 632 633 fn line n ulong to void 634 note a +++ line names the file only inside its header, so added text cannot change the path 635 if eq n 0 636 ret 637 end 638 c = get lb 0 639 if isdg n 640 put st 8 1 641 put st 1 0 642 ret 643 end 644 if eq get st 8 1 645 if startsw n 6 646 setpath n 647 ret 648 end 649 if startsw n 4 650 note +++ /dev/null (a deleted file) names no path; any other form (no b/ prefix from 651 note diff.noprefix, or a C-quoted name) cannot be judged and is refused, never skipped 652 put st 1 0 653 if not isnull n 654 put st 7 1 655 end 656 ret 657 end 658 end 659 if startsw n 3 660 if eq get st 8 2 661 put st 7 2 662 ret 663 end 664 put st 8 0 665 hunk n 666 ret 667 end 668 if eq c 43 669 if eq get st 8 2 670 note an added line before any diff --git header: not a git diff 671 put st 7 2 672 ret 673 end 674 if isavoid n 675 put st 2 add get st 2 1 676 ret 677 end 678 added n 679 ret 680 end 681 if eq c 32 682 put st 2 add get st 2 1 683 end 684 end 685 686 fn refuse to void 687 note the one line that says why nothing was judged 688 k = write 1 trf 0 len trf 689 w = get st 7 690 if eq w 1 691 k1 = write 1 tr1 0 len tr1 692 end 693 if eq w 2 694 k2 = write 1 tr2 0 len tr2 695 end 696 if eq w 3 697 k3 = write 1 tr3 0 len tr3 698 end 699 if eq w 4 700 k4 = write 1 tr4 0 len tr4 701 end 702 if eq w 5 703 k5 = write 1 tr5 0 len tr5 704 end 705 if eq w 6 706 k6 = write 1 tr6 0 len tr6 707 end 708 end 709 710 fn chunk to int 711 note read one block of stdin into lines: 0 more input, 1 end of input, 2 error 712 k = read 0 cb 0 65536 713 if lt k long 0 714 put st 7 5 715 ret 2 716 end 717 if eq k long 0 718 ret 1 719 end 720 kn = ulong k 721 i = ulong 0 722 while lt i kn bound 65536 723 c = get cb i 724 i = add i 1 725 if eq c 10 726 line get st 0 727 put st 0 0 728 else 729 n = get st 0 730 if ge n `16777216` 731 put st 7 4 732 ret 2 733 end 734 put lb n c 735 put st 0 add n 1 736 end 737 end 738 if ne get st 7 0 739 ret 2 740 end 741 ret 0 742 end 743 744 fn main to int 745 put st 8 2 746 note each level stops one pass below its bound; 999998^3 reads of up to 65536 bytes cover any input 747 r = int 0 748 c1 = ulong 0 749 while and eq r 0 lt c1 999998 bound 999999 750 c2 = ulong 0 751 while and eq r 0 lt c2 999998 bound 999999 752 c3 = ulong 0 753 while and eq r 0 lt c3 999998 bound 999999 754 r = chunk 755 c3 = add c3 1 756 end 757 c2 = add c2 1 758 end 759 c1 = add c1 1 760 end 761 if eq r 0 762 put st 7 6 763 end 764 if eq get st 7 0 765 line get st 0 766 end 767 if ne get st 7 0 768 refuse 769 ret 2 770 end 771 if gt get st 3 0 772 k6 = write 1 tfail 0 len tfail 773 ret 1 774 end 775 k7 = write 1 tpass1 0 len tpass1 776 wr get st 4 777 k8 = write 1 tpass2 0 len tpass2 778 ret 0 779 end