code wiki / (root) / nx_uxf_negotiate_gate.nx

nx_uxf_negotiate_gate.nx source

↩ module page · 74 lines · 4475 B

1// nx_uxf_negotiate_gate.nx -- the D001 MIGRATION of nx_uxf_negotiate_test onto nx_gate_verdict (2026-09-06). 2// 3// The headline case is the operator's own: MKV carrying H.264 and AAC, served to Chrome, must resolve to 4// REMUX and not TRANSCODE -- Chrome cannot read the MKV container but decodes both codecs fine, so the 5// correct answer is a LOSSLESS REWRAP. Getting this wrong in the safe-looking direction (transcode 6// everything) is silent quality loss, which is why the plan is asserted per case rather than in aggregate. 7// 8// ALL FIVE ORIGINAL TEETH PRESERVED IN ORDER AND PREDICATE, PLUS TWO THE ORIGINAL LACKED. The original 9// PRINTED whether the capability rows loaded but never asserted it, so a failure to read the TSV would have 10// been judged only indirectly by the outcomes. T0a and T0b now assert the fixture REACHED ITS CONDITION 11// before any outcome is claimed, which is the estate's standing rule for exactly this shape. 12// license_tier: ORIGINAL No hw writes (Rule 26). 13import "nx_gate_verdict.nx" 14import "nx_syscalls.nx" 15import "nx_uxf_negotiate.nx" 16 17const UN_CAPBUF: i64 = 256 18const UN_LENP: i64 = 8 19const UN_CAPS_OK: i64 = 1 20 21func main(argc: i64, argv: *i64) -> i64 { 22 let ctr: *i64 = gv_ctr() 23 gv_head("nx_uxf_negotiate -- store the richest form once, emit what the endpoint can consume" as *u8) 24 25 let lenp: *i64 = sys_mmap(UN_LENP) as *i64 26 let tsv: *u8 = sys_read_file("knowledge/registry/endpoint_caps.tsv\x00" as *u8, lenp) 27 if (tsv as i64) == 0 { 28 gv_puts(" UN-UNREADABLE knowledge/registry/endpoint_caps.tsv could not be read, so NOTHING below could be judged\n" as *u8) 29 let rcx: i64 = gv_verdict("UXF-NEGOTIATE-GATE" as *u8, ctr, "capability table unreadable" as *u8) 30 sys_exit(rcx) 31 return rcx 32 } 33 let n: i64 = lenp[0] 34 35 let chrome_c: *u8 = sys_mmap(UN_CAPBUF) 36 let chrome_k: *u8 = sys_mmap(UN_CAPBUF) 37 let safari_c: *u8 = sys_mmap(UN_CAPBUF) 38 let safari_k: *u8 = sys_mmap(UN_CAPBUF) 39 let okc: i64 = ng_caps_lookup(tsv, n, "chrome\x00" as *u8, chrome_c, chrome_k) 40 let oks: i64 = ng_caps_lookup(tsv, n, "safari\x00" as *u8, safari_c, safari_k) 41 42 // FIXTURE-REACHED-THE-CONDITION: assert the capability rows actually loaded BEFORE judging any plan. 43 gv_check_eq("T0a fixture reached the condition: the chrome capability row loaded" as *u8, okc, UN_CAPS_OK, ctr) 44 gv_check_eq("T0b fixture reached the condition: the safari capability row loaded" as *u8, oks, UN_CAPS_OK, ctr) 45 46 let p1: i64 = ng_negotiate("mkv\x00" as *u8, "h264\x00" as *u8, "aac\x00" as *u8, chrome_c, chrome_k) 47 let p2: i64 = ng_negotiate("webm\x00" as *u8, "vp9\x00" as *u8, "opus\x00" as *u8, chrome_c, chrome_k) 48 let p3: i64 = ng_negotiate("mkv\x00" as *u8, "h265\x00" as *u8, "aac\x00" as *u8, chrome_c, chrome_k) 49 let p4: i64 = ng_negotiate("mp4\x00" as *u8, "h264\x00" as *u8, "aac\x00" as *u8, safari_c, safari_k) 50 let p5: i64 = ng_negotiate("webm\x00" as *u8, "vp9\x00" as *u8, "opus\x00" as *u8, safari_c, safari_k) 51 52 gv_check_eq("T1 HEADLINE mkv h264 aac at chrome is REMUX, a container-only mismatch rewrapped losslessly" as *u8, p1, PLAN_REMUX, ctr) 53 gv_check_eq("T2 webm vp9 opus at chrome is DIRECT, nothing to do" as *u8, p2, PLAN_DIRECT, ctr) 54 gv_check_eq("T3 mkv h265 aac at chrome is TRANSCODE because the codec is genuinely unsupported" as *u8, p3, PLAN_TRANSCODE, ctr) 55 gv_check_eq("T4 mp4 h264 aac at safari is DIRECT" as *u8, p4, PLAN_DIRECT, ctr) 56 gv_check_eq("neg-control-webm-vp9-opus-at-safari-is-TRANSCODE-so-the-ruler-does-not-answer-DIRECT-to-everything" as *u8, p5, PLAN_TRANSCODE, ctr) 57 58 gv_values_head() 59 gv_kv("caps_tsv_bytes" as *u8, n) 60 gv_kv("chrome_caps_loaded" as *u8, okc) 61 gv_kv("safari_caps_loaded" as *u8, oks) 62 gv_kv("PLAN_DIRECT" as *u8, PLAN_DIRECT) 63 gv_kv("PLAN_REMUX" as *u8, PLAN_REMUX) 64 gv_kv("PLAN_TRANSCODE" as *u8, PLAN_TRANSCODE) 65 gv_kv("plan_mkv_h264_aac_chrome" as *u8, p1) 66 gv_kv("plan_webm_vp9_opus_chrome" as *u8, p2) 67 gv_kv("plan_mkv_h265_aac_chrome" as *u8, p3) 68 gv_kv("plan_mp4_h264_aac_safari" as *u8, p4) 69 gv_kv("plan_webm_vp9_opus_safari" as *u8, p5) 70 71 let rc: i64 = gv_verdict("UXF-NEGOTIATE-GATE" as *u8, ctr, "a container-only mismatch resolves to a lossless rewrap and a genuinely unsupported codec resolves to a transcode, decided from a data-driven capability table rather than from a hardcoded endpoint list" as *u8) 72 sys_exit(rc) 73 return rc 74}