code wiki / _hdl_build / nx_lineage_deep_gate.nx

nx_lineage_deep_gate.nx source

↩ module page · 131 lines · 9133 B

1// nx_lineage_deep_gate.nx -- GATE: deeper provenance (R-DEEP). T1 multi-parent CROSS detected (hybrid has two 2// distinct parents; single-parent is not a cross). T2 cross label names both parents. T3 a harvest LOT from a 3// plant. T4 SPLIT into many child lots + conservation (can't split beyond what remains). T5 DEEP TRACE: a jar 4// split from the sauce traces back through the chain to the harvest -> the exact plant (superior). T6 lot 5// provenance page renders + ships. license_tier: ORIGINAL 6import "nx_lineage_deep.nx" 7import "nx_publisher.nx" 8import "nx_seg_store.nx" 9import "nx_syscalls.nx" 10import "nx_gate_verdict.nx" 11 12const LD_BIO: *u8 = "knowledge/store/ldeep-bio-" 13const LD_STAGE_FILE: *u8 = "knowledge/staging/ldeep/jar.html" 14const LD_LIVE_FILE: *u8 = "knowledge/publish/ldeep-live/jar.html" 15 16func 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 } 17func g_i(v: i64) -> i64 { 18 let bb: *u8 = sys_mmap(28); var m: i64 = v 19 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m } 20 let t: *u8 = sys_mmap(28); var k: i64 = 0 21 if m == 0 { t[0] = 48 as u8; k = 1 } 22 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 23 var i: i64 = 0; while i < k { bb[i] = t[k - 1 - i]; i = i + 1 } sys_write(1, bb, k); return 0 24} 25func g_exists(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 } 26 27func main() -> i64 { 28 g_p("=== nx_lineage_deep_gate (R-DEEP: crosses + harvest-lot splitting) ===\n" as *u8) 29 ln_seed_config(LD_BIO) 30 31 // a hybrid cross: Sungold = Sungold Red x Sungold Yellow 32 ln_add(LD_BIO, "sg_a" as *u8, "Sungold Red" as *u8, "plant" as *u8, "Sungold Red" as *u8, 1, "-" as *u8, "-" as *u8, "saved" as *u8, "self" as *u8, "perma_a8_regenerative_ag" as *u8) 33 ln_add(LD_BIO, "sg_b" as *u8, "Sungold Yellow" as *u8, "plant" as *u8, "Sungold Yellow" as *u8, 1, "-" as *u8, "-" as *u8, "saved" as *u8, "self" as *u8, "perma_a8_regenerative_ag" as *u8) 34 ln_add(LD_BIO, "sungold" as *u8, "Sungold" as *u8, "plant" as *u8, "Sungold F1" as *u8, 2, "sg_a" as *u8, "sg_b" as *u8, "crossed" as *u8, "self" as *u8, "perma_a8_regenerative_ag" as *u8) 35 ln_set_gene(LD_BIO, "sungold" as *u8, 94, 90, 92, 88, 91, "Nishi field trial" as *u8, "perma_a8_regenerative_ag" as *u8) 36 // a single-parent (not a cross) 37 ln_add(LD_BIO, "bw_gp" as *u8, "Brandywine founder" as *u8, "plant" as *u8, "Brandywine" as *u8, 1, "-" as *u8, "-" as *u8, "saved" as *u8, "self" as *u8, "perma_a8_regenerative_ag" as *u8) 38 ln_add(LD_BIO, "brandywine" as *u8, "Brandywine" as *u8, "plant" as *u8, "Brandywine" as *u8, 2, "bw_gp" as *u8, "-" as *u8, "saved" as *u8, "self" as *u8, "perma_a8_regenerative_ag" as *u8) 39 40 var pass: i64 = 0 41 var tot: i64 = 0 42 43 // T1 cross detection 44 let a: *u8 = sys_mmap(64); let b: *u8 = sys_mmap(64); ld_parents(LD_BIO, "sungold" as *u8, a, b) 45 g_p("sungold parents: " as *u8); g_p(a); g_p(" x " as *u8); g_p(b); g_p(" cross=" as *u8); g_i(ld_is_cross(LD_BIO, "sungold" as *u8)); g_p(" | brandywine cross=" as *u8); g_i(ld_is_cross(LD_BIO, "brandywine" as *u8)); g_p("\n" as *u8) 46 tot = tot + 1 47 var ok1: i64 = 1 48 if ld_is_cross(LD_BIO, "sungold" as *u8) != 1 { ok1 = 0 } 49 if ld_is_cross(LD_BIO, "brandywine" as *u8) != 0 { ok1 = 0 } 50 if fd_streq(a, "sg_a" as *u8) != 1 { ok1 = 0 } 51 if fd_streq(b, "sg_b" as *u8) != 1 { ok1 = 0 } 52 if ok1 == 1 { pass = pass + 1; g_p("PASS T1 multi-parent cross detected (Sungold = two distinct parents); single-parent is not a cross\n" as *u8) } else { g_p("FAIL T1\n" as *u8) } 53 54 // T2 cross label 55 let cl: *u8 = sys_mmap(256); ld_cross_label(LD_BIO, "sungold" as *u8, cl) 56 g_p("cross label: " as *u8); g_p(cl); g_p("\n" as *u8) 57 tot = tot + 1 58 var ok2: i64 = 1 59 if as_contains(cl, as_len(cl), "Sungold Red" as *u8) != 1 { ok2 = 0 } 60 if as_contains(cl, as_len(cl), "Sungold Yellow" as *u8) != 1 { ok2 = 0 } 61 if as_contains(cl, as_len(cl), " x " as *u8) != 1 { ok2 = 0 } 62 if ok2 == 1 { pass = pass + 1; g_p("PASS T2 cross label names both parents (Sungold = Sungold Red x Sungold Yellow)\n" as *u8) } else { g_p("FAIL T2\n" as *u8) } 63 64 // T3 harvest lot 65 ld_create_lot(LD_BIO, "harvest1" as *u8, "sungold" as *u8, 50, "lb" as *u8, 100) 66 let oh: *u8 = sys_mmap(64); ld_lot_origin_org(LD_BIO, "harvest1" as *u8, oh) 67 g_p("harvest1 origin org=" as *u8); g_p(oh); g_p(" qty=" as *u8); g_i(ld_lot_int(LD_BIO, "harvest1" as *u8, 2)); g_p("\n" as *u8) 68 tot = tot + 1 69 if fd_streq(oh, "sungold" as *u8) == 1 { if ld_lot_int(LD_BIO, "harvest1" as *u8, 2) == 50 { pass = pass + 1; g_p("PASS T3 harvest lot from the plant (50 lb of Sungold)\n" as *u8) } else { g_p("FAIL T3 qty\n" as *u8) } } else { g_p("FAIL T3 origin\n" as *u8) } 70 71 // T4 split + conservation 72 let s1: i64 = ld_split_lot(LD_BIO, "harvest1" as *u8, "sauce1" as *u8, 20, "lb" as *u8, "sauce" as *u8, 101) 73 ld_split_lot(LD_BIO, "harvest1" as *u8, "fresh1" as *u8, 15, "lb" as *u8, "fresh" as *u8, 101) 74 ld_split_lot(LD_BIO, "harvest1" as *u8, "seed1" as *u8, 5, "lb" as *u8, "seed" as *u8, 101) 75 let overshoot: i64 = ld_split_lot(LD_BIO, "harvest1" as *u8, "toomuch" as *u8, 100, "lb" as *u8, "x" as *u8, 101) 76 let rem: i64 = ld_lot_remaining(LD_BIO, "harvest1" as *u8) 77 let sp: *u8 = sys_mmap(48); ld_lot_str(LD_BIO, "sauce1" as *u8, 1, sp) 78 g_p("splits ok; overshoot=" as *u8); g_i(overshoot); g_p(" remaining=" as *u8); g_i(rem); g_p(" sauce1.parent=" as *u8); g_p(sp); g_p("\n" as *u8) 79 tot = tot + 1 80 var ok4: i64 = 1 81 if s1 != 1 { ok4 = 0 } 82 if overshoot != 0 { ok4 = 0 } // conservation: can't split beyond what remains 83 if rem != 10 { ok4 = 0 } // 50 - (20+15+5) 84 if fd_streq(sp, "harvest1" as *u8) != 1 { ok4 = 0 } 85 if ok4 == 1 { pass = pass + 1; g_p("PASS T4 split into sauce/fresh/seed (40 of 50); over-split refused (conservation), 10 remain\n" as *u8) } else { g_p("FAIL T4\n" as *u8) } 86 87 // T5 deep trace: a jar from the sauce traces to the plant 88 ld_split_lot(LD_BIO, "sauce1" as *u8, "jar1" as *u8, 5, "jar" as *u8, "canned" as *u8, 102) 89 let oj: *u8 = sys_mmap(64); ld_lot_origin_org(LD_BIO, "jar1" as *u8, oj) 90 let tr: *u8 = sys_mmap(256); ld_lot_trace(LD_BIO, "jar1" as *u8, tr) 91 g_p("jar1 trace: " as *u8); g_p(tr); g_p(" -> origin=" as *u8); g_p(oj); g_p(" superior=" as *u8); g_i(ln_is_superior(LD_BIO, "sungold" as *u8)); g_p("\n" as *u8) 92 tot = tot + 1 93 var ok5: i64 = 1 94 if fd_streq(oj, "sungold" as *u8) != 1 { ok5 = 0 } 95 if fd_streq(tr, "jar1 <- sauce1 <- harvest1" as *u8) != 1 { ok5 = 0 } 96 if ln_is_superior(LD_BIO, "sungold" as *u8) != 1 { ok5 = 0 } 97 if ok5 == 1 { pass = pass + 1; g_p("PASS T5 deep trace: jar -> sauce -> harvest -> the exact plant (superior Sungold)\n" as *u8) } else { g_p("FAIL T5\n" as *u8) } 98 99 // T6 render + ship 100 let page: *u8 = sys_mmap(65536) 101 let np: i64 = ld_render_lot(LD_BIO, "jar1" as *u8, page) 102 g_p("lot page = " as *u8); g_i(np); g_p(" bytes\n" as *u8) 103 tot = tot + 1 104 var ok6: i64 = 1 105 if as_has_thirdparty_js(page, np) != 0 { ok6 = 0 } 106 if as_contains(page, np, "harvest1" as *u8) != 1 { ok6 = 0 } // the chain 107 if as_contains(page, np, "Sungold" as *u8) != 1 { ok6 = 0 } // the plant 108 if as_contains(page, np, "superior strain" as *u8) != 1 { ok6 = 0 } 109 if as_contains(page, np, "Sungold Red" as *u8) != 1 { ok6 = 0 } // the cross 110 sys_mkdir("knowledge/staging" as *u8, 0x1ed) 111 sys_mkdir("knowledge/staging/ldeep" as *u8, 0x1ed) 112 let sfd: i64 = sys_openat_wr(LD_STAGE_FILE, 420); if sfd >= 0 { sys_write(sfd, page, np); sys_close(sfd) } 113 pub_init() 114 sys_mkdir("knowledge/publish/ldeep-stage" as *u8, 0x1ed) 115 sys_mkdir("knowledge/publish/ldeep-live" as *u8, 0x1ed) 116 pub_submit_to("knowledge/publish/ldeep-queue.tsv" as *u8, LD_STAGE_FILE, "jar.html" as *u8, "nishifoodfamily" as *u8, "nishi-ldeep" as *u8, "internal" as *u8) 117 pub_run_full("knowledge/publish/ldeep-queue.tsv" as *u8, "knowledge/publish/ldeep-ledger.tsv" as *u8, "knowledge/publish/ldeep-stage" as *u8, "knowledge/publish/ldeep-live" as *u8, "publish:ldeep" as *u8) 118 if g_exists(LD_LIVE_FILE) != 1 { ok6 = 0 } 119 if ok6 == 1 { pass = pass + 1; g_p("PASS T6 lot provenance page (chain + plant + genetics + cross) renders sovereign + ships\n" as *u8) } else { g_p("FAIL T6\n" as *u8) } 120 121 g_p("nx_lineage_deep_gate pass=" as *u8); g_i(pass); g_p("/" as *u8); g_i(tot) 122 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check 123 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled 124 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify. 125 let ctr__dry: *i64 = gv_ctr() 126 ctr__dry[0] = pass 127 ctr__dry[1] = tot 128 let rc__dry: i64 = gv_verdict("LINEAGE-DEEP-GATE" as *u8, ctr__dry, "hybrids trace to both parents; one harvest -> many plates, each traceable to the exact plant + seed)" as *u8) 129 sys_exit(rc__dry) 130 return rc__dry 131}