code wiki / _hdl_build / nx_vizsla_jobs_gate.nx

nx_vizsla_jobs_gate.nx source

↩ module page · 285 lines · 11654 B

1// nx_vizsla_jobs_gate.nx -- VIZSLA V2a gate: the job-search engine is gate-proven 2// against a FIXTURE CORPUS with hand-computed best-match order (the oracle is 3// arithmetic in this header, not the module under test). 4// 5// profile: ada SKILL nishilang=300 compilers=200 writing=100; 6// bea SKILL editing=400 writing=100; CLOSED rejected/accepted/withdrawn 7// postings: j1 9000000 [compilers rust writing] j2 12000000 [nishilang compilers systems] 8// j3 7500000 [sales travel] j4 8000000 [editing writing remote] 9// hand scores: ada j1=300 j2=500 j3=0 j4=100 -> rank j2,j1,j4,j3 matched=3 10// bea j1=100 j2=0 j3=0 j4=500 -> rank j4,j1,(j2,j3 file order) matched=2 11// apps: j2 applied -> j1 applied -> j2 interview -> j1 rejected 12// => cadence: j2 last=interview OPEN follow-up; j1 last=rejected CLOSED suppressed 13// => VERDICT apps=4 posts=2 open=1 closed=1 14// 15// Rows: 16// 1 loud-fail missing profile => exit 1 17// 2 best-match-order ada rank1=j2 score=500 + rank2=j1 score=300 exact 18// 3 zero-score-named j3 printed at rank4 score=0 AND verdict matched=3 (never dropped) 19// 4 multi-member bea rank1=j4 score=500 (data-driven per-member ranking) 20// 5 match-determinism twice => byte-identical 21// 6 track-load 4 apps -> new=4 committed seg-2001 22// 7 idempotent re-track => new=0 dup_instore=4 segment=none (law 10) 23// 8 cadence-last j2 last=interview action=follow-up (last status wins) 24// 9 closed-honest NO j1 cadence row BUT verdict apps=4 posts=2 open=1 closed=1 25// (suppressed from cadence, kept in history) 26// 10 cadence-determinism twice => byte-identical 27// Evidence: VIZSLA-JOBS-GATE line -> stdout + knowledge/status/vizsla_gate.log; 28// exit 0 iff 10/10. 29// spec: knowledge/specs/2026-06-10-nishi-vizsla-ladder.md license_tier: ORIGINAL 30import "nx_syscalls.nx" 31 32func jg_slen(s: *u8) -> i64 { 33 var n: i64 = 0 34 while s[n] != (0 as u8) { n = n + 1 } 35 return n 36} 37 38func jg_p(s: *u8) -> i64 { 39 sys_write(1, s, jg_slen(s)) 40 return 0 41} 42 43func jg_cat(dst: *u8, off: i64, s: *u8) -> i64 { 44 var i: i64 = 0 45 while s[i] != (0 as u8) { dst[off + i] = s[i]; i = i + 1 } 46 return off + i 47} 48 49func jg_catn(dst: *u8, off: i64, v: i64) -> i64 { 50 var o: i64 = off 51 var m: i64 = v 52 if m < 0 { dst[o] = 45 as u8; o = o + 1; m = 0 - m } 53 let t: *u8 = sys_mmap(28) 54 var k: i64 = 0 55 if m == 0 { t[0] = 48 as u8; k = 1 } 56 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 57 var i: i64 = 0 58 while i < k { dst[o + i] = t[k - 1 - i]; i = i + 1 } 59 return o + k 60} 61 62func jg_write(path: *u8, content: *u8) -> i64 { 63 let fd: i64 = sys_openat_wr(path, 0x1a4) 64 if fd < 0 { return 0 - 1 } 65 sys_write(fd, content, jg_slen(content)) 66 sys_close(fd) 67 return 0 68} 69 70func jg_readall(path: *u8, szout: *i64) -> *u8 { 71 let fd: i64 = sys_openat_rd(path) 72 if fd < 0 { szout[0] = 0 - 1; return 0 as *u8 } 73 let sz: i64 = sys_lseek(fd, 0, 2) 74 sys_lseek(fd, 0, 0) 75 let buf: *u8 = sys_mmap(sz + 64) 76 var got: i64 = 0 77 var n: i64 = 1 78 while n > 0 { 79 n = sys_read(fd, (buf as i64 + got) as *u8, 65536) 80 if n > 0 { got = got + n } 81 } 82 sys_close(fd) 83 szout[0] = got 84 return buf 85} 86 87func jg_run(elf: *u8, a1: *u8, a2: *u8, a3: *u8, a4: *u8, outpath: *u8) -> i64 { 88 let pid: i64 = sys_fork() 89 if pid == 0 { 90 if (outpath as i64) != 0 { 91 let ofd: i64 = sys_openat_wr(outpath, 0x1a4) 92 if ofd >= 0 { sys_dup3(ofd, 1, 0); sys_dup3(ofd, 2, 0) } 93 } 94 let argv: *i64 = sys_mmap(64) as *i64 95 argv[0] = elf as i64 96 var i: i64 = 1 97 if (a1 as i64) != 0 { argv[i] = a1 as i64; i = i + 1 } 98 if (a2 as i64) != 0 { argv[i] = a2 as i64; i = i + 1 } 99 if (a3 as i64) != 0 { argv[i] = a3 as i64; i = i + 1 } 100 if (a4 as i64) != 0 { argv[i] = a4 as i64; i = i + 1 } 101 argv[i] = 0 102 let envp: *i64 = sys_mmap(16) as *i64 103 envp[0] = 0 104 sys_execve(elf, argv, envp) 105 sys_exit(127) 106 } 107 let st: *i64 = sys_mmap(16) as *i64 108 sys_wait4(pid, st, 0) 109 let sig: i64 = st[0] & 0x7f 110 if sig != 0 { return 128 + sig } 111 return (st[0] >> 8) & 0xff 112} 113 114func jg_has(path: *u8, needle: *u8) -> i64 { 115 let szp: *i64 = sys_mmap(16) as *i64 116 let b: *u8 = jg_readall(path, szp) 117 let sz: i64 = szp[0] 118 let n: i64 = jg_slen(needle) 119 if sz < n { return 0 } 120 var i: i64 = 0 121 while i + n <= sz { 122 var ok: i64 = 1 123 var j: i64 = 0 124 while j < n { 125 if b[i + j] != needle[j] { ok = 0; j = n } else { j = j + 1 } 126 } 127 if ok == 1 { return 1 } 128 i = i + 1 129 } 130 return 0 131} 132 133func jg_fileeq(p1: *u8, p2: *u8) -> i64 { 134 let s1: *i64 = sys_mmap(16) as *i64 135 let s2: *i64 = sys_mmap(16) as *i64 136 let b1: *u8 = jg_readall(p1, s1) 137 let b2: *u8 = jg_readall(p2, s2) 138 if s1[0] != s2[0] { return 0 } 139 if s1[0] <= 0 { return 0 } 140 var i: i64 = 0 141 while i < s1[0] { 142 if b1[i] != b2[i] { return 0 } 143 i = i + 1 144 } 145 return 1 146} 147 148func jg_row(name: *u8, pass: i64) -> i64 { 149 jg_p("ROW " as *u8) 150 jg_p(name) 151 if pass == 1 { jg_p(" PASS\n" as *u8) } else { jg_p(" FAIL\n" as *u8) } 152 return pass 153} 154 155func main(argc: i64, argv: *i64) -> i64 { 156 jg_p("=== VIZSLA JOBS GATE: fixture-corpus best-match KATs (hand-computed order) ===\n" as *u8) 157 var jb: *u8 = "/tmp/nx_vizsla_jobs.sov.elf" as *u8 158 if argc > 1 { jb = argv[1] as *u8 } 159 let pr: i64 = sys_openat_rd(jb) 160 if pr >= 0 { sys_close(pr) } 161 else { 162 jg_p(" instrument missing -> rebuilding via durable runner\n" as *u8) 163 jg_run("_offc/nx_sov_build_run.elf" as *u8, "nx_vizsla_jobs" as *u8, 0 as *u8, 0 as *u8, 0 as *u8, "/tmp/vzj_rebuild.out" as *u8) 164 } 165 166 // epoch-unique virgin store prefix for the tracker 167 let pfx: *u8 = sys_mmap(128) 168 var po: i64 = 0 169 po = jg_cat(pfx, po, "/tmp/vzjG" as *u8) 170 po = jg_catn(pfx, po, sys_now_us()) 171 po = jg_cat(pfx, po, "-" as *u8) 172 pfx[po] = 0 as u8 173 174 let prof: *u8 = "SEEK ada\nSKILL ada 300 nishilang\nSKILL ada 200 compilers\nSKILL ada 100 writing\nSEEK bea\nSKILL bea 400 editing\nSKILL bea 100 writing\nCLOSED rejected\nCLOSED accepted\nCLOSED withdrawn\n" as *u8 175 jg_write("/tmp/vzj_prof.txt" as *u8, prof) 176 let posts: *u8 = "POST j1 9000000 compilers rust writing\nPOST j2 12000000 nishilang compilers systems\nPOST j3 7500000 sales travel\nPOST j4 8000000 editing writing remote\n" as *u8 177 jg_write("/tmp/vzj_posts.txt" as *u8, posts) 178 let apps: *u8 = "APP 2026-06-01 j2 ada applied first-pass\nAPP 2026-06-03 j1 ada applied backup\nAPP 2026-06-05 j2 ada interview phone-screen\nAPP 2026-06-06 j1 ada rejected form-letter\n" as *u8 179 jg_write("/tmp/vzj_apps.txt" as *u8, apps) 180 181 let fp: *u8 = "/tmp/vzj_prof.txt" as *u8 182 let fo: *u8 = "/tmp/vzj_posts.txt" as *u8 183 let flog: *u8 = "/tmp/vzj_fix.log" as *u8 184 var pass: i64 = 0 185 var r: i64 = 0 186 187 // row 1: loud-fail on missing profile 188 let rc1: i64 = jg_run(jb, "match" as *u8, "/tmp/vzj_prof_NOPE.txt" as *u8, fo, flog, "/tmp/vzj_out1.txt" as *u8) 189 r = 0 190 if rc1 == 1 { r = 1 } 191 pass = pass + jg_row("loud-fail-missing-profile" as *u8, r) 192 193 // row 2: hand-computed best-match order for ada 194 let rc2: i64 = jg_run(jb, "match" as *u8, fp, fo, flog, "/tmp/vzj_out2.txt" as *u8) 195 r = 0 196 if rc2 == 0 { 197 if jg_has("/tmp/vzj_out2.txt" as *u8, "VIZSLA-JOBS-MATCH member=ada rank=1 post=j2 score=500 pay=12000000" as *u8) == 1 { 198 if jg_has("/tmp/vzj_out2.txt" as *u8, "VIZSLA-JOBS-MATCH member=ada rank=2 post=j1 score=300 pay=9000000" as *u8) == 1 { r = 1 } 199 } 200 } 201 pass = pass + jg_row("best-match-order" as *u8, r) 202 203 // row 3: zero-score posting PRINTED + matched counts only score>0 204 r = 0 205 if jg_has("/tmp/vzj_out2.txt" as *u8, "VIZSLA-JOBS-MATCH member=ada rank=4 post=j3 score=0" as *u8) == 1 { 206 if jg_has("/tmp/vzj_out2.txt" as *u8, "VIZSLA-JOBS-VERDICT member=ada postings=4 matched=3" as *u8) == 1 { r = 1 } 207 } 208 pass = pass + jg_row("zero-score-named-not-dropped" as *u8, r) 209 210 // row 4: second member ranks differently from the SAME corpus (model is data) 211 r = 0 212 if jg_has("/tmp/vzj_out2.txt" as *u8, "VIZSLA-JOBS-MATCH member=bea rank=1 post=j4 score=500 pay=8000000" as *u8) == 1 { 213 if jg_has("/tmp/vzj_out2.txt" as *u8, "VIZSLA-JOBS-VERDICT member=bea postings=4 matched=2" as *u8) == 1 { r = 1 } 214 } 215 pass = pass + jg_row("multi-member-data-driven" as *u8, r) 216 217 // row 5: match determinism 218 jg_run(jb, "match" as *u8, fp, fo, flog, "/tmp/vzj_out5.txt" as *u8) 219 r = jg_fileeq("/tmp/vzj_out2.txt" as *u8, "/tmp/vzj_out5.txt" as *u8) 220 pass = pass + jg_row("match-determinism" as *u8, r) 221 222 // row 6: track 4 applications into seg-2001 223 let rc6: i64 = jg_run(jb, "track" as *u8, "/tmp/vzj_apps.txt" as *u8, pfx, "2001" as *u8, "/tmp/vzj_out6.txt" as *u8) 224 r = 0 225 if rc6 == 0 { 226 if jg_has("/tmp/vzj_out6.txt" as *u8, "VIZSLA-JOBS-TRACK scanned=4 new=4 dup_infile=0 dup_instore=0 segment=seg-2001" as *u8) == 1 { r = 1 } 227 } 228 pass = pass + jg_row("track-load" as *u8, r) 229 230 // row 7: idempotent re-track (law 10) 231 let rc7: i64 = jg_run(jb, "track" as *u8, "/tmp/vzj_apps.txt" as *u8, pfx, "2009" as *u8, "/tmp/vzj_out7.txt" as *u8) 232 r = 0 233 if rc7 == 0 { 234 if jg_has("/tmp/vzj_out7.txt" as *u8, "VIZSLA-JOBS-TRACK scanned=4 new=0 dup_infile=0 dup_instore=4 segment=none" as *u8) == 1 { r = 1 } 235 } 236 pass = pass + jg_row("idempotent-retrack" as *u8, r) 237 238 // row 8: cadence -- last status wins (j2 applied then interview => interview) 239 let rc8: i64 = jg_run(jb, "cadence" as *u8, pfx, fp, 0 as *u8, "/tmp/vzj_out8.txt" as *u8) 240 r = 0 241 if rc8 == 0 { 242 if jg_has("/tmp/vzj_out8.txt" as *u8, "VIZSLA-JOBS-CADENCE post=j2 member=ada last=interview action=follow-up" as *u8) == 1 { r = 1 } 243 } 244 pass = pass + jg_row("cadence-last-status-wins" as *u8, r) 245 246 // row 9: closed app suppressed from cadence, still counted in history 247 r = 0 248 if jg_has("/tmp/vzj_out8.txt" as *u8, "VIZSLA-JOBS-CADENCE post=j1" as *u8) == 0 { 249 if jg_has("/tmp/vzj_out8.txt" as *u8, "VIZSLA-JOBS-CADENCE-VERDICT apps=4 posts=2 open=1 closed=1" as *u8) == 1 { r = 1 } 250 } 251 pass = pass + jg_row("closed-suppressed-history-kept" as *u8, r) 252 253 // row 10: cadence determinism 254 jg_run(jb, "cadence" as *u8, pfx, fp, 0 as *u8, "/tmp/vzj_out10.txt" as *u8) 255 r = jg_fileeq("/tmp/vzj_out8.txt" as *u8, "/tmp/vzj_out10.txt" as *u8) 256 pass = pass + jg_row("cadence-determinism" as *u8, r) 257 258 let permil: i64 = (pass * 1000) / 10 259 let logfd: i64 = sys_openat_append("knowledge/status/vizsla_gate.log" as *u8, 0x1a4) 260 var fdi: i64 = 0 261 while fdi < 2 { 262 var fd: i64 = 1 263 if fdi == 1 { fd = logfd } 264 if fd > 0 { 265 let line: *u8 = sys_mmap(256) 266 var o: i64 = 0 267 o = jg_cat(line, o, "VIZSLA-JOBS-GATE epoch=" as *u8) 268 o = jg_catn(line, o, sys_now_realtime_sec()) 269 o = jg_cat(line, o, " rows=10 pass=" as *u8) 270 o = jg_catn(line, o, pass) 271 o = jg_cat(line, o, " permil=" as *u8) 272 o = jg_catn(line, o, permil) 273 if pass == 10 { 274 o = jg_cat(line, o, " verdict=GREEN\n" as *u8) 275 } else { 276 o = jg_cat(line, o, " verdict=RED\n" as *u8) 277 } 278 sys_write(fd, line, o) 279 } 280 fdi = fdi + 1 281 } 282 if logfd > 0 { sys_close(logfd) } 283 if pass == 10 { return 0 } 284 return 1 285}