code wiki / _hdl_build / nx_skill_market_gate.nx

nx_skill_market_gate.nx source

↩ module page · 125 lines · 7475 B

1// nx_skill_market_gate.nx -- proves the learner-choice half: WHO you learn from, and what happens when they 2// have not covered it. Three BITE cells, each guarding a way the demand signal could quietly corrupt: 3// treating an un-indexed chef as a chef who declined, counting one enthusiast as a crowd, and asking a chef 4// for work they already published. 5// license_tier: ORIGINAL No hw writes (Rule 26). 6import "nx_syscalls.nx" 7import "nx_skill_request.nx" 8import "nx_gate_verdict.nx" 9 10const SG_PFX: i64 = 200 11const SG_WARC: i64 = 65536 12const SG_FLD: i64 = 1024 13 14func main(argc: i64, argv: *i64) -> i64 { 15 let ctr: *i64 = gv_ctr() 16 gv_head("nx_skill_video + nx_skill_request -- pick your teacher, and ask honestly for what is missing" as *u8) 17 18 let ep: i64 = sys_now_realtime_sec() 19 let vp: *u8 = sys_mmap(SG_PFX) 20 var o: i64 = as_append(vp, 0, "/tmp/svid_" as *u8) 21 o = fd_apnum(vp, o, ep); o = as_append(vp, o, "-" as *u8); vp[o] = 0 as u8 22 let rp: *u8 = sys_mmap(SG_PFX) 23 var r: i64 = as_append(rp, 0, "/tmp/sreq_" as *u8) 24 r = fd_apnum(rp, r, ep); r = as_append(rp, r, "-" as *u8); rp[r] = 0 as u8 25 26 let dice: *u8 = "dice-onion" as *u8 27 let sear: *u8 = "sear" as *u8 28 let uprourl: *u8 = "https://example.org/v/pro-dice" as *u8 29 let uamurl: *u8 = "https://example.org/v/am-dice" as *u8 30 31 // two chefs we have indexed, and one we have not 32 sv_add_chef(vp, "kenji" as *u8, "J. Kenji" as *u8, "@kenji" as *u8, "https://example.org/kenji" as *u8) 33 sv_add_chef(vp, "julia" as *u8, "Julia" as *u8, "@julia" as *u8, "https://example.org/julia" as *u8) 34 35 sv_add_video(vp, "v1" as *u8, dice, "Knife Skills 101" as *u8, "Pro Culinary School" as *u8, "pro" as *u8, uprourl, "CC BY 4.0" as *u8, 480, sv_empty()) 36 sv_add_video(vp, "v2" as *u8, dice, "How I dice onions at home" as *u8, "Home Cook Sam" as *u8, "amateur" as *u8, uamurl, "CC BY 4.0" as *u8, 300, sv_empty()) 37 sv_add_video(vp, "v3" as *u8, dice, "The onion, properly" as *u8, "J. Kenji" as *u8, "chef" as *u8, "https://example.org/v/kenji-dice" as *u8, "CC BY 4.0" as *u8, 600, "kenji" as *u8) 38 sv_add_video(vp, "v4" as *u8, sear, "Searing, properly" as *u8, "Pro Culinary School" as *u8, "pro" as *u8, "https://example.org/v/pro-sear" as *u8, "CC BY 4.0" as *u8, 400, sv_empty()) 39 40 // ---- T1 sources per skill ---- 41 let toks: *i64 = sys_mmap(8 * 64) as *i64 42 var t1: i64 = 1 43 if sv_by_skill(vp, dice, toks) != 3 { t1 = 0 } 44 if sv_by_skill(vp, sear, toks) != 1 { t1 = 0 } 45 let f: *u8 = sys_mmap(SG_FLD) 46 sv_field(vp, "v3" as *u8, SV_F_TITLE, f) 47 if fd_streq(f, "The onion, properly" as *u8) == 0 { t1 = 0 } 48 if sv_seconds(vp, "v3" as *u8) != 600 { t1 = 0 } 49 gv_check("T1 three ways to learn to dice an onion, one to learn to sear" as *u8, t1, ctr) 50 51 // ---- T2 the learner filters by the kind of teacher they want ---- 52 var t2: i64 = 1 53 if sv_by_skill_kind(vp, dice, "pro" as *u8, toks) != 1 { t2 = 0 } 54 if sv_by_skill_kind(vp, dice, "amateur" as *u8, toks) != 1 { t2 = 0 } 55 if sv_by_skill_kind(vp, dice, "chef" as *u8, toks) != 1 { t2 = 0 } 56 gv_check("T2 professional / amateur / a chef you follow are each selectable" as *u8, t2, ctr) 57 58 // ---- T3 BITE: an un-indexed chef is not a chef who declined ---- 59 let ov: *i64 = sys_mmap(16) as *i64 60 var unk_bad: i64 = 0 61 if sv_chef_covers(vp, "nobody" as *u8, dice, ov) == SV_CHEF_UNKNOWN { unk_bad = 1 } 62 var unk_good: i64 = 0 63 if sv_chef_covers(vp, "julia" as *u8, dice, ov) == SV_CHEF_UNKNOWN { unk_good = 1 } 64 gv_bite("T3 never-indexed chef reports UNKNOWN; a chef we hold who simply has no video reports NO" as *u8, unk_bad, unk_good, ctr) 65 66 var t3b: i64 = 1 67 if sv_chef_covers(vp, "kenji" as *u8, dice, ov) != SV_CHEF_YES { t3b = 0 } 68 if fd_streq(ov[0] as *u8, "v3" as *u8) == 0 { t3b = 0 } 69 if sv_chef_covers(vp, "julia" as *u8, dice, ov) != SV_CHEF_NO { t3b = 0 } 70 gv_check("T3b a covered skill hands back the exact video id that covers it" as *u8, t3b, ctr) 71 72 // ---- T4 a technique video is a citation, and rots like one ---- 73 let body: *u8 = sys_mmap(1024) 74 let bl: i64 = as_append(body, 0, "<html><body>knife skills transcript</body></html>" as *u8) 75 let warc: *u8 = sys_mmap(SG_WARC) 76 let wl: i64 = ms_capture(warc, 0, uprourl, "2026-08-06T00:00:00Z" as *u8, "text/html" as *u8, body, bl) 77 var t4: i64 = 1 78 if sv_is_preserved(vp, "v1" as *u8, warc, wl) != 1 { t4 = 0 } 79 if sv_preserved_bytes(vp, "v1" as *u8, warc, wl) != bl { t4 = 0 } 80 if sv_is_preserved(vp, "v2" as *u8, warc, wl) != 0 { t4 = 0 } 81 if sv_preserved_bytes(vp, "v2" as *u8, warc, wl) != (0 - 1) { t4 = 0 } 82 gv_check("T4 only the source whose bytes we actually hold reports preserved -- same predicate as the recipe" as *u8, t4, ctr) 83 84 // ---- T5 BITE: demand is DISTINCT people, not clicks ---- 85 var t5a: i64 = 1 86 if sr_request(rp, vp, "wests" as *u8, "julia" as *u8, dice, "video" as *u8, ov) != SR_COUNTED { t5a = 0 } 87 if sr_count(rp, "julia" as *u8, dice) != 1 { t5a = 0 } 88 var dup_bad: i64 = 0 89 if sr_request(rp, vp, "wests" as *u8, "julia" as *u8, dice, "video" as *u8, ov) == SR_DUPLICATE { dup_bad = 1 } 90 if sr_count(rp, "julia" as *u8, dice) != 1 { t5a = 0 } // the count did NOT move 91 var dup_good: i64 = 0 92 if sr_request(rp, vp, "ana" as *u8, "julia" as *u8, dice, "video" as *u8, ov) == SR_DUPLICATE { dup_good = 1 } 93 if sr_count(rp, "julia" as *u8, dice) != 2 { t5a = 0 } // a second PERSON did move it 94 gv_bite("T5 the same person asking twice is refused as duplicate; a different person is counted" as *u8, dup_bad, dup_good, ctr) 95 gv_check("T5b two clicks by one household = 1 demand; two households = 2" as *u8, t5a, ctr) 96 97 // ---- T6 BITE: never ask a chef for work they have already published ---- 98 var cov_bad: i64 = 0 99 if sr_request(rp, vp, "wests" as *u8, "kenji" as *u8, dice, "video" as *u8, ov) == SR_ALREADY_COVERED { cov_bad = 1 } 100 var cov_good: i64 = 0 101 if sr_request(rp, vp, "bristow" as *u8, "julia" as *u8, dice, "video" as *u8, ov) == SR_ALREADY_COVERED { cov_good = 1 } 102 gv_bite("T6 a request for an already-covered skill is REFUSED; a genuine gap is accepted" as *u8, cov_bad, cov_good, ctr) 103 104 // ---- T7 an un-indexed chef routes to OUR backlog, not to the chef ---- 105 var t7: i64 = 1 106 if sr_request(rp, vp, "wests" as *u8, "nobody" as *u8, sear, "take" as *u8, ov) != SR_COUNTED { t7 = 0 } 107 if sr_is_unindexed(rp, "nobody" as *u8, sear) != 1 { t7 = 0 } 108 if sr_is_unindexed(rp, "julia" as *u8, dice) != 0 { t7 = 0 } 109 gv_check("T7 a request against a chef we never indexed is tagged for crawling, not sent to them" as *u8, t7, ctr) 110 111 // ---- T8 the build order is measured, not guessed ---- 112 let pairs: *i64 = sys_mmap(8 * 64) as *i64 113 let counts: *i64 = sys_mmap(8 * 64) as *i64 114 let nr: i64 = sr_rank(rp, pairs, counts, 16) 115 var t8: i64 = 1 116 if nr < 2 { t8 = 0 } 117 if counts[0] != 3 { t8 = 0 } // julia:dice-onion -- wests, ana, bristow 118 if fd_streq(pairs[0] as *u8, "julia:dice-onion" as *u8) == 0 { t8 = 0 } 119 if counts[1] != 1 { t8 = 0 } 120 gv_check("T8 demand ranks by distinct requesters: julia/dice-onion at 3 leads the queue" as *u8, t8, ctr) 121 122 let rc: i64 = gv_verdict("SKILL-MARKET" as *u8, ctr, "unknown is not no; one person is not a crowd; never ask for work already done" as *u8) 123 sys_exit(rc) 124 return 0 125}