Skip to content

feat(capability): value types for the capability table (RFC-0003, part 1) - #11

Merged
MatejGomboc merged 1 commit into
mainfrom
feat/capability-value-types
Jul 30, 2026
Merged

feat(capability): value types for the capability table (RFC-0003, part 1)#11
MatejGomboc merged 1 commit into
mainfrom
feat/capability-value-types

Conversation

@MatejGomboc

Copy link
Copy Markdown
Member

Summary

The accepted capability design (RFC-0003) becomes code β€” the first increment, and the first time paper meets a compiler. A new no_std crate setonix-capability holds the pure logic of the capability spine, in its own crate so it can be host-unit-tested (a bare-metal target has no test harness, and this is the kernel's most security-critical logic).

This part is the value types; the owned no-Clone Capability and the flat table follow next (Β§5.3 β€” small, reviewable steps).

  • Rights β€” closed bitmask; only attenuation is diminish (subset-only). O-2 is a type property: no constructor from arbitrary bits, no operation that widens. Exhaustive test over all 32 combinations confirms a successful diminish is always a subset of its source.
  • Generation β€” 64-bit, fail-closed on exhaustion (the RFC-0003 amendment made concrete); the mechanism behind O-1 reuse and O-3 destruction.
  • Handle β€” index + generation; the userspace-facing name, no authority by itself.
  • CapabilityError β€” fail-closed for every operation.

Crate doc scopes the compile-time claim to kernel-internal handling per the prior-art amendment (the borrow checker can't span protection domains).

Which pillar does this serve?

Pillar 2 β€” the capability system's enforcement mechanism, now executable.

Borrow Ledger

Microkernel core (capabilities) β€” write ourselves, AI-first authorship under amended Β§5.3, maintainer reviews line by line. Pure logic, no unsafe, no assembly β€” ordinary review, not the boot/asm sparring-partner regime.

unsafe register

  • New unsafe blocks: None. The crate is safe Rust throughout; unsafe_code = "deny" (workspace) applies with no opt-in module.

Checklist

  • Builds for both Tier-1 targets (proves no_std); clippy clean under -D warnings
  • 12 host unit tests pass; formatted; spelling, pins, markdown clean
  • CI gains a capability host-test group + per-target build
  • CHANGELOG.md updated; CLAUDE.md layout notes the crate + the host-test pattern
  • Commits GPG-signed

Standalone for now; the kernel links it once there are kernel objects for capabilities to reference.

πŸ€– Generated with Claude Code

…t 1)

The accepted capability design turns into code, first increment. A new
no_std workspace crate, setonix-capability, holds the pure logic of the
capability spine so it can be host-unit-tested β€” a bare-metal target has no
test harness, and this is the most security-critical logic in the kernel,
so it lives where it can be exercised exhaustively away from the hardware.

This part is the value types the flat table is built from, each carrying a
compiler-checked invariant rather than a rule a reviewer must remember:

  - Rights: a closed bitmask (DUPLICATE, TRANSFER, READ, WRITE, REVOKE)
    whose sole attenuation operation, diminish, is subset-only. O-2
    (non-widenability) is a property of the type β€” there is no constructor
    from arbitrary bits and no operation that adds a right. An exhaustive
    test checks over all 32 combinations that a successful diminish returns
    a subset of its source.
  - Generation: a 64-bit counter, fail-closed on exhaustion (next returns
    None rather than wrapping to a value a stale handle could match). This
    is the mechanism behind O-1's reuse case and O-3's destruction case,
    and the fail-closed width is the RFC-0003 amendment made concrete.
  - Handle: the userspace-facing name β€” a table index plus the generation
    its slot held when minted. Carries no authority by itself.
  - CapabilityError: a fail-closed error for every table operation.

Per the RFC-0003 prior-art amendment, the crate doc states plainly that the
compile-time guarantees cover the kernel's internal handling; the
userspace-observable cross-process transfer is a runtime table operation
the generation scheme secures β€” the borrow checker cannot span protection
domains, so the crate does not pretend it does.

Authorship is AI-first under amended Β§5.3; this is pure architecture-
independent logic with no unsafe and no assembly, so it is ordinary
review, not the boot/asm sparring-partner regime. The crate is standalone
for now β€” the kernel wires it in once there are kernel objects for
capabilities to reference.

Verified locally: fmt, spelling, pins, markdown clean; clippy clean under
-D warnings; 12 host tests pass; builds for both Tier-1 targets (proving it
stays no_std). CI gains a capability host-test group and a per-target build.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@MatejGomboc
MatejGomboc merged commit fe600c8 into main Jul 30, 2026
6 checks passed
@MatejGomboc
MatejGomboc deleted the feat/capability-value-types branch July 30, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant