Add the capability table itself: Capability, CapabilityTable, ObjectRef - #12
Merged
Conversation
RFC-0003's second code increment. The owned, no-Clone Capability<O> value (transfer is a Rust move; the sole duplication is derive - explicit, rights-checked, subset-only, O-2) and the flat per-process CapabilityTable<O, N> of RFC-0003 SS4 Option B: fixed capacity, free-list recycling, O(1) resolution as one index plus two generation checks - slot against handle (the ABA defence, O-1) and object against capability (the destruction half of O-3). Slot generations are bumped at vacate time, so a closed handle dies at the instant of closing, not merely when its slot is reused; a slot whose generation cannot advance is retired outright, capacity being the price of failing closed. A full table hands the capability back in the error rather than dropping it - destroying in-flight authority because the receiver had no room would turn a resource limit into silent revocation. The new ObjectRef trait is everything the table asks of a kernel object: its current generation. The kernel crate implements it when kernel objects exist; a test double implements it today, which is what keeps the whole scheme host-testable. The trait bounds carry the design: insert/remove are object-blind slot mechanics, resolve/derive are the authority checks. All three of the RFC amendment's load-bearing invariants are now stated where they bind - including that a resolve's borrow is held across the caller's whole check-then-act window, the property any future multi-core synchronisation story must preserve. Hardened by an adversarial multi-lens review (RFC conformance, security attack, Rust quality, test coverage) with every finding independently verified, several by mutation testing; all fifteen confirmed findings - documentation precision and test gaps, no behavioural defects - are folded in. Thirty-nine host tests and two doctests: an exhaustive forged-handle sweep for resolve and remove, sibling independence of a derived child from its removed parent, retirement alone and amid live neighbours, free-list LIFO order, the defensive fail-closed branches, and an 8192-operation churn test against a shadow model interleaving inserts, derivations, object destructions and removals. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
RFC-0003's second code increment: the
setonix-capabilitycrate grows from value types into the working mechanism.Capability<O>— owned, deliberately neitherClonenorCopy(§6). Transfer between tables is a Rust move; the sole duplication isderive: explicit, rights-checked, subset-only (O-2). Acompile_faildoctest pinned to E0277 — instantiated with a realObjectReftype, so it guards the instantiation the kernel will actually use — keeps the absence ofClonechecked on every test run. The type is#[must_use]: dropping a capability is a close and must never happen by accident. Minting reads the generation from the object itself, so a capability can never be back-dated.CapabilityTable<O, N>— the flat per-process table of §4 Option B. Fixed capacity (the kernel has no allocator; bounded by construction), free-list recycling, O(1) resolution: one index plus two generation checks — slot vs handle (the ABA defence, O-1) and object vs capability (the destruction half of O-3). Slot generations bump at vacate time, so a closed handle dies the instant it is closed; a slot whose generation cannot advance is retired outright — capacity is the price of failing closed. A full table hands the capability back in the error instead of dropping it: silently destroying in-flight authority would turn a resource limit into revocation.ObjectRef— one method: what generation is the object at now. Everything the table asks of a kernel object; the kernel implements it when kernel objects exist, a test double implements it today, and that is what keeps the security spine host-testable. The trait bounds carry the design:insert/removeare object-blind slot mechanics (transfer plumbing),resolve/deriveare the authority checks.How it was hardened
An adversarial multi-lens review (RFC conformance, security attack, Rust quality, test coverage — 23 agents), every finding independently re-verified against the code, several by mutation testing. All fifteen confirmed findings were documentation precision or test gaps — no behavioural defect survived — and every one is folded in. Notably, the verifiers proved by mutation that
remove's ABA guard and its error-path state restoration were untested; both now have tests that kill those mutants.Verification
compile_failno-Cloneguard — all greenresolveandremovehonour only the exact minted handle); object destruction making parent and derived child inert with no list of holders; a removed parent leaving its derived sibling untouched (no parent link — pinned so RFC-0003a cannot regress it silently); retirement alone and amid live neighbours; free-list LIFO order; both defensive fail-closed branches; an 8192-operation churn test against a shadow model interleaving inserts, subset-random derivations, object destructions, object-blind cleanup and removalscargo clippy -D warnings: clean on host and both Tier-1 bare-metal targets (proving the crate staysno_std)unsafeanywhere in the crateWhat follows (§5.3: small, reviewable increments)
Wiring into the kernel's syscall surface once there are kernel objects to reference; selective revocation once RFC-0003a decides it.
🤖 Generated with Claude Code