nx_fin_dashboard_gate.nx source
↩ module page · 127 lines · 6121 B
1// nx_fin_dashboard_gate.nx -- GATE for the finance dashboard: proves the page is SOVEREIGN zero-JS (no
2// <script, no src= external fetch), carries the live engine output (Avalanche/Snowball), the brand, and
3// the theme controls, and is non-trivial. Renders via fw_render into a buffer (no file/store needed).
4// Exits 0 iff ALL pass. license_tier: ORIGINAL
5import "nx_syscalls.nx"
6import "nx_finance_web.nx"
7
8func g_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
9func g_putn(v: i64) -> i64 {
10 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 }
11 var m: i64 = v; if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m }
12 let d: *u8 = sys_mmap(24); var k: i64 = 0
13 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }
14 var j: i64 = k - 1
15 while j >= 0 { sys_write(1, ((d as i64)+j) as *u8, 1); j = j - 1 }
16 return 0
17}
18func chk(name: *u8, got: i64, want: i64, st: *i64) -> i64 {
19 if got == want { st[0] = st[0] + 1; g_puts(" PASS "); g_puts(name); g_puts("\n") }
20 else { st[1] = st[1] + 1; g_puts(" FAIL "); g_puts(name); g_puts(" got="); g_putn(got); g_puts(" want="); g_putn(want); g_puts("\n") }
21 return 0
22}
23// index of needle in hay[0..n), or -1.
24func gfind(hay: *u8, n: i64, needle: *u8) -> i64 {
25 var nl: i64 = 0; while needle[nl] != (0 as u8) { nl = nl + 1 }
26 if nl == 0 { return 0 }
27 var i: i64 = 0
28 while i + nl <= n {
29 var j: i64 = 0; var ok: i64 = 1
30 while j < nl { if hay[i + j] != needle[j] { ok = 0; j = nl } else { j = j + 1 } }
31 if ok == 1 { return i }
32 i = i + 1
33 }
34 return 0 - 1
35}
36
37func main() -> i64 {
38 let st: *i64 = sys_mmap(16) as *i64
39 st[0] = 0; st[1] = 0
40 let buf: *u8 = sys_mmap(65536)
41 let n: i64 = fw_render(buf, "operator\x00" as *u8)
42 g_puts(" [info] rendered finance dashboard bytes="); g_putn(n); g_puts("\n")
43
44 // SOVEREIGNTY: zero client code, no external fetch.
45 var sc: i64 = 0
46 if gfind(buf, n, "<script\x00" as *u8) < 0 { sc = 1 }
47 chk("zero <script (sovereign zero-JS)", sc, 1, st)
48 var sr: i64 = 0
49 if gfind(buf, n, "src=\x00" as *u8) < 0 { sr = 1 }
50 chk("zero src= (no external fetch)", sr, 1, st)
51
52 // CONTENT: brand + live engine output + theme controls.
53 var t1: i64 = 0
54 if gfind(buf, n, "Nishi Finance\x00" as *u8) >= 0 { t1 = 1 }
55 chk("contains brand 'Nishi Finance'", t1, 1, st)
56 var t2: i64 = 0
57 if gfind(buf, n, "Avalanche\x00" as *u8) >= 0 { t2 = 1 }
58 chk("contains 'Avalanche'", t2, 1, st)
59 var t3: i64 = 0
60 if gfind(buf, n, "Snowball\x00" as *u8) >= 0 { t3 = 1 }
61 chk("contains 'Snowball'", t3, 1, st)
62 var t4: i64 = 0
63 if gfind(buf, n, "Avalanche saves $\x00" as *u8) >= 0 { t4 = 1 }
64 chk("contains live 'Avalanche saves $...'", t4, 1, st)
65 var t5: i64 = 0
66 if gfind(buf, n, "th-dark\x00" as *u8) >= 0 { t5 = 1 }
67 chk("contains theme controls", t5, 1, st)
68 var t6: i64 = 0
69 if gfind(buf, n, "OPAQUE\x00" as *u8) >= 0 { t6 = 1 }
70 chk("states it sits behind the OPAQUE wall", t6, 1, st)
71 var t7: i64 = 0
72 if gfind(buf, n, "Affordable funding\x00" as *u8) >= 0 { t7 = 1 }
73 chk("WIRED: shows the Affordable funding section (R7)", t7, 1, st)
74 var t8: i64 = 0
75 if gfind(buf, n, "advance-fee fraud\x00" as *u8) >= 0 { t8 = 1 }
76 chk("WIRED: financing section carries the scam-shield note", t8, 1, st)
77 var t9: i64 = 0
78 if gfind(buf, n, "Your situation\x00" as *u8) >= 0 { t9 = 1 }
79 chk("WIRED: shows the situation snapshot + climb-out plan", t9, 1, st)
80 var t10: i64 = 0
81 if gfind(buf, n, "how your brain works\x00" as *u8) >= 0 { t10 = 1 }
82 chk("WIRED: shows the accessibility / accommodation section", t10, 1, st)
83 var t11: i64 = 0
84 if gfind(buf, n, "ADHD-aware money guard\x00" as *u8) >= 0 { t11 = 1 }
85 chk("WIRED: shows the ADHD money guard (impulse/planning/inaction)", t11, 1, st)
86 var t12: i64 = 0
87 if gfind(buf, n, "Before you buy\x00" as *u8) >= 0 { t12 = 1 }
88 chk("WIRED: shows the browser before-you-buy / opportunity-cost section", t12, 1, st)
89 var t13: i64 = 0
90 if gfind(buf, n, "Your climb-out plan\x00" as *u8) >= 0 { t13 = 1 }
91 chk("WIRED: shows the fused climb-out plan + one next step", t13, 1, st)
92 var t14: i64 = 0
93 if gfind(buf, n, "Your climb to financial peace\x00" as *u8) >= 0 { t14 = 1 }
94 chk("WIRED: shows the R7 progress tracker (track the climb)", t14, 1, st)
95 var t15: i64 = 0
96 if gfind(buf, n, "% of the way to financial peace\x00" as *u8) >= 0 { t15 = 1 }
97 chk("WIRED: progress shows percent-to-peace", t15, 1, st)
98 var t16: i64 = 0
99 if gfind(buf, n, "action=\"/finance/progress\"\x00" as *u8) >= 0 { t16 = 1 }
100 chk("WIRED: interactive 'I did this step' posts to /finance/progress (zero-JS)", t16, 1, st)
101 var t17: i64 = 0
102 if gfind(buf, n, "Your bills\x00" as *u8) >= 0 { t17 = 1 }
103 chk("WIRED: shows the 'Your bills' section (real recurring bills)", t17, 1, st)
104 var t18: i64 = 0
105 if gfind(buf, n, "action=\"/finance/bills\"\x00" as *u8) >= 0 { t18 = 1 }
106 chk("WIRED: inline add-a-bill form posts to /finance/bills (zero-JS)", t18, 1, st)
107 var t19: i64 = 0
108 if gfind(buf, n, "Your monthly cashflow\x00" as *u8) >= 0 { t19 = 1 }
109 chk("WIRED: shows monthly cashflow (income - bills = surplus/deficit)", t19, 1, st)
110 var t20: i64 = 0
111 if gfind(buf, n, "survival runway\x00" as *u8) >= 0 { t20 = 1 }
112 chk("WIRED: shows the job-loss survival runway", t20, 1, st)
113 var t21: i64 = 0
114 if gfind(buf, n, "Your one thing right now\x00" as *u8) >= 0 { t21 = 1 }
115 chk("WIRED: page-level focus banner (one thing at a time, ADHD)", t21, 1, st)
116 var lok: i64 = 0
117 if n > 1500 { lok = 1 }
118 chk("page length > 1500 bytes", lok, 1, st)
119 var term: i64 = 0
120 if buf[n] == (0 as u8) { term = 1 }
121 chk("NUL-terminated render", term, 1, st)
122
123 g_puts("nx_fin_dashboard_gate: PASS="); g_putn(st[0]); g_puts(" FAIL="); g_putn(st[1]); g_puts("\n")
124 if st[1] == 0 { g_puts("FINANCE DASHBOARD: GREEN\n"); return 0 }
125 g_puts("FINANCE DASHBOARD: RED\n")
126 return 1
127}