nx_blocklist_view_gate.nx source
↩ module page · 48 lines · 3385 B
1// nx_blocklist_view_gate.nx -- proves the viewable page renders the supervised blocklist correctly and writes a live
2// preview. Seeds a PENDING and an APPROVED entry (test prefix), renders, and checks: the pending entry shows an
3// approve action, justification (authority) is visible, the approved entry shows retract and NOT approve. Then writes
4// web_assets/blocklist_preview.html so the operator can open it in the running server. license_tier: ORIGINAL
5import "nx_blocklist_view.nx"
6import "nx_gate.nx"
7import "nx_tabrec.nx"
8func contains(hay: *u8, n: i64, needle: *u8) -> i64 {
9 var nl: i64=0; while needle[nl]!=(0 as u8) { nl=nl+1 }
10 if nl==0 { return 1 }
11 var i: i64=0
12 while i+nl<=n { var m: i64=1; var j: i64=0; while j<nl { if hay[i+j]!=needle[j] { m=0; j=nl } else { j=j+1 } } if m==1 { return 1 } i=i+1 }
13 return 0
14}
15
16func main() -> i64 {
17 gw("=== nx_blocklist_view_gate: viewable, justified, with per-entry approve action ===\n" as *u8)
18 let TP: *u8="knowledge/blocklist-vtest-" as *u8
19
20 let r1: *u8=sys_mmap(512); var a: i64=0
21 a=tr_cat(r1,a,"80800080204a1000" as *u8); a=tr_tab(r1,a); a=tr_cat(r1,a,"10" as *u8); a=tr_tab(r1,a); a=tr_cat(r1,a,"NCII" as *u8); a=tr_tab(r1,a); a=tr_cat(r1,a,"StopNCII" as *u8); a=tr_tab(r1,a); a=tr_cat(r1,a,"2026-06-30" as *u8); a=tr_tab(r1,a); a=tr_cat(r1,a,"SNCII-00042" as *u8); a=tr_tab(r1,a); a=tr_cat(r1,a,"pending" as *u8)
22 bl_put_pfx(TP, "1" as *u8, r1, a)
23
24 let r2: *u8=sys_mmap(512); var b: i64=0
25 b=tr_cat(r2,b,"7777aaaa3333cccc" as *u8); b=tr_tab(r2,b); b=tr_cat(r2,b,"8" as *u8); b=tr_tab(r2,b); b=tr_cat(r2,b,"DMCA" as *u8); b=tr_tab(r2,b); b=tr_cat(r2,b,"AcmeLegal" as *u8); b=tr_tab(r2,b); b=tr_cat(r2,b,"2026-06-30" as *u8); b=tr_tab(r2,b); b=tr_cat(r2,b,"DMCA-7781" as *u8); b=tr_tab(r2,b); b=tr_cat(r2,b,"pending" as *u8)
26 bl_put_pfx(TP, "2" as *u8, r2, b)
27 bl_set_status_pfx(TP, "2" as *u8, "approved" as *u8)
28
29 let out: *u8=sys_mmap(2097152)
30 let n: i64=bl_render_html(TP, out)
31
32 var pass: i64=0; var tot: i64=0
33 tot=tot+1; if contains(out, n, "approve?id=1" as *u8)==1 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) }
34 gw("T1 PENDING entry shows an approve action on the page\n" as *u8)
35 tot=tot+1; if contains(out, n, "StopNCII" as *u8)==1 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) }
36 gw("T2 justification (authority) is VISIBLE, not hidden\n" as *u8)
37 tot=tot+1; if contains(out, n, "retract?id=2" as *u8)==1 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) }
38 gw("T3 APPROVED entry shows a retract action\n" as *u8)
39 tot=tot+1; if contains(out, n, "approve?id=2" as *u8)==0 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) }
40 gw("T4 APPROVED entry does NOT show approve (already approved)\n" as *u8)
41
42 ss_writefile("web_assets/blocklist_preview.html" as *u8, out, n)
43 gw("\n wrote web_assets/blocklist_preview.html (" as *u8); gn(n); gw(" bytes) -- open http://localhost:8080/blocklist_preview.html\n" as *u8)
44
45 gw("\n=== nx_blocklist_view_gate " as *u8); gn(pass); gw("/" as *u8); gn(tot); gw(" ===\n" as *u8)
46 if pass==tot { gw("BLOCKLIST-VIEW GREEN -- justification visible + per-entry approve action, rendered from seg_store\n" as *u8); sys_exit(0); return 0 }
47 gw("BLOCKLIST-VIEW RED\n" as *u8); sys_exit(1); return 1
48}