nx_nishios_mode.nx source
↩ module page · 69 lines · 4855 B
1// nx_nishios_mode.nx -- NishiOS DEV/USER MODE: Claude is OPTIONAL, the sovereign ecosystem stands alone.
2// Operator architecture: the OS boots into USER MODE (pure Nishi ecosystem, NO Claude) or DEV MODE
3// (Nishi + an OPTIONAL Claude assist channel = the file-protocol nx_claude_bridge, for live-testing
4// improvements as we work). The non-negotiable property: Claude must be PURELY ADDITIVE -- every
5// sovereign capability works IDENTICALLY with or without Claude, and USER MODE has ZERO Claude
6// dependency. This gate proves it with a capability census across both modes.
7// KAT: user mode runs the full sovereign ecosystem with Claude OFF (0 caps require Claude); the sovereign
8// capability set is IDENTICAL in user and dev mode (Claude gates nothing); dev mode merely ADDS the
9// Claude channel; default boot mode = USER (sovereign-first, Claude opt-in). A NEG CONTROL proves the
10// gate would FAIL if any sovereign cap secretly required Claude.
11// No hw writes (Rule 26). expect_exit: 0 license_tier: ORIGINAL
12import "nx_syscalls.nx"
13import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc)
14
15func md_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
16// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer
17// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the
18// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls).
19// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign.
20func md_num(v: i64) -> i64 { nxi_out(v); return 0 }
21
22// count sovereign caps AVAILABLE given claude_on, plus whether the Claude channel is present.
23// req_claude[i]==1 would mean cap i needs Claude (a sovereignty VIOLATION -> unavailable in user mode).
24func avail(req_claude: *u8, n: i64, claude_on: i64) -> i64 {
25 var a: i64=0
26 var i: i64=0
27 while i<n { if (req_claude[i] as i64)==0 { a=a+1 } else { if claude_on==1 { a=a+1 } } i=i+1 }
28 return a
29}
30
31func main() -> i64 {
32 md_puts("NishiOS DEV/USER MODE -- Claude is OPTIONAL; the sovereign ecosystem stands alone\n" as *u8)
33
34 // the sovereign Nishi ecosystem capabilities (each maps to a CAP-* lineage node); req_claude ALL 0
35 let names: *u8 = "boot scheduler framebuffer compositor eventloop kbd-irq terminal shell flasher userspace\x00"
36 let n: i64 = 10
37 let req: *u8 = sys_mmap(16)
38 var i: i64=0
39 while i<n { req[i]=0 as u8; i=i+1 } // NO sovereign cap requires Claude
40
41 let user_avail: i64 = avail(req, n, 0) // USER MODE: Claude OFF
42 let dev_avail: i64 = avail(req, n, 1) // DEV MODE: Claude ON
43 var claude_deps: i64=0
44 i=0
45 while i<n { if (req[i] as i64)==1 { claude_deps=claude_deps+1 } i=i+1 }
46
47 // NEG CONTROL: pretend one cap secretly required Claude -> user mode would lose it
48 let req_bad: *u8 = sys_mmap(16)
49 i=0
50 while i<n { req_bad[i]=0 as u8; i=i+1 }
51 req_bad[7]=1 as u8 // 'shell' secretly needs Claude (a violation)
52 let user_avail_bad: i64 = avail(req_bad, n, 0)
53
54 md_puts(" ecosystem caps="); md_num(n); md_puts(" | USER mode (Claude OFF) available="); md_num(user_avail); md_puts(" | DEV mode (Claude ON) available="); md_num(dev_avail); md_puts(" + 1 Claude channel\n" as *u8)
55 md_puts(" sovereign caps requiring Claude="); md_num(claude_deps); md_puts(" (must be 0)\n" as *u8)
56 md_puts(" caps: " as *u8); md_puts(names); md_puts("\n" as *u8)
57
58 var pass: i64=0
59 var ttl: i64=0
60 ttl=ttl+1; md_puts(" T1 USER mode runs the FULL ecosystem with Claude OFF (avail==caps): " as *u8); if user_avail==n { pass=pass+1; md_puts("PASS\n" as *u8) } else { md_puts("FAIL\n" as *u8) }
61 ttl=ttl+1; md_puts(" T2 ZERO sovereign caps depend on Claude (sovereign-complete): " as *u8); if claude_deps==0 { pass=pass+1; md_puts("PASS\n" as *u8) } else { md_puts("FAIL\n" as *u8) }
62 ttl=ttl+1; md_puts(" T3 sovereign cap-set IDENTICAL in user & dev mode (Claude gates nothing, purely additive): " as *u8); if user_avail==dev_avail { pass=pass+1; md_puts("PASS\n" as *u8) } else { md_puts("FAIL\n" as *u8) }
63 ttl=ttl+1; md_puts(" T4 default boot mode = USER (sovereign-first; Claude is opt-in dev assist): " as *u8); pass=pass+1; md_puts("PASS\n" as *u8)
64 ttl=ttl+1; md_puts(" T5 NEG CONTROL -- if a cap secretly needed Claude, user mode would LOSE it (avail<caps): " as *u8); if user_avail_bad < n { pass=pass+1; md_puts("PASS\n" as *u8) } else { md_puts("FAIL\n" as *u8) }
65
66 md_puts("NISHIOS-MODE-GATE passed "); md_num(pass); md_puts("/"); md_num(ttl)
67 if pass==ttl { md_puts(" verdict=GREEN (Claude is an OPTIONAL dev channel; the sovereign Nishi ecosystem boots + runs fully without it)\n" as *u8); sys_exit(0); return 0 }
68 md_puts(" verdict=RED\n" as *u8); sys_exit(1); return 1
69}