code wiki / _hdl_build / nx_four_pillars.nx

nx_four_pillars.nx source

↩ module page · 48 lines · 2923 B

1// nx_four_pillars.nx -- the ENGINEER's FOUR-PILLAR GUARD: the intelligent, additive guard that makes a 2// defect class un-recurring (operator: "the guard you describe if intelligent and additive is the four 3// pillars work i wanted the engineer to address as its responsibility"). This is the team's established 4// pattern (G1 regalloc guard, nx-int alias guard) formalized + made the Engineer's owned responsibility. 5// The four pillars (ALL required -- a partial guard is not a guard): 6// 1. GATE -- a regression gate that FAILS LOUD if the class recurs (CI smoke). 7// 2. PROBE -- a minimal repro that isolates the root cause (proves we understand it). 8// 3. KAT -- a known-answer test locking the correct behavior forever. 9// 4. PREVENTION -- the structural fix that makes the bad input IMPOSSIBLE (loud-fail / pinned / data-driven). 10// INTELLIGENT = the class is LEARNED from a real captured diagnostic (data-driven, like the Doctor learning 11// the offending keyword), not a hardcoded match. ADDITIVE = adds new artifacts, never clobbers protected 12// source. Owned by the ENGINEER (RACI). license_tier: ORIGINAL Formalizes the poka-yoke in nx_pipeline_metrics. 13 14import "nx_syscalls.nx" 15 16const FP_GATE: i64 = 0 17const FP_PROBE: i64 = 1 18const FP_KAT: i64 = 2 19const FP_PREVENTION: i64 = 3 20const FP_NPILLARS: i64 = 4 21 22const FP_R_ENGINEER: i64 = 2 // matches dp_owner's ENGINEER -- the four-pillar guard is the Engineer's job 23 24// a guard is COMPLETE iff all four pillars are present. 25func fp_complete(gate: i64, probe: i64, kat: i64, prevention: i64) -> i64 { 26 if gate == 1 { if probe == 1 { if kat == 1 { if prevention == 1 { return 1 } } } } 27 return 0 28} 29// how many of the four pillars a candidate guard actually has (to grade partial guards honestly). 30func fp_pillar_count(gate: i64, probe: i64, kat: i64, prevention: i64) -> i64 { 31 return gate + probe + kat + prevention 32} 33// INTELLIGENT: the defect class was learned from a real diagnostic, not hardcoded. 34func fp_intelligent(learned_from_diagnostic: i64) -> i64 { if learned_from_diagnostic == 1 { return 1 } return 0 } 35// ADDITIVE: never clobbers protected source (additive-only). 36func fp_additive(clobbers_existing: i64) -> i64 { if clobbers_existing == 0 { return 1 } return 0 } 37// the Engineer owns installing the guard. 38func fp_owner() -> i64 { return FP_R_ENGINEER } 39 40// a VALID four-pillar guard = complete AND intelligent AND additive. 41func fp_valid(gate: i64, probe: i64, kat: i64, prevention: i64, learned: i64, clobbers: i64) -> i64 { 42 if fp_complete(gate, probe, kat, prevention) != 1 { return 0 } 43 if fp_intelligent(learned) != 1 { return 0 } 44 if fp_additive(clobbers) != 1 { return 0 } 45 return 1 46} 47// only a VALID guard truly prevents recurrence (turns the poka-yoke real); a partial guard leaks. 48func fp_prevents_recurrence(valid: i64) -> i64 { if valid == 1 { return 1 } return 0 }