code wiki / _hdl_build / nx_pattern_emit4_register.nx
nx_pattern_emit4_register.nx source
↩ module page · 42 lines · 2913 B
1// nx_pattern_emit4_register.nx -- records PARSER_KAT + GOVERNOR emitters. FIRST registration through
2// the Librarian's repaired registry: idx comes from cl_next_idx (atomic allocation -- no hardcoded
3// index, the root-cause fix for the cross-session collisions) and the line lands via cl_register_dual
4// (live + NTFS journal -- the crash-survival fix proven this session when /tmp died and only the
5// journal lived). Engineer gate = both team-authored tests green. license_tier: ORIGINAL
6import "nx_cap_register.nx"
7import "nx_capreg_librarian.nx"
8import "nx_syscalls.nx"
9
10func pe4r_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 pe4r_run("/tmp/_pe_num_test.sov.elf" as *u8) != 0 { allok = 0 }
27 if pe4r_run("/tmp/_pe_crawl_test.sov.elf" as *u8) != 0 { allok = 0 }
28 cr_w(1, "ENGINEER: team-authored parser+governor tests 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 idx: i64 = cl_next_idx(lp, jp)
36 let ok: i64 = cl_register_dual(lp, jp, idx, 5,
37 2, "SELF PATTERN-EMIT-4 (Builder authors PARSER_KAT + GOVERNOR, shapes 6+7 of 10 hands-off) -- PARSER_KAT: ws-skip decimal parse with -1-refusal (the claim_extract/registry-scan shape; KATs: plain/ws+junk/leading-zeros/all-junk/empty). GOVERNOR: min-gap pacing + clamped exponential backoff, all knobs spec params not magic numbers (polite_crawl spec 1500ms gap, 500ms base, 8s cap; boundary KATs computed FROM the spec by the emitter). PROVEN: team authored _pe_num + _pe_crawl, ENGINEER verified both green, ZERO Claude core logic. FIRST registration via the Librarian repaired registry: idx ALLOCATED by cl_next_idx (not hardcoded -- the collision root-cause fix) + dual-write live+journal (the crash-survival fix). Extends emit(231)/emit2(235)/emit3(241); composes nx_capreg_librarian" as *u8)
38 if ok != 1 { cr_w(1, "DUAL-WRITE FAILED\n" as *u8); sys_exit(1) }
39 cr_w(1, "CAPREG idx=" as *u8); cr_wn(1, idx); cr_w(1, " REGISTERED via Librarian alloc+dual-write (7/10 shapes hands-off incl. SCAFFOLD)\n" as *u8)
40 sys_exit(0)
41 return 0
42}