code wiki / (root) / nx_mesh_hostagent.nx

nx_mesh_hostagent.nx

buildroot/runtime/nx_mesh_hostagent.nx

8859 B198 linesdepth 6pulls 9 transitivereach 0 importersview sourcekind tooltopic mesh
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_connect.nx nx_runtime.nx nx_http_client.nx nx_mesh_hostagent.nx

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

main ha_streq ha_p sys_write ha_demo ha_atoi ha_p ↻ ha_pn sys_mmap sys_write ↻ ha_probe sys_mmap ↻ nx_http_client_sockaddr_ip sys_socket nx_connect_bounded nx_fcntl sys_connect sys_mmap ↻ sys_poll ha_pollfd sys_poll ↻ sys_close nx_http_client_build_reque hc_put_caps sys_mmap ↻ nx_codec_caps_headers sys_mmap ↻ nx_codec_caps_accept_docum nx_codec_caps_accept_encod nx_cc_put sys_write ↻ sys_read ha_resp_2xx ha_decide ha_action_name ha_spawn sys_fork sys_mmap ↻ sys_execve sys_exit

structs

none

consts

15const HA_MAGIC_2048: i64 = 2048
16const HA_MAGIC_2000: i64 = 2000
17const HA_MAGIC_4096: i64 = 4096
18const HA_MAGIC_4095: i64 = 4095
20const HA_HOLD: i64 = 0
21const HA_SPAWN: i64 = 1
22const HA_SERVE: i64 = 2
23const HA_REAP: i64 = 3

functions

25func 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 }
called by 3: ha_gateha_demomain calls 1: sys_write
26func ha_pn(v: i64) -> i64
called by 2: ha_gateha_demo calls 2: sys_mmapsys_write
39func 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
40func 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
41func ha_action_name(a: i64) -> *u8
called by 1: ha_demo
49func ha_decide(warm: i64, demand: i64, idle: i64, ttl: i64) -> i64
called by 2: ha_gateha_demo
56func ha_pollfd(pfd: *u8, fd: i64, events: i64) -> i64
called by 1: ha_probe
61func ha_resp_2xx(buf: *u8, n: i64) -> i64
called by 1: ha_probe
70func ha_probe(port: i64) -> i64
96func ha_sleep_ms(ms: i64) -> i64 { sys_poll(0 as *u8, 0, ms); return 0 }
called by 1: ha_demo calls 1: sys_poll
99func ha_spawn(path: *u8, portstr: *u8) -> i64
109func ha_reap(pid: i64) -> i64
called by 1: ha_demo calls 3: nx_killsys_mmapsys_wait4
116func ha_gate() -> i64
called by 1: main calls 3: ha_pha_decideha_pn
141func ha_demo(path: *u8, portstr: *u8) -> i64
187func main(argc: i64, argv: *i64) -> i64