code wiki / (root) / nx_vault_capture.nx

nx_vault_capture.nx

buildroot/runtime/nx_vault_capture.nx

42799 B1074 linesdepth 22pulls 171 transitivereach 0 importersview sourcekind tooltopic vault
docsdependenciesstructsconstsfunctions

about

nx_vault_capture.nx -- SAVE, as a first-class sovereign verb. (v2: ref-root/phys-root split) OPERATOR 2026-08-06: "saving an image doesn't just go to a download folder -- you have the ability to save the media or the whole site for future consumption if you choose, from the browser to the OS." WHAT THIS DOES: one verb, three scopes, one destination. media <url> the asset alone page <url> the document AS AN ITEM + every image it references site <url> a bounded same-host crawl, every page captured as above Each captured byte becomes a content-addressed vault item (CID = identity, so re-saving is free and duplicates collapse) carrying its provenance at ingest. ONE CHOKEPOINT (vc_ingest_file): the album downloader (mvf_fetch_album_pfx) filed downloads into collections but wrote NO item record, and does not even import the ingest module -- so it structurally COULD NOT. A capture path that does its own recording can forget to record. So there is exactly one way in, and the gate asserts the invariant it holds: EVERY COLLECTION MEMBER RESOLVES TO A RECORD (T6), with a negative control (T7). REF-ROOT vs PHYS-ROOT (v2, the fix for the v1 15/15 live failure). The record's `ref` uses the LOGICAL DSM root /volume1/vault -- a shared folder that needs root/DSM to create and DOES NOT EXIST as a plain dir. All existing records carry that logical root, and nx_vault_gateway SERVES by stripping its 14-char prefix and prepending a writable PHYSICAL root (~/vaultfs). v1 used ONE root for both the ref and the bytes, so every write under the nonexistent /volume1/vault failed (a page + 14 assets = 15/15). v2 keeps the LOGICAL ref in the record (consistent with existing records + the gateway remap) and writes bytes to the PHYSICAL root. Both roots are data-driven (knowledge/status/vault_roots.conf), rule 11/17. ORDERING (nx_mvault_coll): collections are declared BEFORE the bytes land. Composes only proven organs. license_tier: ORIGINAL

dependencies 18 imports · 0 importers

nx_syscalls.nx nx_canon_cid.nx nx_registry.nx nx_media_pool.nx nx_media_sniff.nx nx_mvault_ingest.nx nx_mvault_context.nx nx_mvault_record.nx nx_mvault_layout.nx nx_mvault_reclaim.nx nx_vault_capture.nx

diagram shows first 10 each side; +8 more imports, +0 more importers in the complete lists below.

imports: nx_syscalls.nxnx_canon_cid.nxnx_registry.nxnx_media_pool.nxnx_media_sniff.nxnx_mvault_ingest.nxnx_mvault_context.nxnx_mvault_record.nxnx_mvault_layout.nxnx_mvault_reclaim.nxnx_mvault_reindex.nxnx_mvault_tag.nxnx_mvault_coll.nxnx_mvault_fetch.nxnx_https_fetch_lib.nxnx_paced_fetch.nxnx_ingest_admit.nxnx_url_safety_lib.nx

imported by: nobody (leaf or entry point)

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

main vc_usage vc_werr sys_write vc_strlen argp vc_eq do_selftest sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ vc_ext_of sys_mmap ↻ mvf_basename mvf_strlen sys_munmap vc_cat vc_lower vc_eq ↻ vc_w sys_write ↻ vc_strlen ↻ sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real vc_write_file vc_mkdirp sys_mmap ↻

structs

none

consts

