code wiki / _hdl_build / nx_dev_api.nx

nx_dev_api.nx

buildroot/runtime/_hdl_build/nx_dev_api.nx

19636 B410 linesdepth 8pulls 10 transitivereach 3 importersview sourcekind librarytopic dev
docsdependenciesstructsconstsfunctions

about

nx_dev_api.nx -- SOVEREIGN DEV/CI API: development itself becomes Nishi API calls (operator 2026-07-02: "get this all setup as api calls in the nishi ecosystem ... so we dont use shitty wsl and shitty shell"). The ONE operation no existing API exposed = BUILD (compile a .nx -> ELF). This closes it, so the WSL door is retired: a client POSTs a build request over our own HTTP and reads the gate verdict back. GET /api/dev -> index (routes) POST /api/dev/build body organ=<name> -> fork/exec ./_offc/nx_sov_build_run.elf <name>, capture stdout+stderr, return {organ,exit,output} POST /api/dev/gate body organ=<name> -> build a *_gate + return GREEN/RED verdict + output GET /api/dev/status -> the job-runner receipts tail (what ran, exit codes) PURE ROUTER da_handle(req,req_n,out)->out_n (bytes in, bytes out) so the gate drives it in-process, exactly like ta_handle/ma_handle. THE DEFENSIVE BOUNDARY (rule 12): the organ name is charset-validated [a-z0-9_] only -> no path traversal, no args, FIXED-ARGV exec = injection structurally impossible. AUTH: /api/dev EXECUTES code -> the mutating routes require an X-Nishi-Cap capability token granting the tool "dev_build" (nx_cap_token: HMAC, unforgeable, least-authority, no ambient identity = confused-deputy impossible). No cap / forged / expired / wrong-tool -> 401. Secret from a keyfile (prod), const fallback (gates/dev stay deterministic) -- the tools-API convention. license_tier: ORIGINAL

dependencies 2 imports · 3 importers

nx_syscalls.nx nx_cap_token.nx nx_dev_api.nx nx_dev_api_gate.nx nx_dev_api_serve.nx nx_dev_run_smoke.nx

imports: nx_syscalls.nxnx_cap_token.nx

imported by: nx_dev_api_gate.nxnx_dev_api_serve.nxnx_dev_run_smoke.nx

structs

none

consts

19const DA_MAGIC_16384: i64 = 16384
20const DA_MAGIC_8192: i64 = 8192
21const DA_MAGIC_8000: i64 = 8000
23const DA_OUTCAP: i64 = 262144
24const DA_TMP: *u8 = "/tmp/da_build.out"
25const DA_HARNESS: *u8 = "./_offc/nx_sov_build_run.elf"
26const DA_CAP_TOOL: *u8 = "dev_build" as *u8
27const DA_CAP_KEYFILE: *u8 = "dev_cap_secret.key" as *u8
29const DA_CAP_SECRET: *u8 = "nishi-dev-cap-hmac-secret-v1-REPLACE-FROM-VAULT" as *u8

functions

31func da_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
32func da_cat(d: *u8, o: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){d[o+i]=s[i];i=i+1} return o+i }
33func da_catn(d: *u8, o: i64, v: i64) -> i64
40func da_json_esc(d: *u8, o: i64, s: *u8, n: i64) -> i64
57func da_valid_name(s: *u8, n: i64, out: *u8) -> i64
75func da_body_off(req: *u8, n: i64) -> i64
called by 2: da_headerda_handle
84func da_form_field(req: *u8, boff: i64, n: i64, key: *u8, out: *u8) -> i64
called by 3: da_do_buildda_do_runmain calls 1: da_slen
106func da_read_small(path: *u8, out: *u8, cap: i64) -> i64
119func da_read_tail(path: *u8, out: *u8, cap: i64) -> i64
137func da_build_organ(name: *u8, capbuf: *u8, caplen: *i64) -> i64
162func da_indexof(hay: *u8, n: i64, needle: *u8) -> i64
called by 1: da_header calls 1: da_slen
169func da_header(req: *u8, req_n: i64, key: *u8, out2: *i64) -> i64
184func da_authz(req: *u8, req_n: i64) -> i64
198func da_http_head(out: *u8, o: i64, status: *u8) -> i64
205func da_path_is(path: *u8, plen: i64, lit: *u8) -> i64
called by 1: da_handle calls 1: da_slen
213func da_index(out: *u8) -> i64
called by 1: da_handle calls 2: da_http_headda_cat
219func da_do_build(req: *u8, body: i64, req_n: i64, out: *u8, is_gate: i64) -> i64
251func da_do_status(out: *u8) -> i64
263func da_valid_arg(s: *u8, n: i64, out: *u8) -> i64
called by 1: da_do_run
285func da_run_organ(name: *u8, vn: i64, a1: *u8, a1n: i64, a2: *u8, a2n: i64, a3: *u8, a3n: i64, capbuf: *u8, caplen: *i64) -> i64
318func da_run_allowed(name: *u8, vn: i64) -> i64
called by 1: da_do_run calls 2: sys_mmapda_read_small
340func da_do_run(req: *u8, body: i64, req_n: i64, out: *u8) -> i64
386func da_handle(req: *u8, req_n: i64, out: *u8) -> i64