nx_model_get.nx
buildroot/runtime/nx_model_get.nx
about
nx_model_get.nx -- G9 mg_fetch: hash-verified model acquisition into the gen model store (/compare/gen watch G9).
usage: nx_model_get <url> <expected-sha256> <dest-name>
<dest-name> is relative to the model-store root (e.g. diffusion/z_image_turbo-Q8_0.gguf, loras/x.safetensors).
COMPOSES INCUMBENTS, DUPLICATES NONE:
transport = nx_https_fetch_range (own TLS-1.3, Range windows -- one bounded window in memory at a time, so a
multi-GB body STREAMS and can never be silently truncated by a buffer cap)
hashing = the streaming sha256_init/update/final already inside this compilation unit (nx_sha256 via the
TLS stack / nx_weights_pull) -- the digest covers the FULL body across all windows
verify law = nx_weights_pull (wp_hexenc + fail-closed compare): a mismatched body is DELETED, never stored
decisions = nx_model_get_lib (dest admission, hex normalize, Content-Range/Length parse, conf parse),
offline-proven by nx_model_get_gate
Redirects (HF resolve -> CDN) are followed by a bytes=0-0 probe that reads the Location header, because the
range fetcher itself deliberately does not follow. Resumable: an interrupted pull leaves <dest>.part; a re-run
re-hashes the part from disk and continues from its byte count. Idempotent: an existing verified dest returns
OK-ALREADY-VERIFIED with no network touched. An existing dest that does NOT match is REFUSED and kept
(additive-only: this organ never deletes a model already in the store; only its own .part on hash mismatch).
exit: 0 VERIFIED / OK-ALREADY-VERIFIED | 1 REFUSED (hash mismatch / existing mismatch) | 2 usage/bad-args |
3 UNPROVEN (transport, trust store, no-length -- partial kept for resume where one exists)
license_tier: ORIGINAL
dependencies 5 imports · 0 importers
imports: nx_syscalls.nxnx_https_fetch_follow.nxnx_trust_store_load_from_certdata.nxnx_weights_pull.nxnx_model_get_lib.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
| 27 | const MG_URLCAP: i64 = 4096 // same bound the fetch stack uses for a url buffer |
| 28 | const MG_PROBE_CAP: i64 = 262144 // bytes=0-0 probe response buffer (headers + stub body) |
| 29 | const MG_HOPS_MAX: i64 = 6 // redirect budget, mirrors the fetch stack's default |
| 30 | const MG_HASH_WIN: i64 = 1048576 // on-disk re-hash window for idempotency/resume |
| 31 | const MG_WINDOW_DEFAULT: i64 = 8388608 // range window when the conf carries none (8 MiB) |
| 32 | const MG_WIN_RETRIES: i64 = 3 // window failures tolerated before declaring TRANSPORT-STALL |
| 33 | const MG_PROGRESS_EVERY: i64 = 32 // announce progress every N windows |
| 34 | const MG_CERT_ROOTS: i64 = 512 |
| 35 | const MG_CERT_CAP: i64 = 4194304 |
| 36 | const MG_CONF_PATH: *u8 = "knowledge/gen_model_store.conf" |
| 37 | const MG_ROOT_DEFAULT: *u8 = "/volume1/ai/models" |
| 38 | const MG_RECEIPT_PATH: *u8 = "knowledge/status/modelget.log" |
functions
| 40 | func mgo_put(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 41 | func mgo_num(v: i64) -> i64 |
| 56 | func mg_hash_file_into(ctx: *Sha256, path: *u8) -> i64 |
| 73 | func mg_hash_file_hex(path: *u8, out_hex: *u8) -> i64 |
| 89 | func mg_probe(urlbuf: *u8, store: *TrustStore, use_chrome: i64, st: *i64, locout: *u8, totbox: *i64) -> i64 |
| 146 | func mg_resolve(urlbuf: *u8, store: *TrustStore, chromebox: *i64, totbox: *i64) -> i64 |
| 174 | func mg_receipt(verdict: *u8, dest: *u8, bytes: i64, hex: *u8, url: *u8) -> i64 called by 1: mg_fetch calls 8: sys_openat_appendmgo_putsys_mmapmg_catsys_now_realtime_secsys_write+2 |
| 212 | func main(argc: i64, argv: *i64) -> i64 |
| 281 | func mg_fetch(url: *u8, exphex: *u8, dest: *u8, part: *u8, store: *TrustStore, window: i64) -> i64 |