code wiki / _hdl_build / nx_hang_resolve.nx

nx_hang_resolve.nx

buildroot/runtime/_hdl_build/nx_hang_resolve.nx

2516 B42 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_hang_resolve.nx nx_hang_resolve_test.nx

imports: nx_syscalls.nx

imported by: nx_hang_resolve_test.nx

structs

none

consts

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
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)
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

functions

26func hr_within_sla(steps: i64, sec: i64) -> i64 { if steps <= HR_MAX_STEPS { if sec <= HR_MAX_SEC { return 1 } } return 0 }
called by 2: hr_grademain
27func hr_is_optimal(steps: i64, sec: i64) -> i64 { if steps <= HR_OPT_STEPS { if sec < HR_OPT_SEC { return 1 } } return 0 }
29func hr_grade(steps: i64, sec: i64) -> i64
called by 1: main calls 2: hr_is_optimalhr_within_sla
36func hr_resolution_steps(known_pattern: i64) -> i64 { if known_pattern == 1 { return 1 } return 3 }
39func 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
42func hr_codegen_hang_optimal() -> i64 { return hr_is_optimal(hr_resolution_steps(1), 5) }