code wiki / (root) / nx_stage_path.nx

nx_stage_path.nx

buildroot/runtime/nx_stage_path.nx

17407 B335 linesdepth 3pulls 4 transitivereach 45 importersview sourcekind librarytopic stage
docsdependenciesstructsconstsfunctions

about

nx_stage_path.nx -- THE ONE HOME FOR "WHERE DO THE STAGED MODELS AND LEDGERS LIVE ON THIS HOST". WHY (measured 2026-08-19, lane B drain of the 150 trial-FAILING gates): 115 source sites across ~60 organs spell the literal "/home/elderwesto/nx_stage/<file>" -- the dev box's WSL home. Every nofloat/forge/autofix/coder gate that reads a model or ledger there was promoted to the NAS, where that directory does not exist, and the roster trial read every one of them as RED: 37 gates reporting "MODEL ABSENT" as if the no-float LLM were broken. They were reporting on their own environment in the word reserved for a defect. ★ A GATE THAT CANNOT DISTINGUISH "I COULD NOT LOOK" FROM "I LOOKED AND IT IS BROKEN" TEACHES EVERYONE TO IGNORE IT. (nx_gate_verdict.gv_need already names this law; this lib is the precondition that 37 gates were missing.) ★ A PATH SPELLED AT 115 SITES IS 115 PLACES TO BE WRONG AND ZERO PLACES TO CONFIGURE. RESOLUTION ORDER (CLAUDE.md rule 17, highest wins): 1. environment NX_STAGE=<dir> (read sovereignly from /proc/self/environ) 2. conf knowledge/stage.conf `stage_root=<dir>` (opened via ep_open_rd: CWD, ../, estate root, buildroot -- so the answer does not change with the launch dir) 3. bootstrap SP_DEFAULT_ROOT -- the incumbent literal every consumer carried, kept here ONCE so the dev box keeps working untouched and a NAS that wants model gates sets 1 or 2. sp_root() REPORTS which rung answered, so a precondition message can say where it looked. CONTRACT FOR GATES: sp_skip_unless(GATE, path) -> returns 1 when <path> opens; otherwise prints the gv_need precondition line and EXITS through gv_verdict (rc 3 = SKIP). A gate that calls it BEFORE any check therefore reads SKIP -- "unobservable on this host" -- never RED, and never GREEN. It must be called before the first gv_check: gv_verdict's ordering law turns (precondition missing AND a failed check) into RED on purpose, and a gate that has already run checks against an absent model has already failed them. LAYER: runtime/ library, no main(). Imports only runtime/ libs so _hdl_build/ organs may import it. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 3 imports · 40 importers

nx_syscalls.nx nx_estate_path.nx nx_gate_verdict.nx nx_stage_path.nx nx_autofix_gate.nx nx_autofix_lib.nx nx_autofix_lib_t138.nx nx_block_quant_h2h_gate.nx nx_codegen_bench_gate.nx nx_coder_swap_gate.nx nx_gpu_serve_gate.nx nx_hybrid_moe_cascade_gate.nx nx_nofloat_arch_moe_gate.nx nx_nofloat_moe_real_gate.nx

diagram shows first 10 each side; +0 more imports, +30 more importers in the complete lists below.

imports: nx_syscalls.nxnx_estate_path.nxnx_gate_verdict.nx

imported by: nx_autofix_gate.nxnx_autofix_lib.nxnx_autofix_lib_t138.nxnx_block_quant_h2h_gate.nxnx_codegen_bench_gate.nxnx_coder_swap_gate.nxnx_gpu_serve_gate.nxnx_hybrid_moe_cascade_gate.nxnx_nofloat_arch_moe_gate.nxnx_nofloat_moe_real_gate.nxnx_nofloat_olmoe_forward_gate.nxnx_nofloat_olmoe_gate.nxnx_nofloat_prefill_gate.nxnx_nofloat_prefix_cache_gate.nxnx_nofloat_propose_chat_gate.nxnx_nofloat_propose_solve_gate.nxnx_nofloat_propose_verify_gate.nxnx_nofloat_q6k_gate.nxnx_nofloat_qwen_config_gate.nxnx_nofloat_qwen_decode_gate.nxnx_nofloat_qwen_encode_gate.nxnx_nofloat_qwen_encode_prep_gate.nxnx_nofloat_qwen_fastgen_gate.nxnx_nofloat_qwen_fastgen_i32_gate.nxnx_nofloat_qwen_fastgen_i8_gate.nxnx_nofloat_qwen_fidelity_gate.nxnx_nofloat_qwen_forward_gate.nxnx_nofloat_qwen_gen_gate.nxnx_nofloat_qwen_kvgen_gate.nxnx_nofloat_qwen_stack_gate.nxnx_nofloat_qwen_text_gate.nxnx_nofloat_qwen_wload_gate.nxnx_nofloat_serve_gate.nxnx_nofloat_weightconv_gate.nxnx_q4k_fused_fidelity_gate.nxnx_realweight_quant_gate.nxnx_rigor_envelope_gate.nxnx_safetensors_gate.nxnx_swebench_local_gate.nxnx_zero_claude_ledger_gate.nx

