nx_module_cas.nx
buildroot/runtime/nx_module_cas.nx
about
nx_module_cas.nx -- content-address NishiLang source modules.
LAYER 2 of nishifamily.com/ide rollout per cardinals:
- feedback-lossless-system-state-archival-cas-merkle-dag-cardinal:
module identity = sha256 of canonical bytes, not filename + mtime.
- global rule 19 (API Contract Stability): the IDE pins each user
program to a specific substrate module-graph root hash. Updates
that change any module flip the root, and the IDE refuses to
silently rebind unless nx_abi_lock blesses the diff as additive.
- global rule 13 (Additive-Only Data): module hashes are computed
once and stored; history is never overwritten.
Manifest shape (canonical byte ordering for reproducibility):
bytes[0..31] = sha256(name_utf8)
bytes[32..63] = sha256(source_utf8)
bytes[64..N] = sequence of (32-byte import_root_hash) per import,
sorted lexicographically before hashing.
merkle_root = sha256(bytes[0..N])
Sealed verdict for integrity checks (NX_MODULE_INTEGRITY_*):
0 INCONCLUSIVE not enough bytes / sha256 not initialised
1 SOURCE_MISMATCH source bytes hash != stored source_hash
2 IMPORT_MISMATCH one or more import roots changed
3 ROOT_MISMATCH name/source/imports recompute to a different root
4 VERIFIED every level matches
genealogy_id: nix_2003_paper + ipfs_merkle_dag + in_toto_2018 +
git_object_model_1991 + ostree_immutable_trees
lineage_id: source_module_content_addressing_q10
nx_safety_envelope:
intended_use: "Content-addressed Merkle DAG of substrate
modules. Foundation for nx_vcs / sovereign
VCS replacement / immutable build provenance"
sil_target: SIL3 (CAS integrity = supply-chain trust;
a corrupt CAS = arbitrary code can
masquerade as audited code)
asil_target: QM
dal_target: DAL B
iec_62304_class: B
dependencies 3 imports · 1 importers
imports: nx_syscalls.nxnx_tier.nxnx_sha256.nx
imported by: nx_module_cas_test.nx
structs
| 68 | struct ModuleManifest { |
consts
| 56 | const NX_MODULE_HASH_BYTES: nx_int = 32 |
| 59 | const NX_MODULE_INTEGRITY_INCONCLUSIVE: nx_int = 0 |
| 60 | const NX_MODULE_INTEGRITY_SOURCE_MISMATCH: nx_int = 1 |
| 61 | const NX_MODULE_INTEGRITY_IMPORT_MISMATCH: nx_int = 2 |
| 62 | const NX_MODULE_INTEGRITY_ROOT_MISMATCH: nx_int = 3 |
| 63 | const NX_MODULE_INTEGRITY_VERIFIED: nx_int = 4 |
| 64 | const NX_MODULE_INTEGRITY_N_VERDICTS: nx_int = 5 |
functions
| 88 | func nx_module_cas_compute_root(m: *ModuleManifest) -> nx_int { |
| 119 | func nx_module_cas_verify(m: *ModuleManifest, expected_root: *u8) -> nx_int { |
| 143 | func nx_module_integrity_verdict_is_valid(v: nx_int) -> nx_int {
called by 1: main |