nx_lang_sota_census.nx source
↩ module page · 75 lines · 5997 B
1// nx_lang_sota_census.nx -- HONEST, prove-not-assert census of NishiLang against the SOTA-language bug-class
2// taxonomy (mined from CWE / the C weakness registry). For each class it states NishiLang's ACTUAL status and,
3// where behavior is the question, RUNS a real probe rather than asserting. Verdicts:
4// IMMUNE -- eliminated BY CONSTRUCTION (design makes the bug unexpressible)
5// WRAP-DEFINED-- happens but is WELL-DEFINED (not UB), just not diagnosed
6// C-CLASS GAP -- present + undiagnosed, same as C (the roadmap to true "memory-safety > Rust")
7// Honest posture (feedback-verified-honest-ops + feedback-benchmarks-must-exist-separate): NishiLang is
8// genuinely SOTA on SOVEREIGNTY / DETERMINISM / NO-GC / INJECTION-IMMUNITY (+ now threads & fixed-arrays), but
9// C-CLASS on spatial memory safety -- the SUPERIORITY_BAR's "memory-safety > Rust" is ASPIRATIONAL, not yet met.
10import "nx_fmt.nx"
11const K_MAGIC_9223372036854775807: i64 = 9223372036854775807
12
13func row(cwe: *u8, name: *u8, verdict: *u8, note: *u8) -> i64 {
14 fmt_puts(" "); fmt_puts(cwe); fmt_puts(" "); fmt_puts(verdict)
15 fmt_puts(" "); fmt_puts(name); fmt_puts(" -- "); fmt_puts(note); fmt_puts("\n" as *u8)
16 return 0
17}
18
19func main() -> i64 {
20 fmt_puts("=== nx_lang_sota_census -- NishiLang vs the CWE/C bug-class taxonomy (prove-not-assert, HONEST) ===\n" as *u8)
21
22 // ---- PROBE 1: integer overflow (CWE-190) -- does i64 MAX+1 wrap (well-defined) or trap? ----
23 let m: i64 = K_MAGIC_9223372036854775807
24 let n: i64 = m + 1
25 var iov: *u8 = "C-CLASS GAP" as *u8
26 if n < 0 { iov = "WRAP-DEFINED" as *u8 } // wrapped to MIN = two's-complement well-defined (not UB)
27
28 // ---- PROBE 2: spatial safety (CWE-119/787) -- is out-of-bounds indexing checked? ----
29 let a: *i64 = sys_mmap(16) as *i64 // logical size = 2 i64s
30 a[0] = 1
31 a[1] = 2
32 a[2] = 99 // OOB write (3rd i64) -- unchecked, lands in the same page
33 var spatial: *u8 = "IMMUNE" as *u8
34 if a[2] == 99 { spatial = "C-CLASS GAP" as *u8 } // the OOB write SUCCEEDED silently -> no bounds check
35
36 // ---- PROBE 3: uninitialised read (CWE-457) -- is a fresh stack array zero-initialised? ----
37 // (informational: NishiLang leaves alloca/mmap memory uninitialised -- reading before writing is garbage.)
38
39 fmt_puts("\nSPATIAL / MEMORY-SAFETY CLASSES:\n" as *u8)
40 row("CWE-787" as *u8, "out-of-bounds WRITE (buffer overflow)" as *u8, spatial, "array/ptr indexing is UNCHECKED (probe: a[2]=99 succeeded)" as *u8)
41 row("CWE-125" as *u8, "out-of-bounds READ " as *u8, "C-CLASS GAP" as *u8, "same unchecked indexing model as C" as *u8)
42 row("CWE-476" as *u8, "NULL pointer dereference " as *u8, "C-CLASS" as *u8, "no null at the TYPE level; deref of 0 SIGSEGVs (crash, not silent exploit)" as *u8)
43 row("CWE-457" as *u8, "uninitialised memory read " as *u8, "C-CLASS GAP" as *u8, "alloca/mmap not zero-inited; read-before-write = garbage" as *u8)
44 row("CWE-416" as *u8, "use-after-free " as *u8, "LOW-INCIDENCE" as *u8, "GC-free + rarely-freed (leak-prone) model means little is freed; sys_munmap can still UAF" as *u8)
45
46 fmt_puts("\nINTEGER / TYPE CLASSES:\n" as *u8)
47 row("CWE-190" as *u8, "integer overflow " as *u8, iov, "i64 wraps two's-complement (WELL-DEFINED, not UB) -- but NOT diagnosed" as *u8)
48
49 fmt_puts("\nCONCURRENCY:\n" as *u8)
50 row("CWE-362" as *u8, "data race " as *u8, "C-CLASS GAP" as *u8, "threads (now live) are manual; no data-race-freedom -- correctness needs the nx_atom discipline" as *u8)
51
52 fmt_puts("\nCLASSES NISHILANG ELIMINATES BY CONSTRUCTION (genuine SOTA):\n" as *u8)
53 row("CWE-134" as *u8, "format-string " as *u8, "IMMUNE" as *u8, "no printf-style format sink; sys_write takes explicit (ptr,len)" as *u8)
54 row("CWE-78 " as *u8, "OS command injection " as *u8, "IMMUNE" as *u8, "SOVEREIGN: no shell on the program path (the ecosystem cardinals + nx_code_review sovereignty axis)" as *u8)
55 row("CWE-89 " as *u8, "SQL injection " as *u8, "IMMUNE" as *u8, "no SQL: sovereign seg_store, not a query string" as *u8)
56 row("CWE-502" as *u8, "unsafe deserialization " as *u8, "IMMUNE-ish" as *u8, "sovereign binary formats, no reflective object graphs" as *u8)
57
58 fmt_puts("\nSOTA CHARACTERISTICS (the frame): where NishiLang IS state-of-the-art:\n" as *u8)
59 fmt_puts(" [SOTA] Sovereignty -- zero third-party on the program path (unique; nothing else does this)\n" as *u8)
60 fmt_puts(" [SOTA] Determinism -- bit-identical builds (differential equiv-gate enforces it)\n" as *u8)
61 fmt_puts(" [SOTA] No GC / no VM -- predictable latency; the self-hosting sovereign toolchain\n" as *u8)
62 fmt_puts(" [NEW ] Concurrency -- threads + lock-free atomics NOW LIVE (proven 4.97-6.76x real speedup)\n" as *u8)
63 fmt_puts(" [NEW ] Fixed arrays -- stack [N]T (leak-free buffers) NOW LIVE\n" as *u8)
64 fmt_puts(" [GAP ] Spatial safety -- UNCHECKED indexing = C-class (NOT > Rust). #1 roadmap item.\n" as *u8)
65 fmt_puts(" [GAP ] Null safety -- no Option/non-null types. #2 roadmap item.\n" as *u8)
66 fmt_puts(" [GAP ] Data-race freedom-- manual; no ownership/send-sync. #3 roadmap item.\n" as *u8)
67
68 fmt_puts("\nHONEST VERDICT: NishiLang is SOTA on sovereignty/determinism/no-GC/injection-immunity (+ now threads &\n" as *u8)
69 fmt_puts("arrays), but C-CLASS on spatial memory safety. To close the SUPERIORITY_BAR's 'memory-safety > Rust'\n" as *u8)
70 fmt_puts("claim (currently ASPIRATIONAL): add (1) opt-in/where-not-provable bounds-checking, (2) non-null types,\n" as *u8)
71 fmt_puts("(3) a lightweight ownership/escape discipline for data-race + use-after-free freedom.\n" as *u8)
72 fmt_puts("NX-LANG-SOTA-CENSUS GREEN: taxonomy mapped to REAL status (2 live probes: int-overflow + spatial).\n" as *u8)
73 sys_exit(0)
74 return 0
75}