code wiki / _hdl_build / nx_sourcing_path.nx
nx_sourcing_path.nx
buildroot/runtime/_hdl_build/nx_sourcing_path.nx
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
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
structs
| none |
consts
| 41 | const SP_MAXROWS: i64 = 64 |
| 42 | const SP_BOMBUF: i64 = 65536 |
| 43 | const SP_OUTBUF: i64 = 65536 |
| 44 | const SP_FLDBUF: i64 = 256 |
| 45 | const SP_PERMIL: i64 = 1000 |
| 46 | const SP_ORIGIN_DOM: i64 = 0 |
| 47 | const SP_ORIGIN_ALLIED: i64 = 1 |
| 48 | const SP_ORIGIN_ADVERSARY: i64 = 2 |
| 50 | const SP_T_1M: i64 = 1000000 |
| 51 | const SP_T_100K: i64 = 100000 |
| 52 | const SP_T_300K: i64 = 300000 |
| 53 | const SP_T_100M: i64 = 100000000 |
| 54 | const SP_T_MPF_1M: i64 = 3464 |
| 55 | const SP_T_HMF_1M: i64 = 1250 |
| 56 | const SP_T_FEES_1M: i64 = 4714 |
| 57 | const SP_T_FEES_100K: i64 = 3483 |
| 58 | const SP_T_FEES_300K: i64 = 3733 |
| 59 | const SP_T_FEES_3X100K: i64 = 10449 |
functions
| 61 | func 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 } |
| 66 | func sp_entry_fees(dutiable_c: i64, ocean: i64, k: *i64) -> i64 |
| 82 | func sp_incentive_c(domestic_value_c: i64, permil: i64) -> i64 |
| 89 | func sp_origin_class(rbuf: *u8, rn: i64, cc: *u8) -> i64 |
| 97 | func sp_row_start(buf: *u8, n: i64, want: i64) -> i64 |
| 112 | func sp_rowcount(buf: *u8, n: i64) -> i64 |
| 127 | func sp_num(buf: *u8, n: i64, rs: i64, idx: i64, scratch: *u8) -> i64 |
| 132 | func sp_selftest() -> i64 |
| 191 | func sp_inc_permil(buf: *u8, n: i64, scratch: *u8) -> i64 |
| 207 | func 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 |
| 301 | func sp_emit(out: *u8, o: i64, res: *i64, step: i64) -> i64 |
| 331 | func main(argc: i64, argv: *i64) -> i64 |