code wiki / _hdl_build / nx_engineer_wire_sclass.nx

nx_engineer_wire_sclass.nx source

↩ module page · 55 lines · 4065 B

1// nx_engineer_wire_sclass.nx -- the S-CLASS EXCEED layer on the ENGINEER's wiring capability (operator: 2// "make sure our wiring capabilities on the engineer are s class exceed"). It does NOT replace 3// nx_engineer_wire (rule 15: inherit + extend, never copy) -- it imports it and raises the bar in the three 4// ways the base capability falls short of the operator's own doctrines: 5// (1) MEASURED, not binary -- the base returns regress/neutral/ok; this returns the NET MARGIN 6// (improvements - regressions) so an "exceed" must be measurably positive ("no wave, measured exceed"). 7// (2) NEVER-BRICK aware (#26) -- a wiring that touches a hardware/firmware axis is REJECTED unless a 8// never-brick guarantee is PROVEN, mirroring the genesis gate (firmware node lacking it -> RED). 9// (3) ANTI-DUPLICATE aware -- before wiring a "new" component in, run the cap_guard (nx_cap_exists): a 10// component whose capability already EXISTS is REDUNDANT and must NOT be wired (the exact mistake the 11// guard exists to stop -- caught a near-duplicate of nx_engineer_wire itself this session). 12// Sovereign. license_tier: ORIGINAL 13import "nx_engineer_wire.nx" // ew_regressions / ew_improvements / ew_verdict / ew_safe_to_wire / EW_* 14import "nx_cap_exists.nx" // cap_guard -- the anti-duplicate decision 15import "nx_syscalls.nx" 16 17const EWS_RED: i64 = 0 // REJECT: a regression, a brick-risk, or a redundant duplicate component 18const EWS_HOLD: i64 = 1 // admissible (non-regressing, safe) but NO measured gain -> not an s-class exceed 19const EWS_GREEN: i64 = 2 // measured net-positive, never-brick-safe, non-redundant -> WIRE IT 20 21// (1) MEASURED exceed: the NET margin over a labelled case set = improvements - regressions. This is the 22// magnitude the base capability throws away by collapsing to a binary verdict. 23func ews_margin(n: i64, old_correct: *i64, new_correct: *i64) -> i64 { 24 return ew_improvements(n, old_correct, new_correct) - ew_regressions(n, old_correct, new_correct) 25} 26 27// the s-class certify (software wiring): admit ONLY with ZERO regressions AND a POSITIVE measured margin. 28// a neutral swap (margin 0) is non-regressing but is NOT an exceed -> HOLD, do not claim a win ("no wave"). 29func ews_certify(n: i64, old_correct: *i64, new_correct: *i64) -> i64 { 30 if ew_regressions(n, old_correct, new_correct) > 0 { return EWS_RED } // rule 19: never regress a contract 31 if ews_margin(n, old_correct, new_correct) > 0 { return EWS_GREEN } // measured net-positive 32 return EWS_HOLD 33} 34 35// (2) NEVER-BRICK (#26): a wiring that touches a hardware/firmware axis is RED unless never-brick is PROVEN, 36// regardless of how good its correctness margin looks. Mirrors the genesis gate: the guarantee must be 37// mechanical, not asserted. Software wirings (touches_hw=0) defer to ews_certify. 38func ews_certify_hw(n: i64, old_correct: *i64, new_correct: *i64, touches_hw: i64, neverbrick_proven: i64) -> i64 { 39 if touches_hw == 1 { if neverbrick_proven == 0 { return EWS_RED } } 40 return ews_certify(n, old_correct, new_correct) 41} 42 43// (3) ANTI-DUPLICATE: is the incoming "new" component REDUNDANT? Runs the cap_guard over a pre-built index. 44// 1 = REDUNDANT (a matching capability already EXISTS -> point to it, do not wire a duplicate) | 0 = novel. 45func ews_is_redundant(cap_keywords: *u8, nf: i64, surf: *u8, foff: *i64, fnames: *u8, fnoff: *i64) -> i64 { 46 let gb: *i64 = sys_mmap(16) as *i64 47 return cap_guard(cap_keywords, surf, foff, nf, fnames, fnoff, gb) 48} 49 50// THE FULL S-CLASS ADMISSION. A duplicate component or a brick-risk dominates (RED); otherwise the measured, 51// never-brick-aware certify decides. This is the decision the engineer makes before accepting any wiring. 52func ews_admit(n: i64, old_correct: *i64, new_correct: *i64, touches_hw: i64, neverbrick_proven: i64, redundant: i64) -> i64 { 53 if redundant == 1 { return EWS_RED } // never wire a duplicate of an existing capability 54 return ews_certify_hw(n, old_correct, new_correct, touches_hw, neverbrick_proven) 55}