code wiki / (root) / nx_adhd_gate.nx

nx_adhd_gate.nx source

↩ module page · 59 lines · 3266 B

1// nx_adhd_gate.nx -- R3 GATE: proves the ADHD-intervention engine targets impulse shopping, planning 2// failures, and inaction locks -- and ADVISES, never blocks (autonomy). Headline: a $200 impulse gadget 3// gets a cooling-off PAUSE + is reframed as 8 hours of work and 20% of a $1,000 buffer goal. Exits 0 iff 4// ALL pass. license_tier: ORIGINAL 5import "nx_syscalls.nx" 6import "nx_money.nx" 7import "nx_adhd.nx" 8 9func 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 } 10func g_putn(v: i64) -> i64 { 11 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 } 12 var m: i64 = v; if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m } 13 let d: *u8 = sys_mmap(24); var k: i64 = 0 14 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 15 var j: i64 = k - 1 16 while j >= 0 { sys_write(1, ((d as i64)+j) as *u8, 1); j = j - 1 } 17 return 0 18} 19func chk(name: *u8, got: i64, want: i64, st: *i64) -> i64 { 20 if got == want { st[0] = st[0] + 1; g_puts(" PASS "); g_puts(name); g_puts("\n") } 21 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") } 22 return 0 23} 24 25func main() -> i64 { 26 let st: *i64 = sys_mmap(16) as *i64 27 st[0] = 0; st[1] = 0 28 29 // ---- IMPULSE SHOPPING guard (pause_threshold $100, remaining discretionary budget $500) ---- 30 chk("$200 impulse gadget -> PAUSE (cooling-off)", adhd_spend_decision(20000, 1, 10000, 50000), ADHD_PAUSE, st) 31 chk("$50 small discretionary -> ALLOW", adhd_spend_decision(5000, 1, 10000, 50000), ADHD_ALLOW, st) 32 chk("$600 over-budget impulse -> WARN", adhd_spend_decision(60000, 1, 10000, 50000), ADHD_WARN, st) 33 chk("$300 rent (a NEED) -> ALLOW (not impulse)", adhd_spend_decision(30000, 0, 10000, 50000), ADHD_ALLOW, st) 34 35 // the reframe that defuses the dopamine-buy 36 let hrs: i64 = adhd_hours_cost(20000, 2500) 37 let pct: i64 = adhd_pct_of_goal(20000, 100000) 38 g_puts(" [info] that $200 gadget = "); g_putn(hrs); g_puts(" hours of work, "); g_putn(pct); g_puts("% of a $1,000 buffer goal\n") 39 chk("$200 at $25/hr = 8 hours of your life", hrs, 8, st) 40 chk("$200 = 20% of a $1,000 buffer goal", pct, 20, st) 41 42 // ---- INACTION LOCK breaker ---- 43 chk("big step (effort 5) -> recommend a 2-min micro-step", adhd_needs_micro(5, 4), 1, st) 44 chk("small step (effort 2) -> no micro needed", adhd_needs_micro(2, 4), 0, st) 45 46 // ---- PLANNING-FAILURE guard (lead-time 5 days) ---- 47 chk("bill due in 3 days -> surface NOW (plan ahead for them)", adhd_surface_ahead(3, 5), 1, st) 48 chk("bill due in 10 days -> not yet", adhd_surface_ahead(10, 5), 0, st) 49 50 // ---- AUTONOMY / never-brick: the guard ADVISES, never blocks ---- 51 var advisory: i64 = 1 52 if adhd_spend_decision(99999999, 1, 10000, 50000) > ADHD_WARN { advisory = 0 } // even an extreme buy: ceiling is WARN(2), still the person's call 53 chk("guard NEVER blocks (worst case is advisory WARN, not a wall)", advisory, 1, st) 54 55 g_puts("nx_adhd_gate: PASS="); g_putn(st[0]); g_puts(" FAIL="); g_putn(st[1]); g_puts("\n") 56 if st[1] == 0 { g_puts("SITUATION R3 nx_adhd: GREEN\n"); return 0 } 57 g_puts("SITUATION R3 nx_adhd: RED\n") 58 return 1 59}