code wiki / (root) / nx_remedy.nx

nx_remedy.nx

buildroot/runtime/nx_remedy.nx

21635 B572 linesdepth 5pulls 5 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_remedy.nx -- formalized self-remediation cycle as substrate primitives. Implements the SELF_REMEDIATION_AS_MATHEMATICIAN cardinal as a sequence of named primitives, so NishiLang itself can run the 7-phase cycle autonomously -- no AI in the loop. Every fix is principled, every recommendation cites the math, every applied change is A/B verified AND generalization-proven before adoption. CYCLE PHASES (mirror docs/SELF_REMEDIATION_AS_MATHEMATICIAN.md): 1. detect -- anomaly check vs baseline / threshold / regression 2. diagnose -- classify into closed RootCause taxonomy 3. propose -- rank candidate FixClass options w/ cost+effectiveness 4. apply -- emit ActionPlan struct for the top proposal 5. ab_verify -- before/after measurement verdict 6. generalize -- grid coverage proof (no single-point overfitting) 7. record -- structured provenance ledger entry Closed taxonomies (also numeric IDs for fast dispatch): AnomalyKind : ANOMALY_NONE / TOLERANCE_EXCEEDED / REGRESSION / STATISTICAL_OUTLIER / TIER_OVERFLOW / TIER_UNDERFLOW / CALIBRATION_MISMATCH RootCause : RC01..RC14 (NumericOverflow ... StaleCalibration) FixClass : FX01..FX13 (EscalateNumericTier ... Ensemble) ApplyVerdict : WORKED / NO_CHANGE / REGRESSION GenVerdict : PASSES_GRID / FAILS_AT_CELL CycleVerdict : ADOPT / REJECT_FAILED_AB / REJECT_FAILED_GEN / NO_ACTION_NEEDED genealogy_id: lehmann_casella_1998 (estimator theory) + aristotelian_root_cause (4-cause taxonomy) + toyota_production_system_andon (halt-on-anomaly) lineage_id: estimator_theory + change_impact_measurement

dependencies 2 imports · 1 importers

syscalls.nx nx_estimator_diagnostics.nx nx_remedy.nx nx_remedy_test.nx

imports: syscalls.nxnx_estimator_diagnostics.nx

imported by: nx_remedy_test.nx

structs

104struct AnomalyReport
112struct DiagnosisReport
118struct FixProposal
125struct ActionPlan
131struct CycleOutcome

consts

