code wiki / _hdl_build / nx_hw_envelope.nx

nx_hw_envelope.nx

buildroot/runtime/_hdl_build/nx_hw_envelope.nx

15728 B371 linesdepth 5pulls 8 transitivereach 0 importersview sourcekind tooltopic hw
docsdependenciesstructsconstsfunctions

about

nx_hw_envelope.nx -- HARDWARE-AWARE MODEL ROUTER (2026-07-23; operator: "hardware aware component if we shift to larger or smaller systems so future nishi os can run on anything from a phone to a supercomputer"). Measures the HOST envelope (RAM via /proc/meminfo, logical cores via /proc/cpuinfo, both STREAM-read because /proc stat sizes lie) and picks the maker/bench model roster for this hardware TIER from the sovereign plane knowledge/store/hwtier- (rule 11: thresholds AND rosters are DATA -- rows `tier|min_gb|maker|bench|note`, pipe-packed payload = the declared-canonical store row format). External models appear ONLY in the bench column and are marked BENCH-ONLY (the external-reimpls-bench-only law); the sovereign maker column is always the primary. Fail-closed: absent/empty plane = RED exit 1; no tier fits the measured RAM = RED exit 3; VRAM reports UNMEASURED in v1 (no honest sovereign probe yet), never guessed. nx_hw_envelope probe -- measure host -> JSON nx_hw_envelope route [planeprefix] -- probe + tier-match -> routing JSON (+ hw_envelope.out) nx_hw_envelope selftest -- hermetic teeth (gv lib) license_tier: ORIGINAL expect_exit: 0 No hw writes (Rule 26).

dependencies 5 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_sovjson_lib.nx nx_store_seed_lib.nx nx_seg_store.nx nx_hw_envelope.nx

imports: nx_syscalls.nxnx_gate_verdict.nxnx_sovjson_lib.nxnx_store_seed_lib.nxnx_seg_store.nx

imported by: nobody (leaf or entry point)

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

main sj_werr sys_write sys_exit sj_vlen sj_lit_eq gv_ctr sys_mmap gv_head gv_puts sys_write ↻ sys_mmap ↻ hw_pick gv_check gv_puts ↻ hw_row sys_mmap ↻ sj_atoi_span hw_num_after sj_vlen ↻ hw_count_linestart sj_vlen ↻ hw_makers gv_verdict gv_puts ↻ gv_num sys_mmap ↻ sys_write ↻ sys_munmap gv_journal sys_openat_append sys_mmap ↻ gv_catn sys_mmap ↻ sys_munmap ↻ sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real gv_cat sys_write ↻

structs

none

consts

21const HW_CAP: i64 = 262144
22const HW_PLANE: i64 = 1048576
23const HW_KB_PER_GB: i64 = 1048576
24const HW_SLOT: i64 = 16
25const HW_MAXROWS: i64 = 32
26const HW_ROWI: i64 = 9
27const HW_ROWBYTES: i64 = 2304
28const HW_RES: i64 = 80
29const HW_USAGE: i64 = 2
30const HW_NOFIT: i64 = 3

functions

32func hw_read_stream(path: *u8, buf: *u8, cap: i64) -> i64
48func hw_num_after(q: *u8, n: i64, key: *u8) -> i64
called by 2: hw_probemain calls 1: sj_vlen
80func hw_count_linestart(q: *u8, n: i64, lit: *u8) -> i64
called by 2: hw_probemain calls 1: sj_vlen
99func hw_pick(mins: *i64, n: i64, ram_gb: i64) -> i64
called by 1: main
112func hw_row(q: *u8, ls: i64, le: i64, res: *i64) -> i64
called by 1: main calls 2: sys_mmapsj_atoi_span
140func hw_makers(d: *u8, o: i64, q: *u8, s: i64, e: i64) -> i64
called by 1: main
163func hw_span(d: *u8, o: i64, q: *u8, s: i64, e: i64) -> i64
called by 1: main
171func hw_probe(out: *i64) -> i64
187func main(argc: i64, argv: *i64) -> i64