code wiki / _hdl_build / nx_nishifs_cid.nx
nx_nishifs_cid.nx
buildroot/runtime/_hdl_build/nx_nishifs_cid.nx
about
nx_nishifs_cid.nx -- ladder C2 (the FILE SYSTEM): NishiFS CORE = a content-addressed (CID/Merkle) object store.
This is the rung that turns the OS+FS design's headline exceed axis from DESIGN-TARGET into MEASURED reality.
June-2026 research (deep-research wf_b31a496b-971): dm-verity is fixed-ADDRESS Merkle (not hash-keyed retrieval),
composefs verifies in USERSPACE, and APFS/ext4 have NO data checksums. NishiFS goes content-ADDRESSED: every
object is stored BY its sha256 (the CID), git/IPFS-style, at /tmp/nishifs/<cidhex>. Properties, all proven here:
* content-addressed put/get: store a blob -> get its CID; retrieve BY CID -> the bytes back.
* INTEGRITY-ON-READ: cid_get returns bytes ONLY if they re-hash to the requested CID (tamper -> caught).
* DEDUP by construction: identical content -> identical CID -> one object.
* MERKLE directory: a dir = (name,childCID) entries; the dir's CID = sha256(serialized) -> the whole-tree
state is ONE root CID, so changing ANY leaf changes the root (tamper-evident whole-FS state).
composes nx_sha256 (CID = sha256, proven in the C3 installer) + nx_syscalls. CoW snapshots, mount/format onto a
C1 partition, and native encryption are the NEXT rungs.
NEVER-BRICK (Rule 26): writes FILES only (under /tmp/nishifs); no /dev, no firmware. expect_exit: 0 license_tier: ORIGINAL
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_itoa_lib.nxnx_sha256.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 19 | const GET_OK: i64 = 0 |
| 20 | const GET_NOTFOUND: i64 = 3 |
| 21 | const GET_INTEGRITY_FAIL: i64 = 7 |
functions
| 23 | func ui_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 28 | func ui_num(v: i64) -> i64 { nxi_out(v); return 0 } |
| 29 | func ui_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } called by 1: main |
| 30 | func cid_eq(a: *u8, b: *u8) -> i64 { var i: i64=0; while i<32 { if a[i]!=b[i] { return 0 } i=i+1 } return 1 } |
| 33 | func cid_hex(cid: *u8, out: *u8) -> i64 |
| 49 | func obj_path(hex: *u8, out: *u8) -> i64 |
| 58 | func w_file(path: *u8, buf: *u8, n: i64) -> i64 { let fd: i64=sys_openat_wr(path, 0x1a4); if fd<=0 { return 0-1 } sys_write(fd, buf, n); sys_close(fd); return 0 } |
| 61 | func cid_put(blob: *u8, n: i64, cidout: *u8) -> i64 |
| 70 | func cid_get(cid: *u8, out: *u8, cap: i64, lenout: *i64) -> i64 |
| 89 | func dir_serialize(nA: *u8, cA: *u8, nB: *u8, cB: *u8, out: *u8) -> i64 called by 1: main |
| 101 | func main() -> i64 |