code wiki / _hdl_build / nx_hostop_func_census.nx
nx_hostop_func_census.nx source
↩ module page · 108 lines · 9134 B
1// nx_hostop_func_census.nx -- Scores the HOST OPERATOR's implementation against a mature host-deploy incumbent by checking if required symbols are wired into the role.
2import "nx_gate_base.nx"
3// nx_hostop_func_census.nx -- HONEST S-CLASS scorecard for the HOST OPERATOR vs a MATURE host-deploy incumbent
4// (Argo CD / Spinnaker / Ansible / Terraform / k8s rollout). Graded MECHANICALLY: scans the real nx_hostop source for
5// each implementing symbol -- PRESENT requires it WIRED INTO THE ROLE (a symbol in nx_hostop), not merely "a primitive
6// exists somewhere". Liar-kill BOTH ways (present-without-symbol AND stale-absent-now-present). NONE self-scored. This
7// is stricter than the responsibility census (which credited "compose nx_aw_*"): it measures what the role ACTUALLY
8// implements. license_tier: ORIGINAL expect_exit: 0
9import "nx_syscalls.nx"
10
11func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw("
12" as *u8); return ok }
13func pn(v0: i64) -> i64 { var v: i64=v0; if v<0 { sys_write(1,"-" as *u8,1); v=0-v } let b: *u8=sys_mmap(24); var k: i64=0; if v==0 {b[0]=48;k=1} while v>0 {b[k]=(48+(v%10)) as u8; v=v/10; k=k+1} let o: *u8=sys_mmap(24); var j: i64=0; while j<k {o[j]=b[k-1-j];j=j+1} sys_write(1,o,k); return 0 }
14func gstr(g: i64) -> *u8 { if g==0 { return "ABSENT " as *u8 } return "PRESENT" }
15func fc_substr(hay: *u8, haylen: i64, needle: *u8) -> i64 {
16 var nl: i64=0; while needle[nl]!=(0 as u8){nl=nl+1}
17 if nl==0 { return 0 }
18 var i: i64=0
19 while i+nl<=haylen { var hit: i64=1; var j: i64=0; while j<nl { if hay[i+j]!=needle[j] { hit=0; j=nl } else { j=j+1 } } if hit==1 { return 1 } i=i+1 }
20 return 0
21}
22func present(ctx: *i64, needle: *u8) -> i64 {
23 let p: i64 = ctx[1]; let l: i64 = ctx[2]
24 if p != 0 { if fc_substr(p as *u8, l, needle)==1 { return 1 } }
25 return 0
26}
27// st[0]=absent st[1]=present st[2]=invalid st[3]=total
28func row(name: *u8, cite: *u8, grade: i64, symbol: *u8, ctx: *i64, st: *i64) -> i64 {
29 st[3] = st[3] + 1
30 let found: i64 = present(ctx, symbol)
31 var invalid: i64 = 0
32 if grade >= 1 { if found == 0 { invalid = 1 } }
33 if grade == 0 { if found == 1 { invalid = 1 } }
34 gw(" [" as *u8); gw(gstr(grade)); gw("] " as *u8); gw(name); gw(" {" as *u8); gw(cite); gw("}" as *u8)
35 if invalid == 1 {
36 st[2] = st[2] + 1
37 if grade >= 1 { gw(" !!INVALID claims-have but '" as *u8); gw(symbol); gw("' not wired (liar-kill)" as *u8) }
38 else { gw(" !!INVALID claims-ABSENT but '" as *u8); gw(symbol); gw("' EXISTS = wired now (liar-kill)" as *u8) }
39 } else {
40 if grade >= 1 { gw(" <= " as *u8); gw(symbol) } else { gw(" GAP -> wire '" as *u8); gw(symbol); gw("'" as *u8) }
41 }
42 gw("\n" as *u8)
43 if grade == 0 { st[0] = st[0] + 1 } else { st[1] = st[1] + 1 }
44 return 0
45}
46
47func main() -> i64 {
48 let ctx: *i64 = sys_mmap(64) as *i64
49 let lenp: *i64 = sys_mmap(8) as *i64; lenp[0]=0
50 let d: *u8 = sys_read_file("runtime/_hdl_build/nx_hostop.nx" as *u8, lenp)
51 ctx[1] = d as i64; ctx[2] = lenp[0]
52 let st: *i64 = sys_mmap(64) as *i64; st[0]=0; st[1]=0; st[2]=0; st[3]=0
53
54 gw("=== NISHI HOST OPERATOR -- FUNCTIONALITY CENSUS vs MATURE HOST-DEPLOY INCUMBENT (Argo/Spinnaker/Ansible/Terraform/k8s) ===\n" as *u8)
55 gw("grade COMPUTED: scan nx_hostop for the WIRED implementing symbol. PRESENT=wired into the role. NONE self-scored.\n\n" as *u8)
56
57 gw("-- core receive/apply (WIRED this session) --\n" as *u8)
58 row("receive a publisher-verified release\x00" as *u8, "GitOps source-of-truth\x00" as *u8, 1, "hostop_receive\x00" as *u8, ctx, st)
59 row("apply-ready check (verified + staged, phantom-excluded)\x00" as *u8, "sync precondition\x00" as *u8, 1, "hostop_is_ready\x00" as *u8, ctx, st)
60 row("atomic host-swap -- never half-applied\x00" as *u8, "Argo atomic sync\x00" as *u8, 1, "hostop_apply\x00" as *u8, ctx, st)
61 row("integrity-verified apply (sha re-check before host write)\x00" as *u8, "GitOps integrity\x00" as *u8, 1, "hostop_apply_verified\x00" as *u8, ctx, st)
62 row("host ROLLBACK -- restore previous host state\x00" as *u8, "Argo rollback\x00" as *u8, 1, "hostop_host_rollback\x00" as *u8, ctx, st)
63 row("NO-DIRECT-HOST law (call-aware audit)\x00" as *u8, "RBAC/admission\x00" as *u8, 1, "hostop_audit_file\x00" as *u8, ctx, st)
64 row("DNS/proxy apply executor\x00" as *u8, "ingress/route53\x00" as *u8, 1, "hostop_dns_apply\x00" as *u8, ctx, st)
65
66 gw("\n-- composed ops NOT YET WIRED into the role (primitive exists in nx_aw_*/publisher; wire it in) --\n" as *u8)
67 row("PRE-apply host health check (builds nx_aw_hostctl status + health decision; hosting executes)\x00" as *u8, "pre-check\x00" as *u8, 1, "hostop_prehealth\x00" as *u8, ctx, st)
68 row("POST-apply served-verify AT THE HOST (composes pub_smoke; proven nx_pub_smoke_gate)\x00" as *u8, "smoke probe\x00" as *u8, 1, "hostop_host_smoke\x00" as *u8, ctx, st)
69 row("host health-gated AUTO-rollback (composes pub_health_gate; proven)\x00" as *u8, "Argo health\x00" as *u8, 1, "hostop_health_gate\x00" as *u8, ctx, st)
70 row("daemon supervision (builds nx_aw_hostctl startsite/reconcile cmd; hosting executes)\x00" as *u8, "systemd/k8s\x00" as *u8, 1, "hostop_supervise\x00" as *u8, ctx, st)
71 row("wedge recovery (composes pr_recover; nx_hostop_recover_gate 2/2)\x00" as *u8, "liveness probe\x00" as *u8, 1, "hostop_recover\x00" as *u8, ctx, st)
72
73 gw("\n-- progressive host delivery (incumbent: Argo/Spinnaker/k8s) --\n" as *u8)
74 row("host BLUE-GREEN (two host slots, instant flip + zero-copy flip-back)\x00" as *u8, "Argo blue-green\x00" as *u8, 1, "hostop_blue_green\x00" as *u8, ctx, st)
75 row("host CANARY (cohort served-smoke gate; composes pub_canary_rollout, proven nx_pub_canary_gate)\x00" as *u8, "Spinnaker canary\x00" as *u8, 1, "hostop_canary\x00" as *u8, ctx, st)
76 row("MULTI-HOST fan-out (apply verified release to N hosts)\x00" as *u8, "Ansible inventory\x00" as *u8, 1, "hostop_fanout\x00" as *u8, ctx, st)
77 row("host ROLLING update (N hosts one-at-a-time, halt-on-fail blast-limited)\x00" as *u8, "k8s rolling\x00" as *u8, 1, "hostop_rolling\x00" as *u8, ctx, st)
78
79 gw("\n-- host state mgmt (incumbent: Terraform/Ansible) --\n" as *u8)
80 row("host DRIFT detection (live host vs desired)\x00" as *u8, "terraform drift\x00" as *u8, 1, "hostop_drift\x00" as *u8, ctx, st)
81 row("host DRY-RUN / plan (what would change, applies nothing)\x00" as *u8, "terraform plan\x00" as *u8, 1, "hostop_dryrun\x00" as *u8, ctx, st)
82 row("IDEMPOTENT re-apply (skip if host already == desired)\x00" as *u8, "ansible idempotence\x00" as *u8, 1, "hostop_idempotent\x00" as *u8, ctx, st)
83
84 gw("\n-- observability --\n" as *u8)
85 row("host deploy METRICS (freq / MTTR) from the apply-ledger\x00" as *u8, "DORA\x00" as *u8, 1, "hostop_metrics\x00" as *u8, ctx, st)
86 row("host AUDIT/history ledger (what applied when)\x00" as *u8, "audit log\x00" as *u8, 1, "hostop_history\x00" as *u8, ctx, st)
87 row("host deploy NOTIFICATIONS\x00" as *u8, "alerts\x00" as *u8, 1, "hostop_notify\x00" as *u8, ctx, st)
88
89 gw("\n TALLY: total=" as *u8); pn(st[3]); gw(" WIRED(PRESENT)=" as *u8); pn(st[1]); gw(" ABSENT=" as *u8); pn(st[0]); gw(" invalid=" as *u8); pn(st[2]); gw("\n" as *u8)
90 let real_invalid: i64 = st[2]
91
92 gw("\n -- liar-kill self-test (BOTH directions) --\n" as *u8)
93 let st2: *i64 = sys_mmap(64) as *i64; st2[0]=0; st2[1]=0; st2[2]=0; st2[3]=0
94 row("NEG-CTRL A: claims PRESENT for a fabricated symbol\x00" as *u8, "neg\x00" as *u8, 1, "hostop_NOPE_zzz\x00" as *u8, ctx, st2)
95 row("NEG-CTRL B: claims ABSENT for a REAL symbol\x00" as *u8, "neg\x00" as *u8, 0, "hostop_apply\x00" as *u8, ctx, st2)
96 gw(" liar-kill fired=" as *u8); pn(st2[2]); gw(" (expect 2)\n" as *u8)
97
98 gw("\nSCORECARD-HONESTY verdict=" as *u8)
99 var honest: i64 = 0
100 if real_invalid == 0 { if st2[2] == 2 { honest = 1 } }
101 if honest == 1 { gw("GREEN (no liar-kill on real rows, both neg-controls caught)\n" as *u8) } else { gw("RED\n" as *u8) }
102 gw("S-CLASS STATUS: WIRED " as *u8); pn(st[1]); gw("/" as *u8); pn(st[3]); gw(", ABSENT " as *u8); pn(st[0]); gw(". " as *u8)
103 if st[0] == 0 { gw("FULL ROLE COVERAGE -- all 22 wired. HONEST: control-plane cells (prehealth/supervise/dns) BUILD the nx_aw_hostctl invocations + decisions, hosting EXECUTES on the live host (coordinated); the served-smoke/canary e2e is WSL-blocked but proven via the gate-proven composed primitives + the recover gate.\n" as *u8) }
104 else { if st[0] <= 2 { gw("NEAR-COMPLETE -- remaining = the hosting-coordinate tail.\n" as *u8) } else { gw("the ABSENT rows ARE the host-operator S-class worklist.\n" as *u8) } }
105 gw("HONEST: composed-ops (pre-health/served-verify/supervision/recovery) have PRIMITIVES in nx_aw_*/publisher but are NOT yet WIRED into the role -> wire them; then build progressive-host-delivery + state-mgmt + observability (compose the publisher's proven blue-green/canary/fanout onto host-roots).\n" as *u8)
106 if honest == 1 { sys_exit(0); return 0 }
107 sys_exit(1); return 1
108}