code wiki / _hdl_build / nx_capability_catalog_test.nx

nx_capability_catalog_test.nx source

↩ module page · 34 lines · 3022 B

1// nx_capability_catalog_test.nx -- the catalog answers "do we have X?" by LOOKUP, honestly. Every 2// infra capability that was repeatedly re-discovered this session is now cataloged (HAVE=1); the things 3// NOT built return NO (so nobody greps for them). Exit 0 on 6/6. license_tier: ORIGINAL 4 5import "nx_capability_catalog.nx" 6import "nx_syscalls.nx" 7 8func ct_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 9func ct_num(v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m}; let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48;k=1}; while m>0 {t[k]=48+(m%10); m=m/10; k=k+1}; var i: i64=0; while i<k {bb[i]=t[k-1-i]; i=i+1}; sys_write(1, bb, k); return 0 } 10 11func main() -> i64 { 12 ct_puts("=== CAPABILITY CATALOG: look it up, don't re-discover it ===\n" as *u8) 13 // the infra capabilities I kept FINDING this session -- now answerable by lookup 14 let infra: *i64 = sys_mmap(8*16) as *i64 15 infra[0]=CAT_FETCH; infra[1]=CAT_SERVE; infra[2]=CAT_SSH; infra[3]=CAT_FILEPUT; infra[4]=CAT_DEPLOY; infra[5]=CAT_SEARCH; infra[6]=CAT_WEBBUILD; infra[7]=CAT_JUDGE; infra[8]=CAT_AUDIT 16 let cov: i64 = cat_coverage(infra, 9) 17 18 ct_puts(" lookup: FETCH=" as *u8); ct_num(cat_have(CAT_FETCH)); ct_puts(" SERVE=" as *u8); ct_num(cat_have(CAT_SERVE)); ct_puts(" SSH=" as *u8); ct_num(cat_have(CAT_SSH)); ct_puts(" FILEPUT=" as *u8); ct_num(cat_have(CAT_FILEPUT)); ct_puts(" DEPLOY=" as *u8); ct_num(cat_have(CAT_DEPLOY)); ct_puts("\n" as *u8) 19 ct_puts(" honest NOs: FILEGET=" as *u8); ct_num(cat_have(CAT_FILEGET)); ct_puts(" (only PUT built) EMBED_LEARNED=" as *u8); ct_num(cat_have(CAT_EMBED_LEARNED)); ct_puts(" (LLM-gap)\n" as *u8) 20 ct_puts(" infra coverage = " as *u8); ct_num(cov); ct_puts("/9 cataloged (file+API in knowledge/CAPABILITY_CATALOG.md)\n" as *u8) 21 22 let r: *i64 = sys_mmap(8*8) as *i64 23 r[0] = 0; if cat_have(CAT_FETCH) == 1 { if cat_have(CAT_SERVE) == 1 { if cat_have(CAT_SSH) == 1 { r[0] = 1 } } } // the discovered ones now answerable 24 r[1] = 0; if cat_have(CAT_FILEPUT) == 1 { if cat_have(CAT_DEPLOY) == 1 { r[1] = 1 } } // this session's new ones cataloged 25 r[2] = 0; if cat_have(CAT_FILEGET) == 0 { r[2] = 1 } // honest NO (file-GET not built) 26 r[3] = 0; if cat_have(CAT_EMBED_LEARNED) == 0 { r[3] = 1 } // honest NO (LLM-gap) 27 r[4] = 0; if cov == 9 { r[4] = 1 } // all 9 infra needs cataloged 28 r[5] = 0; if cat_admits_gaps() == 1 { r[5] = 1 } // the catalog admits what it lacks 29 var pass: i64 = 0; var i: i64 = 0 30 while i < 6 { pass = pass + r[i]; i = i + 1 } 31 ct_puts("----\n passed " as *u8); ct_num(pass); ct_puts("/6\n" as *u8) 32 if pass == 6 { ct_puts(" CATALOGED: every infra capability is now a LOOKUP (file+API documented), and the catalog honestly says NO to what is not built -- no more archaeology.\n" as *u8); sys_exit(0); return 0 } 33 ct_puts(" FAIL\n" as *u8); sys_exit(1); return 1 34}