nx_vault_capture.nx
buildroot/runtime/nx_vault_capture.nx
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
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
structs
| none |
consts
| 53 | const VC_MAGIC_4096: i64 = 4096 |
| 54 | const VC_DISK_REFUSE: i64 = 0 - 2 // vc_ingest_file's distinct return for a disk-floor refusal (callers read <0 as fail, correctly) |
| 55 | const 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 |
| 56 | const VC_MAGIC_1024: i64 = 1024 |
| 57 | const VC_MAGIC_65536: i64 = 65536 |
| 58 | const VC_MAGIC_8192: i64 = 8192 |
| 60 | const VC_URL_CAP: i64 = 2048 |
| 61 | const VC_PATH_CAP: i64 = 2048 |
| 62 | const VC_PAGE_CAP: i64 = 4194304 |
| 63 | const VC_LINKS_CAP: i64 = 1048576 |
| 64 | const VC_ITEMS_CAP: i64 = 262144 |
| 65 | const VC_VISIT_CAP: i64 = 262144 |
| 66 | const VC_HEAD_CAP: i64 = 8192 |
| 67 | const VC_REC_CAP: i64 = 4096 |
| 68 | const VC_REPORT_CAP: i64 = 65536 |
| 69 | const VC_EXT_CAP: i64 = 64 |
| 70 | const VC_HOST_CAP: i64 = 512 |
| 71 | const VC_CID_CAP: i64 = 128 |
| 72 | const VC_ROOT_CAP: i64 = 512 |
| 74 | const VC_DEF_ASSETS: i64 = 64 |
| 75 | const VC_DEF_PAGES: i64 = 16 |
| 76 | const VC_MAX_ASSETS: i64 = 512 |
| 77 | const VC_MAX_PAGES: i64 = 256 |
| 80 | const VC_REF_ROOT: *u8 = "/volume1/vault" as *u8 |
| 81 | const VC_PHYS_ROOT: *u8 = "/volume1/homes/elderwesto/vaultfs" as *u8 |
| 82 | const VC_ROOTS_CONF: *u8 = "knowledge/status/vault_roots.conf" as *u8 |
| 84 | const VC_ST_FOUND: i64 = 0 |
| 85 | const VC_ST_NEW: i64 = 1 |
| 86 | const VC_ST_DUP: i64 = 2 |
| 87 | const VC_ST_FAIL: i64 = 3 |
| 88 | const VC_ST_PAGE: i64 = 4 |
| 89 | const VC_ST_PAGES: i64 = 5 |
| 90 | const VC_ST_N: i64 = 6 |
functions
| 92 | func vc_strlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 94 | func vc_cat(dst: *u8, off: i64, s: *u8) -> i64 |
| 100 | func vc_eq(a: *u8, b: *u8) -> i64 |
| 110 | func vc_w(s: *u8) -> i64 { sys_write(1, s, vc_strlen(s)); return 0 } |
| 111 | func vc_werr(s: *u8) -> i64 { sys_write(2, s, vc_strlen(s)); return 0 } |
| 113 | func vc_n(v: i64) -> i64 |
| 121 | func vc_werr_n(v: i64) -> i64 |
| 129 | func vc_lower(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } return c } called by 1: vc_ext_of |
| 131 | func vc_has_pfx(buf: *u8, pfx: *u8) -> i64 |
| 140 | func vc_phys_of(ref: *u8, refroot: *u8, physroot: *u8, out: *u8, cap: i64) -> i64 |
| 154 | func vc_conf_field(buf: *u8, n: i64, key: *u8, out: *u8, cap: i64) -> i64 called by 1: vc_load_roots |
| 184 | func vc_load_roots(ref_out: *u8, phys_out: *u8) -> i64 |
| 199 | func vc_mkdirp(path: *u8) -> i64 called by 4: vc_ingest_filevc_fetch_tmpvc_page_corevc_write_file calls 3: sys_mmapsys_munmapsys_mkdir |
| 229 | func vc_ext_of(url: *u8, deflt: *u8, out: *u8, cap: i64) -> i64 |
| 286 | func vc_ingest_file(store: *u8, ref_root: *u8, phys_root: *u8, tmppath: *u8, called by 3: vc_capture_mediavc_page_coredo_selftest calls 18: sys_mmapig_disk_floorvc_werrig_verdict_strvc_werr_nsys_unlinkat+12 |
| 373 | func vc_pace_hook(url: *u8, phase: i64, status: i64) -> i64 |
| 378 | func vc_fetch_tmp(store_i: i64, phys_root: *u8, url: *u8, seqn: i64, called by 1: vc_capture_media calls 8: vc_catmv_u_decvc_mkdirpsys_openat_wrvc_pace_hookhf_fetch_to_file+2 |
| 397 | func vc_capture_media(store_i: i64, store: *u8, ref_root: *u8, phys_root: *u8, |
| 417 | func vc_items_add(items: *u8, io: i64, cid: *u8) -> i64 |
| 426 | func vc_seen(set: *u8, n: i64, hay: *u8) -> i64 |
| 447 | func vc_page_core(store_i: i64, store: *u8, cpfx: *u8, ref_root: *u8, phys_root: *u8, called by 2: vc_capture_pagevc_capture_site calls 14: sys_mmapvc_catmv_u_decvc_mkdirpsys_openat_wrsys_write+8 |
| 548 | func vc_declare_page_cols(cpfx: *u8, url: *u8, host: *u8, |
| 564 | func vc_report_stats(report: *u8, off: i64, stats: *i64) -> i64 |
| 579 | func vc_capture_page(store_i: i64, store: *u8, cpfx: *u8, ref_root: *u8, phys_root: *u8, |
| 630 | func vc_capture_site(store_i: i64, store: *u8, cpfx: *u8, ref_root: *u8, phys_root: *u8, |
| 775 | func vc_write_file(path: *u8, content: *u8, n: i64) -> i64 |
| 784 | func do_selftest() -> i64 |
| 941 | func vc_usage() -> i64 |
| 946 | func argp(argv: *i64, i: i64) -> *u8 { return (argv[i]) as *u8 } |
| 948 | func vc_atoi(s: *u8) -> i64 |
| 959 | func main(argc: i64, argv: *i64) -> i64 |