code wiki / _hdl_build / nx_supply_case.nx
nx_supply_case.nx
buildroot/runtime/_hdl_build/nx_supply_case.nx
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
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
structs
| none |
consts
| 18 | const SC_MAGIC_7000000: i64 = 7000000 |
| 19 | const SC_MAGIC_4200000000: i64 = 4200000000 |
| 20 | const SC_MAGIC_28000000: i64 = 28000000 |
| 22 | const SC_MAXN: i64 = 64 |
| 23 | const SC_STRONG: i64 = 700 |
| 24 | const SC_PARTIAL: i64 = 400 |
| 25 | const SC_RISK_OK: i64 = 15 |
| 26 | const SC_AFFORD_OK: i64 = 4 |
functions
| 28 | func w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 29 | func we(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(2,s,n); return 0 } |
| 30 | func 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 } |
| 31 | func q() -> i64 { let c: *u8 = sys_mmap(8); c[0] = 34 as u8; sys_write(1,c,1); sys_munmap(c,8); return 0 } |
| 32 | func kv(k: *u8) -> i64 { q(); w(k); q(); w(":" as *u8); return 0 } |
| 34 | func sc_streq(a: *u8, b: *u8) -> i64 called by 1: main |
| 43 | func sc_atoi(s: *u8) -> i64 called by 1: main |
| 57 | func sc_usage() -> i64 |
| 65 | func sc_selftest() -> i64 |
| 129 | func vinit() -> i64 { return 11 } called by 1: sc_selftest |
| 131 | func main(argc: i64, argv: *i64) -> i64 |