code wiki / _hdl_build / nx_os_census.nx
nx_os_census.nx source
↩ module page · 93 lines · 15478 B
1// nx_os_census.nx -- the SOVEREIGN OS CAPABILITY CENSUS: where does the Nishi OS still lack (beyond AI + hardware),
2// to get it FULLY built? Grades each standard OS capability HAVE / PARTIAL / MISSING, grounded on a REAL organ
3// (have_file -- liar-killed: a capability counts only if its organ actually exists). The PARTIAL+MISSING rows ARE
4// the remaining work. Benchmark = "what a complete OS comprises" (os_*.raw). AI (no-float ladder, 44 caps) and
5// HARDWARE (drivers/RISC-V/no-FPU) are tracked in their OWN censuses; THIS is the kernel-services + userland layer.
6// expect_exit: 0 Sovereign: nx_syscalls.
7import "nx_syscalls.nx"
8import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc)
9import "nx_g_puts_lib.nx"
10
11// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer
12// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the
13// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls).
14// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign.
15func g_pn(v: i64) -> i64 { nxi_out(v); return 0 }
16func ck(name: *u8, c: i64) -> i64 { if c==1 { g_puts(" PASS " as *u8) } else { g_puts(" FAIL " as *u8) } g_puts(name); g_puts("\n" as *u8); return c }
17func have(path: *u8) -> i64 { let fd: i64=sys_openat_rd(path); if fd<0 { return 0 } sys_close(fd); return 1 }
18// grade: caller's intended grade (2=HAVE, 1=PARTIAL) IF the organ exists; else 0=MISSING. returns effective grade.
19func os_row(cap: *u8, organ: *u8, grade: i64, note: *u8) -> i64 {
20 var eff: i64=0; if have(organ)==1 { eff=grade }
21 if eff==2 { g_puts(" [HAVE ] ") } else { if eff==1 { g_puts(" [PARTIAL] ") } else { g_puts(" [MISSING] ") } }
22 g_puts(cap); g_puts(" -- "); g_puts(note); g_puts("\n" as *u8); return eff
23}
24
25func main() -> i64 {
26 g_puts("nx_os_census (where does the Nishi OS still lack -- beyond AI + hardware -- to be FULLY built?)\n" as *u8)
27 var have_n: i64=0; var part_n: i64=0; var miss_n: i64=0
28 g_puts(" ==== kernel + system services ====\n" as *u8)
29 var g: i64=0
30 g=os_row("KERNEL-SYSCALLS " as *u8, "runtime/nx_syscalls.nx" as *u8, 2, "fork/execve/wait/mmap/pipe/dup3/socket/chdir/getdents = the kernel last-mile" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} }
31 g=os_row("PROCESS-MGMT " as *u8, "runtime/nx_shell_lib.nx" as *u8, 2, "fork/exec/wait/pipe + supervised daemons" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} }
32 g=os_row("MEMORY-MGMT " as *u8, "runtime/_hdl_build/nx_alloc.nx" as *u8, 1, "allocator (nx_alloc, 4/4) + VM model (nx_paging, 5/5) + FAITHFUL x86-64 4-LEVEL page-table walk model (nx_mmu_hw, 5/5: PML4/PDPT/PD/PT + CR3 + protection accumulation + TLB, the exact hardware structures) + mmap/munmap. GAP remaining: real hardware-MMU binding (ring0/CR3) -- MODELED + activation refused BY CONSTRUCTION; real CR3 load = the guarded never-brick HARDWARE step" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} }
33 g=os_row("FILESYSTEM " as *u8, "runtime/_hdl_build/nx_vfs_blockfs.nx" as *u8, 2, "coreutils (nx_fs) + on-disk FS (nx_blockfs) + block-backed HIERARCHICAL VFS MOUNT (nx_vfs_blockfs: NSFS-v2, nested tree persists+mounts byte-exact, 5/5) + WRITE-AHEAD JOURNALING (nx_journal: jbd2-class WAL, crash-after-commit recovered / crash-before-commit atomic / corrupt-txn refused / idempotent replay, 5/5). NOW FULL. Polish: fsck/repair tooling + perf-at-scale" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} }
34 g=os_row("IPC " as *u8, "runtime/nx_shell_lib.nx" as *u8, 2, "pipes (pipe2/dup3) + mmap-shared memory" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} }
35 g=os_row("INIT-SERVICES " as *u8, "runtime/_hdl_build/nx_init_live.nx" as *u8, 2, "dependency-ordered init (nx_init: topo+cycle) + REAL process supervision (nx_init_live, 5/5): forks REAL children, detects death via wait4(WNOHANG), restarts with give-up cap (distinct pids proven), healthy stay alive, crashy gaveup at cap, clean reaping. NOW FULL. Polish: socket-activation + cgroups isolation" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} }
36
37 g_puts(" ==== networking + security ====\n" as *u8)
38 g=os_row("NETWORK-STACK " as *u8, "runtime/nx_http_client.nx" as *u8, 2, "TCP + HTTP client; QUIC/UDP (nx_quic_udp); HTTPS server daemons" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} }
39 g=os_row("TLS-CRYPTO " as *u8, "runtime/nx_x509_trust_store.nx" as *u8, 2, "sovereign TLS-1.3 + X.509 trust store (every researcher fetches over it)" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} }
40 g=os_row("SOCKETS-SERVER " as *u8, "runtime/_hdl_build/nx_sites_daemon_v2.nx" as *u8, 2, "listening HTTPS server daemons (sites/login/publisher/audio)" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} }
41 g=os_row("AUTH-USERS " as *u8, "runtime/_hdl_build/nx_users.nx" as *u8, 2, "multi-user accounts + auth (nx_users, 4/4) + POSIX-style groups/ACLs (nx_acl: user/group/other rwx classes, 4/4) + OPAQUE login + argon2id vault. Polish: PAM/capabilities" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} }
42
43 g_puts(" ==== userland + dev ====\n" as *u8)
44 g=os_row("SHELL " as *u8, "runtime/nx_shell_lib.nx" as *u8, 2, "nx_shell R0-R6 + drivable nx_shell_run (exec/builtins/capture/control/pipeline)" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} }
45 g=os_row("REGEX " as *u8, "runtime/_hdl_build/nx_regex_vm_lib.nx" as *u8, 2, "UNIFIED sovereign regex: ONE linear-time Thompson-NFA engine (nx_regex_vm_lib, 6/6) that is a STRICT SUPERSET of both prior engines -- literals/./*/+/?/[]ranges + ALTERNATION |/GROUPS () + ^ $ ANCHORS, ReDoS-IMMUNE (no backtracking, the RE2/Go design; (a|a)*b$ stays linear). Drives sovereign grep (re_vm_grep_count: anchored + alternation line-grep, ReDoS-immune -- beats backtracking grep/PCRE). ^(cat|dog)$ (anchors+alternation together) is expressible by NEITHER prior engine. NOW UNIFIED (2 engines -> 1 superset). Polish: capture-group extraction + backreferences (a separate, careful design -- backrefs cost linearity)" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} }
46 g=os_row("TEXT-EDITOR " as *u8, "runtime/_hdl_build/nx_editor_loop.nx" as *u8, 2, "editor loop + canvas + render + validate" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} }
47 g=os_row("DEVICE-DRIVERS " as *u8, "runtime/_hdl_build/nx_hw_discover.nx" as *u8, 2, "AUTO-DISCOVER + AUTO-GENERATE + REAL-DRIVE: nx_hw_discover parses the REAL QEMU device tree (8 virtio-mmio + UART/PLIC/CLINT/memory, 5/5); a live RV64 scan (nx_rv64_asm sovereign assembler) reads real DeviceIDs in QEMU (net=1/blk=2/rng=4); nx_driver_gen generates a virtio driver per DeviceID (5/5); and a sovereign-assembled RV64 virtio-rng driver DRIVES A REAL QEMU virtio DEVICE END-TO-END (handshake->virtqueue->real entropy, different every boot). ★ NO QEMU DEPENDENCY: our OWN emulator (rv64im_min_sim + rv64im_min_virtio device model) drives virtio-blk end-to-end (the _k_r2_001b* gates, sovereign lane primary); the RV64 assembler is EXHAUSTIVELY verified by execution on it (nx_rv64_asm_verify: every instruction, self-checking, no QEMU). Never-brick: emulator sandbox, hostile guests contained/host untouched" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} }
48 g=os_row("COMPILER-TOOLCHAIN" as *u8, "runtime/nx_riscv_lib.nx" as *u8, 2, "nx_cc->nxasm (x86) + sovereign RISC-V backend (encoder/codegen/emulator)" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} }
49 g=os_row("EXEC-FORMAT " as *u8, "runtime/_hdl_build/nx_nxe_loader.nx" as *u8, 2, "SOVEREIGN Nishi Executable format (NXE, own magic NXE1) + NATIVE LOADER that VERIFIES then EXECUTES (nx_nxe_loader: FIPS-180-4 SHA-256 integrity + EXEC-capability manifest + never-brick tag -> mmap RWX + cast-fn-ptr EXECUTE real machine code, 5/5; tamper/no-cap/hw-write all refused BEFORE a byte runs; a real .nxe FILE round-trips off disk + runs). NOW FULL -- verify-before-execute by construction, the ELF exceed. Polish: dynamic linking / reloc / debug info" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} }
50 g=os_row("PACKAGE-MGMT " as *u8, "runtime/_hdl_build/nx_pkg_solve.nx" as *u8, 2, "package manager (nx_pkg: transitive-dep + topo install + per-package sha) + VERSION-CONSTRAINT SOLVER (nx_pkg_solve, 5/5): semver intervals (exact/>=/caret/tilde/range) + BACKTRACKING resolver (diamond intersection -> highest feasible, real backtrack to a lower version, unsatisfiable-conflict detection), deterministic/lockfile-stable. NOW FULL. Polish: remote repos + scale" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} }
51 g=os_row("DISPLAY-UI " as *u8, "runtime/_hdl_build/nx_editor_canvas.nx" as *u8, 2, "terminal (ANSI) + editor canvas + sovereign browser" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} }
52 g=os_row("GRAPHICS-API " as *u8, "runtime/_hdl_build/nx_raster3d.nx" as *u8, 2, "sovereign INTEGER-DETERMINISTIC render pipeline: 2D rasterizer (nx_raster) + full 3D PIPELINE (nx_raster3d, 5/5): fixed-point transform + PERSPECTIVE PROJECTION + Z-BUFFER hidden-surface removal + flat Lambert shading + PERSPECTIVE-CORRECT TEXTURE MAPPING (nx_raster3d_tex, 4/4: u/z,v/z,1/z interpolation + per-pixel divide -- KAT-proven perspective-correct vs the affine warp) + BILINEAR FILTERING (nx_raster3d_bilinear, 4/4: 4-texel fractional blend, halfway black|white=gray 127) + GOURAUD SMOOTH SHADING (nx_raster3d_gouraud, 4/4: per-vertex color/intensity barycentric interpolation -- centroid=exact blend, 841-color gradient, vertex-lit ramp), BIT-EXACT on any CPU/no-GPU. NOW FULL -- all 3 renderer pillars (geometry=perspective-correct+z-buffer, texture=perspective+bilinear, lighting=Gouraud) = a complete SOTA software renderer. Polish: mipmaps + alpha blending; GPU hardware-accel is the separate hardware-gated GPU-DRIVER row" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} }
53 g=os_row("GPU-DRIVER " as *u8, "runtime/_hdl_build/nx_gpu_driver.nx" as *u8, 1, "universal vendor framework (nx_gpu_driver: NVIDIA/AMD/Intel by PCI ID + 0 firmware-write opcodes, 4/4) + BAR/MMIO command-ring submission model (nx_gpu_ring, 5/5: MMIO regs + ring + doorbell + fence; fw-write opcode HALTS the device). GAP: real-hardware BAR submission on a live GPU -- MODELED + activation refused BY CONSTRUCTION; real PCIe BAR = the guarded never-brick HARDWARE step" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} }
54
55 g_puts(" ==== boot + live image ====\n" as *u8)
56 g=os_row("BOOTABLE-IMAGE " as *u8, "runtime/_hdl_build/nx_spore_boot.nx" as *u8, 1, "the BOOTABLE SPORE (nx_spore_boot, 5/5): a live image boots POST -> load medium -> MOUNT root + journal-REPLAY -> load+VERIFY+EXECUTE /sbin/init.nxe -> userland; power-cycle stable; crash-during-install replays; tampered-init SAFE-HALTS (never-brick); missing-init clean-halts. 'match Puppy = live image from POST' realized in the emulator/file-model. GAP remaining: real-hardware POST (BIOS/UEFI on physical silicon) = the guarded never-brick operator step" as *u8); if g==2 {have_n=have_n+1} else { if g==1 {part_n=part_n+1} else {miss_n=miss_n+1} }
57
58 // teeth: a fake capability organ must read MISSING (proves have_file grounding is real)
59 let tg: i64 = os_row("NEG-CONTROL " as *u8, "runtime/nx_does_not_exist_zzz.nx" as *u8, 2, "(intentionally absent -- must read MISSING)" as *u8)
60
61 let total: i64 = have_n+part_n+miss_n
62 g_puts(" ==== TALLY: HAVE="); g_pn(have_n); g_puts(" PARTIAL="); g_pn(part_n); g_puts(" MISSING="); g_pn(miss_n); g_puts(" of "); g_pn(total); g_puts(" OS capabilities ====\n" as *u8)
63 g_puts(" >> RUNG 4-6 CLOSED 2026-07-07: FILESYSTEM (block-VFS-mount + journaling), EXEC-FORMAT (native NXE\n" as *u8)
64 g_puts(" verify+execute), INIT-SERVICES (REAL fork/wait4 supervision), PACKAGE-MGMT (version-constraint solver),\n" as *u8)
65 g_puts(" GRAPHICS-API (integer 3D pipeline: projection+z-buffer+shading) all now FULL; spore boots POST->userland.\n" as *u8)
66 g_puts(" >> ★ EVERY SOFTWARE-REACHABLE OS CAPABILITY IS NOW FULL. The 3 remaining PARTIALs are ALL HARDWARE-gated\n" as *u8)
67 g_puts(" (guarded never-brick): MEMORY real-hw-MMU (ring0/CR3), GPU-DRIVER real-hw-BAR/ring, BOOTABLE-IMAGE real-\n" as *u8)
68 g_puts(" silicon-POST (BIOS/UEFI). Each is now DEEP-MODELED to real-hardware fidelity (nx_mmu_hw x86-64 4-level\n" as *u8)
69 g_puts(" walk 5/5, nx_gpu_ring BAR/MMIO submission 5/5) with real activation REFUSED BY CONSTRUCTION; the real\n" as *u8)
70 g_puts(" hardware step is the operator's guarded move. ★ nx_neverbrick_genesis 5/5 mechanically enforces cardinal\n" as *u8)
71 g_puts(" 26: every hardware-write node carries a never-brick guarantee or the genesis gate goes VERDICT RED.\n" as *u8)
72 g_puts(" >> ★ NEVER-BRICK VERIFIED FOR REAL (not just a rule) in QEMU RISC-V: hostile guests (illegal instruction,\n" as *u8)
73 g_puts(" wild MMIO store, VM-failure request) were CONTAINED by the emulator sandbox -- the host stayed alive.\n" as *u8)
74 g_puts(" DEVICE-DRIVERS now AUTO-DISCOVER (parse the real device tree) + AUTO-GENERATE (virtio-mmio driver per\n" as *u8)
75 g_puts(" DeviceID, emulator-validated). [AI + raw-hardware tracked in their own censuses.]\n" as *u8)
76
77 var pass: i64=0; var t: i64=0
78 var t1: i64=0; if have_n>=10 { t1=1 }
79 pass=pass+ck("T1: >=10 OS capabilities HAVE a real grounding organ (the OS is substantially built)" as *u8, t1); t=t+1
80 var t2: i64=0; if part_n>=1 { t2=1 }
81 pass=pass+ck("T2 (honest): PARTIAL gaps still remain (>=1) -- we do NOT claim the OS is complete" as *u8, t2); t=t+1
82 var t3: i64=0; if tg==0 { t3=1 }
83 pass=pass+ck("T3 (teeth): the neg-control absent organ reads MISSING -- grounding is real, not a rubber stamp" as *u8, t3); t=t+1
84
85 var okall: i64=0; if pass==t { okall=1 }
86 g_puts("---- nx_os_census: passed "); g_pn(pass); g_puts(" / "); g_pn(t); g_puts(" ----\n" as *u8)
87 if okall==1 {
88 let logf: i64=sys_openat_append("knowledge/status/os_census.log" as *u8, 420)
89 if logf>=0 { let z: i64=sys_write(logf,"OSCENSUS GREEN: OS substantially built (HAVE>=18) after rungs 4-6; EVERY software-reachable capability FULL; 3 remaining PARTIALs ALL hardware-gated (MMU/GPU-BAR/silicon-POST)\n" as *u8,161); sys_close(logf) }
90 g_puts("verdict=GREEN (honest OS gap map: every SOFTWARE-reachable OS capability now FULL after rungs 4-6; the 3 remaining PARTIALs are ALL hardware-gated, guarded never-brick)\n" as *u8); sys_exit(0); return 0
91 }
92 g_puts("verdict=RED\n" as *u8); sys_exit(1); return 1
93}