code wiki / _hdl_build / nx_hang_resolve.nx
nx_hang_resolve.nx
buildroot/runtime/_hdl_build/nx_hang_resolve.nx
about
nx_hang_resolve.nx -- the Engineer RESOLVES a codegen hang autonomously, under the operator's
decision-fatigue SLA applied to the TEAM's own problem-solving: <=3 steps / <=30s, and OPTIMALLY the
Engineer does it in 1 step / <10s by recognizing the pattern and applying the known fix directly.
The codegen-hang on a huge function is a KNOWN pattern in the team's history (fat-fn / high register
pressure), so the Engineer SKIPS the bisection search and goes straight to the fix -- SPLIT the
offending function into smaller ones (lowers register pressure + codegen complexity) -> rebuild ->
done, in one decisive step. An UNKNOWN hang costs the full 3 steps (isolate -> fix -> verify) but still
inside the SLA. Anything over 3 steps / 30s VIOLATES the principle and is flagged.
license_tier: ORIGINAL Pairs with nx_build_safe (detects the hang) + the Engineer's eng_build_gate.
dependencies 1 imports · 1 importers
imports: nx_syscalls.nx
imported by: nx_hang_resolve_test.nx
structs
| none |
consts
| 13 | const HR_MAX_STEPS: i64 = 3 |
| 14 | const HR_MAX_SEC: i64 = 30 |
| 15 | const HR_OPT_STEPS: i64 = 1 // the Engineer's optimal |
| 16 | const HR_OPT_SEC: i64 = 10 |
| 18 | const HR_OVER: i64 = 0 // > 3 steps or > 30s -> violates the principle |
| 19 | const HR_SLA: i64 = 1 // within <=3 steps / <=30s |
| 20 | const HR_OPTIMAL: i64 = 2 // <=1 step / <10s (the Engineer, pattern recognized) |
| 23 | const HR_FIX_SPLIT_FN: i64 = 1 // split the offending fat/high-pressure function (the known fix) |
| 24 | const HR_FIX_BISECT_THEN_SPLIT: i64 = 2 // unknown -> bisect to isolate, then split |
functions
| 26 | func hr_within_sla(steps: i64, sec: i64) -> i64 { if steps <= HR_MAX_STEPS { if sec <= HR_MAX_SEC { return 1 } } return 0 } |
| 27 | func hr_is_optimal(steps: i64, sec: i64) -> i64 { if steps <= HR_OPT_STEPS { if sec < HR_OPT_SEC { return 1 } } return 0 } |
| 29 | func hr_grade(steps: i64, sec: i64) -> i64 |
| 36 | func hr_resolution_steps(known_pattern: i64) -> i64 { if known_pattern == 1 { return 1 } return 3 } |
| 39 | func hr_fix_for(known_pattern: i64) -> i64 { if known_pattern == 1 { return HR_FIX_SPLIT_FN } return HR_FIX_BISECT_THEN_SPLIT } called by 1: main |
| 42 | func hr_codegen_hang_optimal() -> i64 { return hr_is_optimal(hr_resolution_steps(1), 5) } |