code wiki / _hdl_build / nx_domain_admit.nx

nx_domain_admit.nx source

↩ module page · 874 lines · 47222 B

1// nx_domain_admit.nx -- THE REFUSING ADMISSION GATE for a /compare domain. 2// Specified but never built: knowledge/compare/ADMISSION_STANDARD.txt ends with an ENFORCEMENT RUNG that 3// says COMPOSE the admission checks from the instruments that already exist and wire it into the authoring 4// lane so a new .matrix cannot publish without passing. Measured 2026-08-06: 0 matches for nx_domain_admit 5// across 50,386 files. The standard existed as prose and nothing refused against it, which is exactly the 6// estate's central defect -- a rule that scores nothing changes nothing. 7// 8// WHAT THIS ENFORCES (the mechanical subset; the rest is reported UNVERIFIED, never faked GREEN): 9// C1 SYMBOL GROUNDING -- every non-_ABSENT_ row's symbol must occur, ON A WORD BOUNDARY, inside the organ 10// the row itself declares. This is the liar-kill check: it is what stops a matrix asserting coverage 11// that no file backs. A prefix or substring hit does NOT count (the standard names 11 prefix rows 12// repaired in arrears; a bare substring is how they passed in the first place). 13// C2 RIVAL BARS -- knowledge/barcheck.conf must carry at least one pinned row for the domain, OR the 14// matrix header must explicitly declare the bars UNPINNED. An unpinned comparison is unfalsifiable; 15// the standard permits saying so out loud and forbids staying silent. 16// C3 EXECUTABLE EVIDENCE -- knowledge/compare/<domain>.gates must exist and be non-empty, else the domain 17// is CLAIM-ONLY and must say so. 18// C4 FRESH-KILL -- every gate the <domain>.gates map declares, partitioned by its durable bite record: 19// bite-proven / never-bitten / bitten-but-zero-kill. Reports, does not refuse. 20// C5 SECOND METHOD CLASS -- the signed experiential row, READ and cryptographically VERIFIED through the 21// estate's one verifier (at_verify_row), in THREE states that must never collapse into each other: 22// SIGNED / UNSIGNED-CANDIDATE / ABSENT, plus a separately declared SIGNED-BUT-REFUSED. Reports. 23// C6 STAMP AND BOARD -- ALWAYS ABSTAINS, and names which conjunct it could not evaluate. The stamp half 24// is read from knowledge/status/evstamp_<domain>.verdict (forking the producer measured ~25 s per 25// domain); the board half is structurally unavailable, because nx_sota_status has no `why <domain>` 26// verb and publishes no per-domain verdict at all. An abstention that names its dead conjunct is a 27// measurement; a bare UNVERIFIED is not, and a bare UNVERIFIED is what this organ printed for both of 28// these from the day it was written until 2026-08-25. 29// 30// EXIT: 0 = ADMIT, 1 = REFUSE, 2 = usage, 3 = matrix unreadable. 31// A REFUSE is not a failure of the domain -- the standard says an unproven domain is admitted as HONESTLY 32// UNPROVEN when it declares that. This gate refuses SILENT unprovenness, not unprovenness. 33// 100% sovereign. No hardware writes (Rule 26). license_tier: ORIGINAL expect_exit: 0 34import "nx_syscalls.nx" 35import "nx_deploy_lib.nx" 36// THE ONE SYMBOL RULER (2026-08-23): cl_symbol_declared -- a top-level `func <sym>` declaration in the organ 37// the row names. Three organs answered "does the symbol exist" three ways (this gate: word boundary; the 38// page: substring; the ranker: declaration) and a rung read LANDED on the page and OPEN in the ranker at 39// once. C1 below MEASURES the disagreement between its word-boundary rule and the declaration rule on 40// every grounded row (printed per row, summed per domain and per sweep) before the verdict switches. 41import "nx_catalog_lib.nx" 42 43// THE PURE DECISION CORE LIVES IN nx_domain_admit_lib.nx, AND THIS ORGAN NOW IMPORTS IT RATHER THAN 44// DEFINING IT. Reason, 2026-08-25: nx_organ_ship reported "PROVE NO-GATE-FOUND -- a NAMED absence, NOT 45// a pass" for this target, and a gate could not be written while the checks lived inside a top-level 46// programme -- nothing can import a main(), and a gate that fork/execs the deployed elf is not 47// mutation-provable (every mutant returns NOT-REACHED, and the GREEN that produces reads exactly like a 48// proof). The functions were MOVED, not copied: da_wfind, da_classify_row, da_symstart, da_tenths, 49// da_count_lines, da_hasline, da_kv, da_c4 and the gates-map resolver now have exactly one definition 50// each, in the library, and nx_domain_admit_gate.nx drives them in-process. 51import "nx_domain_admit_lib.nx" 52 53const DA_MCAP: i64 = 1048576 54const DA_AT: i64 = 64 55// THE TREE THIS GATE AUDITS -- ONE literal, replacing three former call sites (main, da_c1, da_sweep). 56// MEASURED 2026-08-20: this gate read the bare "knowledge/compare/" (the nishihost twin) while 57// nx_compare_regen PUBLISHES from "buildroot/knowledge/compare/". The two trees are FORKED, not 58// stale, so converging them by copy would destroy real work in one direction or the other: the 59// nishihost twin holds a richer @sub for ecosysdesign (the 2026-08-04 HBS WP 05-016 re-read), and 60// buildroot holds every [@key] citation mark the refs rung landed -- proven by scan, the nishihost 61// tree has matches=0 with corpus_complete=1 over 379 files, so a nishihost->buildroot copy would 62// strip all 981 marks and turn nx_compare_refs_gate's declared-refs-cited-inline tooth RED fleet-wide. 63// ★AN ADMISSION GATE MUST AUDIT THE COPY THAT PUBLISHES, AND REPOINTING THE GATE MOVES NO DATA. 64// ★AND THE OLD TARGET DID NOT MERELY MIS-JUDGE DOMAINS -- IT COULD NOT SEE THE ONES MOST LIKELY TO 65// BE WRONG: knowledge/compare/devmgmt.matrix is ABSENT while buildroot/knowledge/compare/devmgmt.matrix 66// is 10,325 B, published and page-verified GREEN. The newest admitted domain was invisible to its own 67// admission gate, and --all reported domains=45 as if that were the population. 68const DA_CDIR: *u8 = "buildroot/knowledge/compare\x00" 69// DA_CDIRS (the publishing tree) and DA_GATESDIR (the tree that owns the .gates maps) MOVED to 70// nx_domain_admit_lib.nx, together with da_read_2dir/da_gates_read -- the resolver that uses them. The 71// 2026-08-25 defect was that C3 and C4 each built that path themselves and only one was repointed; a 72// constant and the one resolver that reads it belong in the same file, where they cannot half-move. 73 74// da_slen/da_w/da_wn/da_n/da_cat/da_isword/da_wfind/da_eol/da_sl_eq/da_symstart MOVED to 75// nx_domain_admit_lib.nx so the gate can drive them in-process. da_wfind in particular is the liar-kill 76// mechanism -- the word boundary is why a prefix, a suffix or a substring inside a longer identifier is 77// NOT a grounding -- and it now has teeth on all four of those cases. 78// C1 RULE MEASUREMENT: 1 when the word-boundary rule grounds the row and the declaration rule does NOT 79// (declared=0: the symbol is a mention -- comment, string, tooth name, a token in a log -- not a `func`; 80// declared=-1: the declaration ruler could not read the organ path at all, e.g. a non-source path). 81// Every such row is printed: the switch to one ruler is a measured decision, never a quiet flip. 82func da_rule_disagree(mb: *u8, p1: i64, p2: i64, sym: i64, symend: i64, dom: *u8) -> i64 { 83 let org: *u8 = sys_mmap(DA_PATH) 84 var o: i64 = 0 85 var i: i64 = p1 + 1 86 while i < p2 { if o < DA_PATH - 1 { org[o] = mb[i]; o = o + 1 } i = i + 1 } 87 org[o] = 0 as u8 88 let sy: *u8 = sys_mmap(DA_PATH) 89 var q: i64 = 0 90 i = sym 91 while i < symend { if q < DA_PATH - 1 { sy[q] = mb[i]; q = q + 1 } i = i + 1 } 92 sy[q] = 0 as u8 93 let d: i64 = cl_symbol_declared(org, sy) 94 if d == 1 { return 0 } 95 da_w(" C1 rule-disagree dom=" as *u8); da_w(dom); da_w(" sym=" as *u8); da_w(sy); da_w(" organ=" as *u8); da_w(org) 96 da_w(" wordboundary=1 declared=" as *u8); da_n(d); da_w("\n" as *u8) 97 return 1 98} 99 100// da_try / da_read_organ / da_classify_row MOVED to nx_domain_admit_lib.nx. da_classify_row is the 101// four-way answer the whole admission rests on -- declared-gap, grounded, ungrounded, organ-unreadable -- 102// and every one of the four is now bite-proven against in-memory rows and /tmp fixtures. 103 104// C1 for one domain. Returns the FAULT COUNT (ungrounded + unreadable); 0 means every declared symbol is 105// word-boundary-present in the organ its own row names. Extracted so the single-domain path and the sweep 106// run the SAME code -- a sweep that re-implements the check is a second opinion, not a wider one. 107func da_c1(dom: *u8, mb: *u8, sb: *u8, verbose: i64, agg: *i64) -> i64 { 108 let path: *u8 = sys_mmap(DA_PATH) 109 var p: i64 = da_cat(path, 0, DA_CDIRS) 110 p = da_cat(path, p, dom) 111 p = da_cat(path, p, ".matrix" as *u8) 112 path[p] = 0 as u8 113 let mn: i64 = dp_read(path, mb, DA_MCAP - 4) 114 if mn <= 0 { da_w(" " as *u8); da_w(dom); da_w(" NO-MATRIX\n" as *u8); return 1 } 115 116 var rows: i64 = 0 117 var absent: i64 = 0 118 var grounded: i64 = 0 119 var ungrounded: i64 = 0 120 var unreadable: i64 = 0 121 var newwatch: i64 = 0 122 var disagree: i64 = 0 123 var i: i64 = 0 124 while i < mn { 125 let le: i64 = da_eol(mb, mn, i) 126 if le > i { 127 let f: i64 = mb[i] as i64 128 var skip: i64 = 0 129 if f == DA_HASH { skip = 1 } 130 if f == DA_AT { skip = 1 } 131 if f == DA_NL { skip = 1 } 132 if skip == 0 { 133 var p1: i64 = 0 - 1 134 var p2: i64 = 0 - 1 135 var p3: i64 = 0 - 1 136 var k: i64 = i 137 while k < le { 138 if mb[k] == (DA_PIPE as u8) { 139 if p1 < 0 { p1 = k } else { if p2 < 0 { p2 = k } else { if p3 < 0 { p3 = k; k = le } } } 140 } 141 k = k + 1 142 } 143 if p3 > 0 { 144 rows = rows + 1 145 let sa: i64 = p2 + 1 146 let cls: i64 = da_classify_row(mb, p1, p2, p3, sb) 147 if cls == 0 { absent = absent + 1 } 148 if cls == 1 { grounded = grounded + 1; disagree = disagree + da_rule_disagree(mb, p1, p2, da_symstart(mb, sa, p3), p3, dom) } 149 if cls == 3 { 150 unreadable = unreadable + 1 151 if verbose == 1 { 152 da_w(" C1 UNREADABLE organ: " as *u8) 153 da_wn(mb, p1 + 1, p2 - (p1 + 1)) 154 da_w(" (row: " as *u8); da_wn(mb, i, p1 - i); da_w(")\n" as *u8) 155 } 156 } 157 if cls == 4 { 158 newwatch = newwatch + 1 159 if verbose == 1 { 160 da_w(" C1 WATCH-NEW-ORGAN: " as *u8) 161 da_wn(mb, p1 + 1, p2 - (p1 + 1)) 162 da_w(" (row: " as *u8); da_wn(mb, i, p1 - i); da_w(")\n" as *u8) 163 } 164 } 165 if cls == 2 { 166 ungrounded = ungrounded + 1 167 if verbose == 1 { 168 da_w(" C1 UNGROUNDED symbol " as *u8) 169 da_wn(mb, sa, p3 - sa) 170 da_w(" not word-boundary-present in " as *u8) 171 da_wn(mb, p1 + 1, p2 - (p1 + 1)) 172 da_w("\n row: " as *u8); da_wn(mb, i, p1 - i); da_w("\n" as *u8) 173 } 174 } 175 } 176 } 177 } 178 i = le + 1 179 } 180 da_w(" " as *u8); da_w(dom) 181 da_w(" rows=" as *u8); da_n(rows) 182 da_w(" grounded=" as *u8); da_n(grounded) 183 da_w(" absent=" as *u8); da_n(absent) 184 da_w(" ungrounded=" as *u8); da_n(ungrounded) 185 da_w(" unreadable=" as *u8); da_n(unreadable) 186 da_w(" watch_new_organ=" as *u8); da_n(newwatch) 187 da_w(" rule_disagree=" as *u8); da_n(disagree) 188 agg[0] = agg[0] + disagree 189 if ungrounded + unreadable == 0 { da_w(" OK\n" as *u8) } else { da_w(" FAULT\n" as *u8) } 190 return ungrounded + unreadable 191} 192 193// Sweep every *.matrix in knowledge/compare. This is what makes the gate a standing instrument instead of 194// a thing someone remembers to run: the denominator is the directory, so a domain cannot dodge the check 195// by never being named. 196func da_sweep(mb: *u8, sb: *u8, nbuf: *u8, ncap: i64, nlen: *i64) -> i64 { 197 let fd: i64 = sys_openat_rd(DA_CDIR) 198 if fd < 0 { da_w("SWEEP REFUSE: cannot open buildroot/knowledge/compare\n" as *u8); return 0 - 1 } 199 let agg: *i64 = sys_mmap(16) as *i64 200 agg[0] = 0 201 let dbuf: *u8 = sys_mmap(1 << 16) 202 let dom: *u8 = sys_mmap(256) 203 var domains: i64 = 0 204 var faulty: i64 = 0 205 var faults: i64 = 0 206 var go: i64 = 1 207 while go == 1 { 208 let nr: i64 = sys_getdents64(fd, dbuf, 1 << 16) 209 if nr <= 0 { go = 0 } else { 210 var pos: i64 = 0 211 while pos < nr { 212 let rec: *u8 = ((dbuf as i64) + pos) as *u8 213 let reclen: i64 = dirent_reclen(rec) 214 let name: *u8 = ((rec as i64) + 19) as *u8 215 var ln: i64 = 0 216 while name[ln] != (0 as u8) { ln = ln + 1 } 217 // THE SUFFIX LENGTH IS DERIVED FROM THE SUFFIX, NEVER HAND-COUNTED BESIDE IT. This block 218 // wrote 7 six times as the length of ".matrix"; change that literal and all six still 219 // compile and still read a window, just the wrong one, with no diagnostic anywhere. 220 let suf: *u8 = ".matrix\x00" as *u8 221 let sl: i64 = da_slen(suf) 222 if ln > sl { 223 var m: i64 = 1 224 var j: i64 = 0 225 while j < sl { if name[ln-sl+j] != suf[j] { m = 0; j = sl } else { j = j + 1 } } 226 if m == 1 { 227 var c: i64 = 0 228 while c < ln - sl { dom[c] = name[c]; c = c + 1 } 229 dom[ln-sl] = 0 as u8 230 domains = domains + 1 231 let f: i64 = da_c1(dom, mb, sb, 0, agg) 232 if f > 0 { 233 faulty = faulty + 1 234 faults = faults + f 235 // COLLECT THE NAME, not just the count. A count-only ratchet on a tree nine 236 // lanes write reports a regression without saying WHOSE, which makes it 237 // unusable exactly when it fires. 238 var q: i64 = nlen[0] 239 var c2: i64 = 0 240 while dom[c2] != (0 as u8) { 241 if q < ncap - 2 { nbuf[q] = dom[c2]; q = q + 1 } 242 c2 = c2 + 1 243 } 244 if q < ncap - 1 { nbuf[q] = DA_NL as u8; q = q + 1 } 245 nlen[0] = q 246 } 247 } 248 } 249 if reclen <= 0 { pos = nr } else { pos = pos + reclen } 250 } 251 } 252 } 253 sys_close(fd) 254 da_w("\nSWEEP domains=" as *u8); da_n(domains) 255 da_w(" faulty-domains=" as *u8); da_n(faulty) 256 da_w(" total-faults=" as *u8); da_n(faults) 257 da_w(" c1-rule-disagree(wordboundary=1,declared!=1)=" as *u8); da_n(agg[0]); da_w("\n" as *u8) 258 return faulty 259} 260 261const DA_NAMEBUF: i64 = 65536 262const DA_MODE_0644: i64 = 420 263const DA_CH_R: i64 = 114 // 'r' -- distinguishes --ratchet from --all at argv[1][2] 264const DA_BASELINE: *u8 = "knowledge/status/domain_admit.baseline" 265 266// THE RATCHET (2026-08-20). Repointing this gate to the publishing tree took the sweep from 267// domains=45 faulty=3 to domains=61 faulty=54 / faults=342 -- because 16 domains had never been 268// audited at all, not because anything regressed that day. A gate that is permanently RED is one 269// everyone learns to ignore, so the standing 342 are held as a WORKLIST and only NEW offenders fail. 270// ★RATCHET ON A SET OF NAMES, NEVER A COUNT: on a tree nine lanes write, a count-only ratchet reports 271// a regression without saying WHOSE, which makes it useless exactly when it fires. 272// ★SELF-BASELINES ON FIRST SIGHT, so adopting it cannot break a single caller by construction. 273// ★AND THE BAR IS PRINTED IN THE VERDICT: a threshold nobody can see is a threshold nobody can act on 274// (the magic-number chain reported against an invisible bar for weeks). 275// da_count_lines / da_hasline -- the ratchet's set logic -- MOVED to nx_domain_admit_lib.nx. 276func da_write_file(path: *u8, buf: *u8, n: i64) -> i64 { 277 let tmp: *u8 = sys_mmap(DA_PATH) 278 var o: i64 = da_cat(tmp, 0, path) 279 o = da_cat(tmp, o, ".new" as *u8); tmp[o] = 0 as u8 280 let fd: i64 = sys_openat_wr(tmp, DA_MODE_0644) 281 if fd < 0 { return 0 - 1 } 282 var off: i64 = 0 283 while off < n { 284 let r: i64 = sys_write(fd, ((buf as i64) + off) as *u8, n - off) 285 if r <= 0 { sys_close(fd); return 0 - 2 } 286 off = off + r 287 } 288 sys_close(fd) 289 if sys_renameat(tmp, path) != 0 { return 0 - 3 } 290 return 0 291} 292const DA_LOG: *u8 = "knowledge/status/domain_admit.log" 293const DA_ZERO: i64 = 48 294const DA_NUMCAP: i64 = 28 295func da_catn(dst: *u8, o: i64, v: i64) -> i64 { 296 var x: i64 = o 297 var m: i64 = v 298 if m == 0 { dst[x] = DA_ZERO as u8; return x + 1 } 299 let t: *u8 = sys_mmap(DA_NUMCAP) 300 var k: i64 = 0 301 while m > 0 { t[k] = (DA_ZERO + (m % 10)) as u8; m = m / 10; k = k + 1 } 302 var i: i64 = 0 303 while i < k { dst[x] = t[k - 1 - i]; x = x + 1; i = i + 1 } 304 return x 305} 306// A VERDICT NOBODY COLLECTS IS A VERDICT NOBODY HAS. This organ sat REGISTERED-DARK while it audited 307// the WRONG TREE for weeks -- ★a gate nobody runs does not degrade to neutral, it degrades to a false 308// sense of coverage, because its existence is counted and its verdict is not. So the ratchet writes its 309// own durable line, the way every collected gate in this estate does, and the canonical verdict token is 310// LAST on the line so a positional reader cannot mistake a field for it. 311func da_log(base: i64, cur: i64, nnew: i64, nfixed: i64, green: i64) -> i64 { 312 let fd: i64 = sys_openat_append(DA_LOG, DA_MODE_0644) 313 if fd < 0 { return 0 - 1 } 314 let b: *u8 = sys_mmap(DA_PATH) 315 var o: i64 = da_cat(b, 0, "DOMAINADMIT epoch=" as *u8) 316 o = da_catn(b, o, sys_now_realtime_sec()) 317 o = da_cat(b, o, " baseline_faulty=" as *u8); o = da_catn(b, o, base) 318 o = da_cat(b, o, " current_faulty=" as *u8); o = da_catn(b, o, cur) 319 o = da_cat(b, o, " new=" as *u8); o = da_catn(b, o, nnew) 320 o = da_cat(b, o, " fixed=" as *u8); o = da_catn(b, o, nfixed) 321 if green == 1 { o = da_cat(b, o, " verdict=GREEN\n" as *u8) } else { o = da_cat(b, o, " verdict=RED\n" as *u8) } 322 sys_write(fd, b, o) 323 sys_close(fd) 324 return 0 325} 326// ==== C7 CONTRACT AGREEMENT (2026-08-23, compare CE5) ==== 327// MEASURED BY THE PARENT LANE: the same contract symbol was declared as a RUNG on two boards with two 328// different costs (graphics.plan GR8 ntb_bake_pbr 1u / charsim.plan R4 2u; sr_sss_preint 1 vs 1.5; 329// dyna_bind_skin 1 vs 1.5; fa_expr_morph 2 vs 1). The ranker runs per domain, so one piece of work was 330// priced twice and ranked in two universes that can never reconcile -- the "scattered" the operator named. 331// ONE CONTRACT, DECLARED ONCE: a symbol declared as a rung on more than one board must carry the SAME est 332// on every board, and a symbol on more than one matrix must name the SAME organ path. Deps are domain-local 333// rung ids and are NOT compared. No new row kind: ownership is expressed by agreement, never by a rename. 334// Ratcheted on the SET of disagreeing symbols (kind:sym per line), like the C1 ratchet above: self- 335// baselines on first sight, RED only on a NEW offender, tightens on a fix -- a detector born permanently 336// red is one everyone learns to ignore. 337const DA_C7_BASELINE: *u8 = "knowledge/status/domain_admit_c7.baseline" 338const DA_C7_LOG: *u8 = "knowledge/status/domain_admit_c7.log" 339const DA_KIND_RUNG: i64 = 1 340const DA_KIND_MATRIX: i64 = 2 341const DA_REC_FIELDS: i64 = 4 // kind, dom, sym, val -- one record per declaration 342const DA_SUF_PLAN: *u8 = ".plan\x00" 343const DA_SUF_MATRIX: *u8 = ".matrix\x00" 344// The token the C2 bar-check looks for, hoisted so its LENGTH can be derived at the one site that needs 345// it rather than hand-written as an 8 beside the literal -- the two drift the moment the token is retitled. 346const DA_UNPINNED: *u8 = "UNPINNED\x00" 347 348// da_tenths -- the C7 estimate parser -- MOVED to nx_domain_admit_lib.nx. 349func da_ends_with(name: *u8, ln: i64, suf: *u8) -> i64 { 350 let sl: i64 = da_slen(suf) 351 if ln <= sl { return 0 } 352 var j: i64 = 0 353 while j < sl { if name[ln - sl + j] != suf[j] { return 0 } j = j + 1 } 354 return 1 355} 356// copy mb[a..b) into the arena as a NUL-terminated string; returns its pointer, advances ao[0] 357func da_arena_put(arena: *u8, ao: *i64, mb: *u8, a: i64, b: i64) -> *u8 { 358 let p: *u8 = ((arena as i64) + ao[0]) as *u8 359 var i: i64 = a 360 var o: i64 = ao[0] 361 while i < b { arena[o] = mb[i]; o = o + 1; i = i + 1 } 362 arena[o] = 0 as u8 363 ao[0] = o + 1 364 return p 365} 366// pass 0: total bytes + lines of every *.plan and *.matrix (the DERIVED bounds); pass 1: collect records. 367// rec[i*4+0]=kind, +1=dom ptr, +2=sym ptr, +3=val ptr (est text for a rung, organ path for a matrix row) 368func da_c7_walk(pass: i64, mb: *u8, tot: *i64, rec: *i64, nrec: *i64, arena: *u8, ao: *i64) -> i64 { 369 let fd: i64 = sys_openat_rd(DA_CDIR) 370 if fd < 0 { return 0 - 1 } 371 let dbuf: *u8 = sys_mmap(1 << 16) 372 var go: i64 = 1 373 while go == 1 { 374 let nr: i64 = sys_getdents64(fd, dbuf, 1 << 16) 375 if nr <= 0 { go = 0 } else { 376 var pos: i64 = 0 377 while pos < nr { 378 let r: *u8 = ((dbuf as i64) + pos) as *u8 379 let reclen: i64 = dirent_reclen(r) 380 let name: *u8 = ((r as i64) + 19) as *u8 381 var ln: i64 = 0 382 while name[ln] != (0 as u8) { ln = ln + 1 } 383 var kind: i64 = 0 384 var sl: i64 = 0 385 // The suffix is ALREADY a named constant here and its length was STILL hand-written 386 // beside it -- retitle DA_SUF_PLAN to ".plans" and sl=5 silently truncates every domain 387 // name by one character while compiling clean. Derived from the constant it measures. 388 if da_ends_with(name, ln, DA_SUF_PLAN) == 1 { kind = DA_KIND_RUNG; sl = da_slen(DA_SUF_PLAN) } 389 if da_ends_with(name, ln, DA_SUF_MATRIX) == 1 { kind = DA_KIND_MATRIX; sl = da_slen(DA_SUF_MATRIX) } 390 if kind > 0 { 391 let path: *u8 = sys_mmap(DA_PATH) 392 var p: i64 = da_cat(path, 0, DA_CDIRS) 393 var c: i64 = 0 394 while c < ln { path[p] = name[c]; p = p + 1; c = c + 1 } 395 path[p] = 0 as u8 396 let n: i64 = dp_read(path, mb, DA_MCAP - 4) 397 if n > 0 { 398 if pass == 0 { tot[0] = tot[0] + n; tot[1] = tot[1] + da_count_lines(mb, n) + 1; tot[2] = tot[2] + 1 } 399 else { 400 // the domain name, once per file, into the arena 401 let dom: *u8 = da_arena_put(arena, ao, name, 0, ln - sl) 402 var i: i64 = 0 403 while i < n { 404 let le: i64 = da_eol(mb, n, i) 405 if le > i { 406 var p1: i64 = 0 - 1 407 var p2: i64 = 0 - 1 408 var p3: i64 = 0 - 1 409 var p6: i64 = 0 - 1 410 var p7: i64 = 0 - 1 411 var np: i64 = 0 412 var k: i64 = i 413 while k < le { 414 if mb[k] == (DA_PIPE as u8) { 415 np = np + 1 416 if np == 1 { p1 = k } 417 if np == 2 { p2 = k } 418 if np == 3 { p3 = k } 419 if np == 6 { p6 = k } 420 if np == 7 { p7 = k } 421 } 422 k = k + 1 423 } 424 if kind == DA_KIND_RUNG { 425 // rung|id|title|sym|done|exec|est|deps -> sym = [p3+1, p4), est = [p6+1, p7) 426 if p7 > 0 { if da_sl_eq(mb, i, p1, "rung" as *u8) == 1 { 427 var p4: i64 = p3 + 1 428 while p4 < le { if mb[p4] == (DA_PIPE as u8) { break } p4 = p4 + 1 } 429 let b: i64 = nrec[0] * DA_REC_FIELDS 430 rec[b] = DA_KIND_RUNG 431 rec[b + 1] = dom as i64 432 rec[b + 2] = da_arena_put(arena, ao, mb, p3 + 1, p4) as i64 433 rec[b + 3] = da_arena_put(arena, ao, mb, p6 + 1, p7) as i64 434 nrec[0] = nrec[0] + 1 435 } } 436 } else { 437 let f: i64 = mb[i] as i64 438 var skip: i64 = 0 439 if f == DA_HASH { skip = 1 } 440 if f == DA_AT { skip = 1 } 441 if p3 < 0 { skip = 1 } 442 if skip == 0 { 443 let sa: i64 = p2 + 1 444 if da_sl_eq(mb, sa, p3, "_ABSENT_" as *u8) == 0 { 445 let b2: i64 = nrec[0] * DA_REC_FIELDS 446 rec[b2] = DA_KIND_MATRIX 447 rec[b2 + 1] = dom as i64 448 rec[b2 + 2] = da_arena_put(arena, ao, mb, da_symstart(mb, sa, p3), p3) as i64 449 rec[b2 + 3] = da_arena_put(arena, ao, mb, p1 + 1, p2) as i64 450 nrec[0] = nrec[0] + 1 451 } 452 } 453 } 454 } 455 i = le + 1 456 } 457 } 458 } 459 } 460 if reclen <= 0 { pos = nr } else { pos = pos + reclen } 461 } 462 } 463 } 464 sys_close(fd) 465 return 0 466} 467func da_streq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if b[i] != (0 as u8) { return 0 } return 1 } 468func da_c7_log(base: i64, cur: i64, nnew: i64, nfixed: i64, green: i64) -> i64 { 469 let fd: i64 = sys_openat_append(DA_C7_LOG, DA_MODE_0644) 470 if fd < 0 { return 0 - 1 } 471 let b: *u8 = sys_mmap(DA_PATH) 472 var o: i64 = da_cat(b, 0, "DOMAINADMIT-C7 epoch=" as *u8) 473 o = da_catn(b, o, sys_now_realtime_sec()) 474 o = da_cat(b, o, " baseline_disagree=" as *u8); o = da_catn(b, o, base) 475 o = da_cat(b, o, " current_disagree=" as *u8); o = da_catn(b, o, cur) 476 o = da_cat(b, o, " new=" as *u8); o = da_catn(b, o, nnew) 477 o = da_cat(b, o, " fixed=" as *u8); o = da_catn(b, o, nfixed) 478 if green == 1 { o = da_cat(b, o, " verdict=GREEN\n" as *u8) } else { o = da_cat(b, o, " verdict=RED\n" as *u8) } 479 sys_write(fd, b, o) 480 sys_close(fd) 481 return 0 482} 483// The census + the ratchet. Returns the number of NEW offenders against the baseline (0 on first sight). 484func da_c7(mb: *u8) -> i64 { 485 da_w("\n=== C7 CONTRACT AGREEMENT -- one symbol, one est across every plan; one symbol, one organ across every matrix ===\n" as *u8) 486 let tot: *i64 = sys_mmap(24) as *i64 487 tot[0] = 0; tot[1] = 0; tot[2] = 0 488 if da_c7_walk(0, mb, tot, 0 as *i64, 0 as *i64, 0 as *u8, 0 as *i64) < 0 { da_w(" C7 UNOBSERVABLE: cannot open the compare tree\n" as *u8); return 0 } 489 // DERIVED bounds: one record per line at most; the arena holds slices of the files (<= their bytes), two 490 // NULs per record, and one domain name per file (a name is bounded by the path slot it came from) 491 let maxrec: i64 = tot[1] + 1 492 let rec: *i64 = sys_mmap(maxrec * DA_REC_FIELDS * 8) as *i64 493 let nrec: *i64 = sys_mmap(16) as *i64 494 nrec[0] = 0 495 let arena: *u8 = sys_mmap(tot[0] + maxrec * 2 + tot[2] * (DA_PATH + 1)) 496 let ao: *i64 = sys_mmap(16) as *i64 497 ao[0] = 0 498 da_c7_walk(1, mb, tot, rec, nrec, arena, ao) 499 let n: i64 = nrec[0] 500 let seen: *u8 = sys_mmap(n + 1) 501 var z: i64 = 0 502 while z < n { seen[z] = 0 as u8; z = z + 1 } 503 let cur: *u8 = sys_mmap(DA_NAMEBUF) 504 var cl: i64 = 0 505 var kind: i64 = DA_KIND_RUNG 506 var pass: i64 = 0 507 var total_single: i64 = 0 508 var total_agree: i64 = 0 509 var total_disagree: i64 = 0 510 while pass < 2 { 511 var single: i64 = 0 512 var agree: i64 = 0 513 var disagree: i64 = 0 514 var i: i64 = 0 515 while i < n { 516 if seen[i] == (0 as u8) { if rec[i * DA_REC_FIELDS] == kind { 517 let sym: *u8 = rec[i * DA_REC_FIELDS + 2] as *u8 518 let val0: *u8 = rec[i * DA_REC_FIELDS + 3] as *u8 519 var members: i64 = 0 520 var same: i64 = 1 521 var j: i64 = i 522 while j < n { 523 if rec[j * DA_REC_FIELDS] == kind { if da_streq(rec[j * DA_REC_FIELDS + 2] as *u8, sym) == 1 { 524 seen[j] = 1 as u8 525 members = members + 1 526 let vj: *u8 = rec[j * DA_REC_FIELDS + 3] as *u8 527 if kind == DA_KIND_RUNG { 528 if da_tenths(vj, 0, da_slen(vj)) != da_tenths(val0, 0, da_slen(val0)) { same = 0 } 529 } else { if da_streq(vj, val0) == 0 { same = 0 } } 530 } } 531 j = j + 1 532 } 533 if members == 1 { single = single + 1 } 534 else { 535 if same == 1 { agree = agree + 1 } 536 else { 537 disagree = disagree + 1 538 da_w(" C7 CONTRACT-DISAGREE kind=" as *u8) 539 if kind == DA_KIND_RUNG { da_w("rung" as *u8) } else { da_w("matrix" as *u8) } 540 da_w(" sym=" as *u8); da_w(sym) 541 var j2: i64 = i 542 while j2 < n { 543 if rec[j2 * DA_REC_FIELDS] == kind { if da_streq(rec[j2 * DA_REC_FIELDS + 2] as *u8, sym) == 1 { 544 da_w(" " as *u8); da_w(rec[j2 * DA_REC_FIELDS + 1] as *u8) 545 if kind == DA_KIND_RUNG { da_w(":est=" as *u8) } else { da_w(":organ=" as *u8) } 546 da_w(rec[j2 * DA_REC_FIELDS + 3] as *u8) 547 } } 548 j2 = j2 + 1 549 } 550 da_w("\n" as *u8) 551 // the offender SET for the ratchet: kind:sym per line 552 if kind == DA_KIND_RUNG { cl = da_cat(cur, cl, "rung:" as *u8) } else { cl = da_cat(cur, cl, "matrix:" as *u8) } 553 if cl + da_slen(sym) + 2 < DA_NAMEBUF { cl = da_cat(cur, cl, sym); cur[cl] = DA_NL as u8; cl = cl + 1 } 554 } 555 } 556 } } 557 i = i + 1 558 } 559 da_w(" C7 " as *u8) 560 if kind == DA_KIND_RUNG { da_w("rung" as *u8) } else { da_w("matrix" as *u8) } 561 da_w(" symbols: single=" as *u8); da_n(single); da_w(" multi-agree=" as *u8); da_n(agree); da_w(" multi-disagree=" as *u8); da_n(disagree) 562 da_w(" sum=" as *u8); da_n(single + agree + disagree); da_w(" of declarations=" as *u8) 563 var decl: i64 = 0 564 var q: i64 = 0 565 while q < n { if rec[q * DA_REC_FIELDS] == kind { decl = decl + 1 } q = q + 1 } 566 da_n(decl); da_w("\n" as *u8) 567 total_single = total_single + single; total_agree = total_agree + agree; total_disagree = total_disagree + disagree 568 kind = DA_KIND_MATRIX 569 pass = pass + 1 570 } 571 da_w(" C7 partition: single=" as *u8); da_n(total_single); da_w(" multi-agree=" as *u8); da_n(total_agree); da_w(" multi-disagree=" as *u8); da_n(total_disagree) 572 da_w(" distinct=" as *u8); da_n(total_single + total_agree + total_disagree); da_w(" records=" as *u8); da_n(n); da_w(" (a declaration belongs to exactly one symbol: sum of member counts == records)\n" as *u8) 573 // ---- the ratchet on the offender SET ---- 574 let base: *u8 = sys_mmap(DA_NAMEBUF) 575 let bn: i64 = dp_read(DA_C7_BASELINE, base, DA_NAMEBUF - 4) 576 if bn <= 0 { 577 let wr: i64 = da_write_file(DA_C7_BASELINE, cur, cl) 578 da_w(" C7 RATCHET BASELINE-WRITTEN baseline_disagree=" as *u8); da_n(total_disagree); da_w(" write_rc=" as *u8); da_n(wr) 579 da_w(" (self-baselined on first sight -- cannot fail by construction; the standing set is the worklist above)\n" as *u8) 580 da_c7_log(total_disagree, total_disagree, 0, 0, 1) 581 return 0 582 } 583 let basecount: i64 = da_count_lines(base, bn) 584 var nnew: i64 = 0 585 var i2: i64 = 0 586 while i2 < cl { 587 let e: i64 = da_eol(cur, cl, i2) 588 if e > i2 { if da_hasline(base, bn, cur, i2, e - i2) == 0 { 589 nnew = nnew + 1 590 da_w(" C7 NEW-OFFENDER " as *u8); da_wn(cur, i2, e - i2); da_w(" (not in the baseline -- this one is YOURS)\n" as *u8) 591 } } 592 i2 = e + 1 593 } 594 var nfixed: i64 = 0 595 var j3: i64 = 0 596 while j3 < bn { 597 let e2: i64 = da_eol(base, bn, j3) 598 if e2 > j3 { if da_hasline(cur, cl, base, j3, e2 - j3) == 0 { 599 nfixed = nfixed + 1 600 da_w(" C7 FIXED " as *u8); da_wn(base, j3, e2 - j3); da_w(" (was disagreeing, now one contract -- the floor tightens)\n" as *u8) 601 } } 602 j3 = e2 + 1 603 } 604 da_w(" C7 RATCHET baseline_disagree=" as *u8); da_n(basecount); da_w(" current_disagree=" as *u8); da_n(total_disagree) 605 da_w(" new=" as *u8); da_n(nnew); da_w(" fixed=" as *u8); da_n(nfixed); da_w("\n" as *u8) 606 if nnew == 0 { if nfixed > 0 { 607 let wr2: i64 = da_write_file(DA_C7_BASELINE, cur, cl) 608 da_w(" C7 RATCHET TIGHTENED write_rc=" as *u8); da_n(wr2); da_w("\n" as *u8) 609 } } 610 if nnew > 0 { da_c7_log(basecount, total_disagree, nnew, nfixed, 0) } else { da_c7_log(basecount, total_disagree, nnew, nfixed, 1) } 611 return nnew 612} 613 614func da_ratchet(mb: *u8, sb: *u8, cur: *u8, cl: *i64) -> i64 { 615 da_w("=== nx_domain_admit --ratchet -- only NEW offenders fail; the standing set is the worklist ===\n" as *u8) 616 da_sweep(mb, sb, cur, DA_NAMEBUF, cl) 617 // C7 runs with its own ratchet; its NEW offenders fail this verdict exactly like C1's 618 let c7new: i64 = da_c7(mb) 619 let cn: i64 = cl[0] 620 let curcount: i64 = da_count_lines(cur, cn) 621 let base: *u8 = sys_mmap(DA_NAMEBUF) 622 let bn: i64 = dp_read(DA_BASELINE, base, DA_NAMEBUF - 4) 623 if bn <= 0 { 624 let wr: i64 = da_write_file(DA_BASELINE, cur, cn) 625 da_w("RATCHET BASELINE-WRITTEN baseline_faulty=" as *u8); da_n(curcount) 626 da_w(" current_faulty=" as *u8); da_n(curcount) 627 da_w(" new=0 fixed=0 write_rc=" as *u8); da_n(wr); da_w("\n" as *u8) 628 if wr != 0 { 629 da_w("verdict=RED (self-baseline could not be WRITTEN -- a ratchet that cannot persist its floor is not a ratchet)\n" as *u8) 630 sys_exit(1); return 1 631 } 632 if c7new > 0 { 633 da_log(curcount, curcount, 0, 0, 0) 634 da_w("verdict=RED (C1 self-baselined, but C7 names a NEW contract disagreement above)\n" as *u8) 635 sys_exit(1); return 1 636 } 637 da_log(curcount, curcount, 0, 0, 1) 638 da_w("verdict=GREEN (self-baselined on first sight -- this run CANNOT fail, by construction)\n" as *u8) 639 sys_exit(0); return 0 640 } 641 let basecount: i64 = da_count_lines(base, bn) 642 var nnew: i64 = 0 643 var i: i64 = 0 644 while i < cn { 645 let e: i64 = da_eol(cur, cn, i) 646 if e > i { 647 if da_hasline(base, bn, cur, i, e - i) == 0 { 648 nnew = nnew + 1 649 da_w(" NEW-OFFENDER domain=" as *u8); da_wn(cur, i, e - i) 650 da_w(" (not in the baseline -- this one is YOURS)\n" as *u8) 651 } 652 } 653 i = e + 1 654 } 655 var nfixed: i64 = 0 656 var j: i64 = 0 657 while j < bn { 658 let e2: i64 = da_eol(base, bn, j) 659 if e2 > j { 660 if da_hasline(cur, cn, base, j, e2 - j) == 0 { 661 nfixed = nfixed + 1 662 da_w(" FIXED domain=" as *u8); da_wn(base, j, e2 - j) 663 da_w(" (was faulty, now clean -- the floor tightens to exclude it)\n" as *u8) 664 } 665 } 666 j = e2 + 1 667 } 668 da_w("RATCHET baseline_faulty=" as *u8); da_n(basecount) 669 da_w(" current_faulty=" as *u8); da_n(curcount) 670 da_w(" new=" as *u8); da_n(nnew) 671 da_w(" fixed=" as *u8); da_n(nfixed); da_w("\n" as *u8) 672 if nnew > 0 { 673 da_log(basecount, curcount, nnew, nfixed, 0) 674 da_w("verdict=RED (a domain that was clean at the baseline now declares a symbol no file backs -- each is NAMED above)\n" as *u8) 675 sys_exit(1); return 1 676 } 677 if c7new > 0 { 678 da_log(basecount, curcount, nnew, nfixed, 0) 679 da_w("verdict=RED (C1 holds, but C7 names a NEW contract disagreement above -- one symbol, one cost)\n" as *u8) 680 sys_exit(1); return 1 681 } 682 if nfixed > 0 { 683 let wr2: i64 = da_write_file(DA_BASELINE, cur, cn) 684 da_w("RATCHET TIGHTENED write_rc=" as *u8); da_n(wr2) 685 da_w(" (a ratchet that does not tighten when you improve is just a threshold)\n" as *u8) 686 } 687 da_log(basecount, curcount, nnew, nfixed, 1) 688 da_w("verdict=GREEN (no NEW offender against a baseline of " as *u8); da_n(basecount) 689 da_w(" -- the standing set is the adjudication worklist, printed per domain by --all)\n" as *u8) 690 sys_exit(0); return 0 691} 692 693// ==== C4 FRESH-KILL -- da_kv, da_c4_partition and da_c4 MOVED to nx_domain_admit_lib.nx ==== 694// The doctrine that justifies the three buckets and the deliberate refusal to assert freshness travels 695// WITH the code, in the library. Duplicating it here would be two copies of one argument, and the copy 696// nobody edits is the one the next reader believes. 697 698func main(argc: i64, argv: *i64) -> i64 { 699 if argc < 2 { 700 da_w("usage: nx_domain_admit <domain> | --all | --ratchet\n" as *u8) 701 da_w(" composes the ADMISSION_STANDARD checks into one REFUSING gate\n" as *u8) 702 da_w(" --all sweeps every knowledge/compare/*.matrix for C1 symbol grounding + C7 contract agreement (one symbol, one est / one organ)\n" as *u8) 703 sys_exit(2); return 2 704 } 705 let a1: *u8 = argv[1] as *u8 706 if a1[0] == (45 as u8) { 707 let smb: *u8 = sys_mmap(DA_MCAP) 708 let ssb: *u8 = sys_mmap(DA_SCAP) 709 let nb: *u8 = sys_mmap(DA_NAMEBUF) 710 let nl: *i64 = sys_mmap(16) as *i64 711 nl[0] = 0 712 if a1[2] == (DA_CH_R as u8) { return da_ratchet(smb, ssb, nb, nl) } 713 da_w("=== nx_domain_admit --all -- C1 symbol grounding across every compare matrix + C7 contract agreement ===\n" as *u8) 714 let faulty: i64 = da_sweep(smb, ssb, nb, DA_NAMEBUF, nl) 715 let c7new: i64 = da_c7(smb) 716 if faulty == 0 { if c7new == 0 { 717 da_w("VERDICT=ADMIT (every matrix grounds every symbol it declares; no new contract disagreement)\n" as *u8) 718 sys_exit(0); return 0 719 } } 720 if faulty > 0 { da_w("VERDICT=REFUSE (a matrix declares a symbol no file backs)\n" as *u8) } 721 else { da_w("VERDICT=REFUSE (C7: a NEW contract disagreement, named above)\n" as *u8) } 722 sys_exit(1); return 1 723 } 724 let dom: *u8 = argv[1] as *u8 725 let path: *u8 = sys_mmap(DA_PATH) 726 var p: i64 = da_cat(path, 0, DA_CDIRS) 727 p = da_cat(path, p, dom) 728 p = da_cat(path, p, ".matrix" as *u8) 729 path[p] = 0 as u8 730 731 let mb: *u8 = sys_mmap(DA_MCAP) 732 let mn: i64 = dp_read(path, mb, DA_MCAP - 4) 733 da_w("=== nx_domain_admit -- " as *u8); da_w(dom); da_w(" ===\n" as *u8) 734 if mn <= 0 { 735 da_w(" C1 REFUSE: no readable matrix at " as *u8); da_w(path); da_w("\n" as *u8) 736 da_w("VERDICT=REFUSE\n" as *u8) 737 sys_exit(3); return 3 738 } 739 740 let sb: *u8 = sys_mmap(DA_SCAP) 741 var rows: i64 = 0 742 var absent: i64 = 0 743 var grounded: i64 = 0 744 var ungrounded: i64 = 0 745 var unreadable: i64 = 0 746 var newwatch: i64 = 0 747 748 var i: i64 = 0 749 while i < mn { 750 let le: i64 = da_eol(mb, mn, i) 751 if le > i { 752 let f: i64 = mb[i] as i64 753 var skip: i64 = 0 754 if f == DA_HASH { skip = 1 } 755 if f == DA_AT { skip = 1 } 756 if f == DA_NL { skip = 1 } 757 if skip == 0 { 758 // first three pipes -> label | organ | symbol 759 var p1: i64 = 0 - 1 760 var p2: i64 = 0 - 1 761 var p3: i64 = 0 - 1 762 var k: i64 = i 763 while k < le { 764 if mb[k] == (DA_PIPE as u8) { 765 if p1 < 0 { p1 = k } else { if p2 < 0 { p2 = k } else { if p3 < 0 { p3 = k; k = le } } } 766 } 767 k = k + 1 768 } 769 if p3 > 0 { 770 rows = rows + 1 771 let sa: i64 = p2 + 1 772 // Same classifier as the sweep path -- this copy of the row loop is precisely what 773 // da_c1's own comment warns about ("a sweep that re-implements the check is a second 774 // opinion, not a wider one"), and it is why the watch-row defect existed twice. 775 let cls: i64 = da_classify_row(mb, p1, p2, p3, sb) 776 if cls == 0 { absent = absent + 1 } 777 if cls == 1 { grounded = grounded + 1; da_rule_disagree(mb, p1, p2, da_symstart(mb, sa, p3), p3, dom) } 778 if cls == 3 { 779 unreadable = unreadable + 1 780 da_w(" C1 UNREADABLE organ: " as *u8) 781 da_wn(mb, p1 + 1, p2 - (p1 + 1)) 782 da_w(" (row: " as *u8); da_wn(mb, i, p1 - i); da_w(")\n" as *u8) 783 } 784 if cls == 4 { 785 newwatch = newwatch + 1 786 da_w(" C1 WATCH-NEW-ORGAN (a contract on an organ that does not exist yet -- counted and named, not a fault): " as *u8) 787 da_wn(mb, p1 + 1, p2 - (p1 + 1)) 788 da_w(" (row: " as *u8); da_wn(mb, i, p1 - i); da_w(")\n" as *u8) 789 } 790 if cls == 2 { 791 ungrounded = ungrounded + 1 792 da_w(" C1 UNGROUNDED symbol " as *u8) 793 da_wn(mb, sa, p3 - sa) 794 da_w(" not word-boundary-present in " as *u8) 795 da_wn(mb, p1 + 1, p2 - (p1 + 1)) 796 da_w("\n row: " as *u8); da_wn(mb, i, p1 - i); da_w("\n" as *u8) 797 } 798 } 799 } 800 } 801 i = le + 1 802 } 803 804 // ---- C2: rival bars pinned, or the matrix header declares them unpinned ---- 805 let bb: *u8 = sys_mmap(DA_MCAP) 806 let bn: i64 = dp_read("knowledge/barcheck.conf" as *u8, bb, DA_MCAP - 4) 807 var bars: i64 = 0 808 if bn > 0 { 809 var bi: i64 = 0 810 let dl: i64 = da_slen(dom) 811 while bi < bn { 812 let ble: i64 = da_eol(bb, bn, bi) 813 if ble > bi { 814 if bb[bi] != (DA_HASH as u8) { 815 var bp: i64 = 0 - 1 816 var bk: i64 = bi 817 while bk < ble { if bb[bk] == (DA_PIPE as u8) { bp = bk; bk = ble } else { bk = bk + 1 } } 818 if bp > bi { if da_sl_eq(bb, bi, bp, dom) == 1 { bars = bars + 1 } } 819 } 820 } 821 bi = ble + 1 822 } 823 } 824 var unpinned_declared: i64 = 0 825 if da_wfind(mb, mn, DA_UNPINNED, 0, da_slen(DA_UNPINNED)) >= 0 { unpinned_declared = 1 } 826 827 // ---- C3: executable evidence -- ONE resolver, shared with C4 (da_gates_read) ---- 828 // Strictly additive: this can turn has_gates 0 into 1 and never 1 into 0, and C3 does not gate the 829 // verdict, so no domain that passes today can begin to fail because of it. C3 and C4 each built this 830 // path independently until 2026-08-25, which is exactly how the 2026-08-20 repoint left one of the 831 // two behind and has_gates read 0 for every domain in the estate. One resolver cannot half-move. 832 let gn: i64 = da_gates_read(dom, sb) 833 var has_gates: i64 = 0 834 if gn > 0 { has_gates = 1 } 835 836 da_w("\n rows=" as *u8); da_n(rows) 837 da_w(" grounded=" as *u8); da_n(grounded) 838 da_w(" absent=" as *u8); da_n(absent) 839 da_w(" ungrounded=" as *u8); da_n(ungrounded) 840 da_w(" organ-unreadable=" as *u8); da_n(unreadable) 841 da_w(" watch-new-organ=" as *u8); da_n(newwatch) 842 da_w("\n C2 bars pinned=" as *u8); da_n(bars) 843 da_w(" unpinned-declared=" as *u8); da_n(unpinned_declared) 844 da_w("\n C3 gates file=" as *u8); da_n(has_gates) 845 da_w("\n" as *u8) 846 da_c4(dom, sb) 847 // C5 and C6 were HARD-CODED PLACEHOLDER STRINGS from the day this organ was written until 2026-08-25: 848 // every domain in the estate got the same literal UNVERIFIED, which is a constant wearing the shape of 849 // a measurement. Both now read real artifacts and both, like C3 and C4, REPORT WITHOUT REFUSING -- so 850 // no domain that is admitted today can begin to be refused because of them. 851 // rows is passed to C6 on purpose: the evidence stamp cannot tell an honest RED from a read that never 852 // saw the domain, and this gate's own row count is the second opinion that separates them. 853 da_c5(dom, sb) 854 da_c6(dom, sb, rows) 855 856 var fail: i64 = 0 857 if ungrounded > 0 { fail = 1 } 858 if unreadable > 0 { fail = 1 } 859 if bars == 0 { if unpinned_declared == 0 { fail = 1 } } 860 861 if fail == 1 { 862 da_w("\nVERDICT=REFUSE\n" as *u8) 863 if ungrounded > 0 { da_w(" reason: a symbol the matrix declares is NOT in the organ it names -- the row asserts coverage no file backs\n" as *u8) } 864 if unreadable > 0 { da_w(" reason: a declared organ path could not be read -- an unresolvable citation is not a citation\n" as *u8) } 865 if bars == 0 { if unpinned_declared == 0 { da_w(" reason: no barcheck row for this domain AND no UNPINNED declaration -- the comparison is silently unfalsifiable\n" as *u8) } } 866 sys_exit(1); return 1 867 } 868 869 da_w("\nVERDICT=ADMIT" as *u8) 870 if has_gates == 0 { da_w(" (CLAIM-ONLY -- no <domain>.gates, which is permitted when declared)" as *u8) } 871 da_w("\n" as *u8) 872 sys_exit(0) 873 return 0 874}