code wiki / _hdl_build / nx_ingest_audit_gate.nx

nx_ingest_audit_gate.nx source

↩ module page · 47 lines · 2775 B

1// nx_ingest_audit_gate.nx -- prove the audit's NEW logic: the grade-table parser answers correctly 2// in both polarities and fails loudly when the table is missing. (The fact probes it dispatches to 3// carry their own gates: mediafacts 8/8, modelfacts 9/9, varfacts 6/6 -- not re-proven here.) 4// license_tier: ORIGINAL No hw writes (Rule 26). 5import "nx_syscalls.nx" 6import "nx_gate_verdict.nx" 7import "nx_ingest_audit.nx" 8 9func ig_wfile(path: *u8, s: *u8) -> i64 { 10 let fd: i64 = sys_openat_wr(path, 0x1a4) 11 if fd < 0 { return 0 - 1 } 12 var n: i64 = 0 13 while s[n] != (0 as u8) { n = n + 1 } 14 var w: i64 = 0 15 while w < n { let k: i64 = sys_write(fd, ((s as i64) + w) as *u8, n - w); if k <= 0 { sys_close(fd); return 0 - 1 } w = w + k } 16 sys_close(fd) 17 return n 18} 19 20func main(argc: i64, argv: *i64) -> i64 { 21 let ctr: *i64 = gv_ctr() 22 gv_head("nx_ingest_audit_gate -- the grade table is parsed right, and its absence is loud" as *u8) 23 24 // fixture conf: 2 rows for a test lane (one CLAIMED, one GAP), 1 row for another lane, a comment 25 let fix: *u8 = "/tmp/ia_gate_grades.conf" as *u8 26 ig_wfile(fix, "# comment line must be skipped\ntestlane\tS\tCLAIMED\tsome gate 5/5\ntestlane\tR2\tGAP\tunbuilt\notherlane\tU\tCLAIMED\tx\n" as *u8) 27 28 // T1 the named lane returns exactly ITS rows (not the comment, not the other lane's) 29 let r1: i64 = ia_ladder_from(fix, "testlane" as *u8) 30 gv_check("T1 LANE ROWS PARSED: the fixture lane yields exactly its 2 rows -- comments and other lanes excluded by the tab-anchored match" as *u8, (r1 == 2) as i64, ctr) 31 32 // T2 an absent lane yields zero rows -- the driver of the CLI's loud AUDIT-RED path 33 let r2: i64 = ia_ladder_from(fix, "missing" as *u8) 34 gv_check("T2 ABSENT LANE IS ZERO: an ungraded lane returns 0 rows so the CLI exits RED -- a missing grade table can never read as an empty success" as *u8, (r2 == 0) as i64, ctr) 35 36 // T3 an unreadable conf is DISTINCT from an empty lane (-1, the fail-closed arm) 37 let r3: i64 = ia_ladder_from("/tmp/ia_gate_absent_file.conf" as *u8, "testlane" as *u8) 38 gv_check("T3 UNREADABLE CONF IS ITS OWN FAILURE: -1, not 0 -- a lost table and an ungraded lane are two different facts" as *u8, (r3 == 0 - 1) as i64, ctr) 39 40 // T4 the REAL table grades the model lane with all 6 rungs (the live full-ladder lane) 41 let r4: i64 = ia_ladder_from("knowledge/ladder_grades.conf" as *u8, "model" as *u8) 42 gv_check("T4 LIVE TABLE: the model lane carries all 6 ladder rungs in the real knowledge/ladder_grades.conf" as *u8, (r4 == 6) as i64, ctr) 43 44 let rc: i64 = gv_verdict("INGEST-AUDIT-GATE", ctr, "fixture-driven parser proof, both polarities, distinct failure arms, live table checked" as *u8) 45 sys_exit(rc) 46 return rc 47}