code wiki / (root) / nx_doc_vault.nx

nx_doc_vault.nx

buildroot/runtime/nx_doc_vault.nx

7012 B177 linesdepth 2pulls 2 transitivereach 14 importersview sourcekind librarytopic doc
docsdependenciesstructsconstsfunctions

about

nx_doc_vault.nx -- LEGAL RUNG D1: per-tenant document vault (retention core). module: nishi-core.legal.doc_vault capability: LEGAL_DOC_VAULT The storage + audit home for D5 seals, encoding the registry's retention requirements as invariants BY CONSTRUCTION: ADDITIVE-ONLY (Rule 13) -- a new version never overwrites or removes an old one; soft-delete only demotes is_current. History is sacred. SINGLE AUTHORITATIVE COPY -- exactly one is_current=1 per doc (UETA Section 16) = the authoritative copy. VERSIONED + TAMPER-EVIDENT -- each version links prev_hash == (UETA Section 12) prior version's content_hash, so any alteration of a non-final version breaks the chain (the I/O layer adds recompute-SHA256-vs-stored for the final version). PER-TENANT ISOLATION -- vault index lives at the tenant's (MRPC 1.6 confidentiality) private prefix <base><tid>.docvault; tenant-id validated [A-Za-z0-9_-] only (no '.'/'/' -> no cross-tenant traversal), the proven nx_vizsla_tenant discipline. Representation: a flat i64 record array (caller-allocated; substrate scale- agnostic, no internal allocation) -- record r, field f at flat[r*VF_STRIDE+f]. content_hash is an i64 in this logic core; the I/O layer stores the full SHA-256 digest and the chain comparison is identical. Composes: nx_syscalls (tenant-id validation). Distinct from nx_vizsla_tenant because: that shards CONTACTS/relate data; this shards VERSIONED DOCUMENTS with a tamper-evident chain. license_tier: ORIGINAL lineage_id: nishi_doc_vault_d1

dependencies 1 imports · 14 importers

nx_syscalls.nx nx_doc_vault.nx nx_doc_annotate_gate.nx nx_doc_envelope_gate.nx nx_doc_serve_gate.nx nx_doc_vault_gate.nx nx_legal_blob_gate.nx nx_legal_portal.nx nx_legal_portal_boot.nx nx_legal_portal_boot_gate.nx nx_legal_portal_daemon.nx nx_legal_portal_gate.nx

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

imports: nx_syscalls.nx

imported by: nx_doc_annotate_gate.nxnx_doc_envelope_gate.nxnx_doc_serve_gate.nxnx_doc_vault_gate.nxnx_legal_blob_gate.nxnx_legal_portal.nxnx_legal_portal_boot.nxnx_legal_portal_boot_gate.nxnx_legal_portal_daemon.nxnx_legal_portal_gate.nxnx_legal_portal_live_gate.nxnx_legal_portal_post_gate.nxnx_legal_store.nxnx_legal_store_gate.nx

structs

none

consts

37const VAULT_OK: i64 = 0
38const VAULT_CHAIN_BROKEN: i64 = 1
39const VAULT_NOT_FOUND: i64 = 2
40const VAULT_FULL: i64 = 3
43const VF_DOC: i64 = 0 // document id (logical doc, e.g. a name hash)
44const VF_VER: i64 = 1 // version number (1,2,3...)
45const VF_HASH: i64 = 2 // content hash (SHA-256 in the I/O layer)
46const VF_SIZE: i64 = 3 // content size in bytes
47const VF_CUR: i64 = 4 // 1 = current authoritative copy, 0 = superseded/retired
48const VF_TS: i64 = 5 // timestamp
49const VF_PREV: i64 = 6 // prev version's content hash (0 for v1) -- the chain link
50const VF_SEAL: i64 = 7 // 1 = a D5 e-sign seal is attached to this version
51const VF_STRIDE: i64 = 8

functions

55func nx_vault_add(flat: *i64, count: i64, cap: i64, doc_id: i64, chash: i64, size: i64, ts: i64) -> i64
84func nx_vault_current_idx(flat: *i64, count: i64, doc_id: i64) -> i64
95func nx_vault_version_count(flat: *i64, count: i64, doc_id: i64) -> i64
called by 2: mainmain
106func nx_vault_current_count(flat: *i64, count: i64, doc_id: i64) -> i64
called by 1: main
118func nx_vault_verify_chain(flat: *i64, count: i64, doc_id: i64) -> i64
called by 2: mainmain
144func nx_vault_soft_delete(flat: *i64, count: i64, doc_id: i64) -> i64
called by 1: main calls 1: nx_vault_current_idx
152func nx_vault_attach_seal(flat: *i64, count: i64, doc_id: i64) -> i64
called by 2: mainmain calls 1: nx_vault_current_idx
162func nx_vault_valid_tid(s: *u8) -> i64
called by 4: mainmainmainls_path