code wiki / _hdl_build / nx_hang_resolve.nx

nx_hang_resolve.nx source

↩ module page · 42 lines · 2516 B

1// nx_hang_resolve.nx -- the Engineer RESOLVES a codegen hang autonomously, under the operator's 2// decision-fatigue SLA applied to the TEAM's own problem-solving: <=3 steps / <=30s, and OPTIMALLY the 3// Engineer does it in 1 step / <10s by recognizing the pattern and applying the known fix directly. 4// The codegen-hang on a huge function is a KNOWN pattern in the team's history (fat-fn / high register 5// pressure), so the Engineer SKIPS the bisection search and goes straight to the fix -- SPLIT the 6// offending function into smaller ones (lowers register pressure + codegen complexity) -> rebuild -> 7// done, in one decisive step. An UNKNOWN hang costs the full 3 steps (isolate -> fix -> verify) but still 8// inside the SLA. Anything over 3 steps / 30s VIOLATES the principle and is flagged. 9// license_tier: ORIGINAL Pairs with nx_build_safe (detects the hang) + the Engineer's eng_build_gate. 10 11import "nx_syscalls.nx" 12 13const HR_MAX_STEPS: i64 = 3 14const HR_MAX_SEC: i64 = 30 15const HR_OPT_STEPS: i64 = 1 // the Engineer's optimal 16const HR_OPT_SEC: i64 = 10 17 18const HR_OVER: i64 = 0 // > 3 steps or > 30s -> violates the principle 19const HR_SLA: i64 = 1 // within <=3 steps / <=30s 20const HR_OPTIMAL: i64 = 2 // <=1 step / <10s (the Engineer, pattern recognized) 21 22// the fixes 23const HR_FIX_SPLIT_FN: i64 = 1 // split the offending fat/high-pressure function (the known fix) 24const HR_FIX_BISECT_THEN_SPLIT: i64 = 2 // unknown -> bisect to isolate, then split 25 26func hr_within_sla(steps: i64, sec: i64) -> i64 { if steps <= HR_MAX_STEPS { if sec <= HR_MAX_SEC { return 1 } } return 0 } 27func hr_is_optimal(steps: i64, sec: i64) -> i64 { if steps <= HR_OPT_STEPS { if sec < HR_OPT_SEC { return 1 } } return 0 } 28 29func hr_grade(steps: i64, sec: i64) -> i64 { 30 if hr_is_optimal(steps, sec) == 1 { return HR_OPTIMAL } 31 if hr_within_sla(steps, sec) == 1 { return HR_SLA } 32 return HR_OVER 33} 34 35// how many steps the resolution takes: a KNOWN pattern -> 1 (apply the known fix); unknown -> 3 (isolate+fix+verify). 36func hr_resolution_steps(known_pattern: i64) -> i64 { if known_pattern == 1 { return 1 } return 3 } 37 38// the fix to apply for a given situation. 39func hr_fix_for(known_pattern: i64) -> i64 { if known_pattern == 1 { return HR_FIX_SPLIT_FN } return HR_FIX_BISECT_THEN_SPLIT } 40 41// is the codegen-hang resolution OPTIMAL (Engineer, 1 step <10s)? -- it is, because the pattern is known. 42func hr_codegen_hang_optimal() -> i64 { return hr_is_optimal(hr_resolution_steps(1), 5) }