code wiki / _hdl_build / nx_ncf_scaffold_register.nx

nx_ncf_scaffold_register.nx source

↩ module page · 56 lines · 4777 B

1// nx_ncf_scaffold_register.nx -- registers the DECLARED-SCAFFOLD pe8 field-kinds 6 2// (KEYWORD_NUL_SPLIT) + 7 (CRC32_TRAILER) with author=tutor (X-AUT-002a vocab) so the A2 3// autonomy meter DEBITS them: counted in auth_all (the ` author=` denominator, 4// nx_autonomy_meter:108) but NEVER in auth_emit (` author=emitter`, :109). These are 5// HAND-WRITTEN seed primitives (operator-authorized R3, X-AUT-NCF-001); tagging them 6// author=emitter to inflate A2 would be the cheat and is REFUSED. Modeled exactly on 7// nx_autmeter_register (the accepted tutor-tag pattern, author=tutor-with-team -> debited). 8// GUARD: the SEED proof re-runs GREEN at register time -- it (a) drives pe8 to AUTHOR the 9// generic _pe_kw_crc [KEYWORD_NUL_SPLIT][CRC32_TRAILER] record + proves the malformed-table 10// rails REFUSE, then (b) builds+runs the organ-authored KAT (emitter-computed crc trailer + 11// crc-tamper arm) sovereignly. Refuse to register a red scaffold. license_tier: ORIGINAL 12import "nx_cap_register.nx" 13import "nx_capreg_librarian.nx" 14import "nx_syscalls.nx" 15 16// fork+exec the sovereign driver on a module basename; returns the child's exit code (-1 on 17// signal). Mirrors nx_vnscene_register vr_run. 18func sr_run(name: *u8) -> i64 { 19 let pid: i64 = sys_fork() 20 if pid == 0 { 21 let dn: i64 = sys_openat_wr("/dev/null" as *u8, 0x1a4) 22 if dn >= 0 { sys_dup3(dn, 1, 0); sys_dup3(dn, 2, 0) } 23 let argv: *i64 = sys_mmap(32) as *i64 24 argv[0] = "_offc/nx_sov_build_run.elf" as *u8 as i64 25 argv[1] = name as i64 26 argv[2] = 0 27 let envp: *i64 = sys_mmap(16) as *i64 28 envp[0] = 0 29 sys_execve("_offc/nx_sov_build_run.elf" as *u8, argv, envp) 30 sys_exit(127) 31 } 32 let st: *i64 = sys_mmap(16) as *i64 33 sys_wait4(pid, st, 0) 34 if (st[0] % 128) != 0 { return 0 - 1 } 35 return (st[0] >> 8) & 0xff 36} 37 38func main() -> i64 { 39 let lp: *u8 = "/tmp/nishi_cap_registry.log" as *u8 40 let jp: *u8 = "knowledge/status/cap_registry_durable.log" as *u8 41 // GUARD 1: the SEED harness authors _pe_kw_crc + proves the rails REFUSE (exit 0). 42 if sr_run("_seed_ncf_kinds67" as *u8) != 0 { cr_w(1, "SEED harness not green -- refuse register\n" as *u8); sys_exit(1) } 43 // GUARD 2: the organ-authored KAT (emitter-computed crc + crc-tamper arm) builds+runs green. 44 if sr_run("_pe_kw_crc_test" as *u8) != 0 { cr_w(1, "scaffold KAT not green -- refuse register\n" as *u8); sys_exit(1) } 45 let idx: i64 = cl_next_idx(lp, jp) 46 // CRITICAL: the name text must NEVER contain the literal ` author=emitter` substring -- 47 // the A2 meter (nx_autonomy_meter:109) substring-counts ` author=emitter` toward the 48 // numerator, so even prose mentioning the emitter tag would falsely INFLATE A2 (the cheat). 49 // Refer to the emitter tag WITHOUT writing that exact string ("the emitter author-tag"). 50 let ok: i64 = cl_register_dual(lp, jp, idx, 6, 51 2, "SELF NCF-SCAFFOLD author=tutor (DECLARED-SCAFFOLD, operator-authorized R3, X-AUT-NCF-001 / spec 2026-06-13-keystone-newcontrolflow-route-decision.md -- and the meter DEBITS it honestly: counted in auth_all, NEVER in the emitter numerator) -- two GENERIC hand-written pe8/STRUCT_WALK v2 field-kinds no existing shape emits and the transducer cannot synthesize (author_share for new control flow MEASURED=0): kind 6 KEYWORD_NUL_SPLIT (scan to first 0x00, split keyword from value-start, body-relative multi-slot out -- the universal NUL-split of PNG tEXt / ID3v2 text frames / gzip+ZIP filename / DNS labels, NOT a PNG hack) + kind 7 CRC32_TRAILER (crc32 poly 0xEDB88320 reflected BAKED as a math constant at emit time, verify the 4-byte BE stored trailer over a caller-given range, refuse on mismatch -- the universal crc32-trailer of PNG/gzip/ZIP/Ethernet FCS/IEEE 802.3, NOT a PNG hack). BOOTSTRAP-PROVISIONAL until >=2 independent parsers ride them (X-AUT-NCF-BOOT); the first rider (the PNG-tEXt reader) is authored BY nx_auto_builder hands-off from a DATA spec carrying the emitter author-tag, NOT hand-written. SEED PROVEN: pe8 authors _pe_kw_crc from a 2-field table, malformed-table rails (kind 6 last / out-slot<2 / unknown kind 8) REFUSE, the organ-authored KAT builds+runs GREEN sovereignly (no gcc) with an emitter-COMPUTED crc trailer (crc32(abc NUL)=2807916624 == python oracle) AND a crc-tamper arm that FIRES (flip 1 body byte -> verify refuses -1, no fake-green). DEBITED vs autonomy: this register row is author=tutor by law -- the payoff reader is the organ-authored counted cap." as *u8) 52 if ok != 1 { cr_w(1, "DUAL-WRITE FAILED\n" as *u8); sys_exit(1) } 53 cr_w(1, "CAPREG idx=" as *u8); cr_wn(1, idx); cr_w(1, " NCF-SCAFFOLD author=tutor registered (DEBITED -- the honest scaffold debit)\n" as *u8) 54 sys_exit(0) 55 return 0 56}