code wiki / _hdl_build / nx_survey_evidence_gate.nx
nx_survey_evidence_gate.nx source
↩ module page · 209 lines · 10930 B
1// nx_survey_evidence_gate.nx -- the EVIDENCE-DRIVEN METRICS gate (operator 2026-07-10: "dont just make up
2// metrics we are evidence driven use proven evidence as of 25 26 that the feedback and questions will help
3// us identify quantitative and qualitative areas of improvement").
4// The nx_connect_h2h_exceed keystone applied to METRIC SELECTION: a shipped analytic is EVIDENCED only when
5// (a) its implementation symbol exists in runtime/nx_survey_stats.nx on disk, AND
6// (b) a VERBATIM needle from the corresponding banked 2024-2026 corpus (knowledge/library/swc_svy_*.txt,
7// fetched keyless from OpenAlex over sovereign TLS) is found in the banked bytes -- real literature
8// tying that metric/question class to identifying improvement areas.
9// Three verdict classes per row:
10// EVIDENCED symbol present + needle present (we ship it, the field backs it)
11// EVIDENCED-GAP symbol ABSENT + needle present (the field says it matters; our honest build list --
12// the evidence itself ranks the roadmap: attention checks, LLM text coding)
13// REJECTED needle absent (fabricated citation -> the row DIES; the neg-control proves this fires)
14// Exits 0 iff every real row lands its declared class AND the fabricated row is REJECTED.
15// license_tier: ORIGINAL expect_exit: 0
16import "nx_syscalls.nx"
17
18func ep(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
19func en(v: i64) -> i64 {
20 var m: i64 = v
21 if m < 0 { ep("-" as *u8); m = 0 - m }
22 let t: *u8 = sys_mmap(28)
23 var k: i64 = 0
24 if m == 0 { t[0] = 48 as u8; k = 1 }
25 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }
26 let o: *u8 = sys_mmap(28)
27 var i: i64 = 0
28 while i < k { o[i] = t[k - 1 - i]; i = i + 1 }
29 sys_write(1, o, k)
30 return 0
31}
32func eslen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
33// bounded whole-file read (fresh mmap sized to the file)
34func eread(path: *u8, szp: *i64) -> *u8 {
35 let fd: i64 = sys_openat_rd(path)
36 if fd < 0 { szp[0] = 0 - 1; return 0 as *u8 }
37 let sz: i64 = sys_lseek(fd, 0, 2)
38 sys_lseek(fd, 0, 0)
39 let buf: *u8 = sys_mmap(sz + 64)
40 var got: i64 = 0
41 var n: i64 = 1
42 while n > 0 {
43 n = sys_read(fd, (buf as i64 + got) as *u8, 65536)
44 if n > 0 { got = got + n }
45 }
46 sys_close(fd)
47 szp[0] = got
48 return buf
49}
50func ehas(buf: *u8, n: i64, needle: *u8) -> i64 {
51 let nl: i64 = eslen(needle)
52 if nl == 0 { return 0 }
53 if n < nl { return 0 }
54 var i: i64 = 0
55 while i + nl <= n {
56 var k: i64 = 0
57 var hit: i64 = 1
58 while k < nl { if buf[i+k] != needle[k] { hit = 0; k = nl } else { k = k + 1 } }
59 if hit == 1 { return 1 }
60 i = i + 1
61 }
62 return 0
63}
64// one evidence row. expect: 1 = EVIDENCED (symbol+needle), 2 = EVIDENCED-GAP (needle only, symbol declared
65// absent), 0 = REJECTED expected (fabricated needle must NOT be found). Returns 1 pass / 0 fail.
66func erow(label: *u8, bank: *u8, needle: *u8, src: *u8, srcn: i64, sym: *u8, expect: i64, st: *i64) -> i64 {
67 let szp: *i64 = sys_mmap(16) as *i64
68 let bb: *u8 = eread(bank, szp)
69 var needle_ok: i64 = 0
70 if szp[0] > 1000 { needle_ok = ehas(bb, szp[0], needle) }
71 var sym_ok: i64 = 0
72 if sym[0] != (0 as u8) { sym_ok = ehas(src, srcn, sym) }
73 var cls: i64 = 0 - 1
74 if needle_ok == 1 { if sym_ok == 1 { cls = 1 } else { cls = 2 } }
75 if needle_ok == 0 { cls = 0 }
76 var pass: i64 = 0
77 if cls == expect { pass = 1 }
78 if pass == 1 { st[0] = st[0] + 1; ep(" PASS " as *u8) } else { st[1] = st[1] + 1; ep(" FAIL " as *u8) }
79 if cls == 1 { ep("[EVIDENCED ] " as *u8) }
80 if cls == 2 { ep("[EVIDENCED-GAP] " as *u8) }
81 if cls == 0 { ep("[REJECTED ] " as *u8) }
82 ep(label)
83 if pass == 0 {
84 ep(" (needle=" as *u8)
85 en(needle_ok)
86 ep(" sym=" as *u8)
87 en(sym_ok)
88 ep(" want-class=" as *u8)
89 en(expect)
90 ep(")" as *u8)
91 }
92 ep("\n" as *u8)
93 return pass
94}
95
96func main() -> i64 {
97 let st: *i64 = sys_mmap(16) as *i64
98 st[0] = 0
99 st[1] = 0
100 ep("=== nx_survey_evidence_gate -- every metric earns its place from banked 2024-26 literature (fabricated citations DIE) ===\n" as *u8)
101 let szp: *i64 = sys_mmap(16) as *i64
102 let src: *u8 = eread("runtime/nx_survey_stats.nx" as *u8, szp)
103 let srcn: i64 = szp[0]
104 if srcn < 1000 { ep("VERDICT: RED (stats source missing)\n" as *u8); return 1 }
105 let esrc: *u8 = eread("runtime/nx_survey_engine.nx" as *u8, szp)
106 let esrcn: i64 = szp[0]
107 if esrcn < 1000 { ep("VERDICT: RED (engine source missing)\n" as *u8); return 1 }
108 let qsrc: *u8 = eread("runtime/nx_survey_quality.nx" as *u8, szp)
109 let qsrcn: i64 = szp[0]
110 if qsrcn < 1000 { ep("VERDICT: RED (quality source missing)\n" as *u8); return 1 }
111 let nsrc: *u8 = eread("runtime/nx_survey_sentiment.nx" as *u8, szp)
112 let nsrcn: i64 = szp[0]
113 if nsrcn < 1000 { ep("VERDICT: RED (sentiment source missing)\n" as *u8); return 1 }
114 let nosym: *u8 = sys_mmap(4)
115 nosym[0] = 0 as u8
116
117 // -- QUANTITATIVE improvement identification --
118 erow("NPS on 0-10 scales -> satisfaction/loyalty improvement target (hospital marketing study, banked)" as *u8,
119 "knowledge/library/swc_svy_nps.txt" as *u8,
120 "Net Promoter Score (NPS) in Hospital Marketing Strategy" as *u8,
121 src, srcn, "st_nps" as *u8, 1, st)
122 erow("NPS validity ACTIVELY STUDIED (efficacy-in-predicting study) -> never NPS alone; distribution+mean shown beside it" as *u8,
123 "knowledge/library/swc_svy_nps.txt" as *u8,
124 "Efficacy of the Net Promoter Score in predicting" as *u8,
125 src, srcn, "st_desc" as *u8, 1, st)
126 erow("NPS corpus carries criticisms -> caveat surfaced on the insights page" as *u8,
127 "knowledge/library/swc_svy_nps.txt" as *u8,
128 "criticisms" as *u8,
129 src, srcn, "st_desc" as *u8, 1, st)
130 erow("95pct CI margins + power honesty at small n (Power to Detect What)" as *u8,
131 "knowledge/library/swc_svy_sig.txt" as *u8,
132 "Power to Detect What" as *u8,
133 src, srcn, "st_ci_margin" as *u8, 1, st)
134 erow("small-pilot reliability caution -> fail-closed critical table past df 10" as *u8,
135 "knowledge/library/swc_svy_sig.txt" as *u8,
136 "Sample size determination for conducting a pilot study" as *u8,
137 src, srcn, "st_crit05_pm" as *u8, 1, st)
138 erow("cross-sectional ASSOCIATION analysis identifies factors (sleep-quality/performance study)" as *u8,
139 "knowledge/library/swc_svy_xtab.txt" as *u8,
140 "sleep quality and its association with academic performance" as *u8,
141 src, srcn, "st_chisq" as *u8, 1, st)
142 erow("key-driver analysis in active 2024-26 use -> prioritizes what to fix first" as *u8,
143 "knowledge/library/swc_svy_driver.txt" as *u8,
144 "Key drivers of cybersecurity audit effectiveness" as *u8,
145 src, srcn, "st_corr" as *u8, 1, st)
146 erow("factor-vs-outcome breakdown -> burnout/engagement factors inform interventions (nurses study)" as *u8,
147 "knowledge/library/swc_svy_pulse.txt" as *u8,
148 "Factors Associated with Burnout and Work Engagement" as *u8,
149 src, srcn, "st_segment_means" as *u8, 1, st)
150 erow("aggregate wellbeing metric precedent (MHQ population metric)" as *u8,
151 "knowledge/library/swc_svy_pulse.txt" as *u8,
152 "aggregate metric of population mental wellbeing" as *u8,
153 src, srcn, "st_desc" as *u8, 1, st)
154 erow("repeated cross-sections track change over waves (banked trend studies)" as *u8,
155 "knowledge/library/swc_svy_trend.txt" as *u8,
156 "Repeated Cross-Sectional Study" as *u8,
157 src, srcn, "st_trend_split" as *u8, 1, st)
158
159 erow("anonymity + bias-reduction methods improve HONEST responding (systematic review, banked) -> @anon + tokens-never-rendered + k-floor" as *u8,
160 "knowledge/library/swc_svy_disclose.txt" as *u8,
161 "effectiveness of social desirability bias reduction methods in survey research" as *u8,
162 esrc, esrcn, "anon" as *u8, 1, st)
163
164 // -- QUALITATIVE improvement identification --
165 erow("open-text answers surface the most-important issues (LLM coding-at-scale study) -> theme frequency shipped" as *u8,
166 "knowledge/library/swc_svy_sent.txt" as *u8,
167 "code open-text social survey responses at scale" as *u8,
168 src, srcn, "st_text_themes" as *u8, 1, st)
169 erow("lexicon-based sentiment (VADER-style, negation+intensifier aware) surfaces emotional valence -> Tone card shipped" as *u8,
170 "knowledge/library/swc_svy_sent.txt" as *u8,
171 "VADER" as *u8,
172 nsrc, nsrcn, "sn_score" as *u8, 1, st)
173
174 // satisficing/careless responding degrades data quality -> attention checks + straight-lining DETECTION now
175 // SHIPPED (was an EVIDENCED-GAP; flipped 2026-07-10 when nx_survey_quality landed). qsrc = the detector source.
176 erow("satisficing/careless responding degrades data quality -> attention-check DETECTION shipped" as *u8,
177 "knowledge/library/swc_svy_quality.txt" as *u8,
178 "Response Satisficing Across Online Data Sources" as *u8,
179 qsrc, qsrcn, "sq_attention" as *u8, 1, st)
180 erow("straight-lining / longstring C/IER screening shipped (genuine low-scorers protected, gate-proven)" as *u8,
181 "knowledge/library/swc_svy_quality.txt" as *u8,
182 "careless responding in crowdsourced online surveys" as *u8,
183 qsrc, qsrcn, "sq_longstring" as *u8, 1, st)
184
185 // -- EVIDENCED GAPS: the literature says these matter; we do NOT ship them yet -> the honest build list --
186 erow("GAP: WARNING statements (pre-emptive) reduce careless responding -> a prevention rung (we DETECT, not warn)" as *u8,
187 "knowledge/library/swc_svy_quality.txt" as *u8,
188 "reducing careless responding in crowdsourced online surveys" as *u8,
189 src, srcn, nosym, 2, st)
190 erow("GAP: LLM-era sentiment on open text (Reality Check study) -> neural coding = named next rung" as *u8,
191 "knowledge/library/swc_svy_sent.txt" as *u8,
192 "Sentiment Analysis in the Era of Large Language Models" as *u8,
193 src, srcn, nosym, 2, st)
194
195 // -- NEG-CONTROL: a fabricated metric with a fabricated citation MUST die --
196 erow("NEG-CONTROL: fabricated 'quantum vibe score improvement theorem' citation" as *u8,
197 "knowledge/library/swc_svy_nps.txt" as *u8,
198 "quantum vibe score improvement theorem" as *u8,
199 src, srcn, "st_vibe_score" as *u8, 0, st)
200
201 ep("nx_survey_evidence_gate: PASS=" as *u8)
202 en(st[0])
203 ep(" FAIL=" as *u8)
204 en(st[1])
205 ep("\n" as *u8)
206 if st[1] == 0 { ep("VERDICT: GREEN (metrics evidence-grounded in banked 2024-26 literature; gaps evidence-ranked; fabricated citations die)\n" as *u8); return 0 }
207 ep("VERDICT: RED\n" as *u8)
208 return 1
209}