code wiki / _hdl_build / nx_impact_gate.nx

nx_impact_gate.nx source

↩ module page · 122 lines · 7529 B

1// nx_impact_gate.nx -- GATE: R-IMPACT. The food arc's clean+environmental+value model, on strawberries. 2// Proves the operator's UNIQUE CONCEPT, MEASURED not claimed: T1 cleaner (much less pesticide), T2 the OPPOSITE 3// on environment (less carbon+water, MORE soil = regenerative), T3 cheaper for the customer, T4 yet WE earn a 4// higher margin (vertical integration), T5 the TRIPLE WIN (Pareto domination on every axis + our margin), T6 5// greenwash LIAR-KILL (a clean CLAIM with high residue is caught by the measured clean score), T7 research- 6// grounded, T8 sovereign comparison page shipped. license_tier: ORIGINAL 7import "nx_impact.nx" 8import "nx_food_provenance.nx" 9import "nx_food_science.nx" 10import "nx_publisher.nx" 11import "nx_seg_store.nx" 12import "nx_syscalls.nx" 13import "nx_gate_verdict.nx" 14 15const IG_FOOD: *u8 = "knowledge/store/food-" 16const IG_Q: *u8 = "knowledge/publish/impact-queue.tsv" 17const IG_LED: *u8 = "knowledge/publish/impact-ledger.tsv" 18const IG_STG: *u8 = "knowledge/publish/impact-stage" 19const IG_LIVE: *u8 = "knowledge/publish/impact-live" 20const IG_STAGE_FILE: *u8 = "knowledge/staging/impact/strawberries.html" 21const IG_LIVE_FILE: *u8 = "knowledge/publish/impact-live/strawberries.html" 22 23func g_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 24func g_i(v: i64) -> i64 { 25 let bb: *u8 = sys_mmap(28); var m: i64 = v 26 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m } 27 let t: *u8 = sys_mmap(28); var k: i64 = 0 28 if m == 0 { t[0] = 48 as u8; k = 1 } 29 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 30 var i: i64 = 0; while i < k { bb[i] = t[k - 1 - i]; i = i + 1 } sys_write(1, bb, k); return 0 31} 32func g_money(c: i64) -> i64 { let b: *u8 = sys_mmap(24); let o: i64 = im_money(b, 0, c); sys_write(1, b, o); return 0 } 33func g_exists(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 } 34 35func main() -> i64 { 36 g_p("=== nx_impact_gate (R-IMPACT: clean + environmental + value, strawberries) ===\n" as *u8) 37 fd_seed(IG_FOOD) 38 fd_seed_provenance(IG_FOOD) 39 let sw: i64 = im_seed(IG_FOOD) 40 g_p("impact records authored this run=" as *u8); g_i(sw); g_p("\n" as *u8) 41 let straw: *u8 = "strawberry" as *u8 42 43 g_p("clean: conv=" as *u8); g_i(im_clean(IG_FOOD, straw, "conv" as *u8)); g_p(" nishi=" as *u8); g_i(im_clean(IG_FOOD, straw, "nishi" as *u8)) 44 g_p(" price: conv=" as *u8); g_money(im_price(IG_FOOD, straw, "conv" as *u8)); g_p(" nishi=" as *u8); g_money(im_price(IG_FOOD, straw, "nishi" as *u8)) 45 g_p(" margin: conv=" as *u8); g_money(im_margin(IG_FOOD, straw, "conv" as *u8)); g_p(" nishi=" as *u8); g_money(im_margin(IG_FOOD, straw, "nishi" as *u8)); g_p("\n" as *u8) 46 47 var pass: i64 = 0 48 var tot: i64 = 0 49 50 // T1 cleaner 51 tot = tot + 1 52 var ok1: i64 = 1 53 if im_pesticide(IG_FOOD, straw, "nishi" as *u8) >= im_pesticide(IG_FOOD, straw, "conv" as *u8) { ok1 = 0 } 54 if im_clean(IG_FOOD, straw, "nishi" as *u8) <= im_clean(IG_FOOD, straw, "conv" as *u8) { ok1 = 0 } 55 if ok1 == 1 { pass = pass + 1; g_p("PASS T1 cleaner (Nishi pesticide load far below conventional)\n" as *u8) } else { g_p("FAIL T1\n" as *u8) } 56 57 // T2 greener -- the OPPOSITE (less carbon+water, MORE soil = regenerative) 58 tot = tot + 1 59 if im_greener(IG_FOOD, straw, "nishi" as *u8, "conv" as *u8) == 1 { pass = pass + 1; g_p("PASS T2 the OPPOSITE on environment (less carbon+water, BUILDS soil vs degrades)\n" as *u8) } else { g_p("FAIL T2\n" as *u8) } 60 61 // T3 cheaper for the customer 62 let sav: i64 = im_savings(IG_FOOD, straw, "nishi" as *u8, "conv" as *u8) 63 tot = tot + 1 64 if sav > 0 { pass = pass + 1; g_p("PASS T3 customer SPENDS LESS (saves " as *u8); g_money(sav); g_p(")\n" as *u8) } else { g_p("FAIL T3\n" as *u8) } 65 66 // T4 yet WE earn MORE (the unique concept: vertical integration) 67 let mn: i64 = im_margin(IG_FOOD, straw, "nishi" as *u8) 68 let mc: i64 = im_margin(IG_FOOD, straw, "conv" as *u8) 69 tot = tot + 1 70 if mn > mc { pass = pass + 1; g_p("PASS T4 we GAIN MORE profit (Nishi margin " as *u8); g_money(mn); g_p(" > conventional " as *u8); g_money(mc); g_p(") while the customer pays less\n" as *u8) } else { g_p("FAIL T4\n" as *u8) } 71 72 // T5 the TRIPLE WIN -- Pareto domination on every axis + margin 73 tot = tot + 1 74 if im_triple_win(IG_FOOD, straw) == 1 { pass = pass + 1; g_p("PASS T5 TRIPLE WIN: Nishi dominates conventional on clean + carbon + water + soil + price AND our margin\n" as *u8) } else { g_p("FAIL T5\n" as *u8) } 75 76 // T6 greenwash LIAR-KILL: a clean CLAIM with high residue is caught (clean is MEASURED) 77 tot = tot + 1 78 var ok6: i64 = 1 79 if im_clean(IG_FOOD, straw, "greenwash" as *u8) >= 50 { ok6 = 0 } // measured dirty despite the "eco" name 80 if im_clean(IG_FOOD, straw, "greenwash" as *u8) >= im_clean(IG_FOOD, straw, "nishi" as *u8) { ok6 = 0 } 81 if im_greener(IG_FOOD, straw, "greenwash" as *u8, "conv" as *u8) != 0 { ok6 = 0 } // not actually regenerative (soil not improved) 82 if ok6 == 1 { pass = pass + 1; g_p("PASS T6 greenwash liar-kill (an 'eco' CLAIM with high residue scores DIRTY -- clean is measured, not claimed)\n" as *u8) } else { g_p("FAIL T6\n" as *u8) } 83 84 // T7 research-grounded 85 tot = tot + 1 86 var ok7: i64 = 1 87 let cbuf: *u8 = sys_mmap(64) 88 im_field_str(IG_FOOD, straw, "nishi" as *u8, 7, cbuf); if fd_sci_cited(cbuf) != 1 { ok7 = 0 } 89 im_field_str(IG_FOOD, straw, "conv" as *u8, 7, cbuf); if fd_sci_cited(cbuf) != 1 { ok7 = 0 } 90 if ok7 == 1 { pass = pass + 1; g_p("PASS T7 research-grounded (impact figures cite the regenerative-ag corpus)\n" as *u8) } else { g_p("FAIL T7\n" as *u8) } 91 92 // T8 sovereign comparison page + ship 93 let page: *u8 = sys_mmap(65536) 94 let np: i64 = im_render_compare(IG_FOOD, straw, page) 95 tot = tot + 1 96 var ok8: i64 = 1 97 if as_has_thirdparty_js(page, np) != 0 { ok8 = 0 } 98 if as_contains(page, np, "You save" as *u8) != 1 { ok8 = 0 } 99 if as_contains(page, np, "$4.50" as *u8) != 1 { ok8 = 0 } 100 if as_contains(page, np, "opposite" as *u8) != 1 { ok8 = 0 } 101 sys_mkdir("knowledge/staging" as *u8, 0x1ed) 102 sys_mkdir("knowledge/staging/impact" as *u8, 0x1ed) 103 let sfd: i64 = sys_openat_wr(IG_STAGE_FILE, 420); if sfd >= 0 { sys_write(sfd, page, np); sys_close(sfd) } 104 pub_init() 105 sys_mkdir(IG_STG, 0x1ed) 106 sys_mkdir(IG_LIVE, 0x1ed) 107 pub_submit_to(IG_Q, IG_STAGE_FILE, "strawberries.html" as *u8, "nishifoodfamily" as *u8, "nishi-impact" as *u8, "internal" as *u8) 108 pub_run_full(IG_Q, IG_LED, IG_STG, IG_LIVE, "publish:impact" as *u8) 109 if g_exists(IG_LIVE_FILE) != 1 { ok8 = 0 } 110 if ok8 == 1 { pass = pass + 1; g_p("PASS T8 sovereign comparison page shipped (cleaner, greener, cheaper)\n" as *u8) } else { g_p("FAIL T8\n" as *u8) } 111 112 g_p("nx_impact_gate pass=" as *u8); g_i(pass); g_p("/" as *u8); g_i(tot) 113 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check 114 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled 115 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify. 116 let ctr__dry: *i64 = gv_ctr() 117 ctr__dry[0] = pass 118 ctr__dry[1] = tot 119 let rc__dry: i64 = gv_verdict("IMPACT-GATE" as *u8, ctr__dry, "the triple win MEASURED: cleaner + greener + cheaper for them, more margin for us)" as *u8) 120 sys_exit(rc__dry) 121 return rc__dry 122}