code wiki / _hdl_build / nx_bench_fetch.nx
nx_bench_fetch.nx
buildroot/runtime/_hdl_build/nx_bench_fetch.nx
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
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
structs
| none |
consts
| 24 | const BF_CAP: i64 = 8388608 |
| 25 | const BF_ROOTS_MAX: i64 = 512 |
| 26 | const BF_CERTBUF: i64 = 4194304 |
| 27 | const BF_HOPS: i64 = 6 |
| 28 | const BF_MODE: i64 = 0x1a4 |
| 29 | const BF_DMODE: i64 = 0x1ed |
| 30 | const BF_MKDIRAT: i64 = 258 |
| 31 | const BF_ATFDCWD: i64 = 0 - 100 |
| 32 | const BF_D0: i64 = 48 |
| 33 | const BF_B10: i64 = 10 |
| 34 | const BF_NUMB: i64 = 24 |
| 35 | const BF_STDERR: i64 = 2 |
| 36 | const BF_EXIT_USAGE: i64 = 2 |
| 37 | const BF_EXIT_FETCH: i64 = 3 |
| 38 | const BF_ARGC_MIN: i64 = 3 |
| 39 | const BF_ARGC_FORCE: i64 = 4 |
functions
| 41 | func bf_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 42 | func bf_w(s: *u8) -> i64 { sys_write(1, s, bf_slen(s)); return 0 } |
| 43 | func bf_werr(s: *u8) -> i64 { sys_write(BF_STDERR, s, bf_slen(s)); return 0 } |
| 44 | func bf_wn(v: i64) -> i64 |
| 58 | func bf_pfx(s: *u8, pfx: *u8) -> i64 called by 1: main |
| 63 | func bf_has(s: *u8, sub: *u8) -> i64 |
| 77 | func bf_exists(p: *u8) -> i64 |
| 83 | func bf_mkdir(p: *u8) -> i64 { return __syscall(BF_MKDIRAT, BF_ATFDCWD, p as i64, BF_DMODE, 0, 0, 0) } |
| 85 | func main(argc: i64, argv: *i64) -> i64 |