code wiki / (root) / nx_gpu_ctl.nx

nx_gpu_ctl.nx

buildroot/runtime/nx_gpu_ctl.nx

6457 B102 linesdepth 16pulls 96 transitivereach 0 importersview sourcekind tooltopic gpu
docsdependenciesstructsconstsfunctions

about

nx_gpu_ctl.nx -- SOVEREIGN GPU-provider CONTROL PLANE (Vast.ai) over our OWN TLS-1.2 stack (console.vast.ai is TLS-1.2-only; the shipped stack is 1.3-only). Retires the curl+ssh provisioning dance: every verb is one authenticated request via t12_request (nx_tls12_req.nx) -- Bearer key read from a vault FILE, never argv. The MCP-ready capability the operator asked for: turn a GPU ON/OFF, provision, check, destroy -- all sovereign. nx_gpu_ctl me <keyfile> GET /api/v0/users/current/ -> account (auth proof) nx_gpu_ctl find <keyfile> GET /api/v0/bundles/?q=<vm 5090> -> offer list nx_gpu_ctl up <offer_id> <keyfile> PUT /api/v0/asks/<id>/ {vm KVM} -> {new_contract:<inst>} nx_gpu_ctl status <instance_id> <keyfile> GET /api/v0/instances/<id>/ -> state + ssh + $/hr nx_gpu_ctl off <instance_id> <keyfile> PUT /api/v0/instances/<id>/ {stopped}-> stop billing, keep disk nx_gpu_ctl on <instance_id> <keyfile> PUT /api/v0/instances/<id>/ {running}-> resume nx_gpu_ctl destroy <instance_id> <keyfile> DELETE /api/v0/instances/<id>/ -> tear down (billing ends) OPERATOR-DRIVEN by design (nothing acts autonomously). license_tier: ORIGINAL expect_exit: 0

dependencies 1 imports · 0 importers

nx_tls12_req.nx nx_gpu_ctl.nx

imports: nx_tls12_req.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main gc_usage gc_run t12_request sys_mmap nx_url_new nx_https_url_for_fetch nx_url_parse strlen _scheme_is_https tr_slen sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real nx_https_url_connect sys_socket sys_set_socket_timeout sys_mmap ↻ sys_setsockopt sys_munmap sys_mmap ↻ nx_https_build_sockaddr nx_connect_bounded nx_fcntl sys_connect sys_mmap ↻ sys_poll sys_close sys_setsockopt ↻ nx_dns_resolve_default nx_dns_resolve_with_failov nx_dns_resolve_a_record sys_set_socket_timeout ↻ tr_client_hello sys_mmap ↻ tr_b2 nx_csprng_fill sys_mmap ↻ nx_csprng_urandom_path sys_openat_rd

structs

none

consts

14const GC_MAGIC_262144: i64 = 262144
15const GC_MAGIC_4096: i64 = 4096
16const GC_MAGIC_4095: i64 = 4095
17const GC_MAGIC_2048: i64 = 2048
19const GC_VM_BODY: *u8 = "{\"image\":\"docker.io/vastai/kvm:ubuntu_terminal\",\"disk\":50,\"runtype\":\"ssh_direct\",\"vm\":true,\"label\":\"nishi-sovereign-gpu\",\"target_state\":\"running\"}" as *u8
20const GC_FIND_URL: *u8 = "https://console.vast.ai/api/v0/bundles/?q=%7B%22gpu_name%22%3A%7B%22eq%22%3A%22RTX%205090%22%7D%2C%22num_gpus%22%3A%7B%22eq%22%3A1%7D%2C%22rentable%22%3A%7B%22eq%22%3Atrue%7D%2C%22vms_enabled%22%3A%7B%22eq%22%3Atrue%7D%2C%22order%22%3A%5B%5B%22dph_total%22%2C%22asc%22%5D%5D%2C%22limit%22%3A40%7D" as *u8

functions

22func gc_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
23func gc_putn(v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 }
24func gc_streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while a[i]!=(0 as u8){ if a[i]!=b[i]{return 0} i=i+1 } if b[i]!=(0 as u8){return 0} return 1 }
25func gc_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 }
26func gc_readfile(path: *u8, out: *u8, cap: i64) -> i64
36func gc_url(prefix: *u8, id: *u8, out: *u8) -> i64
44func gc_bodylen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
46func gc_usage() -> i64
calls 2: gc_usagegc_run
52func gc_run(url: *u8, method: *u8, mlen: i64, tok: *u8, tn: i64, body: *u8, blen: i64) -> i64
63func main(argc: i64, argv: *i64) -> i64