code wiki / (root) / nx_dm_research_fetch.nx

nx_dm_research_fetch.nx source

↩ module page · 101 lines · 6739 B

1// nx_dm_research_fetch.nx -- SOVEREIGN multi-source web-fetch that GROUNDS the "exceed Google DeepMind, 2// hardware-rung-up" roadmap in REAL fetched facts (Rule 4: agent prompts / roadmaps need VERIFIED facts, 3// never assumptions). Mirrors the proven nx_ge_research_fetch: reuses the sovereign TLS-1.3 stack 4// (nx_https_fetch_follow) + the Mozilla CA store, and SAVES each source to knowledge/fetched/dm_*.raw so 5// the DeepMind capability corpus COMPOUNDS to the Library and can be grepped to CITE (the >=2-source 6// corroboration / no-hearsay rule). The .raw files are the evidence_src the DeepMind capability ladder 7// (knowledge/registry/deepmind_capability_ladder.tsv) cites -> the grader liar-kills any cited file that 8// is missing. 100% sovereign (own TLS, nx_cc->nxasm, no curl/wget/gcc). The only non-Nishi inputs are the 9// CA-root DATA + the fetched pages = exactly the researcher's contract. 10// 11// The URL set is GROUPED BY THE LADDER LAYER each capability informs (HW/ISA -> MATH -> TOOLCHAIN/ORGANS 12// -> AI -> RESEARCH canopy), so the corpus maps 1:1 onto the god->canopy evolution tree. 13// expect_exit: 0 license_tier: ORIGINAL 14import "nx_syscalls.nx" 15import "nx_x509_trust_store.nx" 16import "nx_trust_store_load_from_certdata.nx" 17import "nx_https_fetch_follow.nx" 18const K_MAGIC_4194304: i64 = 4194304 19const K_MAGIC_8388608: i64 = 8388608 20 21func df_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 22func df_putn(v: i64) -> i64 { 23 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 } 24 var m: i64 = v 25 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m } 26 let d: *u8 = sys_mmap(24); var k: i64 = 0 27 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 28 var j: i64 = k - 1 29 while j >= 0 { sys_write(1, ((d as i64)+j) as *u8, 1); j = j - 1 } 30 return 0 31} 32 33// idempotent (rule #10): a source already on disk is skipped, so re-runs only fill gaps. This is also the 34// LEAK WORKAROUND -- the TLS stack leaks mmap per fetch, so the set completes across a few resumable passes 35// instead of one OOM-killed run. 36func have_file(path: *u8) -> i64 { 37 let fd: i64 = sys_openat_rd(path) 38 if fd < 0 { return 0 } 39 sys_close(fd) 40 return 1 41} 42 43// fetch url -> save body to opath (O_TRUNC, fresh). returns 1 iff a readable (non-empty, non-gzip) body saved. 44func fetch_save(url: *u8, opath: *u8, store: *TrustStore, out: *u8, cap: i64) -> i64 { 45 if have_file(opath) == 1 { df_puts(opath); df_puts(" [have-skip]\n"); return 1 } 46 let status: *i64 = sys_mmap(8) as *i64 47 let n: i64 = nx_https_fetch_follow(url, store, out, cap, 6, status) 48 df_puts(url); df_puts(" status="); df_putn(status[0]); df_puts(" bytes="); df_putn(n) 49 if n <= 0 { df_puts(" FETCH-FAIL\n"); return 0 } 50 var gz: i64 = 0 51 if n >= 2 { if out[0] == 0x1f as u8 { if out[1] == 0x8b as u8 { gz = 1 } } } 52 if gz == 1 { df_puts(" [GZIP-skip]\n"); return 0 } 53 let fd: i64 = sys_openat_wr(opath, 0x1a4) 54 if fd < 0 { df_puts(" SAVE-FAIL\n"); return 0 } 55 sys_write(fd, out, n) 56 sys_close(fd) 57 df_puts(" SAVED\n") 58 return 1 59} 60 61func main() -> i64 { 62 let r: i64 = nx_trust_store_load_from_certdata("data/mozilla_certdata.txt" as *u8, 512, K_MAGIC_4194304) 63 if r <= 0 { df_puts("DF: certdata load failed\n"); return 1 } 64 let store: *TrustStore = r as *TrustStore 65 df_puts("CA roots="); df_putn(trust_store_count(store)); df_puts("\n") 66 let cap: i64 = K_MAGIC_8388608 67 let out: *u8 = sys_mmap(cap) 68 var ok: i64 = 0 69 70 df_puts("== SPINE: the DeepMind capability index (extract the capability set from here) ==\n") 71 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Google_DeepMind" as *u8, "knowledge/fetched/dm_spine_deepmind.raw" as *u8, store, out, cap) 72 73 df_puts("== HW / ISA layer: RL-driven chip design (AlphaChip) ==\n") 74 ok = ok + fetch_save("https://en.wikipedia.org/wiki/AlphaChip" as *u8, "knowledge/fetched/dm_hw_alphachip.raw" as *u8, store, out, cap) 75 76 df_puts("== MATH layer: algorithm DISCOVERY (AlphaTensor matmul / AlphaGeometry) ==\n") 77 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Matrix_multiplication_algorithm" as *u8, "knowledge/fetched/dm_math_matmul.raw" as *u8, store, out, cap) 78 ok = ok + fetch_save("https://en.wikipedia.org/wiki/AlphaTensor" as *u8, "knowledge/fetched/dm_math_alphatensor.raw" as *u8, store, out, cap) 79 ok = ok + fetch_save("https://en.wikipedia.org/wiki/AlphaGeometry" as *u8, "knowledge/fetched/dm_math_alphageometry.raw" as *u8, store, out, cap) 80 81 df_puts("== TOOLCHAIN / ORGANS layer: code+algorithm synthesis (AlphaDev faster sort/hash) ==\n") 82 ok = ok + fetch_save("https://en.wikipedia.org/wiki/AlphaDev" as *u8, "knowledge/fetched/dm_tool_alphadev.raw" as *u8, store, out, cap) 83 84 df_puts("== AI layer: sovereign models / science (AlphaFold, WaveNet, Gemini, deep learning) ==\n") 85 ok = ok + fetch_save("https://en.wikipedia.org/wiki/AlphaFold" as *u8, "knowledge/fetched/dm_ai_alphafold.raw" as *u8, store, out, cap) 86 ok = ok + fetch_save("https://en.wikipedia.org/wiki/WaveNet" as *u8, "knowledge/fetched/dm_ai_wavenet.raw" as *u8, store, out, cap) 87 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Gemini_(language_model)" as *u8, "knowledge/fetched/dm_ai_gemini.raw" as *u8, store, out, cap) 88 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Deep_learning" as *u8, "knowledge/fetched/dm_ai_deeplearning.raw" as *u8, store, out, cap) 89 90 df_puts("== RESEARCH canopy: RL self-play = the self-improvement flywheel (the layer that exceeds DeepMind) ==\n") 91 ok = ok + fetch_save("https://en.wikipedia.org/wiki/AlphaGo" as *u8, "knowledge/fetched/dm_research_alphago.raw" as *u8, store, out, cap) 92 ok = ok + fetch_save("https://en.wikipedia.org/wiki/AlphaZero" as *u8, "knowledge/fetched/dm_research_alphazero.raw" as *u8, store, out, cap) 93 ok = ok + fetch_save("https://en.wikipedia.org/wiki/MuZero" as *u8, "knowledge/fetched/dm_research_muzero.raw" as *u8, store, out, cap) 94 ok = ok + fetch_save("https://en.wikipedia.org/wiki/AlphaStar_(software)" as *u8, "knowledge/fetched/dm_research_alphastar.raw" as *u8, store, out, cap) 95 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Reinforcement_learning" as *u8, "knowledge/fetched/dm_research_rl.raw" as *u8, store, out, cap) 96 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Monte_Carlo_tree_search" as *u8, "knowledge/fetched/dm_research_mcts.raw" as *u8, store, out, cap) 97 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Artificial_general_intelligence" as *u8, "knowledge/fetched/dm_research_agi.raw" as *u8, store, out, cap) 98 99 df_puts("DM READABLE SOURCES SAVED: "); df_putn(ok); df_puts(" / 17\n") 100 return 0 101}