nx_supply_risk_test.nx source
↩ module page · 141 lines · 8216 B
1// nx_supply_risk_test.nx -- gate for manufacturing sourcing + approval risk.
2// T4 is the finding: on effective cost the low-cost bases CONVERGE, so the
3// cheapest sticker is not the cheapest programme. T7/T8 answer the other
4// question -- what actually blocks a foreign-developed application, and what
5// does not.
6// expect_exit: 0 license_tier: ORIGINAL
7import "nx_syscalls.nx"
8import "nx_supply_risk.nx"
9
10func t_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
11func t_putn(v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64 = v; if m < 0 { m = 0 - m; sys_write(1, "-" as *u8, 1) } 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; while i < k { bb[i] = t[k - 1 - i]; i = i + 1 } sys_write(1, bb, k); return 0 }
12
13func main() -> i64 {
14 var pass: i64 = 0
15 var total: i64 = 0
16
17 let spend: i64 = 10000 // $10M API programme
18
19 // --- T1 sticker ordering is what you would expect ---
20 total = total + 1
21 let st_us: i64 = sr_sticker_cost_k(SR_US, spend)
22 let st_in: i64 = sr_sticker_cost_k(SR_INDIA, spend)
23 let st_cn: i64 = sr_sticker_cost_k(SR_CHINA, spend)
24 let st_pl: i64 = sr_sticker_cost_k(SR_POLAND, spend)
25 t_puts("T1 sticker on $10M: US=$" as *u8); t_putn(st_us); t_puts("k Poland=$" as *u8); t_putn(st_pl); t_puts("k India=$" as *u8); t_putn(st_in); t_puts("k China=$" as *u8); t_putn(st_cn); t_puts("k: " as *u8)
26 var ok1: i64 = 1
27 if st_us != 10000 { ok1 = 0 }
28 if st_cn >= st_in { ok1 = 0 }
29 if st_in >= st_pl { ok1 = 0 }
30 if ok1 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) }
31
32 // --- T2 importing rigor has a price, and it scales with the discount ---
33 total = total + 1
34 let a_us: i64 = sr_audit_burden_k(SR_US)
35 let a_in: i64 = sr_audit_burden_k(SR_INDIA)
36 let a_cn: i64 = sr_audit_burden_k(SR_CHINA)
37 t_puts("T2 annual audit burden US=$" as *u8); t_putn(a_us); t_puts("k India=$" as *u8); t_putn(a_in); t_puts("k China=$" as *u8); t_putn(a_cn); t_puts("k (rises as sticker falls): " as *u8)
38 var ok2: i64 = 1
39 if a_in <= a_us { ok2 = 0 }
40 if a_cn <= a_in { ok2 = 0 }
41 if ok2 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) }
42
43 // --- T3 effective cost = sticker + audit + expected delay ---
44 total = total + 1
45 let ef_us: i64 = sr_effective_cost_k(SR_US, spend)
46 let ef_in: i64 = sr_effective_cost_k(SR_INDIA, spend)
47 let ef_cn: i64 = sr_effective_cost_k(SR_CHINA, spend)
48 let ef_pl: i64 = sr_effective_cost_k(SR_POLAND, spend)
49 t_puts("T3 EFFECTIVE: US=$" as *u8); t_putn(ef_us); t_puts("k Poland=$" as *u8); t_putn(ef_pl); t_puts("k India=$" as *u8); t_putn(ef_in); t_puts("k China=$" as *u8); t_putn(ef_cn); t_puts("k: " as *u8)
50 var ok3: i64 = 1
51 if ef_us <= st_us { ok3 = 0 }
52 if ef_in <= st_in { ok3 = 0 }
53 if ok3 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) }
54
55 // --- T4 THE FINDING: the low-cost bases CONVERGE on effective cost ---
56 // China's sticker beats India's by $700k and Poland's by $2.5M, yet all
57 // three land within a few percent once risk is priced.
58 total = total + 1
59 let conv: i64 = sr_low_cost_converged(spend, 100)
60 let best_st: i64 = sr_best_sticker(spend)
61 let best_ef: i64 = sr_best_effective(spend)
62 t_puts("T4 cheapest STICKER=" as *u8); t_puts(sr_name(best_st)); t_puts(" cheapest EFFECTIVE=" as *u8); t_puts(sr_name(best_ef)); t_puts(" ; low-cost trio converged within 10%=" as *u8); t_putn(conv); t_puts(": " as *u8)
63 var ok4: i64 = 1
64 if best_st != SR_CHINA { ok4 = 0 }
65 if conv != 1 { ok4 = 0 }
66 if best_ef == best_st { ok4 = 0 }
67 if ok4 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) }
68
69 // --- T5 how much of the advertised saving actually survives ---
70 total = total + 1
71 let ret_in: i64 = sr_saving_retained_permil(SR_INDIA, spend)
72 let ret_cn: i64 = sr_saving_retained_permil(SR_CHINA, spend)
73 let ret_pl: i64 = sr_saving_retained_permil(SR_POLAND, spend)
74 t_puts("T5 saving retained: India=" as *u8); t_putn(ret_in); t_puts(" permil China=" as *u8); t_putn(ret_cn); t_puts(" permil Poland=" as *u8); t_putn(ret_pl); t_puts(" permil (1000 = fully retained): " as *u8)
75 var ok5: i64 = 1
76 if ret_in >= 1000 { ok5 = 0 }
77 if ret_cn >= 1000 { ok5 = 0 }
78 if ret_pl <= ret_cn { ok5 = 0 }
79 if ok5 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) }
80
81 // --- T6 EU-GMP is available at every base: rigor IS importable ---
82 // GMP is inspection-based, not nationality-based. This is the fact that
83 // makes the whole strategy legitimate.
84 total = total + 1
85 var s6: i64 = 0
86 var all6: i64 = 1
87 while s6 < SR_N {
88 let e: i64 = sr_eu_gmp_available(s6)
89 if e != 1 { all6 = 0 }
90 s6 = s6 + 1
91 }
92 t_puts("T6 EU-GMP certification available at all " as *u8); t_putn(SR_N); t_puts(" bases (rigor is importable): " as *u8)
93 if all6 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) }
94
95 // --- T7 WHAT ACTUALLY BLOCKS A FOREIGN APPLICATION ---
96 // Not nationality. Single-population data, or a failed facility.
97 total = total + 1
98 let single: i64 = sr_approval_blocker(0, 1, SR_INDIA)
99 let multi: i64 = sr_approval_blocker(1, 3, SR_INDIA)
100 let one_region: i64 = sr_approval_blocker(1, 1, SR_INDIA)
101 t_puts("T7 single-country data=" as *u8); t_putn(single); t_puts(" multiregional 3 regions=" as *u8); t_putn(multi); t_puts(" 'multiregional' with 1 region=" as *u8); t_putn(one_region); t_puts(" want 2/1/2: " as *u8)
102 var ok7: i64 = 1
103 if single != SR_RISK_SINGLE_POPULATION { ok7 = 0 }
104 if multi != SR_APPROVAL_OK { ok7 = 0 }
105 if one_region != SR_RISK_SINGLE_POPULATION { ok7 = 0 }
106 if ok7 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) }
107
108 // --- T8 being foreign is NOT itself a barrier, and the capture bias
109 // historically ran toward APPROVING, not blocking ---
110 total = total + 1
111 let bar: i64 = sr_foreign_origin_is_a_barrier()
112 let bias: i64 = sr_capture_bias_favours_approval()
113 t_puts("T8 foreign origin is a barrier=" as *u8); t_putn(bar); t_puts(" ; regulator-capture bias favours approval=" as *u8); t_putn(bias); t_puts(" want 0/1: " as *u8)
114 if bar == 0 { if bias == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } } else { t_puts("FAIL\n" as *u8) }
115
116 // --- T9 a clean multiregional programme at a low-risk site has no
117 // modelled blocker ---
118 total = total + 1
119 let clean: i64 = sr_approval_blocker(1, 3, SR_POLAND)
120 let clean2: i64 = sr_approval_blocker(1, 2, SR_SWITZERLAND)
121 t_puts("T9 multiregional + Poland=" as *u8); t_putn(clean); t_puts(" multiregional + Switzerland=" as *u8); t_putn(clean2); t_puts(" want 1/1 (OK): " as *u8)
122 if clean == SR_APPROVAL_OK { if clean2 == SR_APPROVAL_OK { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } } else { t_puts("FAIL\n" as *u8) }
123
124 // --- T10 fail-closed on unknown bases and negative spend ---
125 total = total + 1
126 let b1: i64 = sr_cost_permil(99)
127 let b2: i64 = sr_effective_cost_k(99, spend)
128 let b3: i64 = sr_sticker_cost_k(SR_US, 0 - 5)
129 let b4: i64 = sr_eu_gmp_available(99)
130 t_puts("T10 unknown base cost=" as *u8); t_putn(b1); t_puts(" effective=" as *u8); t_putn(b2); t_puts(" negative spend=" as *u8); t_putn(b3); t_puts(" EU-GMP=" as *u8); t_putn(b4); t_puts(": " as *u8)
131 var ok10: i64 = 1
132 if b1 != SR_INVALID { ok10 = 0 }
133 if b2 != SR_INVALID { ok10 = 0 }
134 if b3 != SR_INVALID { ok10 = 0 }
135 if b4 != 0 { ok10 = 0 }
136 if ok10 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) }
137
138 t_puts("SUPPLY-RISK-GATE passed " as *u8); t_putn(pass); t_puts("/" as *u8); t_putn(total)
139 if pass == total { t_puts(" verdict=GREEN\n" as *u8); sys_exit(0); return 0 }
140 t_puts(" verdict=RED\n" as *u8); sys_exit(1); return 1
141}