code wiki / _hdl_build / nx_infra_reconcile.nx

nx_infra_reconcile.nx source

↩ module page · 34 lines · 1787 B

1// nx_infra_reconcile.nx -- sovereign DECLARATIVE INFRA RECONCILE (HashiCorp Terraform / IaC-class) over the 2// infra_hosts census. Declare the DESIRED end-state of every host (control_path=sovereign, 3// trust=behavior-attested, sovereign_control=FULL) and compute the DRIFT vs OBSERVED -- a `plan` of exactly 4// what must change to reach sovereign control. Idempotent: a converged host re-reconciles to ZERO changes; 5// any drift>0 is NEVER reported converged (no-false-converge liar-kill). This is the "control" half of the 6// operator thread "sovereign control of NAS/router/west-server": declare it, measure the gap, drive it. 7// Pure logic over the posture constants. license_tier: ORIGINAL Composes nx_infra_control. 8import "nx_infra_control.nx" 9import "nx_syscalls.nx" 10 11// the DESIRED sovereign end-state every host reconciles toward. 12func ir_desired_cp() -> i64 { return CP_SOVEREIGN } 13func ir_desired_tp() -> i64 { return TP_BEHAVIOR_ATTESTED } 14func ir_desired_sc() -> i64 { return SC_FULL } 15 16// drift = number of fields where OBSERVED != DESIRED (0 = at desired state; this is the per-host `plan` size). 17func ir_drift(cp: i64, tp: i64, sc: i64) -> i64 { 18 var d: i64 = 0 19 if cp != ir_desired_cp() { d = d + 1 } 20 if tp != ir_desired_tp() { d = d + 1 } 21 if sc != ir_desired_sc() { d = d + 1 } 22 return d 23} 24 25// converged iff zero drift. any drift>0 -> NOT converged (the no-false-converge guarantee). 26func ir_converged(drift: i64) -> i64 { if drift == 0 { return 1 } return 0 } 27 28// total drift across the fleet (parallel arrays) = total sovereign-control work remaining. 29func ir_total_drift(cps: *i64, tps: *i64, scs: *i64, n: i64) -> i64 { 30 var t: i64 = 0 31 var i: i64 = 0 32 while i < n { t = t + ir_drift(cps[i], tps[i], scs[i]); i = i + 1 } 33 return t 34}