code wiki / _hdl_build / nx_bench_fetch.nx

nx_bench_fetch.nx

buildroot/runtime/_hdl_build/nx_bench_fetch.nx

5817 B130 linesdepth 21pulls 146 transitivereach 0 importersview sourcekind benchtopic bench
docsdependenciesstructsconstsfunctions

about

nx_bench_fetch.nx -- THE GENERIC SOVEREIGN URL->FILE FETCHER (rule 15 DRY; eats the hardcoded-URL fetcher-family duplication class). WHY IT EXISTS: the ecosystem has ~119 `*_research_fetch` organs, each a copy of the same TLS+save body with its URLs BAKED IN. I wrote two more this session (swebv, gmmlu) before the third instance made the pattern obvious -- rule 15 says extract at 3. Every one of those copies also inherited the same latent bugs (the ff_putn no-write class, the missing self-mkdir) precisely because they were copies. This organ is the one body they should all have called: URL and destination are ARGUMENTS, not source edits. nx_bench_fetch <url> <outpath> [force] outpath MUST be under knowledge/fetched/ or /tmp/ (boundary defense, rule 12) idempotent: an existing outpath is a HAVE-SKIP unless `force` is passed prints: status=<http> bytes=<n> SAVED | HAVE-SKIP | FETCH-FAIL | SAVE-FAIL | GZIP-skip exit 0 saved-or-skipped | 2 usage/denied | 3 fetch failed SELF-MKDIRS knowledge/fetched (rule 20: a tool that needs a dir makes it -- the missing-dir bug that silently SAVE-FAIL'd 119 organs, seq191). license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_x509_trust_store.nx nx_trust_store_load_from_certdata. nx_https_fetch_follow.nx nx_bench_fetch.nx

imports: nx_syscalls.nxnx_x509_trust_store.nxnx_trust_store_load_from_certdata.nxnx_https_fetch_follow.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main bf_werr sys_write bf_slen sys_exit bf_has bf_slen ↻ bf_pfx

structs

none

consts

24const BF_CAP: i64 = 8388608
25const BF_ROOTS_MAX: i64 = 512
26const BF_CERTBUF: i64 = 4194304
27const BF_HOPS: i64 = 6
28const BF_MODE: i64 = 0x1a4
29const BF_DMODE: i64 = 0x1ed
30const BF_MKDIRAT: i64 = 258
31const BF_ATFDCWD: i64 = 0 - 100
32const BF_D0: i64 = 48
33const BF_B10: i64 = 10
34const BF_NUMB: i64 = 24
35const BF_STDERR: i64 = 2
36const BF_EXIT_USAGE: i64 = 2
37const BF_EXIT_FETCH: i64 = 3
38const BF_ARGC_MIN: i64 = 3
39const BF_ARGC_FORCE: i64 = 4

functions

41func bf_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 3: bf_wbf_werrbf_has
42func bf_w(s: *u8) -> i64 { sys_write(1, s, bf_slen(s)); return 0 }
43func bf_werr(s: *u8) -> i64 { sys_write(BF_STDERR, s, bf_slen(s)); return 0 }
called by 1: main calls 2: sys_writebf_slen
44func bf_wn(v: i64) -> i64
58func bf_pfx(s: *u8, pfx: *u8) -> i64
called by 1: main
63func bf_has(s: *u8, sub: *u8) -> i64
called by 1: main calls 1: bf_slen
77func bf_exists(p: *u8) -> i64
83func bf_mkdir(p: *u8) -> i64 { return __syscall(BF_MKDIRAT, BF_ATFDCWD, p as i64, BF_DMODE, 0, 0, 0) }
85func main(argc: i64, argv: *i64) -> i64