code wiki / (root) / nx_mvault_coll.nx

nx_mvault_coll.nx

buildroot/runtime/nx_mvault_coll.nx

12853 B296 linesdepth 6pulls 11 transitivereach 5 importersview sourcekind librarytopic mvault
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_canon_cid.nx nx_registry.nx nx_seg_store.nx nx_mvault_coll.nx nx_mvault.nx nx_mvault_coll_gate.nx nx_mvault_fetch.nx nx_vault_gateway.nx

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

43const MVC_PFX: *u8 = "knowledge/store/mvcoll-\x00"
44const MVC_KP: *u8 = "col:\x00"
45const MVC_IDS: *u8 = "col:ids\x00"
50const MVC_REC_CAP: i64 = 8192
51const MVC_KEY_CAP: i64 = 512
52const MVC_IC_CAP: i64 = 65536

functions

54func mvc_strlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
55func 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 }
60func mvc_colid(kind: *u8, site: *u8, key: *u8, cidout: *u8) -> i64
78func mvc_rec_build(out: *u8, kind: *u8, site: *u8, key: *u8, name: *u8, url: *u8, parent: *u8) -> i64
101func mvc_declare_pfx(prefix: *u8, kind: *u8, site: *u8, key: *u8, name: *u8, url: *u8, parent: *u8, cidout: *u8) -> i64
110func mvc_get_pfx(prefix: *u8, colid: *u8, ptrout: *i64, lenout: *i64) -> i64
called by 1: mvc_get calls 1: reg_get
120func mvc_ci_key(out: *u8, colid: *u8) -> i64
126func mvc_ic_key(out: *u8, item: *u8) -> i64
134func mvc_count_lines(buf: *u8, n: i64) -> i64
151func mvc_batch_add_pfx(prefix: *u8, colid: *u8, items: *u8, items_n: i64) -> i64
259func mvc_items_pfx(prefix: *u8, colid: *u8, out: *u8, cap: i64) -> i64
265func mvc_of_item_pfx(prefix: *u8, item: *u8, out: *u8, cap: i64) -> i64
271func mvc_list_pfx(prefix: *u8, out: *u8, cap: i64) -> i64
called by 2: mvc_listmain calls 1: reg_index
275func mvc_count_pfx(prefix: *u8, colid: *u8) -> i64
288func mvc_declare(kind: *u8, site: *u8, key: *u8, name: *u8, url: *u8, parent: *u8, cidout: *u8) -> i64
called by 1: do_coll calls 1: mvc_declare_pfx
291func mvc_get(colid: *u8, ptrout: *i64, lenout: *i64) -> i64 { return mvc_get_pfx(MVC_PFX, colid, ptrout, lenout) }
292func mvc_batch_add(colid: *u8, items: *u8, items_n: i64) -> i64 { return mvc_batch_add_pfx(MVC_PFX, colid, items, items_n) }
called by 1: do_coll calls 1: mvc_batch_add_pfx
293func mvc_items(colid: *u8, out: *u8, cap: i64) -> i64 { return mvc_items_pfx(MVC_PFX, colid, out, cap) }
called by 1: do_coll calls 1: mvc_items_pfx
294func mvc_of_item(item: *u8, out: *u8, cap: i64) -> i64 { return mvc_of_item_pfx(MVC_PFX, item, out, cap) }
called by 1: do_coll calls 1: mvc_of_item_pfx
295func mvc_list(out: *u8, cap: i64) -> i64 { return mvc_list_pfx(MVC_PFX, out, cap) }
296func mvc_count(colid: *u8) -> i64 { return mvc_count_pfx(MVC_PFX, colid) }