code wiki / (root) / nx_wired_status.nx

nx_wired_status.nx source

↩ module page · 164 lines · 7009 B

1// nx_wired_status.nx -- mandatory wired-status declaration per primitive. 2// 3// module: nishi-core.audit.wired_status 4// depends: nishi-core.io.syscalls 5// disk_kb: 4 6// capability: CORE_IO 7// wired_status: FULLY_WIRED 8// 9// license_tier: PUBLIC_NISHI_SUBSTRATE 10// genealogy_id: nishi_no_false_ok_cardinal_2026 + 11// type_state_pattern_haskell_indexed_monad + 12// software_engineering_progress_honesty_research 13// 14// Per cardinal [[feedback-no-false-ok-substrate-honesty-audit]]: 15// every `.nx` file in the Nishi family declares its wired_status in 16// the module header. Substrate audit reads these + verifies against 17// implementation presence + refuses external claims that diverge. 18// 19// THIS file's own wired_status is FULLY_WIRED because: sealed-enum 20// declaration is the implementation; no further execution needed; it 21// is a TYPE-LEVEL primitive. 22 23// nx_safety_envelope: 24// intended_use: AUTO_APPLIED -- primitive-specific tuning queued 25// sil_target: SIL1 26// evidence: [bulk_applied_2026-05-16, see-file-comment-for-detail] 27// verdict: NOT_YET_EVALUATED 28 29import "nx_syscalls.nx" 30 31// ===== WiredStatus sealed enum ==================================== 32// 33// Mandatory header-declaration enum. Every .nx file declares one. 34 35const NX_WIRED_FULLY_WIRED: i64 = 1 36const NX_WIRED_PARTIAL_WIRED: i64 = 2 37const NX_WIRED_HONEST_STUB: i64 = 3 38const NX_WIRED_DECLARED_ONLY: i64 = 4 39const NX_WIRED_REFACTOR_TARGET: i64 = 5 40const NX_WIRED_DEPRECATED: i64 = 6 41 42func nx_wired_status_name(s: i64) -> *u8 { 43 if s == NX_WIRED_FULLY_WIRED { return "FULLY_WIRED" } 44 if s == NX_WIRED_PARTIAL_WIRED { return "PARTIAL_WIRED" } 45 if s == NX_WIRED_HONEST_STUB { return "HONEST_STUB" } 46 if s == NX_WIRED_DECLARED_ONLY { return "DECLARED_ONLY" } 47 if s == NX_WIRED_REFACTOR_TARGET { return "REFACTOR_TARGET" } 48 if s == NX_WIRED_DEPRECATED { return "DEPRECATED" } 49 return "UNKNOWN" 50} 51 52// ===== Honest verb tier =========================================== 53// 54// Map from WiredStatus to the precise descriptive verb tier. External 55// claims about a primitive must use the verb at or below the file's 56// wired_status declaration — never above. 57 58const NX_VERB_SCAFFOLDED: i64 = 1 // file exists with declared signatures + types 59const NX_VERB_STUBBED: i64 = 2 // signatures + STUB-variant return; no execution 60const NX_VERB_PARTIAL: i64 = 3 // some paths execute 61const NX_VERB_WIRED: i64 = 4 // composes against substrate that runs end-to-end + passing smoke 62const NX_VERB_SHIPPED: i64 = 5 // WIRED + commit landed + visible to downstream 63 64func nx_verb_name(v: i64) -> *u8 { 65 if v == NX_VERB_SCAFFOLDED { return "SCAFFOLDED" } 66 if v == NX_VERB_STUBBED { return "STUBBED" } 67 if v == NX_VERB_PARTIAL { return "PARTIAL" } 68 if v == NX_VERB_WIRED { return "WIRED" } 69 if v == NX_VERB_SHIPPED { return "SHIPPED" } 70 return "UNKNOWN" 71} 72 73// Max-claimable verb tier for a given wired_status. Caller composing 74// external prose about a primitive can use ANY verb at-or-below this 75// tier; using a verb ABOVE this tier fails the honesty audit. 76 77func nx_wired_max_claimable_verb(status: i64) -> i64 { 78 if status == NX_WIRED_FULLY_WIRED { return NX_VERB_SHIPPED } 79 if status == NX_WIRED_PARTIAL_WIRED { return NX_VERB_PARTIAL } 80 if status == NX_WIRED_HONEST_STUB { return NX_VERB_STUBBED } 81 if status == NX_WIRED_DECLARED_ONLY { return NX_VERB_SCAFFOLDED } 82 if status == NX_WIRED_REFACTOR_TARGET { return NX_VERB_PARTIAL } 83 if status == NX_WIRED_DEPRECATED { return NX_VERB_WIRED } 84 return NX_VERB_SCAFFOLDED 85} 86 87// ===== ClaimVerdict =============================================== 88// 89// When external prose makes a claim about a primitive, claim audit 90// returns this verdict. 91 92const NX_CLAIM_HONEST: i64 = 1 93const NX_CLAIM_OVERSTATED: i64 = 2 // used SHIPPED where WIRED applicable 94const NX_CLAIM_UNDERSTATED: i64 = 3 // used SCAFFOLDED where SHIPPED accurate 95const NX_CLAIM_HEADER_MISSING: i64 = 4 // primitive doesn't declare wired_status 96const NX_CLAIM_IMPL_DOESNT_MATCH: i64 = 5 // header says WIRED but body is stub 97 98func nx_claim_verdict_name(v: i64) -> *u8 { 99 if v == NX_CLAIM_HONEST { return "HONEST" } 100 if v == NX_CLAIM_OVERSTATED { return "OVERSTATED" } 101 if v == NX_CLAIM_UNDERSTATED { return "UNDERSTATED" } 102 if v == NX_CLAIM_HEADER_MISSING { return "HEADER_MISSING" } 103 if v == NX_CLAIM_IMPL_DOESNT_MATCH { return "IMPL_DOESNT_MATCH" } 104 return "UNKNOWN" 105} 106 107// ===== STUB-variant convention ==================================== 108// 109// Per cardinal: every domain's verdict enum MUST include a 110// *_STUB_NOT_WIRED variant that is the default initialization. 111// Caller checking `if v == *_OK` does not fire on uninitialized 112// stub return. 113 114// Common STUB constants the substrate uses where domains don't define 115// their own. Domain-specific verdicts should define their own. 116const NX_STUB_NOT_WIRED: i64 = -7777 // sentinel: substrate detects this in audit 117const NX_STUB_PARTIAL_IMPL: i64 = -7778 118const NX_STUB_DECLARED_ONLY: i64 = -7779 119 120// ===== Default-init guard ========================================= 121// 122// When a struct holds a verdict field, substrate convention: init to 123// NX_STUB_NOT_WIRED. Any function returning the struct without 124// setting the verdict explicitly returns STUB. Caller can detect. 125 126func nx_audit_is_stub_verdict(v: i64) -> i64 { 127 if v == NX_STUB_NOT_WIRED { return 1 } 128 if v == NX_STUB_PARTIAL_IMPL { return 1 } 129 if v == NX_STUB_DECLARED_ONLY { return 1 } 130 if v == 0 { return 1 } // uninitialized 131 return 0 132} 133 134// ===== Substrate-claim composition ================================ 135// 136// Per cardinal: caller prose claims about substrate composition must 137// use the LOWEST verb tier across all dependencies. A primitive that 138// composes against an HONEST_STUB dependency cannot claim WIRED. 139 140func nx_claim_compose_verb(my_status: i64, dep_max_verb: i64) -> i64 { 141 let my_max: i64 = nx_wired_max_claimable_verb(my_status) 142 if dep_max_verb < my_max { return dep_max_verb } 143 return my_max 144} 145 146// ===== Substrate file metadata ==================================== 147// 148// One record per .nx file; populated by nx_claim_audit scanner. 149 150struct WiredFileRecord { 151 record_hk: i64, 152 file_path_ptr: *u8, 153 file_path_len: i64, 154 declared_status: i64, // NX_WIRED_* from header 155 inferred_status: i64, // detected by audit from body 156 drift_verdict: i64, // NX_CLAIM_* 157 lines_of_code: i64, 158 n_functions: i64, 159 n_stub_returns: i64, // count of NX_STUB_*_NOT_WIRED returns 160 last_audited_unix: i64, 161 is_current: i64, 162} 163 164const NX_WIRED_FILE_RECORD_BYTES: i64 = 80 // 10 fields * 8 bytes