code wiki / _hdl_build / nx_nv1d_register.nx

nx_nv1d_register.nx source

↩ module page · 42 lines · 3017 B

1// nx_nv1d_register.nx -- GOVERNED registration of daemon-side NV1 2// validate-on-upload (the second named rung from the NV1 spec). Engineer 3// evidence = format gates rebuilt+rerun THIS invocation; the live daemon 4// KATs are re-runnable via bash _nv1_validate_kats (verdict GREEN cited). 5// license_tier: ORIGINAL 6import "nx_cap_register.nx" 7import "nx_capreg_librarian.nx" 8import "nx_syscalls.nx" 9 10func ndr_run(path: *u8) -> i64 { 11 let pid: i64 = sys_fork() 12 if pid == 0 { 13 let dn: i64 = sys_openat_wr("/dev/null" as *u8, 0x1a4) 14 if dn >= 0 { sys_dup3(dn, 1, 0); sys_dup3(dn, 2, 0) } 15 let argv: *i64 = sys_mmap(32) as *i64; argv[0] = path as i64; argv[1] = 0 16 let envp: *i64 = sys_mmap(16) as *i64; envp[0] = 0 17 sys_execve(path, argv, envp); sys_exit(127) 18 } 19 let st: *i64 = sys_mmap(16) as *i64 20 sys_wait4(pid, st, 0) 21 return st[0] 22} 23 24func main() -> i64 { 25 var allok: i64 = 1 26 if ndr_run("/tmp/nx_nv1_gate.elf" as *u8) != 0 { allok = 0 } 27 if ndr_run("/tmp/nx_nv1_lpc_gate.elf" as *u8) != 0 { allok = 0 } 28 cr_w(1, "ENGINEER: nv1 format gates all-pass=" as *u8); cr_wn(1, allok); cr_w(1, "\n" as *u8) 29 let eng: i64 = ig_engineer(1, 1, 1, allok) 30 let dec: i64 = ig_decision(eng, ig_council(eng, 1, 1, 2), 1) 31 if dec != IG_INGEST { cr_w(1, "HELD\n" as *u8); sys_exit(1) } 32 if cr_can_register(5, 2, 6, dec) != 1 { cr_w(1, "REFUSED\n" as *u8); sys_exit(1) } 33 let lp: *u8 = "/tmp/nishi_cap_registry.log" as *u8 34 let jp: *u8 = "knowledge/status/cap_registry_durable.log" as *u8 35 let idx1: i64 = cl_next_idx(lp, jp) 36 let ok1: i64 = cl_register_dual(lp, jp, idx1, 5, 37 2, "GEN NV1-DAEMON-VALIDATE-ON-UPLOAD (arc=NISHI-VIDEO rung 2 of the NV1 spec) LIVE on nishifamily.com. nx_sites_daemon_v2 circle upload REWRITTEN buffer-then-validate-then-store: full body received into lazy mmap (cap 32MB) FIRST; ext=nv1 bodies must pass nv1_validate (A raw + L LPC kinds) or 400 nv1-invalid + NOTHING STORED (Cardinal-18 log line names the negative rc); truncation also stores nothing (old path left truncated files in the store -- fixed); legacy webm stays opaque back-compat. sd2_body_copy helper keeps receive-loop nesting shallow (nested-if miscompile landmine). DEPLOY = FIRST VAULT-FLOW SHIP SCRIPT: _nv1_validate_ship carries NO plaintext NAS pw (machine-key -> argon2id vault -> RAM var -> shred; pays the named debt for new scripts; older scripts still owe). LIVE KATs re-runnable bash _nv1_validate_kats VERDICT=GREEN: valid A-NV1 + L-NV1 accepted AND store-RT BYTE-IDENTICAL, bad-magic + truncated REJECTED + absent from listing, webm ok, public sweep 4x200. Daemon rollback bak sites.elf.bak-pre-nv1validate-20260610. K3 transient-download lesson: post-bounce first download can drop -> dl retry-once in KATs" as *u8) 38 if ok1 != 1 { cr_w(1, "DUAL-WRITE FAILED\n" as *u8); sys_exit(1) } 39 cr_w(1, "CAPREG idx=" as *u8); cr_wn(1, idx1); cr_w(1, " REGISTERED -- daemon NV1 validate\n" as *u8) 40 sys_exit(0) 41 return 0 42}