41const NX_MAGIC_950000000: i64 = 950000000
42const NX_MAGIC_900000000: i64 = 900000000
43const NX_MAGIC_700000000: i64 = 700000000
44const NX_MAGIC_800000000: i64 = 800000000
45const NX_MAGIC_500000000: i64 = 500000000
46const NX_MAGIC_990000000: i64 = 990000000
47const NX_MAGIC_600000000: i64 = 600000000
48const NX_MAGIC_850000000: i64 = 850000000
49const NX_MAGIC_750000000: i64 = 750000000
53const NX_ANOMALY_NONE: i64 = 0
54const NX_ANOMALY_TOLERANCE_EXCEEDED: i64 = 1
55const NX_ANOMALY_REGRESSION: i64 = 2
56const NX_ANOMALY_STATISTICAL_OUTLIER: i64 = 3
57const NX_ANOMALY_TIER_OVERFLOW: i64 = 4
58const NX_ANOMALY_TIER_UNDERFLOW: i64 = 5
59const NX_ANOMALY_CALIBRATION_MISMATCH: i64 = 6
61const NX_RC_NUMERIC_OVERFLOW: i64 = 1
62const NX_RC_NUMERIC_UNDERFLOW: i64 = 2
63const NX_RC_PRECISION_LOSS: i64 = 3
64const NX_RC_HASH_QUALITY_BIAS: i64 = 4
65const NX_RC_SAMPLE_DENSITY_TOO_LOW: i64 = 5
66const NX_RC_SAMPLE_VARIANCE_TOO_HIGH: i64 = 6
67const NX_RC_SIGN_HANDLING_ERROR: i64 = 7
68const NX_RC_OFF_BY_ONE: i64 = 8
69const NX_RC_ALGORITHM_ASYMPTOTIC: i64 = 9
70const NX_RC_DOMAIN_VIOLATED: i64 = 10
71const NX_RC_ESTIMATOR_MISMATCH: i64 = 11
72const NX_RC_SYSTEMIC_HW_LIMIT: i64 = 12
73const NX_RC_RACE_OR_ORDERING: i64 = 13
74const NX_RC_STALE_CALIBRATION: i64 = 14
76const NX_FX_ESCALATE_TIER: i64 = 1
77const NX_FX_SWAP_ALGORITHM: i64 = 2
78const NX_FX_DENSER_SAMPLING: i64 = 3
79const NX_FX_MORE_SEEDS_PER_SAMPLE: i64 = 4
80const NX_FX_SWAP_HASH_FAMILY: i64 = 5
81const NX_FX_REFORMULATE_MATH: i64 = 6
82const NX_FX_FIX_SIGN_HANDLING: i64 = 7
83const NX_FX_DEFEND_DOMAIN: i64 = 8
84const NX_FX_UPGRADE_Q_SCALE: i64 = 9
85const NX_FX_UNLOCK_TIER_ADAPTER: i64 = 10
86const NX_FX_RECALIBRATE_TABLE: i64 = 11
87const NX_FX_TIGHTEN_SYNC: i64 = 12
88const NX_FX_ENSEMBLE: i64 = 13
90const NX_APPLY_WORKED: i64 = 0
91const NX_APPLY_NO_CHANGE: i64 = 1
92const NX_APPLY_REGRESSION: i64 = 2
94const NX_GEN_PASSES: i64 = 0
95const NX_GEN_FAILS_AT_CELL: i64 = 1
97const NX_CYCLE_ADOPT: i64 = 0
98const NX_CYCLE_REJECT_FAILED_AB: i64 = 1
99const NX_CYCLE_REJECT_FAILED_GEN: i64 = 2
100const NX_CYCLE_NO_ACTION_NEEDED: i64 = 3
282const NX_FIX_PROPOSAL_BYTES: i64 = 32

functions

141func nx_anomaly_alloc() -> *AnomalyReport
152func nx_diag_report_alloc() -> *DiagnosisReport
161func nx_plan_alloc() -> *ActionPlan
170func nx_cycle_outcome_alloc() -> *CycleOutcome
188func nx_remedy_detect(observed: i64, baseline: i64, tolerance_ppb: i64,
235func nx_remedy_diagnose(anomaly: *AnomalyReport, comparison_verdict: i64,
284func nx_remedy_fp_at(arr: *FixProposal, i: i64) -> *FixProposal
288func nx_remedy_fp_set(arr: *FixProposal, i: i64,
called by 1: nx_remedy_propose calls 1: nx_remedy_fp_at
298func nx_remedy_propose(rc_code: i64, out: *FixProposal, max_n: i64) -> i64
356func nx_remedy_apply_plan(top: *FixProposal, plan: *ActionPlan) -> i64
377func nx_remedy_ab_verify(before: *EstimatorDiag, after: *EstimatorDiag,
401func nx_remedy_generalize(befores: **EstimatorDiag, afters: **EstimatorDiag,
424func rl_putc(fd: i64, c: i64) -> i64
called by 1: rl_i64
431func rl_str(fd: i64, s: *u8, len: i64) -> i64
called by 1: nx_remedy_record
436func rl_i64(fd: i64, n: i64) -> i64
460func nx_remedy_record(fd: i64, cycle_id: i64, anomaly: *AnomalyReport,
called by 1: nx_remedy_cycle_run calls 2: rl_strrl_i64
504func nx_remedy_cycle_run(