code wiki / _hdl_build / nx_sourcing_path.nx

nx_sourcing_path.nx

buildroot/runtime/_hdl_build/nx_sourcing_path.nx

18018 B382 linesdepth 6pulls 8 transitivereach 4 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_sourcing_path.nx -- SOVEREIGN SOURCING-MIX + RESHORE-PATH PRICER. Operator 2026-08-06: "i'd like to be market competitive and shift to full american supply chain with local government help." That is a PATH, not a point. nx_landed_cost prices ONE shipment from ONE corridor; this organ prices a whole BILL OF MATERIALS whose components come from DIFFERENT corridors, and then prices the CURVE from today's mix to fully domestic -- with the incentive layer that is the actual bridge. COMPOSES, NEVER DUPLICATES (rule 15). It imports nx_landed_cost.nx for the PROVEN duty core (lc_is_domestic / lc_pref_ok / lc_s301_applies / lc_is_col2 + the corridor plane readers, all gate-proven 15/15 on 2026-08-06) and nx_supplychain_case.nx for domestic-content and weighted risk. A NishiLang target CAN import another target -- measured, not assumed (nx_lcimport_probe: the importing main() wins and every imported symbol resolves). So there is ONE duty implementation in the estate, not two. ★THE CORRECTNESS POINT THAT FORCED THIS DESIGN: **MPF AND HMF ARE PER CUSTOMS ENTRY, NOT PER LINE ITEM.** Pricing a BOM by calling a per-shipment pricer once per component charges the $33.58 MPF FLOOR once per component. On a 3-part BOM of $1,000 parts that is 10,449c of fees instead of 3,733c -- a ~2.8x over-count that lands hardest on small runs, i.e. exactly the domestic pilot the operator wants to justify. Entry fees are therefore computed ONCE on the AGGREGATE dutiable value. INTEGER-EXACT, NO FLOAT (sovereign law): money in CENTS, rates in BASIS POINTS, shares in PERMIL. DATA, NOT CODE (rule 11): the BOM is a seg-store plane; so are the incentives. Adding a component or a grant programme is a plane row, no reship. BOM row `srcbom-` : <id> TAB <label> TAB <cc> TAB <value_c> TAB <col1bps> TAB <col2bps> TAB <s301bps> TAB <single01> TAB <energyrisk0-100> TAB <us_value_c> INCENTIVE `incentive-` : <id> TAB <label> TAB <permil_of_domestic_value> TAB <note> us_value_c = what THIS component would cost made domestically. It is the field that makes the reshore path priceable at all; without it "shift to domestic" has no cost. VERBS: nx_sourcing_path mix <bomprefix> <units> <unitprice_c> <ocean01> <pref01> [incprefix] nx_sourcing_path path <bomprefix> <units> <unitprice_c> <ocean01> <pref01> [incprefix] nx_sourcing_path selftest license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 3 imports · 2 importers

nx_syscalls.nx nx_landed_cost.nx nx_supplychain_case.nx nx_sourcing_path.nx nx_evidence.nx nx_gonogo.nx

imports: nx_syscalls.nxnx_landed_cost.nxnx_supplychain_case.nx

imported by: nx_evidence.nxnx_gonogo.nx

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

main spw sys_write lc_eq sp_selftest 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 ↻ sp_entry_fees sp_incentive_c lc_load_regime sts_load sts_gen_note sts_pfxhash ss_max_segid sys_mmap ↻ ss_cat ss_readall ss_segid_ok ss_open_cached ssc_init sys_mmap ↻ ssc_sig_of ss_cat ↻ sys_fstatat ssc_streq ss_open ss_open2

structs

none

consts

41const SP_MAXROWS: i64 = 64
42const SP_BOMBUF: i64 = 65536
43const SP_OUTBUF: i64 = 65536
44const SP_FLDBUF: i64 = 256
45const SP_PERMIL: i64 = 1000
46const SP_ORIGIN_DOM: i64 = 0
47const SP_ORIGIN_ALLIED: i64 = 1
48const SP_ORIGIN_ADVERSARY: i64 = 2
50const SP_T_1M: i64 = 1000000
51const SP_T_100K: i64 = 100000
52const SP_T_300K: i64 = 300000
53const SP_T_100M: i64 = 100000000
54const SP_T_MPF_1M: i64 = 3464
55const SP_T_HMF_1M: i64 = 1250
56const SP_T_FEES_1M: i64 = 4714
57const SP_T_FEES_100K: i64 = 3483
58const SP_T_FEES_300K: i64 = 3733
59const SP_T_FEES_3X100K: i64 = 10449

functions

61func spw(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 }
called by 4: mainmainsp_selftestmain calls 1: sys_write
66func sp_entry_fees(dutiable_c: i64, ocean: i64, k: *i64) -> i64
called by 2: sp_selftestsp_mix
82func sp_incentive_c(domestic_value_c: i64, permil: i64) -> i64
called by 2: sp_selftestsp_mix
89func sp_origin_class(rbuf: *u8, rn: i64, cc: *u8) -> i64
97func sp_row_start(buf: *u8, n: i64, want: i64) -> i64
112func sp_rowcount(buf: *u8, n: i64) -> i64
127func sp_num(buf: *u8, n: i64, rs: i64, idx: i64, scratch: *u8) -> i64
132func sp_selftest() -> i64
191func sp_inc_permil(buf: *u8, n: i64, scratch: *u8) -> i64
207func sp_mix(bom: *u8, bn: i64, rbuf: *u8, rn: i64, units: i64, price: i64, ocean: i64, pref: i64, incpermil: i64, domesticate: i64, res: *i64) -> i64
301func sp_emit(out: *u8, o: i64, res: *i64, step: i64) -> i64
called by 1: main calls 2: lc_litlc_num
331func main(argc: i64, argv: *i64) -> i64