code wiki / (root) / nx_brane.nx

nx_brane.nx

buildroot/runtime/nx_brane.nx

8486 B240 linesdepth 2pulls 2 transitivereach 2 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_brane.nx -- capability-token cell membrane. Per [[feedback-naming-discipline-no-industry-competitor-overlap]]: "nx_brane" replaces the "container" semantic in cardinal naming. A brane is the cell's membrane -- the boundary that controls what crosses (capability tokens for IO, network egress, file system access, peer messages, etc). THE CORE SECURITY PRIMITIVE. Every IO operation a cell attempts goes through brane capability checks. No capability token = no crossing. This is what makes the substrate's per-cell isolation real (not just a convention). Per Captain Moroni doctrine: every IO is a potential attack vector. Default is DENY; capabilities are explicitly granted at cell instantiation. Granted capabilities can expire (auto-revoke). Composes: nx_cell -- each cell has its own brane nx_restriction -- IO-boundary gate composes brane checks with methyl + pamp + crispr verdicts nx_xenocell -- hostile foreign agent's brane has zero legit capabilities by construction nx_provenance_chain -- capability-check decisions are transforms V1 ships: - sealed enum NxCapKind (10 capability classes) - struct NxCapToken (kind + scope + expires_us + originator) - struct NxBrane with capability_tokens ring - grant + revoke + check + count_active verbs Gap list (V1 honest perf verdict): - capabilities are flat; no hierarchical scopes (V2 adds nesting) - no automatic refresh on near-expiry (caller polls) - cap_check is O(n) linear scan (V2 hash-index if N > ~32)

dependencies 2 imports · 2 importers

nx_syscalls.nx nx_tier.nx nx_brane.nx nx_brane_test.nx nx_cell_anatomy_compose_test.nx

imports: nx_syscalls.nxnx_tier.nx

imported by: nx_brane_test.nxnx_cell_anatomy_compose_test.nx

structs

71struct NxCapToken
81struct NxBrane

consts

42const NX_CAP_FILE_READ: nx_int = 0
43const NX_CAP_FILE_WRITE: nx_int = 1
44const NX_CAP_NET_EGRESS: nx_int = 2
45const NX_CAP_NET_INGRESS: nx_int = 3
46const NX_CAP_PEER_MESSAGE: nx_int = 4
47const NX_CAP_HARDWARE_IO: nx_int = 5 // GPIO/SPI/etc on MCU
48const NX_CAP_KERNEL_SYSCALL: nx_int = 6 // mmap/etc privileged
49const NX_CAP_SIGN_AS_SELF: nx_int = 7 // use cell's methyl key
50const NX_CAP_DAC_OUTPUT: nx_int = 8 // silicon DAC emit
51const NX_CAP_DRONE_ACTUATE: nx_int = 9 // physical drone control
54const NX_CAP_N_KINDS: nx_int = 10
58const NX_BR_OK: nx_int = 0
59const NX_BR_ERR_FULL: nx_int = 1
60const NX_BR_ERR_BAD_KIND: nx_int = 2
61const NX_BR_DENIED: nx_int = 3 // no matching capability
62const NX_BR_EXPIRED: nx_int = 4 // matching cap is expired
63const NX_BR_GRANTED: nx_int = 5 // check succeeded
88const NX_BR_TOKEN_BYTES: nx_size = 40

functions

92func nx_cap_kind_is_valid(k: nx_int) -> nx_int
called by 2: nx_brane_grantmain
100func nx_brane_new(cell_id: nx_int, capacity: nx_size) -> *NxBrane
called by 2: mainmain calls 1: sys_mmap
110func _brane_at(b: *NxBrane, idx: nx_size) -> *NxCapToken
120func nx_brane_grant(b: *NxBrane,
147func nx_brane_check(b: *NxBrane,
called by 2: mainmain calls 1: _brane_at
178func nx_brane_revoke(b: *NxBrane,
called by 1: main calls 1: _brane_at
214func nx_brane_revoke_all(b: *NxBrane) -> nx_int
called by 2: mainmain
222func nx_brane_count_active(b: *NxBrane, now_us: nx_size) -> nx_int
called by 1: main calls 1: _brane_at
238func nx_brane_token_count(b: *NxBrane) -> nx_size
called by 1: main