nx_mvault_coll.nx
buildroot/runtime/nx_mvault_coll.nx
about
nx_mvault_coll.nx -- the vault's COLLECTION / PROVENANCE axis.
WHY THIS EXISTS (operator 2026-07-31: "though we split by media i want to be
able to look by site or album or other tagged or original source groupings"):
the core vault record is {class,type,source,mls,ref} -- five fields, none of
which can say WHICH ALBUM or WHICH SITE an item came from. `source` is a
single flat string ("cam"/"gen"). So grouping by album/site was not merely
missing from the UI, it was UNREPRESENTABLE IN THE SCHEMA.
★★★★★ THE ORDERING LAW THIS ENFORCES: build the grouping axis BEFORE the
downloader. Ingesting albums into a schema that cannot remember their album
would repeat the 07-30 classifier disaster exactly -- 53,567 files typed
`unknown` because the axis was broken while the bulk migration ran, then a
35,615-record backfill to repair it. An axis added AFTER the ingest is a
backfill; added BEFORE, it is free.
DESIGN
A collection is a NAMED GROUPING with a kind: site | album | source | set.
Membership is MANY-TO-MANY -- one file can sit in several albums, and an
album holds many files -- so it is a RELATION, not a field on the item.
That is also why this did not belong on the core record: a `album` field
would have permitted exactly one, and the first re-post would have broken it.
colid = CID of the canonical {kind,site,key} record. DERIVED, never minted:
the same album on the same site always yields the same colid, so declaring
it twice is a no-op and re-running an ingest cannot fork a duplicate
collection (rule 10, idempotent BY CONSTRUCTION rather than by remembering).
Item identity is untouched. The vault keys records by CONTENT CID, so this
plane only ever ADDS relations -- dedup, history and every existing record
keep working unchanged (rule 13, additive-only).
Lives in its OWN store prefix. The mvault mv:ids index is already ~10.7 MiB
at 160,269 items; folding memberships into it would bloat the very index
that just overflowed (see nx_registry.nx 2026-07-31).
license_tier: ORIGINAL
dependencies 4 imports · 4 importers
imports: nx_syscalls.nxnx_canon_cid.nxnx_registry.nxnx_seg_store.nx
imported by: nx_mvault.nxnx_mvault_coll_gate.nxnx_mvault_fetch.nxnx_vault_gateway.nx
structs
| none |
consts
| 43 | const MVC_PFX: *u8 = "knowledge/store/mvcoll-\x00" |
| 44 | const MVC_KP: *u8 = "col:\x00" |
| 45 | const MVC_IDS: *u8 = "col:ids\x00" |
| 50 | const MVC_REC_CAP: i64 = 8192 |
| 51 | const MVC_KEY_CAP: i64 = 512 |
| 52 | const MVC_IC_CAP: i64 = 65536 |
functions
| 54 | func mvc_strlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 55 | func mvc_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){dst[off+i]=s[i]; i=i+1} return off+i } |
| 60 | func mvc_colid(kind: *u8, site: *u8, key: *u8, cidout: *u8) -> i64 |
| 78 | func mvc_rec_build(out: *u8, kind: *u8, site: *u8, key: *u8, name: *u8, url: *u8, parent: *u8) -> i64 |
| 101 | func mvc_declare_pfx(prefix: *u8, kind: *u8, site: *u8, key: *u8, name: *u8, url: *u8, parent: *u8, cidout: *u8) -> i64 called by 3: mvc_declaremainmvf_fetch_album_pfx calls 5: mvc_colidsys_mmapmvc_rec_buildreg_putsys_munmap |
| 110 | func mvc_get_pfx(prefix: *u8, colid: *u8, ptrout: *i64, lenout: *i64) -> i64 |
| 120 | func mvc_ci_key(out: *u8, colid: *u8) -> i64 |
| 126 | func mvc_ic_key(out: *u8, item: *u8) -> i64 |
| 134 | func mvc_count_lines(buf: *u8, n: i64) -> i64 |
| 151 | func mvc_batch_add_pfx(prefix: *u8, colid: *u8, items: *u8, items_n: i64) -> i64 called by 3: mvc_batch_addmainmvf_fetch_album_pfx calls 11: sys_mmapmvc_ci_keymvc_strlenss_getmvc_count_linesreg_id_present+5 |
| 259 | func mvc_items_pfx(prefix: *u8, colid: *u8, out: *u8, cap: i64) -> i64 |
| 265 | func mvc_of_item_pfx(prefix: *u8, item: *u8, out: *u8, cap: i64) -> i64 |
| 271 | func mvc_list_pfx(prefix: *u8, out: *u8, cap: i64) -> i64 |
| 275 | func mvc_count_pfx(prefix: *u8, colid: *u8) -> i64 |
| 288 | func mvc_declare(kind: *u8, site: *u8, key: *u8, name: *u8, url: *u8, parent: *u8, cidout: *u8) -> i64 |
| 291 | func mvc_get(colid: *u8, ptrout: *i64, lenout: *i64) -> i64 { return mvc_get_pfx(MVC_PFX, colid, ptrout, lenout) } |
| 292 | func mvc_batch_add(colid: *u8, items: *u8, items_n: i64) -> i64 { return mvc_batch_add_pfx(MVC_PFX, colid, items, items_n) } |
| 293 | func mvc_items(colid: *u8, out: *u8, cap: i64) -> i64 { return mvc_items_pfx(MVC_PFX, colid, out, cap) } |
| 294 | func mvc_of_item(item: *u8, out: *u8, cap: i64) -> i64 { return mvc_of_item_pfx(MVC_PFX, item, out, cap) } |
| 295 | func mvc_list(out: *u8, cap: i64) -> i64 { return mvc_list_pfx(MVC_PFX, out, cap) } |
| 296 | func mvc_count(colid: *u8) -> i64 { return mvc_count_pfx(MVC_PFX, colid) } |