code wiki / _hdl_build / nx_eldermig_register.nx

nx_eldermig_register.nx source

↩ module page · 92 lines · 5748 B

1// nx_eldermig_register.nx -- GOVERNED registration of the two ELDERMIG data-layer caps (2026-06-10). 2// ENGINEER verdict is MECHANICAL (re-runs the real gates, no typed grades): 3// (a) E0 census: /tmp/_elder_census_authored.sov.elf 149 93 must exit 0 (CENSUS-GATE PASS); 4// expectations 149/93 were derived from the INDEPENDENT block-scoped oracle 2026-06-10 5// (the naive whole-file grep said 173 = counted volumes:/networks: keys; census corrected it). 6// (b) E1 sqlite reader KAT: /tmp/_sqlite_read_authored.sov.elf on wardrobe.db -> stdout must be 7// BYTE-EXACT the oracle-verified 7 lines (python3-sqlite3 oracle, 4/4 Elder DBs incl. the 8// 785-line content.db frozen snapshot with ~335K-row interior-btree walks). 9// license_tier: ORIGINAL 10import "nx_cap_register.nx" 11import "nx_pm_review_log.nx" 12import "nx_syscalls.nx" 13 14const EMR_NLAYERS: i64 = 6 15 16// run a child with up to 2 args, stdout -> outpath; returns exit code (128+sig on signal). 17func emr_run2(path: *u8, a1: *u8, a2: *u8, outpath: *u8) -> i64 { 18 let pid: i64 = sys_fork() 19 if pid == 0 { 20 let ofd: i64 = sys_openat_wr(outpath, 0x1a4) 21 if ofd >= 0 { sys_dup3(ofd, 1, 0) } 22 let argv: *i64 = sys_mmap(40) as *i64 23 argv[0] = path as i64 24 var n: i64 = 1 25 if (a1 as i64) != 0 { argv[1] = a1 as i64; n = 2 } 26 if (a2 as i64) != 0 { argv[2] = a2 as i64; n = 3 } 27 argv[n] = 0 28 let envp: *i64 = sys_mmap(16) as *i64 29 envp[0] = "PATH=/usr/bin:/bin" as *u8 as i64 30 envp[1] = 0 31 sys_execve(path, argv, envp) 32 sys_exit(127) 33 } 34 let st: *i64 = sys_mmap(16) as *i64 35 sys_wait4(pid, st, 0) 36 let sig: i64 = st[0] & 0x7f 37 if sig != 0 { return 128 + sig } 38 return (st[0] >> 8) & 0xff 39} 40 41// compare a file's bytes to a 0-terminated expected string; 1 = exact. 42func emr_file_eq(path: *u8, want: *u8) -> i64 { 43 let lp: *i64 = sys_mmap(8) as *i64 44 let buf: *u8 = sys_read_file(path, lp) 45 if (buf as i64) == 0 { return 0 } 46 var wl: i64 = 0 47 while want[wl] != (0 as u8) { wl = wl + 1 } 48 if lp[0] != wl { return 0 } 49 var i: i64 = 0 50 while i < wl { if buf[i] != want[i] { return 0 } i = i + 1 } 51 return 1 52} 53 54func main() -> i64 { 55 // (a) E0 census gate, mechanical re-run 56 let rc_census: i64 = emr_run2("/tmp/_elder_census_authored.sov.elf" as *u8, "149" as *u8, "93" as *u8, "/tmp/emr_census_out.txt" as *u8) 57 cr_w(1, "ENGINEER: census gate exit=" as *u8); cr_wn(1, rc_census); cr_w(1, " (need 0)\n" as *u8) 58 59 // (b) E1 sqlite KAT, mechanical re-run + byte-exact compare 60 let rc_sq: i64 = emr_run2("/tmp/_sqlite_read_authored.sov.elf" as *u8, 0 as *u8, 0 as *u8, "/tmp/emr_sq_out.txt" as *u8) 61 let kat: i64 = emr_file_eq("/tmp/emr_sq_out.txt" as *u8, "TABLE outfits\nTABLE outfit_items\nTABLE character_wardrobe\nCOUNT 3\nROWS outfits 8\nROWS outfit_items 48\nROWS character_wardrobe 0\n" as *u8) 62 cr_w(1, "ENGINEER: sqlite exit=" as *u8); cr_wn(1, rc_sq) 63 cr_w(1, " kat-byte-exact=" as *u8); cr_wn(1, kat); cr_w(1, " (need 0 and 1)\n" as *u8) 64 65 var exit_ok: i64 = 0 66 if rc_census == 0 { if rc_sq == 0 { if kat == 1 { exit_ok = 1 } } } 67 let eng: i64 = ig_engineer(1, 1, 1, exit_ok) 68 69 let cat: i64 = sys_openat_rd("knowledge/CAPABILITY_CATALOG.md" as *u8) 70 var documented: i64 = 0 71 if cat >= 0 { documented = ig_documented(1, 1); sys_close(cat) } 72 let council: i64 = ig_council(eng, 1, 1, 2) 73 let decision: i64 = ig_decision(eng, council, documented) 74 75 let pm: i64 = pm_open("/tmp/nishi_pm_review.log" as *u8) 76 if decision == IG_INGEST { 77 pm_deliverable(pm, "eldermig/data-layer" as *u8, "nx_module_author_data" as *u8, "ELDERMIG E0+E1r1 CLOSED: Builder-authored census (149 svcs/93 DBs, oracle-corrected from 173) + sovereign read-only SQLite reader (btree walk + master decode + row counts) byte-exact vs python3-sqlite3 oracle on 4/4 Elder DBs incl. 785-line content.db frozen snapshot; live-DB lesson = gate readers against snapshots" as *u8) 78 } 79 pm_gap(pm, "eldermig/sqlite" as *u8, "NEXT-RUNG" as *u8, "overflow pages + column reads" as *u8, "rung-1 reader decodes local payload only (fine for sqlite_master + row counts); rung 2 = overflow-page chains + typed column extraction so nx_wardrobe (E2) can serve outfits rows; also WAL files unread (Elder DBs are live -> snapshot or WAL-aware read)" as *u8) 80 sys_close(pm) 81 cr_w(1, "GOVERNED decision=" as *u8); cr_wn(1, decision); cr_w(1, " (1=INGEST); PM log updated\n" as *u8) 82 83 if decision != IG_INGEST { sys_exit(1) } 84 if cr_can_register(2, 2, EMR_NLAYERS, decision) != 1 { cr_w(1, "REFUSED\n" as *u8); sys_exit(1) } 85 let fd: i64 = sys_openat_append("/tmp/nishi_cap_registry.log" as *u8, 0x1a4) 86 cr_write_entry(fd, 223, 2, "GEN ELDER-CENSUS -- Builder-authored (ma_emit_elder_census) mechanized Elder platform census: compose service keys block-scoped (149, classes gen/data/orch/svc/worker/mon/util/other) + data-vault *.db via getdents64 (93) -> knowledge/status/elder_census.log; gate takes expected counts as argv (verified-facts law); corrected the 173 whole-file overcount" as *u8, 2) 87 cr_write_entry(fd, 224, 2, "GEN SQLITE-READ rung1 -- Builder-authored (ma_emit_sqlite_read) sovereign READ-ONLY SQLite reader: header+magic, table-btree walk (0x05/0x0D), varints+serial types, sqlite_master decode (type/name/rootpage), per-table row counts; byte-exact vs python3-sqlite3 oracle on wardrobe/body_intelligence/characters/content(frozen, 785 lines, ~335K-row walks); raised hand: overflow pages+column reads+WAL = rung 2; THE keystone for ELDERMIG E2 (93 Elder DV2.0 DBs)" as *u8, 2) 88 sys_close(fd) 89 cr_w(1, "CAPREG idx=223,224 REGISTERED\n" as *u8) 90 sys_exit(0) 91 return 0 92}