code wiki / (root) / nx_asset_page_gate.nx

nx_asset_page_gate.nx source

↩ module page · 49 lines · 4216 B

1// nx_asset_page_gate.nx -- the referee for nx_asset_page_lib (2026-09-17): the asset page emits the viewer script only when 2// a tier shows a GLB canvas. Planted manifests, in-process: an image-only manifest needs no viewer, a GLB tier on either 3// direction (tasset, tasset2) needs it, and the predicate reads the FORMAT column -- the word glb in a label, in an 4// evidence column, in a judge axis or on a row type that merely starts with tasset does not count. A CRLF manifest is 5// read the same as an LF one. The emitter's wiring is proven end to end by the media-judge workflow plan, whose last row 6// is nx_page_verify over the live page. 7// license_tier: ORIGINAL No hw writes (Rule 26). 8import "nx_syscalls.nx" 9import "nx_gate_verdict.nx" 10import "nx_asset_page_lib.nx" 11 12const AG_IMG_ONLY: *u8 = "meta\tdiora14\timg\tMedia judged\ntasset\t1\timg\t/compare/x/a.jpg\tORIGINAL\ntasset\t2\timg\t/compare/x/b.png\tMEASURED\ntier\t1\tLIVE\tnote\njudge\tnx_photomark\tface_found\t1\tflag\tevidence\n" 13const AG_GLB_TIER: *u8 = "meta\tkk\tglb\tA mesh\ntasset\t1\tglb\t/exceed/kk/a.glb\tORIGINAL\ntier\t1\tLIVE\tnote\njudge\torgan\taxis\t1\tunit\tevidence\n" 14const AG_GLB_OUTBOUND: *u8 = "meta\tkk\timg\tA mesh\ntasset\t1\timg\t/x/a.png\tORIGINAL\ntasset2\t3\tglb\t/exceed/kk/c.glb\tIMPROVED\ntier\t1\tLIVE\tnote\n" 15const AG_GLB_IN_LABEL: *u8 = "meta\tkk\timg\tA mesh\ntasset\t1\timg\t/x/a.png\tglb\ntier\t1\tLIVE\tthe glb is coming\n" 16const AG_GLB_IN_JUDGE: *u8 = "meta\tkk\timg\tA mesh\ntasset\t1\timg\t/x/a.png\tORIGINAL\njudge\tnx_mesh\tglb\t1\tglb\tglb\n" 17const AG_GLB_ON_LOOKALIKE: *u8 = "meta\tkk\timg\tA mesh\ntassetx\t1\tglb\t/x/a.glb\tORIGINAL\n" 18const AG_GLB_CRLF: *u8 = "meta\tkk\tglb\tA mesh\r\ntasset\t1\tglb\r\n" 19const AG_GLB_UPPER: *u8 = "meta\tkk\tglb\tA mesh\ntasset\t1\tGLB\t/x/a.glb\tORIGINAL\n" 20const AG_COL_LINE: *u8 = "tasset\t2\tglb\t/x/y.glb\tlabel" 21const AG_COL_FORMAT_LEN: i64 = 3 22const AG_COL_ABSENT: i64 = 9 23const AG_I64: i64 = 8 24 25func ag_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } 26func ag_has(s: *u8) -> i64 { return apl_has_glb(s, ag_len(s)) } 27 28func main(argc: i64, argv: *i64) -> i64 { 29 gv_head("nx_asset_page_gate -- the viewer script belongs to a page that shows a GLB canvas, and only to that page" as *u8) 30 let ctr: *i64 = gv_ctr() 31 gv_check_eq("image-only-manifest-needs-no-viewer" as *u8, ag_has(AG_IMG_ONLY), 0, ctr) 32 gv_check_eq("glb-tier-needs-the-viewer" as *u8, ag_has(AG_GLB_TIER), 1, ctr) 33 gv_check_eq("glb-on-the-outbound-direction-needs-the-viewer" as *u8, ag_has(AG_GLB_OUTBOUND), 1, ctr) 34 gv_check_eq("crlf-manifest-reads-the-same-as-lf" as *u8, ag_has(AG_GLB_CRLF), 1, ctr) 35 gv_check_eq("neg-control-glb-in-a-label-or-note-is-not-a-canvas" as *u8, ag_has(AG_GLB_IN_LABEL), 0, ctr) 36 gv_check_eq("neg-control-glb-in-a-judge-row-is-not-a-canvas" as *u8, ag_has(AG_GLB_IN_JUDGE), 0, ctr) 37 gv_check_eq("neg-control-a-row-type-that-only-starts-with-tasset-does-not-count" as *u8, ag_has(AG_GLB_ON_LOOKALIKE), 0, ctr) 38 gv_check_eq("neg-control-format-is-matched-exactly-not-case-folded" as *u8, ag_has(AG_GLB_UPPER), 0, ctr) 39 gv_check_eq("neg-control-empty-manifest-needs-no-viewer" as *u8, apl_has_glb("" as *u8, 0), 0, ctr) 40 // the column reader the predicate stands on: the format column of a known line is exactly three bytes 41 let span: *i64 = sys_mmap(2 * AG_I64) as *i64 42 let got: i64 = apl_col(AG_COL_LINE, 0, ag_len(AG_COL_LINE), APL_COL_FORMAT, span) 43 gv_check_eq("column-reader-finds-the-format-column" as *u8, got, 1, ctr) 44 gv_check_eq("column-reader-format-span-is-three-bytes" as *u8, span[1] - span[0], AG_COL_FORMAT_LEN, ctr) 45 gv_check_eq("neg-control-column-reader-refuses-a-column-the-line-lacks" as *u8, apl_col(AG_COL_LINE, 0, ag_len(AG_COL_LINE), AG_COL_ABSENT, span), 0, ctr) 46 gv_values_head() 47 gv_kv("img_only" as *u8, ag_has(AG_IMG_ONLY)); gv_kv("glb_tier" as *u8, ag_has(AG_GLB_TIER)); gv_kv("glb_outbound" as *u8, ag_has(AG_GLB_OUTBOUND)); gv_kv("glb_in_label" as *u8, ag_has(AG_GLB_IN_LABEL)) 48 return gv_verdict("nx_asset_page_gate" as *u8, ctr, "the viewer script is emitted for a page that shows a GLB canvas and for no other page" as *u8) 49}