structs

none

consts

36const SP_PATH_MAX: i64 = 4096
39const SP_ENVIRON_BYTES: i64 = 65536
40const SP_DEFAULT_ROOT: *u8 = "/home/elderwesto/nx_stage"
41const SP_CONF: *u8 = "knowledge/stage.conf"
42const SP_CONF_KEY: *u8 = "stage_root="
43const SP_ENV_KEY: *u8 = "NX_STAGE="
47const SP_MODELS_DEFAULT_ROOT: *u8 = "/mnt/c/Users/elder/elder-ai-platform/models/unified"
48const SP_MODELS_CONF_KEY: *u8 = "models_root="
49const SP_MODELS_ENV_KEY: *u8 = "NX_MODELS="
50const SP_SRC_ENV: i64 = 1
51const SP_SRC_CONF: i64 = 2
52const SP_SRC_DEFAULT: i64 = 3
213const SP_ENGINE_MODEL_ENV_KEY: *u8 = "NX_ENGINE_MODEL="
214const SP_ENGINE_MODEL_CONF_KEY: *u8 = "engine_model="
215const SP_SRC_NONE: i64 = 0
272const SP_RIGOR_CONF: *u8 = "knowledge/rigor.conf"
273const SP_RIGOR_KEY_Z: *u8 = "z_micro="
274const SP_RIGOR_KEY_B: *u8 = "boot_reps="
275const SP_RIGOR_KEY_SEED: *u8 = "boot_seed="
276const SP_RIGOR_KEY_WIDTH: *u8 = "width_target_permil="

functions

54func sp_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
55func sp_cat(d: *u8, o: i64, s: *u8) -> i64 { var i: i64 = 0; var p: i64 = o; while s[i] != (0 as u8) { d[p] = s[i]; p = p + 1; i = i + 1 } return p }
57func sp_match(buf: *u8, at: i64, n: i64, lit: *u8) -> i64
63func sp_take_value(buf: *u8, from: i64, n: i64, out: *u8) -> i64
81func sp_env(key: *u8, out: *u8) -> i64
98func sp_conf(key: *u8, out: *u8) -> i64
115func sp_resolve_root(envkey: *u8, confkey: *u8, dflt: *u8, out: *u8) -> i64
123func sp_root(out: *u8) -> i64 { return sp_resolve_root(SP_ENV_KEY, SP_CONF_KEY, SP_DEFAULT_ROOT, out) }
125func sp_models_root(out: *u8) -> i64 { return sp_resolve_root(SP_MODELS_ENV_KEY, SP_MODELS_CONF_KEY, SP_MODELS_DEFAULT_ROOT, out) }
127func sp_join_name(name: *u8, out: *u8) -> *u8
called by 2: sp_pathsp_models_path calls 2: sp_slensp_cat
135func sp_path(name: *u8, out: *u8) -> *u8 { sp_root(out); return sp_join_name(name, out) }
137func sp_models_path(rel: *u8, out: *u8) -> *u8 { sp_models_root(out); return sp_join_name(rel, out) }
139func sp_present(path: *u8) -> i64
146func sp_src_name(src: i64) -> *u8
called by 1: sp_skip_because
155func sp_skip_because(gate: *u8, path: *u8, src: i64, envkey: *u8, confkey: *u8) -> i64
172func sp_skip_unless(gate: *u8, path: *u8) -> i64
179func sp_models_skip_unless(gate: *u8, path: *u8) -> i64
188func sp_guarded(gate: *u8, name: *u8) -> *u8
193func sp_models_guarded(gate: *u8, rel: *u8) -> *u8
218func sp_engine_model(out: *u8) -> i64
238func sp_engine_src_name(src: i64) -> *u8
245func sp_engine_model_skip(gate: *u8, path: *u8, src: i64) -> i64
279func sp_conf_in(file: *u8, key: *u8, out: *u8) -> i64
297func sp_atoi(s: *u8) -> i64
313func sp_rigor_int(key: *u8, dflt: i64) -> i64
321func sp_rigor_present() -> i64
329func sp_rigor_params(p: *i64) -> i64