53const VC_MAGIC_4096: i64 = 4096
54const VC_DISK_REFUSE: i64 = 0 - 2 // vc_ingest_file's distinct return for a disk-floor refusal (callers read <0 as fail, correctly)
55const VC_EXIT_UNSAFE_URL: i64 = 9 // R11: the edge verb refused an SSRF-unsafe url; distinct from a fetch failure (6) so a caller can tell a REFUSAL from a FAILURE
56const VC_MAGIC_1024: i64 = 1024
57const VC_MAGIC_65536: i64 = 65536
58const VC_MAGIC_8192: i64 = 8192
60const VC_URL_CAP: i64 = 2048
61const VC_PATH_CAP: i64 = 2048
62const VC_PAGE_CAP: i64 = 4194304
63const VC_LINKS_CAP: i64 = 1048576
64const VC_ITEMS_CAP: i64 = 262144
65const VC_VISIT_CAP: i64 = 262144
66const VC_HEAD_CAP: i64 = 8192
67const VC_REC_CAP: i64 = 4096
68const VC_REPORT_CAP: i64 = 65536
69const VC_EXT_CAP: i64 = 64
70const VC_HOST_CAP: i64 = 512
71const VC_CID_CAP: i64 = 128
72const VC_ROOT_CAP: i64 = 512
74const VC_DEF_ASSETS: i64 = 64
75const VC_DEF_PAGES: i64 = 16
76const VC_MAX_ASSETS: i64 = 512
77const VC_MAX_PAGES: i64 = 256
80const VC_REF_ROOT: *u8 = "/volume1/vault" as *u8
81const VC_PHYS_ROOT: *u8 = "/volume1/homes/elderwesto/vaultfs" as *u8
82const VC_ROOTS_CONF: *u8 = "knowledge/status/vault_roots.conf" as *u8
84const VC_ST_FOUND: i64 = 0
85const VC_ST_NEW: i64 = 1
86const VC_ST_DUP: i64 = 2
87const VC_ST_FAIL: i64 = 3
88const VC_ST_PAGE: i64 = 4
89const VC_ST_PAGES: i64 = 5
90const VC_ST_N: i64 = 6

functions

92func vc_strlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
94func vc_cat(dst: *u8, off: i64, s: *u8) -> i64
100func vc_eq(a: *u8, b: *u8) -> i64
110func vc_w(s: *u8) -> i64 { sys_write(1, s, vc_strlen(s)); return 0 }
called by 1: do_selftest calls 2: sys_writevc_strlen
111func vc_werr(s: *u8) -> i64 { sys_write(2, s, vc_strlen(s)); return 0 }
113func vc_n(v: i64) -> i64
121func vc_werr_n(v: i64) -> i64
129func vc_lower(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } return c }
called by 1: vc_ext_of
131func vc_has_pfx(buf: *u8, pfx: *u8) -> i64
140func vc_phys_of(ref: *u8, refroot: *u8, physroot: *u8, out: *u8, cap: i64) -> i64
154func vc_conf_field(buf: *u8, n: i64, key: *u8, out: *u8, cap: i64) -> i64
called by 1: vc_load_roots
184func vc_load_roots(ref_out: *u8, phys_out: *u8) -> i64
199func vc_mkdirp(path: *u8) -> i64
229func vc_ext_of(url: *u8, deflt: *u8, out: *u8, cap: i64) -> i64
286func vc_ingest_file(store: *u8, ref_root: *u8, phys_root: *u8, tmppath: *u8,
373func vc_pace_hook(url: *u8, phase: i64, status: i64) -> i64
378func vc_fetch_tmp(store_i: i64, phys_root: *u8, url: *u8, seqn: i64,
397func vc_capture_media(store_i: i64, store: *u8, ref_root: *u8, phys_root: *u8,
417func vc_items_add(items: *u8, io: i64, cid: *u8) -> i64
called by 2: vc_page_coremain calls 1: vc_strlen
426func vc_seen(set: *u8, n: i64, hay: *u8) -> i64
447func vc_page_core(store_i: i64, store: *u8, cpfx: *u8, ref_root: *u8, phys_root: *u8,
548func vc_declare_page_cols(cpfx: *u8, url: *u8, host: *u8,
564func vc_report_stats(report: *u8, off: i64, stats: *i64) -> i64
579func vc_capture_page(store_i: i64, store: *u8, cpfx: *u8, ref_root: *u8, phys_root: *u8,
630func vc_capture_site(store_i: i64, store: *u8, cpfx: *u8, ref_root: *u8, phys_root: *u8,
775func vc_write_file(path: *u8, content: *u8, n: i64) -> i64
784func do_selftest() -> i64
941func vc_usage() -> i64
946func argp(argv: *i64, i: i64) -> *u8 { return (argv[i]) as *u8 }
948func vc_atoi(s: *u8) -> i64
959func main(argc: i64, argv: *i64) -> i64