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/doctrine/README.md # 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 / doctrine / README.md` 155 lines · 9351 bytes Raw Blame History Rendered 1 # Doctrine consistency check (seeded `.om`) 2 3 Owner: [aien-architecture-mv #316](https://github.com/aien-dev/aien-architecture-mv/issues/316) 4 under [#300](https://github.com/aien-dev/aien-architecture-mv/issues/300); the check itself is 5 aien-architecture#7. Status: **replaces `scripts/check_doctrine.sh` (bash + GNU grep + gawk); 6 byte-for-byte parity on a 40-case corpus; wired into the `doctrine` gate step.** 7 8 Two native Omega programs, built only by the pinned seed compiler named in 9 `../zero-legacy/omega.pin` (`seed/out/omc` of `aien-dev/omega-mv` at ``a0eafa39``, sha256 10 ``734f0a39`…6b61`). No C, Rust, Python, shell or foreign regex engine is on their implementation 11 path: every ERE of the old script is a hand-written matcher in `doctrine.om`, with the ERE kept 12 in a `note` above it. 13 14 | Program | Role | 15 | --- | --- | 16 | `doctrine.om` | the checker: `doctrine [ROOT]` (ROOT defaults to `.`) | 17 | `gate.om` | the gate runner: builds `../zero-legacy/sha256.om` and `doctrine.om`, checks the compiler against the pin, runs the checker on ROOT, prints `AIEN-OBS` lines | 18 | `gate.sh` | independently authenticate `$AIEN_OMC` before compiling `gate.om`, then exec it | 19 | `corpus.sh` | the parity corpus runner (needs the retired bash oracle; see below) | 20 21 ## Contract (unchanged from the bash script) 22 23 Inputs under ROOT: `doctrine/*.md` and `docs/milestone-*-spec.md` in bash's `LC_ALL=C` glob 24 order (byte order, no dotfiles, `[ -f ]` after following symlinks). Text between 25 `` and `` is blanked with 26 line numbers kept (historical provenance is never checked). 27 28 Checks, in output order: 0 `unbalanced-historical-marker` (raw file); 1 `alpha-naming`, 29 `fixed-el1-handoff`, `obsolete-m27-closure`, `obsolete-roadmap-generation`, 30 `retired-milestone-identifier`, `status-outside-roadmap` and `duplicate-roadmap-table` (the last 31 two exempt `doctrine/ROADMAP.md`); 2 `physics-zero-range`; 3 `roadmap-missing` / 32 `roadmap-structure` (41 rows M0-M40, closed status list, era ranges); 4 33 `milestone-number-mismatch` (a code cited under a number other than its ROADMAP row, both 34 `Milestone N (`CODE`)` and `CODE (MN)` spellings). 35 36 Output: `FAIL [check] file:line: text` per finding (check 1 text is the line with leading 37 `[[:space:]]` removed and cut to 160 bytes; checks 2 and 4 print the whole line), then the 38 70-dash rule, `check_doctrine: scanned N files; F failure(s); 0 deferred finding(s).` and 39 `check_doctrine: PASS` or `check_doctrine: FAIL`. Exit 0 pass, 1 fail, 2 when ROOT cannot be 40 entered (`check_doctrine: cannot cd to ROOT` on stderr). The DEFERRED allowlist of the script was 41 empty, so the deferred count is the constant 0. 42 43 Byte semantics throughout, as the script had under `LC_ALL=C`: `\b`/`\<` word characters are 44 `[A-Za-z0-9_]`, `[[:space:]]` is bytes 9-13 and 32, and gawk's bracket `[-–]` in check 2 is the 45 four bytes 45, 226, 128, 147, so an en dash range such as `M27–M35` never matched there (grep's 46 `(-|–)` in check 1 does match the three-byte en dash). Both behaviours are reproduced. 47 48 ## Build and run 49 50 ``` 51 AIEN_OMC=/path/to/seed/out/omc tests/gates/run.sh doctrine # the gate step 52 # or by hand 53 $AIEN_OMC < tools/doctrine/doctrine.om > doctrine && chmod +x doctrine 54 ./doctrine /path/to/checkout 55 ``` 56 57 `gate.sh` authenticates `AIEN_OMC` against the reviewed `../zero-legacy/omega.pin` 58 using trusted system `sed` and `sha256sum` **before invoking the candidate compiler**. 59 This is a temporary external bootstrap boundary, not a completed all-.om cutover. 60 Native self-hashing is defense in depth, not independent authentication. This assumes 61 trusted OS/tools/pin and a compiler file not concurrently replaced. Separate build 62 commands stop on failure rather than falling through to an older gate binary. 63 64 `gate.sh` exits 3 (NOT_RUN) when `AIEN_OMC` is unset, not executable, mismatched, or produces no program; 65 `gate.om` exits 3 when the compiler's native sha256 differs from `omega.pin`; otherwise its exit 66 is the checker's (0/1/2) and it prints `AIEN-OBS doctrine_sha256 ""` 67 before the run and `AIEN-OBS doctrine_exit N` after it. The gate manifest 68 `tests/gates/arch-doctrine.gate` is `requires: host` (the compiler is AArch64 only), so the hosted 69 x86 AIEN Checks job skips it. The hosted `AIEN Pinned-omc Gates` job runs it on an 70 `ubuntu-24.04-arm` runner with omc born from seed-0 at the `omega.pin` commit (#363). 71 72 ## Oracle and corpus 73 74 Oracle: `scripts/check_doctrine.sh` as of ``1adbb2a`` (sha256 ``ea5c9069`…b68a`), run with 75 `PATH=/usr/bin:/bin` (GNU grep 3.11, gawk 5.2.1, GNU sed 4.9, coreutils 9.4) on the Spark. 76 Recover it with `git show `1adbb2a`:scripts/check_doctrine.sh > /tmp/oracle.sh`. 77 78 ``` 79 sh tools/doctrine/corpus.sh /tmp/oracle.sh ./doctrine [REPO-ROOT] 80 ``` 81 82 40 cases: the real tree (PASS, 30 files) plus 39 mutated copies under a scratch directory, one or 83 more per check and per regex branch, including: every status tag spelling and `[REOPENED` with 84 and without a closing bracket; wrong milestone numbers in both citation syntaxes, with 85 `Milestones`, `MILESTONE`, bare `M`, underscores and backticks in the gap, two citations on one 86 line, a `M05` roadmap row (string comparison `5` vs `05`), a duplicated code (last row wins), a 87 missing roadmap, a roadmap that is a directory, a roadmap with no rows, short rows, extra rows, 88 rows inside a historical block; second BEGIN, stray END, BEGIN+END on one line, unterminated 89 BEGIN; `28-milestone`, `Twenty-eight precise milestones`, `^MILESTONE N — `, `M1–M27`; every 90 alpha/EL1/retired-identifier literal with word-boundary negatives (`alphabet`, `SENTINEL_GATE_12`, 91 `éALPHA`); physics-zero ranges with spaces, en dash, a dot inside the 30-byte window, and the 92 longest-match case `Physics Zero (see M1-M2) M27-M35`; CRLF files, a file without a trailing 93 newline, empty files, a 300-byte line with leading tab/space/CR (strip + 160 cut), extra files 94 that test glob order and exclusion (`Aa.md`, `ZZ.md`, `_under.md`, `.hidden.md`, a directory 95 named `sub.md`, a symlink to a file, a dangling symlink, `milestone--spec.md`, 96 `Milestone-9-spec.md`, `milestone-spec.md`), a relative ROOT and a missing ROOT. 97 98 Result (2026-10-24, `build/doctrine` sha256 ``14eb7d84`…6edb`): **40/40 cases identical** in 99 stdout and exit code. For the missing-ROOT case bash additionally prints its own 100 `cd: …: No such file or directory` diagnostic before the script's message; the corpus compares 101 the script's own stderr line, which is identical. 102 103 ## Preserved quirks (reproduced, not corrected) 104 105 - A second `BEGIN` before an `END` makes the awk print the duplicate's line number and `exit`; 106 awk's `exit` still runs the `END` rule, which prints the first BEGIN's line too. The report is 107 therefore `FAIL [unbalanced-historical-marker] f:33\n32: HISTORICAL-PROVENANCE marker without 108 partner` (two lines). Same in `doctrine.om`. 109 - The roadmap row counter is an unset awk variable until the first row passes: `expected row M, 110 found M1` (no digit) and `found ` (no digit) when the roadmap has no rows. 111 - Check 4 compares the cited digits with the roadmap digits as strings (`5` differs from `05`). 112 113 ## Limits 114 115 - Buffers: a scanned file is read into an 8 MiB pool (longer files are truncated), at most 1024 116 files and 65536 bytes of file names, 512 roadmap codes, lines and files of at most 999,999 117 bytes/lines (an overrun traps, exit 104). The real corpus is 30 files, 608 KB, longest line 118 1197 bytes. 119 - A roadmap row number with more than 19 digits wraps where awk would print a float; files that 120 exist but cannot be opened are treated as empty where the script would print an awk/grep 121 error. Neither occurs in the repository and neither is in the corpus. 122 - `ROOT` defaults to `.`; the script defaulted to its own parent directory, which a program with 123 no fixed location cannot know. 124 125 NOT_RUN: nothing in this directory runs under the hosted x86 workflow (AArch64 compiler only); 126 `aien-test run ARCH-DOCTRINE` was not run here, only `tests/gates/run.sh doctrine`, which is also 127 what the hosted AArch64 job runs. 128 129 ## Bootstrap rejection regression (NOT_RUN) 130 131 This loader repair does not change `doctrine.om`, its matching rules, the gate manifest, 132 or the author's 40-case parity receipt above. Native execution of the changed loader 133 and the sentinel procedure below is NOT_RUN; older receipts do not qualify this head. 134 135 From the repository root in an isolated fixture checkout, with `AIEN_OMC` an absolute path already 136 independently verified against the pinned digest, use the shared native sentinel: 137 138 ```sh 139 set -eu 140 ROOT="$PWD" 141 cd tools/doctrine 142 mkdir -p build 143 "$AIEN_OMC" < ../zero-legacy/fixtures/loader-sentinel.om > build/loader-sentinel 144 chmod +x build/loader-sentinel 145 rm -f build/untrusted-compiler-ran 146 if build/loader-sentinel; then rc=0; else rc=$?; fi 147 [ "$rc" -eq 98 ] && [ -f build/untrusted-compiler-ran ] || exit 1 148 rm -f build/untrusted-compiler-ran 149 if AIEN_OMC="$PWD/build/loader-sentinel" sh ./gate.sh "$ROOT"; then rc=0; else rc=$?; fi 150 [ "$rc" -eq 3 ] && [ ! -e build/untrusted-compiler-ran ] || exit 1 151 ``` 152 153 The direct-run precondition proves the sentinel creates the marker before checking that 154 the loader rejects it without execution. The zero-legacy loader has its own equivalent 155 procedure in its README; both loaders require independent rejection receipts.