code wiki / (root) / nx_accommodate_gate.nx

nx_accommodate_gate.nx source

↩ module page · 75 lines · 4173 B

1// nx_accommodate_gate.nx -- R2 GATE: proves the accommodation engine adapts the SAME 5-step climb-out plan 2// to the person so the disability disappears. The headline: ADHD profile -> ONE next step surfaced (not a 3// wall of 5 = no overwhelm); default profile -> all 5. Low-energy scales with the day. Plus next-step 4// selection, UI flags, and the survey-answers -> accommodation-flags composition. Exits 0 iff ALL pass. 5// license_tier: ORIGINAL 6import "nx_syscalls.nx" 7import "nx_accommodate.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} 24func seti(a: *i64, i: i64, v: i64) -> i64 { a[i] = v; return 0 } 25 26func main() -> i64 { 27 let st: *i64 = sys_mmap(16) as *i64 28 st[0] = 0; st[1] = 0 29 let total: i64 = 5 // the 5-step climb-out plan 30 31 // HEADLINE: the SAME plan adapts -- ADHD sees ONE thing, default sees all five. 32 let adhd_view: i64 = ac_load_budget(AC_ADHD, 2, total) 33 let default_view: i64 = ac_load_budget(0, 2, total) 34 g_puts(" [info] same 5-step plan -> ADHD shows "); g_putn(adhd_view); g_puts(", default shows "); g_putn(default_view); g_puts("\n") 35 chk("ADHD -> ONE thing at a time (1 item)", adhd_view, 1, st) 36 chk("default -> full plan (5 items)", default_view, 5, st) 37 var disappears: i64 = 0 38 if adhd_view < default_view { disappears = 1 } 39 chk("MEASURED: overwhelm removed (ADHD view < default view)", disappears, 1, st) 40 41 // low-energy (sleep apnea / brain fog) scales with the day 42 chk("low-energy + low day -> 1 item", ac_load_budget(AC_LOW_ENERGY, 0, total), 1, st) 43 chk("low-energy + medium day -> 2 items", ac_load_budget(AC_LOW_ENERGY, 1, total), 2, st) 44 chk("low-energy + good day -> full plan", ac_load_budget(AC_LOW_ENERGY, 2, total), 5, st) 45 46 // the single NEXT step (priority-ordered; first not-done) 47 let done: *i64 = sys_mmap(8 * 8) as *i64 48 seti(done,0,0); seti(done,1,0); seti(done,2,0); seti(done,3,0); seti(done,4,0) 49 chk("next step = step 0 (stabilize bills)", ac_next_step(done, 5), 0, st) 50 seti(done,0,1) 51 chk("after step 0 done -> next step = 1", ac_next_step(done, 5), 1, st) 52 seti(done,1,1); seti(done,2,1); seti(done,3,1); seti(done,4,1) 53 chk("all done -> -1", ac_next_step(done, 5), 0 - 1, st) 54 55 // UI-adaptation flags 56 chk("ADHD -> reminders on", ac_wants_reminder(AC_ADHD), 1, st) 57 chk("default -> reminders off", ac_wants_reminder(0), 0, st) 58 chk("ADHD -> plain language on", ac_wants_plain(AC_ADHD), 1, st) 59 chk("low-vision -> large text on", ac_wants_large(AC_LOW_VISION), 1, st) 60 chk("ADHD -> large text off (not its need)", ac_wants_large(AC_ADHD), 0, st) 61 62 // COMPOSITION: survey answers -> accommodation flags (has_adhd=yes, low_vision=no, low_energy=yes) 63 var acc: i64 = 0 64 acc = ac_flag_if(acc, 1, AC_ADHD) // "I have ADHD" -> yes 65 acc = ac_flag_if(acc, 0, AC_LOW_VISION) // low vision -> no 66 acc = ac_flag_if(acc, 1, AC_LOW_ENERGY) // fatigue -> yes 67 chk("survey -> flags = ADHD+LOW_ENERGY (3)", acc, 3, st) 68 chk("composed profile still surfaces ONE thing (ADHD wins)", ac_load_budget(acc, 2, total), 1, st) 69 chk("composed profile wants plain language", ac_wants_plain(acc), 1, st) 70 71 g_puts("nx_accommodate_gate: PASS="); g_putn(st[0]); g_puts(" FAIL="); g_putn(st[1]); g_puts("\n") 72 if st[1] == 0 { g_puts("SITUATION R2 nx_accommodate: GREEN\n"); return 0 } 73 g_puts("SITUATION R2 nx_accommodate: RED\n") 74 return 1 75}