nx_media_ingest_pipeline_gate.nx source
↩ module page · 57 lines · 3559 B
1// nx_media_ingest_pipeline_gate.nx -- teeth for the keystone pipeline's path resolver + always-inform contract.
2// license_tier: ORIGINAL
3//
4// D001 MIGRATION 2026-09-01 (/compare/mediaingest). This gate was one of FOUR in this domain that the matrix
5// header listed as "candidate gates already in tree" and that had NO ELF AT ALL (exit 127). The reason was not
6// neglect: /api/promote REFUSES a gate that rolls its own verdict, so the source could never become an
7// artifact, so the domain's own evidence base was a list of names. The refusal was correct and the fix is the
8// migration, never the allow_own_verdict escape -- that escape ships a gate whose outcome nothing can read.
9//
10// WHAT CHANGED AND WHAT DID NOT. The four subjects, their order and their assertions are byte-for-byte the
11// same checks; only the verdict machinery moved from a hand-rolled pass/tot pair onto nx_gate_verdict:
12// - gv_ctr/gv_check make DECLARED == EXECUTED by construction. The hand-rolled version could print
13// "pass=4/4" while a tooth had silently stopped running, because the same code incremented both numbers.
14// - the exit code is now produced by gv_verdict, so /api/gate_run and nx_gate_green can both READ the
15// outcome, and the run records a harness.jrnl frame -- without which flake and erosion are invisible
16// for this gate specifically.
17// - T3 is renamed to say it is a NEGATIVE CONTROL. It always was one; it was invisible to the L2 census
18// purely by naming, which costs nothing to fix and makes it countable.
19// The old main() printed verdict=GREEN/RED and exited 0/1, so this migration does not CHANGE the verdict for
20// any input -- it makes the same verdict legible to the judge.
21import "nx_syscalls.nx"
22import "nx_media_ingest_pipeline.nx"
23import "nx_gate_verdict.nx"
24
25func g_streq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if b[i] != (0 as u8) { return 0 } return 1 }
26
27func main() -> i64 {
28 gv_head("=== nx_media_ingest_pipeline_gate -- path resolver + always-inform contract (mediaingest) ===" as *u8)
29 let c: *i64 = gv_ctr()
30 let out: *u8 = sys_mmap(4096)
31
32 // T1: NAS path built exactly
33 mp_join(GALX_DIR_NAS, "foo.elf" as *u8, out)
34 var t1: i64 = 0
35 if g_streq(out, "/volume1/ai/galx/foo.elf" as *u8) == 1 { t1 = 1 }
36 if t1 == 0 { gv_puts(" DIAG T1 join=" as *u8); gv_puts(out); gv_puts("\n" as *u8) }
37 gv_check("nas-path-joined-exactly" as *u8, t1, c)
38
39 // T2: a missing tool RESOLVES TO 0 -> reported, never a silent skip (the always-inform contract).
40 // This is the tooth that matters: a resolver that silently skips a missing tool turns an absent
41 // capability into a clean run, which is the defect the whole pipeline's contract exists to refuse.
42 var t2: i64 = 0
43 if mp_resolve("__nonexistent_tool_xyz__.elf" as *u8, out) == 0 { t2 = 1 }
44 gv_check("missing-tool-is-REPORTED-not-silently-skipped" as *u8, t2, c)
45
46 // T3/T4 are a matched pair: the same predicate must answer both ways, or it discriminates nothing.
47 var t3: i64 = 0
48 if mp_exists("/__no_such_path_zzz__" as *u8) == 0 { t3 = 1 }
49 gv_check("neg-control-bogus-path-does-not-exist" as *u8, t3, c)
50
51 var t4: i64 = 0
52 if mp_exists("/" as *u8) == 1 { t4 = 1 }
53 gv_check("real-path-exists" as *u8, t4, c)
54
55 return gv_verdict("nx_media_ingest_pipeline_gate" as *u8, c,
56 "subject: mp_join, mp_resolve and mp_exists -- D001-migrated 2026-09-01, same four checks, verdict now readable by nx_gate_green" as *u8)
57}