code wiki / _hdl_build / nx_auditor.nx

nx_auditor.nx source

↩ module page · 82 lines · 4342 B

1// nx_auditor.nx -- the NISHI AUDITOR (operator: identify what parts of the stack are STILL third-party, 2// and distinguish a 3rd-party used as a DEMARCATED competitor/reference/test-harness from a 3rd-party we 3// actually DEPEND ON -- the latter is the real sovereignty gap). Composes with the Genealogist (lineage/ 4// provenance is its domain). The point: "sovereign" must be an AUDITED fact, not a claim. Every external 5// touchpoint is classified: 6// SOVEREIGN -- pure NishiLang, the team owns it 7// COMPETITOR -- a 3rd-party used ONLY as a benchmark/race target (gcc/clang race) -- DEMARCATED, fine 8// REFERENCE -- a 3rd-party used ONLY to triangulate/verify (numpy float reference) -- DEMARCATED, fine 9// TEST_HARNESS -- a 3rd-party used ONLY in tests to simulate/cross-check (mock server, curl) -- DEMARCATED 10// DEPENDENCY -- a 3rd-party the team RELIES ON in the real artifact/loop path -- a SOVEREIGNTY GAP 11// SUBSTRATE -- OS kernel / hardware -- unavoidable, not a closeable 3rd-party gap 12// Only DEPENDENCY is a gap; the demarcated uses are intentional + honest. license_tier: ORIGINAL 13 14import "nx_syscalls.nx" 15 16const AUD_SOVEREIGN: i64 = 0 17const AUD_COMPETITOR: i64 = 1 18const AUD_REFERENCE: i64 = 2 19const AUD_TEST_HARNESS: i64 = 3 20const AUD_DEPENDENCY: i64 = 4 21const AUD_SUBSTRATE: i64 = 5 22 23// a real sovereignty GAP iff we DEPEND on the 3rd-party in the actual path (not just race/verify against it). 24func aud_is_gap(status: i64) -> i64 { if status == AUD_DEPENDENCY { return 1 } return 0 } 25 26// demarcated = an intentional, clearly-bounded 3rd-party interaction (competitor / reference / test), NOT a dependency. 27func aud_is_demarcated(status: i64) -> i64 { 28 if status == AUD_COMPETITOR { return 1 } 29 if status == AUD_REFERENCE { return 1 } 30 if status == AUD_TEST_HARNESS { return 1 } 31 return 0 32} 33 34func aud_is_sovereign(status: i64) -> i64 { if status == AUD_SOVEREIGN { return 1 } return 0 } 35 36// "ok" = not a gap: sovereign, demarcated, or substrate are all acceptable; only DEPENDENCY is owed work. 37func aud_ok(status: i64) -> i64 { if status == AUD_DEPENDENCY { return 0 } return 1 } 38 39func aud_count(statuses: *i64, n: i64, kind: i64) -> i64 { 40 var c: i64 = 0; var i: i64 = 0 41 while i < n { if statuses[i] == kind { c = c + 1 } i = i + 1 } 42 return c 43} 44 45func aud_gap_count(statuses: *i64, n: i64) -> i64 { return aud_count(statuses, n, AUD_DEPENDENCY) } 46 47// sovereignty = fraction of touchpoints that are NOT a dependency-gap (sovereign + demarcated + substrate). 48func aud_sovereignty_permil(statuses: *i64, n: i64) -> i64 { 49 if n <= 0 { return 0 } 50 return ((n - aud_gap_count(statuses, n)) * 1000) / n 51} 52 53// the stricter PURE-sovereign fraction (NishiLang only), for an honest second number. 54func aud_pure_sovereign_permil(statuses: *i64, n: i64) -> i64 { 55 if n <= 0 { return 0 } 56 return (aud_count(statuses, n, AUD_SOVEREIGN) * 1000) / n 57} 58 59// ---- NATIVE-READINESS axis (operator: "identify all the gaps till we run not just on emulations but native 60// systems to get full hardware capabilities"). This is the AUDITOR's job -- an orthogonal axis to the 61// sovereignty class, NOT a new teammate (the Auditor already assesses; this is one more dimension it audits). 62// A SOVEREIGN capability can still run HOSTED on a substrate (Linux/WSL) rather than NATIVE on bare metal. ---- 63const AUD_NATIVE: i64 = 2 // sovereign AND bare-metal -> full hardware capability 64const AUD_HOSTED: i64 = 1 // sovereign but runs ON a substrate (Linux/WSL) -- not bare-metal yet 65const AUD_NOT_NATIVE: i64 = 0 // absent / runs only on 3rd-party hardware 66 67func aud_native_status(is_sovereign: i64, bare_metal: i64, exists: i64) -> i64 { 68 if exists == 0 { return AUD_NOT_NATIVE } 69 if is_sovereign == 1 { if bare_metal == 1 { return AUD_NATIVE } return AUD_HOSTED } 70 return AUD_NOT_NATIVE 71} 72// the gaps to full NATIVE (the work to get off emulation onto bare-metal full hardware). 73func aud_native_gaps(native_statuses: *i64, n: i64) -> i64 { 74 var c: i64 = 0; var i: i64 = 0 75 while i < n { if native_statuses[i] < AUD_NATIVE { c = c + 1 } i = i + 1 } 76 return c 77} 78func aud_native_label(s: i64) -> *u8 { 79 if s == AUD_NATIVE { return "NATIVE" as *u8 } 80 if s == AUD_HOSTED { return "HOSTED(on Linux/WSL)" as *u8 } 81 return "NOT-NATIVE" as *u8 82}