code wiki / (root) / nx_readiness_research_fetch.nx

nx_readiness_research_fetch.nx source

↩ module page · 81 lines · 5138 B

1// nx_readiness_research_fetch.nx -- the Nishi RESEARCHER grounding the 2// PRODUCT-READINESS arc (operator: "evaluate from the hardware rung up each 3// rung what we need to do to get this to market, not just water but all 4// things"). The real frameworks: NASA/DoD Technology Readiness Levels, 5// Manufacturing Readiness Levels, stage-gate, go-to-market, DFM, regulatory. 6// Mirrors the proven fetcher: own TLS-1.3 + Mozilla CA, idempotent have-skip, 7// ->knowledge/fetched/readiness_*.raw. COVERAGE: 14. expect_exit: 0 8import "nx_syscalls.nx" 9import "nx_x509_trust_store.nx" 10import "nx_trust_store_load_from_certdata.nx" 11import "nx_https_fetch_follow.nx" 12const K_MAGIC_4194304: i64 = 4194304 13const K_MAGIC_8388608: i64 = 8388608 14 15func ff_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 16func ff_putn(v: i64) -> i64 { 17 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 } 18 var m: i64 = v 19 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m } 20 let d: *u8 = sys_mmap(24) 21 var k: i64 = 0 22 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 23 var j: i64 = k - 1 24 while j >= 0 { sys_write(1, (d as i64 + j) as *u8, 1); j = j - 1 } 25 return 0 26} 27func have_file(path: *u8) -> i64 { 28 let fd: i64 = sys_openat_rd(path) 29 if fd < 0 { return 0 } 30 sys_close(fd) 31 return 1 32} 33func fetch_save(url: *u8, opath: *u8, store: *TrustStore, out: *u8, cap: i64) -> i64 { 34 if have_file(opath) == 1 { ff_puts(opath); ff_puts(" [have-skip]\n" as *u8); return 1 } 35 let status: *i64 = sys_mmap(8) as *i64 36 let n: i64 = nx_https_fetch_follow(url, store, out, cap, 6, status) 37 ff_puts(url); ff_puts(" status=" as *u8); ff_putn(status[0]); ff_puts(" bytes=" as *u8); ff_putn(n) 38 if n <= 0 { ff_puts(" FETCH-FAIL\n" as *u8); return 0 } 39 var gz: i64 = 0 40 if n >= 2 { if out[0] == 0x1f as u8 { if out[1] == 0x8b as u8 { gz = 1 } } } 41 if gz == 1 { ff_puts(" [GZIP-skip]\n" as *u8); return 0 } 42 let fd: i64 = sys_openat_wr(opath, 0x1a4) 43 if fd < 0 { ff_puts(" SAVE-FAIL\n" as *u8); return 0 } 44 sys_write(fd, out, n) 45 sys_close(fd) 46 ff_puts(" SAVED\n" as *u8) 47 return 1 48} 49 50func main() -> i64 { 51 let r: i64 = nx_trust_store_load_from_certdata("data/mozilla_certdata.txt" as *u8, 512, K_MAGIC_4194304) 52 if r <= 0 { ff_puts("READINESS: certdata load failed\n" as *u8); return 1 } 53 let store: *TrustStore = r as *TrustStore 54 ff_puts("CA roots=" as *u8); ff_putn(trust_store_count(store)); ff_puts("\n" as *u8) 55 let cap: i64 = K_MAGIC_8388608 56 let out: *u8 = sys_mmap(cap) 57 var ok: i64 = 0 58 59 ff_puts("== READINESS LADDERS (TRL / MRL, hardware rung up) ==\n" as *u8) 60 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Technology_readiness_level" as *u8, "knowledge/fetched/readiness_r1_trl.raw" as *u8, store, out, cap) 61 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Manufacturing_readiness_level" as *u8, "knowledge/fetched/readiness_r2_mrl.raw" as *u8, store, out, cap) 62 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Systems_development_life_cycle" as *u8, "knowledge/fetched/readiness_r3_sdlc.raw" as *u8, store, out, cap) 63 64 ff_puts("== PRODUCT DEVELOPMENT + GO-TO-MARKET ==\n" as *u8) 65 ok = ok + fetch_save("https://en.wikipedia.org/wiki/New_product_development" as *u8, "knowledge/fetched/readiness_p1_npd.raw" as *u8, store, out, cap) 66 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Phase-gate_process" as *u8, "knowledge/fetched/readiness_p2_phase_gate.raw" as *u8, store, out, cap) 67 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Go_to_market" as *u8, "knowledge/fetched/readiness_p3_gtm.raw" as *u8, store, out, cap) 68 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Product-market_fit" as *u8, "knowledge/fetched/readiness_p4_pmf.raw" as *u8, store, out, cap) 69 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Minimum_viable_product" as *u8, "knowledge/fetched/readiness_p5_mvp.raw" as *u8, store, out, cap) 70 71 ff_puts("== MANUFACTURING + REGULATORY ==\n" as *u8) 72 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Design_for_manufacturability" as *u8, "knowledge/fetched/readiness_m1_dfm.raw" as *u8, store, out, cap) 73 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Bill_of_materials" as *u8, "knowledge/fetched/readiness_m2_bom.raw" as *u8, store, out, cap) 74 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Contract_manufacturer" as *u8, "knowledge/fetched/readiness_m3_contract_mfg.raw" as *u8, store, out, cap) 75 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Regulatory_compliance" as *u8, "knowledge/fetched/readiness_m4_regulatory.raw" as *u8, store, out, cap) 76 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Quality_management_system" as *u8, "knowledge/fetched/readiness_m5_qms.raw" as *u8, store, out, cap) 77 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Verification_and_validation" as *u8, "knowledge/fetched/readiness_m6_vandv.raw" as *u8, store, out, cap) 78 79 ff_puts("READABLE SOURCES SAVED THIS PASS+HAVE: " as *u8); ff_putn(ok); ff_puts(" / 14\n" as *u8) 80 return 0 81}