code wiki / _hdl_build / nx_acceptview_gate.nx
nx_acceptview_gate.nx source
↩ module page · 92 lines · 6490 B
1// nx_acceptview_gate.nx -- teeth for the ACCEPTANCE QUEUE's JOIN KEY.
2//
3// WHY IT EXISTS (2026-09-03). nx_acceptview renders, for each subject, the operator's own rejection words
4// beside the referee capture the panel actually graded. Its first cut joined those two by searching the
5// accept- plane row for the SUBJECT NAME as a bare substring -- and "face" matched the SKIN row, because
6// skin's targets carry graphics:gpe_skin_microsurface and "microsurface" contains "face". The served page
7// put one subject's words underneath another subject's image.
8//
9// That defect is invisible to every check that asks "did the page render" or "is there an image": the page
10// was well-formed, the image was real, the words were real, and only the PAIRING was wrong.
11// ★★★★★★A WRONG JOIN PRODUCES A PAGE THAT LOOKS ENTIRELY CORRECT, SO ONLY A TOOTH THAT ASSERTS THE PAIRING
12// CAN SEE IT -- and this is the surface an operator signs acceptance from, so a wrong pairing here does not
13// merely mislead a reader, it corrupts a signature.
14//
15// SUBJECT: av_needle and av_key_hit, the two pure functions that ARE the join. Being pure, these teeth
16// drive them in-process -- no fork, no plane read, no page written, nothing published by this gate.
17// license_tier: ORIGINAL expect_exit: 0
18import "nx_acceptview.nx"
19import "nx_gate_verdict.nx"
20
21func agl_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
22
23func main(argc: i64, argv: *i64) -> i64 {
24 let ctr: *i64 = gv_ctr()
25
26 let nd: *u8 = sys_mmap(AV_PATHB)
27 let nd2: *u8 = sys_mmap(AV_PATHB)
28 let subj: *u8 = "face" as *u8
29 let sl: i64 = agl_len(subj)
30 let ndl: i64 = av_needle(nd, AV_PATHB, subj, 0, sl)
31
32 gv_check_eq("T1 av_needle builds ga_accept_<subject>, so its length is the declared prefix plus the subject" as *u8,
33 ndl, agl_len(AV_KEYPFX) + sl, ctr)
34
35 let skinrow: *u8 = "beach-skin-relief-0830 REJECT graphics:gpe_skin_microsurface,ga_accept_skin" as *u8
36 let facerow: *u8 = "charsim-face-0830 REJECT charsim:cs_face_texture,ga_accept_face" as *u8
37 gv_check("T2 the FACE key does NOT match the SKIN row -- the exact defect that put skin words under face capture on the served page, and the whole reason this gate exists" as *u8,
38 (av_key_hit(skinrow, 0, agl_len(skinrow), nd, ndl) == 0) as i64, ctr)
39 gv_check("T3 the FACE key DOES match the FACE row -- without this, T2 passes for the trivial reason that the matcher never matches anything" as *u8,
40 (av_key_hit(facerow, 0, agl_len(facerow), nd, ndl) == 1) as i64, ctr)
41
42 let paint: *u8 = "x REJECT ga_accept_facepaint" as *u8
43 gv_check("T4 the FACE key does NOT match ga_accept_facepaint -- a prefix is not a key, and a longer sibling subject must never borrow this one words" as *u8,
44 (av_key_hit(paint, 0, agl_len(paint), nd, ndl) == 0) as i64, ctr)
45 let comma: *u8 = "x REJECT ga_accept_face,graphics:gpe_other" as *u8
46 gv_check("T5 a comma ends the key, so ga_accept_face followed by a second target still matches -- T4 did not buy its strictness by rejecting the common multi-target shape" as *u8,
47 (av_key_hit(comma, 0, agl_len(comma), nd, ndl) == 1) as i64, ctr)
48 let spaced: *u8 = "x REJECT ga_accept_face other" as *u8
49 gv_check("T6 a space ends the key" as *u8,
50 (av_key_hit(spaced, 0, agl_len(spaced), nd, ndl) == 1) as i64, ctr)
51
52 let tabrow: *u8 = sys_mmap(AV_PATHB)
53 var tl: i64 = av_cat(tabrow, 0, "charsim-face-0830" as *u8)
54 tabrow[tl] = AV_TAB as u8
55 tl = tl + 1
56 tl = av_cat(tabrow, tl, "ga_accept_face" as *u8)
57 tabrow[tl] = AV_TAB as u8
58 tl = tl + 1
59 tl = av_cat(tabrow, tl, "poorly done" as *u8)
60 tabrow[tl] = 0 as u8
61 gv_check("T7 fixture-reached-tab: a genuine tab byte separates the key from the next field and the key still matches, so the terminator set covers the separator the plane really uses" as *u8,
62 (av_key_hit(tabrow, 0, tl, nd, ndl) == 1) as i64, ctr)
63
64 let colon: *u8 = "x REJECT graphics:ga_accept_face" as *u8
65 gv_check("T8 a left-hand namespace is ACCEPTED on purpose -- graphics:ga_accept_face is a legitimate way to write the target, and requiring a left boundary would trade a measured false positive for an unmeasured false negative" as *u8,
66 (av_key_hit(colon, 0, agl_len(colon), nd, ndl) == 1) as i64, ctr)
67
68 gv_check("T9 neg-control-empty-subject: av_needle REFUSES an empty subject instead of building the bare prefix, which would then match EVERY acceptance target in the plane" as *u8,
69 (av_needle(nd2, AV_PATHB, subj, 0, 0) == -1) as i64, ctr)
70 gv_check("T10 neg-control-cap-refused: a needle that will not fit its buffer returns -1 rather than writing past it" as *u8,
71 (av_needle(nd2, 4, subj, 0, sl) == -1) as i64, ctr)
72 gv_check("T11 neg-control-zero-length-needle: a key of length zero matches NOTHING, so an unkeyable subject shows no words rather than the first row on the plane" as *u8,
73 (av_key_hit(facerow, 0, agl_len(facerow), nd, 0) == 0) as i64, ctr)
74 gv_check("T12 neg-control-empty-range: an empty search window matches nothing" as *u8,
75 (av_key_hit(facerow, 5, 5, nd, ndl) == 0) as i64, ctr)
76 gv_check("T13 neg-control-key-absent-entirely: a row naming no acceptance target at all does not match" as *u8,
77 (av_key_hit("beach-hair-0830 REJECT graphics:gpe_hair_wind" as *u8, 0, 44, nd, ndl) == 0) as i64, ctr)
78
79 gv_check("T14 the needle is intact after the refusal paths ran, so T9 and T10 refused WITHOUT writing and the teeth before them were not measuring a different key" as *u8,
80 (av_key_hit(facerow, 0, agl_len(facerow), nd, ndl) == 1) as i64, ctr)
81
82 gv_values_head()
83 gv_kv("needle_len" as *u8, ndl)
84 gv_kv("prefix_len" as *u8, agl_len(AV_KEYPFX))
85 gv_kv("subject_len" as *u8, sl)
86 gv_kv("face_key_vs_skin_row" as *u8, av_key_hit(skinrow, 0, agl_len(skinrow), nd, ndl))
87 gv_kv("face_key_vs_face_row" as *u8, av_key_hit(facerow, 0, agl_len(facerow), nd, ndl))
88 gv_kv("face_key_vs_facepaint" as *u8, av_key_hit(paint, 0, agl_len(paint), nd, ndl))
89 gv_kv("face_key_vs_namespaced" as *u8, av_key_hit(colon, 0, agl_len(colon), nd, ndl))
90
91 return gv_verdict("ACCEPTVIEW-GATE" as *u8, ctr, "the subject-to-plane-row join (av_needle, av_key_hit); the page emitter, the escaper and the referee fork are OUT OF SCOPE here and stay unproven by this gate" as *u8)
92}