Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/docs/CAPABILITY_ABI.md # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / docs / CAPABILITY_ABI.md` 58 lines ยท 3702 bytes Raw Blame History Rendered 1 # Capability ABI: one production authority, one separate Rust implementation 2 3 Ruling of the ABI qualification (abi-qual, 2026-10-11). The two capability implementations in this 4 repository are intentionally independent. They are not two builds of one binary contract, and they 5 must never be linked in place of each other. 6 7 | | Native C authority (production ABI) | Rust crates (separate implementation) | 8 |---|---|---| 9 | Source | `native/capability/aienos_capability.{h,c}` | `crates/aienos-capability` (core, `no_std`), `crates/aienos-capability-ffi` (C binding) | 10 | Generation | 64 bits, `AIENOS_CAP_GENERATION_BITS` = 64 | 32 bits, `AIENOS_CAP32_GENERATION_BITS` = 32 | 11 | `AienosCapRef` | 16 bytes, align 8, generation at offset 8 | 8 bytes, align 4, generation at offset 4 | 12 | `AienosCapEntry` / `AienosCapMint` | 88 / 64 bytes | 64 / 48 bytes | 13 | Exported symbols | `aienos_cap_*` | `aienos_cap32_*`, plus `aienos_cap32_abi_layout` (ABI version 1) | 14 | Who links it | omega (`libaienos_capability.a` merged into `librx_compose.a`, header copy `src/runtime/aienos_cap.h`), `native/argus` | nothing in this repository | 15 16 ## Why the separate prefix 17 18 Before this ruling the Rust FFI crate exported the same 17 function names as the C library with the 19 smaller layout. A program compiled against `aienos_capability.h` and linked against 20 `libaienos_capability_ffi.a` resolved every symbol and silently misread every `AienosCapRef` and 21 `AienosCapEntry`. With the `aienos_cap32_` prefix that program now fails to link. 22 23 The 32-bit generation is not widened: the Rust crates keep their own contract, and a slot whose 24 generation reaches `u32::MAX` fails closed (`ERR_EXHAUSTED`) instead of wrapping. 25 26 ## What enforces it 27 28 - `native/capability/aienos_capability.c`: `_Static_assert`s pin the production layout. 29 - `crates/aienos-capability-ffi/src/lib.rs`: `const` layout asserts and `aienos_cap32_abi_layout`, 30 which reports `AienosCapRef` size, generation offset, generation size and `AienosCapEntry` size. 31 - `scripts/cap_abi_isolation_test.sh`: builds both archives and fails unless they share no 32 `aienos_cap*` symbol, a C caller of `aienos_cap_*` fails to link against the Rust archive, a cap32 33 caller links against it, and a drifted C header (narrowed or reordered `AienosCapRef`) is rejected. 34 - CI: the `capability-abi` job in `.github/workflows/native-suites.yml` runs the C rule tests, the 35 Rust crates' fmt, clippy and tests, and the isolation script. 36 37 ```bash 38 make -C native/capability test 39 cargo test -p aienos-capability -p aienos-capability-ffi 40 bash scripts/cap_abi_isolation_test.sh # ends with AIENOS_CAP_ABI_ISOLATION: PASS 41 ``` 42 43 ## Restart fix brought to the Rust side 44 45 The Rust authority had the restart defect the C authority fixed in `b1fa747`: a restart started the new 46 table at the old boot generation + 1, which a reclaim had already used, so a reference minted after 47 one reclaim validated again after the restart. `aienos_cap32_restart` now starts the new table at or 48 above `AuthorityState::generation_floor()` of the table it replaces (`take_boot_gen_above`), and 49 refuses with `ERR_EXHAUSTED` when no such start exists. 50 51 ## Known differences (not interchangeable, by design or still open) 52 53 - The C authority also seeds a restart from `CLOCK_BOOTTIME` so a new process starts above an old one 54 on the same boot. The `no_std` Rust core has no clock: its starts are monotonic within one process 55 only. 56 - The C `auth_use` requires privileged operations to present an entry on `AIENOS_CAP_RES_AUTHORITY` 57 (issue #266, `docs/CAPABILITY_AUTHORITY_RESOURCE.md`). The Rust core does not have that check yet. 58 Nothing links the Rust crates today; port the check before any consumer does.