code wiki / _hdl_build / nx_impact_gate.nx

nx_impact_gate.nx source

↩ module page · 115 lines · 7134 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" 13 14const IG_FOOD: *u8 = "knowledge/store/food-" 15const IG_Q: *u8 = "knowledge/publish/impact-queue.tsv" 16const IG_LED: *u8 = "knowledge/publish/impact-ledger.tsv" 17const IG_STG: *u8 = "knowledge/publish/impact-stage" 18const IG_LIVE: *u8 = "knowledge/publish/impact-live" 19const IG_STAGE_FILE: *u8 = "knowledge/staging/impact/strawberries.html" 20const IG_LIVE_FILE: *u8 = "knowledge/publish/impact-live/strawberries.html" 21 22func 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 } 23func g_i(v: i64) -> i64 { 24 let bb: *u8 = sys_mmap(28); var m: i64 = v 25 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m } 26 let t: *u8 = sys_mmap(28); var k: i64 = 0 27 if m == 0 { t[0] = 48 as u8; k = 1 } 28 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 29 var i: i64 = 0; while i < k { bb[i] = t[k - 1 - i]; i = i + 1 } sys_write(1, bb, k); return 0 30} 31func 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 } 32func g_exists(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 } 33 34func main() -> i64 { 35 g_p("=== nx_impact_gate (R-IMPACT: clean + environmental + value, strawberries) ===\n" as *u8) 36 fd_seed(IG_FOOD) 37 fd_seed_provenance(IG_FOOD) 38 let sw: i64 = im_seed(IG_FOOD) 39 g_p("impact records authored this run=" as *u8); g_i(sw); g_p("\n" as *u8) 40 let straw: *u8 = "strawberry" as *u8 41 42 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)) 43 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)) 44 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) 45 46 var pass: i64 = 0 47 var tot: i64 = 0 48 49 // T1 cleaner 50 tot = tot + 1 51 var ok1: i64 = 1 52 if im_pesticide(IG_FOOD, straw, "nishi" as *u8) >= im_pesticide(IG_FOOD, straw, "conv" as *u8) { ok1 = 0 } 53 if im_clean(IG_FOOD, straw, "nishi" as *u8) <= im_clean(IG_FOOD, straw, "conv" as *u8) { ok1 = 0 } 54 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) } 55 56 // T2 greener -- the OPPOSITE (less carbon+water, MORE soil = regenerative) 57 tot = tot + 1 58 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) } 59 60 // T3 cheaper for the customer 61 let sav: i64 = im_savings(IG_FOOD, straw, "nishi" as *u8, "conv" as *u8) 62 tot = tot + 1 63 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) } 64 65 // T4 yet WE earn MORE (the unique concept: vertical integration) 66 let mn: i64 = im_margin(IG_FOOD, straw, "nishi" as *u8) 67 let mc: i64 = im_margin(IG_FOOD, straw, "conv" as *u8) 68 tot = tot + 1 69 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) } 70 71 // T5 the TRIPLE WIN -- Pareto domination on every axis + margin 72 tot = tot + 1 73 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) } 74 75 // T6 greenwash LIAR-KILL: a clean CLAIM with high residue is caught (clean is MEASURED) 76 tot = tot + 1 77 var ok6: i64 = 1 78 if im_clean(IG_FOOD, straw, "greenwash" as *u8) >= 50 { ok6 = 0 } // measured dirty despite the "eco" name 79 if im_clean(IG_FOOD, straw, "greenwash" as *u8) >= im_clean(IG_FOOD, straw, "nishi" as *u8) { ok6 = 0 } 80 if im_greener(IG_FOOD, straw, "greenwash" as *u8, "conv" as *u8) != 0 { ok6 = 0 } // not actually regenerative (soil not improved) 81 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) } 82 83 // T7 research-grounded 84 tot = tot + 1 85 var ok7: i64 = 1 86 let cbuf: *u8 = sys_mmap(64) 87 im_field_str(IG_FOOD, straw, "nishi" as *u8, 7, cbuf); if fd_sci_cited(cbuf) != 1 { ok7 = 0 } 88 im_field_str(IG_FOOD, straw, "conv" as *u8, 7, cbuf); if fd_sci_cited(cbuf) != 1 { ok7 = 0 } 89 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) } 90 91 // T8 sovereign comparison page + ship 92 let page: *u8 = sys_mmap(65536) 93 let np: i64 = im_render_compare(IG_FOOD, straw, page) 94 tot = tot + 1 95 var ok8: i64 = 1 96 if as_has_thirdparty_js(page, np) != 0 { ok8 = 0 } 97 if as_contains(page, np, "You save" as *u8) != 1 { ok8 = 0 } 98 if as_contains(page, np, "$4.50" as *u8) != 1 { ok8 = 0 } 99 if as_contains(page, np, "opposite" as *u8) != 1 { ok8 = 0 } 100 sys_mkdir("knowledge/staging" as *u8, 0x1ed) 101 sys_mkdir("knowledge/staging/impact" as *u8, 0x1ed) 102 let sfd: i64 = sys_openat_wr(IG_STAGE_FILE, 420); if sfd >= 0 { sys_write(sfd, page, np); sys_close(sfd) } 103 pub_init() 104 sys_mkdir(IG_STG, 0x1ed) 105 sys_mkdir(IG_LIVE, 0x1ed) 106 pub_submit_to(IG_Q, IG_STAGE_FILE, "strawberries.html" as *u8, "nishifoodfamily" as *u8, "nishi-impact" as *u8, "internal" as *u8) 107 pub_run_full(IG_Q, IG_LED, IG_STG, IG_LIVE, "publish:impact" as *u8) 108 if g_exists(IG_LIVE_FILE) != 1 { ok8 = 0 } 109 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) } 110 111 g_p("nx_impact_gate pass=" as *u8); g_i(pass); g_p("/" as *u8); g_i(tot) 112 if pass == tot { g_p(" verdict=GREEN (the triple win MEASURED: cleaner + greener + cheaper for them, more margin for us)\n" as *u8); return 0 } 113 g_p(" verdict=RED\n" as *u8) 114 return 1 115}