nx_doc_vault.nx
buildroot/runtime/nx_doc_vault.nx
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
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
| 37 | const VAULT_OK: i64 = 0 |
| 38 | const VAULT_CHAIN_BROKEN: i64 = 1 |
| 39 | const VAULT_NOT_FOUND: i64 = 2 |
| 40 | const VAULT_FULL: i64 = 3 |
| 43 | const VF_DOC: i64 = 0 // document id (logical doc, e.g. a name hash) |
| 44 | const VF_VER: i64 = 1 // version number (1,2,3...) |
| 45 | const VF_HASH: i64 = 2 // content hash (SHA-256 in the I/O layer) |
| 46 | const VF_SIZE: i64 = 3 // content size in bytes |
| 47 | const VF_CUR: i64 = 4 // 1 = current authoritative copy, 0 = superseded/retired |
| 48 | const VF_TS: i64 = 5 // timestamp |
| 49 | const VF_PREV: i64 = 6 // prev version's content hash (0 for v1) -- the chain link |
| 50 | const VF_SEAL: i64 = 7 // 1 = a D5 e-sign seal is attached to this version |
| 51 | const VF_STRIDE: i64 = 8 |
functions
| 55 | func nx_vault_add(flat: *i64, count: i64, cap: i64, doc_id: i64, chash: i64, size: i64, ts: i64) -> i64 |
| 84 | func nx_vault_current_idx(flat: *i64, count: i64, doc_id: i64) -> i64 |
| 95 | func nx_vault_version_count(flat: *i64, count: i64, doc_id: i64) -> i64 |
| 106 | func nx_vault_current_count(flat: *i64, count: i64, doc_id: i64) -> i64 called by 1: main |
| 118 | func nx_vault_verify_chain(flat: *i64, count: i64, doc_id: i64) -> i64 |
| 144 | func nx_vault_soft_delete(flat: *i64, count: i64, doc_id: i64) -> i64 |
| 152 | func nx_vault_attach_seal(flat: *i64, count: i64, doc_id: i64) -> i64 |
| 162 | func nx_vault_valid_tid(s: *u8) -> i64 |