nx_media_ingest_pipeline_gate.nx source
↩ module page · 34 lines · 2026 B
1// nx_media_ingest_pipeline_gate.nx -- teeth for the keystone pipeline's path resolver + always-inform contract.
2// license_tier: ORIGINAL
3import "nx_syscalls.nx"
4import "nx_media_ingest_pipeline.nx"
5
6func g_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
7func g_putn(v: i64) -> i64 {
8 let t: *u8 = sys_mmap(28); var m: i64 = v; var k: i64 = 0
9 if m == 0 { t[0] = 48 as u8; k = 1 }
10 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }
11 let b: *u8 = sys_mmap(28); var i: i64 = 0
12 while i < k { b[i] = t[k - 1 - i]; i = i + 1 }
13 sys_write(1, b, k); return 0
14}
15func 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 }
16
17func main() -> i64 {
18 var pass: i64 = 0; var tot: i64 = 0
19 let out: *u8 = sys_mmap(4096)
20
21 // T1: NAS path built exactly
22 mp_join(GALX_DIR_NAS, "foo.elf" as *u8, out)
23 tot = tot + 1; if g_streq(out, "/volume1/ai/galx/foo.elf" as *u8) == 1 { pass = pass + 1 } else { g_puts("FAIL T1 join=" as *u8); g_puts(out); g_puts("\n" as *u8) }
24 // T2: a missing tool RESOLVES TO 0 -> reported, never a silent skip (the always-inform contract)
25 tot = tot + 1; if mp_resolve("__nonexistent_tool_xyz__.elf" as *u8, out) == 0 { pass = pass + 1 } else { g_puts("FAIL T2 missing-not-detected\n" as *u8) }
26 // T3: mp_exists false for a bogus path
27 tot = tot + 1; if mp_exists("/__no_such_path_zzz__" as *u8) == 0 { pass = pass + 1 } else { g_puts("FAIL T3 exists-false\n" as *u8) }
28 // T4: mp_exists true for a real path (root dir)
29 tot = tot + 1; if mp_exists("/" as *u8) == 1 { pass = pass + 1 } else { g_puts("FAIL T4 exists-root\n" as *u8) }
30
31 g_puts("nx_media_ingest_pipeline_gate pass=" as *u8); g_putn(pass); g_puts("/" as *u8); g_putn(tot)
32 if pass == tot { g_puts(" verdict=GREEN\n" as *u8); sys_exit(0); return 0 }
33 g_puts(" verdict=RED\n" as *u8); sys_exit(1); return 1
34}