code wiki / _hdl_build / nx_dev_api.nx
nx_dev_api.nx
buildroot/runtime/_hdl_build/nx_dev_api.nx
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
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
| 19 | const DA_MAGIC_16384: i64 = 16384 |
| 20 | const DA_MAGIC_8192: i64 = 8192 |
| 21 | const DA_MAGIC_8000: i64 = 8000 |
| 23 | const DA_OUTCAP: i64 = 262144 |
| 24 | const DA_TMP: *u8 = "/tmp/da_build.out" |
| 25 | const DA_HARNESS: *u8 = "./_offc/nx_sov_build_run.elf" |
| 26 | const DA_CAP_TOOL: *u8 = "dev_build" as *u8 |
| 27 | const DA_CAP_KEYFILE: *u8 = "dev_cap_secret.key" as *u8 |
| 29 | const DA_CAP_SECRET: *u8 = "nishi-dev-cap-hmac-secret-v1-REPLACE-FROM-VAULT" as *u8 |
functions
| 31 | func da_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 32 | func 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 } |
| 33 | func da_catn(d: *u8, o: i64, v: i64) -> i64 called by 9: da_catnda_do_buildda_do_rungpnmkreq_pathdsv_add_content_length+3 calls 2: sys_mmapda_catn |
| 40 | func da_json_esc(d: *u8, o: i64, s: *u8, n: i64) -> i64 |
| 57 | func da_valid_name(s: *u8, n: i64, out: *u8) -> i64 |
| 75 | func da_body_off(req: *u8, n: i64) -> i64 |
| 84 | func da_form_field(req: *u8, boff: i64, n: i64, key: *u8, out: *u8) -> i64 |
| 106 | func da_read_small(path: *u8, out: *u8, cap: i64) -> i64 |
| 119 | func da_read_tail(path: *u8, out: *u8, cap: i64) -> i64 called by 3: da_build_organda_do_statusda_run_organ calls 4: sys_openat_rdsys_lseeksys_readsys_close |
| 137 | func da_build_organ(name: *u8, capbuf: *u8, caplen: *i64) -> i64 |
| 162 | func da_indexof(hay: *u8, n: i64, needle: *u8) -> i64 |
| 169 | func da_header(req: *u8, req_n: i64, key: *u8, out2: *i64) -> i64 |
| 184 | func da_authz(req: *u8, req_n: i64) -> i64 called by 2: da_do_buildda_do_run calls 6: sys_mmapda_read_smallda_slenda_headercapt_verifysys_now_realtime_sec |
| 198 | func da_http_head(out: *u8, o: i64, status: *u8) -> i64 |
| 205 | func da_path_is(path: *u8, plen: i64, lit: *u8) -> i64 |
| 213 | func da_index(out: *u8) -> i64 |
| 219 | func da_do_build(req: *u8, body: i64, req_n: i64, out: *u8, is_gate: i64) -> i64 |
| 251 | func da_do_status(out: *u8) -> i64 |
| 263 | func da_valid_arg(s: *u8, n: i64, out: *u8) -> i64 called by 1: da_do_run |
| 285 | func da_run_organ(name: *u8, vn: i64, a1: *u8, a1n: i64, a2: *u8, a2n: i64, a3: *u8, a3n: i64, capbuf: *u8, caplen: *i64) -> i64 |
| 318 | func da_run_allowed(name: *u8, vn: i64) -> i64 |
| 340 | func da_do_run(req: *u8, body: i64, req_n: i64, out: *u8) -> i64 |
| 386 | func da_handle(req: *u8, req_n: i64, out: *u8) -> i64 called by 3: maindsv_servemain calls 8: da_body_offda_path_isda_indexda_do_statusda_do_buildda_do_run+2 |