code wiki / _hdl_build / nx_rebuild_plan_test.nx
nx_rebuild_plan_test.nx source
↩ module page · 45 lines · 2132 B
1// nx_rebuild_plan_test.nx -- runs the BUILT-not-INSTALLED detector and prints its verdict.
2//
3// WHY THIS EXISTS (2026-07-30): nx_rebuild_plan is PROMOTED but was UNREGISTERED (an S3 UNEXPOSED
4// instance, nx_wirecensus). Registering it makes it callable, but a NEW MCP tool needs a client
5// reconnect before a stub exists, and /api/gate_run -- the one route that executes an organ on demand --
6// admits VERIFIERS ONLY (name must end gate|test|kat), which is exactly what makes that route
7// never-brick. So the sanctioned way to run a non-verifier organ on demand, this session, is a thin
8// verifier that forks it. That is this file.
9//
10// COMPOSITION, NOT REIMPLEMENTATION (the nx_debt_view pattern): fork-capture the canonical binary via
11// tr_run1 so there is no second copy of the staleness logic to drift.
12//
13// ⚠nx_plan_run was tried first and REFUSED: its plane reader reports 'plan plane EMPTY / unseeded'
14// for a plane that nx_store_put load prints a row from -- writer and runner disagree on the same
15// prefix. Filed separately; not worked around here.
16// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
17import "nx_tool_run.nx"
18
19const RPT_CAP: i64 = 262144
20const RPT_ELF: *u8 = "/volume1/homes/elderwesto/nishihost/nx_rebuild_plan.elf" as *u8
21
22func rpt_w(s: *u8) {
23 var n: i64 = 0
24 while s[n] != (0 as u8) { n = n + 1 }
25 sys_write(1, s, n)
26}
27
28func main(argc: i64, argv: *i64) -> i64 {
29 let out: *u8 = sys_mmap(RPT_CAP + 16)
30 let olen: *i64 = sys_mmap(16) as *i64
31 let rc: i64 = tr_run1(RPT_ELF, 0 as *u8, out, RPT_CAP, olen)
32 let n: i64 = olen[0]
33 if rc == 127 {
34 rpt_w("REBUILD-PLAN-TEST verdict=RED exec-127 (binary absent at the registered path)\n" as *u8)
35 return 1
36 }
37 if n <= 0 {
38 rpt_w("REBUILD-PLAN-TEST verdict=RED empty-capture (organ produced no output)\n" as *u8)
39 return 1
40 }
41 sys_write(1, out, n)
42 rpt_w("\nREBUILD-PLAN-TEST verdict=GREEN detector ran and produced output above.\n" as *u8)
43 rpt_w(" NOTE: GREEN means the DETECTOR RAN, not that the fleet is fresh -- read its numbers.\n" as *u8)
44 return 0
45}