nx_mesh_hostagent.nx
buildroot/runtime/nx_mesh_hostagent.nx
about
nx_mesh_hostagent.nx -- WORKER MESH: the AUTONOMOUS host-agent that makes autoscale HANDS-OFF. It runs on the
worker host, and each tick it: reads DEMAND, PROBES the worker for warmth (bounded, ~1s), DECIDES via the autoscale
policy (SPAWN/SERVE/HOLD/REAP), and ACTUATES -- fork+execve the worker on SPAWN, nx_kill+wait4 on REAP. No human in
the loop: the organ physically starts and stops the worker process as demand comes and goes. On NishiOS this forks
the container natively; the exact same fork/kill lifecycle is exercised here against a real child process.
CLI: (no args) -> self-test GATE (the decision policy)
demo <workerpath> <port> -> run the autonomous cold->SPAWN->SERVE->(idle)->REAP->cold cycle, forking and
killing a REAL worker child on a built-in demand schedule (proves the loop)
Actions: 0 HOLD 1 SPAWN 2 SERVE 3 REAP. license_tier: ORIGINAL
dependencies 4 imports · 0 importers
imports: nx_syscalls.nxnx_connect.nxnx_runtime.nxnx_http_client.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 15 | const HA_MAGIC_2048: i64 = 2048 |
| 16 | const HA_MAGIC_2000: i64 = 2000 |
| 17 | const HA_MAGIC_4096: i64 = 4096 |
| 18 | const HA_MAGIC_4095: i64 = 4095 |
| 20 | const HA_HOLD: i64 = 0 |
| 21 | const HA_SPAWN: i64 = 1 |
| 22 | const HA_SERVE: i64 = 2 |
| 23 | const HA_REAP: i64 = 3 |
functions
| 25 | func ha_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 26 | func ha_pn(v: i64) -> i64 |
| 39 | func ha_atoi(s: *u8) -> i64 { var v: i64 = 0; var i: i64 = 0; while s[i] != (0 as u8) { let c: i64 = s[i] as i64; if c >= 48 { if c <= 57 { v = v * 10 + (c - 48) } } i = i + 1 } return v } called by 1: ha_demo |
| 40 | func ha_streq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while b[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if a[i] != (0 as u8) { return 0 } return 1 } called by 1: main |
| 41 | func ha_action_name(a: i64) -> *u8 called by 1: ha_demo |
| 49 | func ha_decide(warm: i64, demand: i64, idle: i64, ttl: i64) -> i64 |
| 56 | func ha_pollfd(pfd: *u8, fd: i64, events: i64) -> i64 called by 1: ha_probe |
| 61 | func ha_resp_2xx(buf: *u8, n: i64) -> i64 called by 1: ha_probe |
| 70 | func ha_probe(port: i64) -> i64 called by 1: ha_demo calls 11: sys_mmapnx_http_client_sockaddr_ipv4sys_socketnx_connect_boundedha_pollfdsys_poll+5 |
| 96 | func ha_sleep_ms(ms: i64) -> i64 { sys_poll(0 as *u8, 0, ms); return 0 } |
| 99 | func ha_spawn(path: *u8, portstr: *u8) -> i64 |
| 109 | func ha_reap(pid: i64) -> i64 |
| 116 | func ha_gate() -> i64 |
| 141 | func ha_demo(path: *u8, portstr: *u8) -> i64 |
| 187 | func main(argc: i64, argv: *i64) -> i64 |