nx_asset_catalog.nx
buildroot/runtime/nx_asset_catalog.nx
about
nx_asset_catalog.nx -- UNIVERSAL ORGANIZATION TOOLING arc, R1.
Turns the R0 content-addressed asset RECORDS (nx_asset_record) into an actual CATALOG: the single
source-of-truth inventory (org_research.tsv CONFIRMED dam-ssot-catalog) with ingest / list /
get-by-CID, IDEMPOTENT re-ingest, and DEDUP-by-CID (content-addressed-dedup: identical content ->
exactly ONE record, never a second copy). This is PURE COMPOSITION -- zero new storage/identity:
* record identity + bytes -> nx_asset_record (ar_cid -> the record's CID = its catalog key)
* durable append-only KV -> nx_seg_store (ss_open snapshot + ss_hget / ss_begin+ss_add+
ss_commit), same store the records already use
THE CATALOG = the set of record CIDs held in ONE seg_store. Membership/order is tracked by a
single reserved index key whose value is the newline-joined list of member CIDs (one append per
NEW record). Because seg_store is content-addressed + last-writer-wins per key:
* a record is stored under its CID -> re-storing identical bytes is a no-op by content
* the index key (CAT_IDX) is re-committed -> the newest segment shadows the old list
so DEDUP and IDEMPOTENCE both fall out of the substrate, and ADDITIVE law #13 holds (a DUP writes
nothing; the prior record + index history stay on disk, never deleted).
LAWS: #9 single responsibility (each cat_* does ONE thing); #10 idempotent (re-ingest == DUP,
count unchanged); #13 additive (dedup COLLAPSES to one record, never destroys history); #15 DRY
(composes R0 + the store, no copied boilerplate). No hardware/persistent-firmware writes (#26).
API:
cat_ingest(prefix, bytes, n, out2) -> 0 ok / <0 err; out2[0]=status (CAT_NEW|CAT_DUP),
out2[1]=unused; the record's CID is written into `cidout`
via the cat_ingest_cid variant (see below).
cat_get(prefix, cid, ptrout, lenout) -> 1 found / 0 tombstoned / -1 absent (ss_hget semantics)
cat_list(prefix, out_cids, cap) -> count of CIDs written into out_cids[] (ptrs to NUL-term)
cat_count(prefix) -> number of records in the catalog (>=0)
license_tier: ORIGINAL
dependencies 4 imports · 16 importers
diagram shows first 10 each side; +0 more imports, +6 more importers in the complete lists below.
imports: nx_syscalls.nxnx_canon_cid.nxnx_seg_store.nxnx_asset_record.nx
imported by: nx_asset_catalog_gate.nxnx_asset_dashboard_gate.nxnx_asset_dashboard_lib.nxnx_asset_exceed_gate.nxnx_asset_ingest_lib.nxnx_asset_ingest_real.nxnx_asset_ingest_real_gate.nxnx_asset_merkle.nxnx_asset_merkle_gate.nxnx_asset_search.nxnx_asset_search_gate.nxnx_asset_signals.nxnx_asset_signals_gate.nxnx_asset_status.nxnx_asset_status_gate.nxnx_library.nx
structs
| none |
consts
| 35 | const K_MAGIC_4096: i64 = 4096 |
functions
| 38 | func CAT_NEW() -> i64 { return 1 } |
| 39 | func CAT_DUP() -> i64 { return 2 } |
| 42 | func cat_idx_key() -> *u8 { return "__nx_catalog_index__\x00" as *u8 } |
| 44 | func cat_strlen(s: *u8) -> i64 called by 1: cat_ingest_cid |
| 55 | func cat_idx_load(h: *i64, out_cids: *i64, cap: i64) -> i64 |
| 86 | func cat_idx_has(cids: *i64, n: i64, cid: *u8) -> i64 |
| 100 | func cat_ingest_cid(prefix: *u8, bytes: *u8, n: i64, cidout: *u8, out2: *i64) -> i64 |
| 147 | func cat_ingest(prefix: *u8, bytes: *u8, n: i64, out2: *i64) -> i64 |
| 154 | func cat_get(prefix: *u8, cid: *u8, ptrout: *i64, lenout: *i64) -> i64 |
| 160 | func cat_list(prefix: *u8, out_cids: *i64, cap: i64) -> i64 called by 11: maindp_asset_listgt_img_metamr_rootmr_containsas_by_field+5 calls 2: ss_open_cachedcat_idx_load |
| 170 | func cat_count(prefix: *u8) -> i64 called by 11: mainpx_deduppx_unifiednc_distinctmaingt_doc+5 calls 3: ss_open_cachedsys_mmapcat_idx_load |