code wiki / _hdl_build / nx_supply_case.nx

nx_supply_case.nx

buildroot/runtime/_hdl_build/nx_supply_case.nx

9932 B190 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic supply
docsdependenciesstructsconstsfunctions

about

nx_supply_case.nx -- CLI for nx_supplychain_case: the DOMESTIC supply-chain security + good-jobs business case, for presenting a reshoring plan to city/state/federal government. WHY THIS EXISTS: nx_supplychain_case already carried sc_domestic_permil / sc_weighted_risk / sc_payroll / sc_benefits / sc_home_afford and had NO main(), so a gate could exercise it but NO CALLER COULD EVER REACH IT. That is an ADOPTION GAP, not a missing primitive -- the maths was bought and never wired. This organ adds ONLY composition + arg parsing; it reimplements NOTHING. nx_supply_case case <jobs> <annual_wage_c> <benefit_pct> <median_home_c> <n> [<origin> <energy_risk> <single_source> <value_c>]xN nx_supply_case selftest origin: 0 domestic | 1 allied | 2 adversary. energy_risk 0-100. single_source 0|1. ENVELOPE (declared): home affordability is an INTEGER income multiple straight from the lib, so 4.2x and 4.9x both read 4 -- do NOT read it finer than a whole multiple. Per-corridor FOB and the incentive layer are NOT modelled here; this organ prices SECURITY and JOBS, never landed cost. Pair it with nx_landed_cost, which prices the border and knows nothing about jobs. exit: 0 ok | 2 usage | 3 selftest-fail license_tier: ORIGINAL expect_exit: 0

dependencies 2 imports · 0 importers

nx_supplychain_case.nx nx_syscalls.nx nx_supply_case.nx

imports: nx_supplychain_case.nxnx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main sc_usage we sys_write sys_exit sc_streq sc_selftest w sys_write ↻ sys_mmap nxa_die sys_write ↻ sys_exit ↻ nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sc_domestic_permil wn w ↻ sys_mmap ↻ sys_write ↻ sys_munmap vinit sc_weighted_risk sc_payroll sc_benefits sc_home_afford sys_exit ↻ sc_atoi we ↻ sys_mmap ↻ sc_domestic_permil ↻

structs

none

consts

18const SC_MAGIC_7000000: i64 = 7000000
19const SC_MAGIC_4200000000: i64 = 4200000000
20const SC_MAGIC_28000000: i64 = 28000000
22const SC_MAXN: i64 = 64
23const SC_STRONG: i64 = 700
24const SC_PARTIAL: i64 = 400
25const SC_RISK_OK: i64 = 15
26const SC_AFFORD_OK: i64 = 4

functions

28func w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 4: wnkvsc_selftestmain calls 1: sys_write
29func we(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(2,s,n); return 0 }
called by 2: sc_usagemain calls 1: sys_write
30func wn(v: i64) -> i64 { var m: i64=v; if m<0{w("-" as *u8);m=0-m} let t:*u8=sys_mmap(28); var k:i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i:i64=0; let o:*u8=sys_mmap(28); while i<k{o[i]=t[k-1-i];i=i+1} sys_write(1,o,k); sys_munmap(t,28); sys_munmap(o,28); return 0 }
31func q() -> i64 { let c: *u8 = sys_mmap(8); c[0] = 34 as u8; sys_write(1,c,1); sys_munmap(c,8); return 0 }
called by 2: kvmain calls 3: sys_mmapsys_writesys_munmap
32func kv(k: *u8) -> i64 { q(); w(k); q(); w(":" as *u8); return 0 }
called by 1: main calls 2: qw
34func sc_streq(a: *u8, b: *u8) -> i64
called by 1: main
43func sc_atoi(s: *u8) -> i64
called by 1: main
57func sc_usage() -> i64
called by 1: main calls 1: we
65func sc_selftest() -> i64
129func vinit() -> i64 { return 11 }
called by 1: sc_selftest
131func main(argc: i64, argv: *i64) -> i64