nx_brane.nx
buildroot/runtime/nx_brane.nx
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
imports: nx_syscalls.nxnx_tier.nx
imported by: nx_brane_test.nxnx_cell_anatomy_compose_test.nx
structs
| 71 | struct NxCapToken |
| 81 | struct NxBrane |
consts
| 42 | const NX_CAP_FILE_READ: nx_int = 0 |
| 43 | const NX_CAP_FILE_WRITE: nx_int = 1 |
| 44 | const NX_CAP_NET_EGRESS: nx_int = 2 |
| 45 | const NX_CAP_NET_INGRESS: nx_int = 3 |
| 46 | const NX_CAP_PEER_MESSAGE: nx_int = 4 |
| 47 | const NX_CAP_HARDWARE_IO: nx_int = 5 // GPIO/SPI/etc on MCU |
| 48 | const NX_CAP_KERNEL_SYSCALL: nx_int = 6 // mmap/etc privileged |
| 49 | const NX_CAP_SIGN_AS_SELF: nx_int = 7 // use cell's methyl key |
| 50 | const NX_CAP_DAC_OUTPUT: nx_int = 8 // silicon DAC emit |
| 51 | const NX_CAP_DRONE_ACTUATE: nx_int = 9 // physical drone control |
| 54 | const NX_CAP_N_KINDS: nx_int = 10 |
| 58 | const NX_BR_OK: nx_int = 0 |
| 59 | const NX_BR_ERR_FULL: nx_int = 1 |
| 60 | const NX_BR_ERR_BAD_KIND: nx_int = 2 |
| 61 | const NX_BR_DENIED: nx_int = 3 // no matching capability |
| 62 | const NX_BR_EXPIRED: nx_int = 4 // matching cap is expired |
| 63 | const NX_BR_GRANTED: nx_int = 5 // check succeeded |
| 88 | const NX_BR_TOKEN_BYTES: nx_size = 40 |
functions
| 92 | func nx_cap_kind_is_valid(k: nx_int) -> nx_int |
| 100 | func nx_brane_new(cell_id: nx_int, capacity: nx_size) -> *NxBrane |
| 110 | func _brane_at(b: *NxBrane, idx: nx_size) -> *NxCapToken |
| 120 | func nx_brane_grant(b: *NxBrane, |
| 147 | func nx_brane_check(b: *NxBrane, |
| 178 | func nx_brane_revoke(b: *NxBrane, |
| 214 | func nx_brane_revoke_all(b: *NxBrane) -> nx_int |
| 222 | func nx_brane_count_active(b: *NxBrane, now_us: nx_size) -> nx_int |
| 238 | func nx_brane_token_count(b: *NxBrane) -> nx_size called by 1: main |