notes

What a capability can name

Name: provisional, minted 2026-10-23 (UTC) by comments/929-kernel-capabilities.

kernel/src/capability_object.rs is the kernel's half of the capability model: the set of nouns a process can be handed, the capability table's size, and the checks that keep the kernel's rights vocabulary and the ABI's in step. The table itself is crates/capability_table, which is pure logic. The model is §10 (process model: capability-based, microkernel), and nifeos/nife:notes/capabilities.md is the introduction. This note carries the design the file's doc comments link to.

The nouns

Each variant of Object is a decision. What follows is why each is there.

A PageFrame count is NonZeroU64. Every dispatch path derives an end address from the count, and page_frame_map's tail check computes (count - 1) * PAGE_SIZE, so a zero would underflow: a debug build panics and a release build wraps. The type removes the branch at no cost, since the niche keeps Option<Object> the same size. page_frame_run_len is const, so a caller passing a literal gets the refusal at compile time. The count rides on the capability, not on MAP's arguments, so the system call's argument shape is the same for a run as for one page. §102 (a Frame names a run of pages) is the ruling.

What a slot costs

A slot is 32 bytes: Object is as wide as its widest variant, PageFrame, at 24 bytes, plus the rights. §102 priced the slot count on 24 bytes a slot. At 64 slots a table is 2,048 bytes of slots, and the option §102 priced at 12 KiB a thread for 512 slots would be 32 KiB. sched::MAXIMUM_THREADS is 1,024, so every whole-machine figure §102 quoted is larger again. The refusal does not change; the size assertions in cap.rs exist so the number a reader quotes is the one the compiler agrees with.

The table is 64 slots, calef's ruling of 2026-10-04 (UTC) for milestone 754 (the capability table grows to 64 slots), chosen over moving holdings into a new process after a gpu-and-keyboard boot reached 31 of 32. The table lives in its thread's TCB page, cost 1,032 bytes a thread more than 32 slots, and no static memory; the page-fit assertion in crate::thread is the check. The free-slot word is a u64, so 64 is also the ceiling the type allows; going further needs a wider word or a second one. Sizing a table per process is milestone 778 (capability tables sized per process).

A full table fails silently. A progenitor that fills its table dies in user_mode_runtime::trap before a console exists to carry a word, and script/test never boots the real progenitor, so script/swish-check is the gate that does. That is why the size is a measured peak plus headroom.

The peak, recorded

CAPABILITY_TABLE_PEAK_MEASURED is 39, which script/swish-check's aarch64 leg read on 2026-11-11 (UTC) on the boot with a gpu and a keyboard. The progenitor reaches it before it runs boot_self_test. It then still holds the four slots the hand-over grants for the program on a machine with a virtio disk: the kernel's half of the self-test and disk 0's trio (milestone 1063 (the boot self-test's spawning checks run from userspace)). It deletes them once the program finishes. The boot that runs the full script for milestone 892 (a std program at the prompt holds the network and a name resolver) peaks at 37. There the spawn service builds jig install and holds a copy of the boot terminal, which it places as that job's standard input. A boot with no NVMe disk peaks two lower, because the disk tree's endpoint and client-window pool are held for the life of the boot. The peak trace itemizes what sits on the peak.

The record is checked rather than the ceiling, which would only fire on a boot that had already died. When the console line fires, measure, update the record, and re-read the headroom before raising the slot count. Every slot held for the life of the boot is one slot on the peak.

report_peak runs in the scheduler's idle loop, the one place reached after every phase of a boot and by definition not busy. It waits for the mark to stay still for 16 idle passes. With a window of one, an aarch64 interactive boot printed six lines on its way up, because the progenitor blocks on IPC several times while it builds the login stack and each pause looked like an ending. At 16 it prints one. The window is a coalescing window, not a margin on the measurement: getting it wrong costs an extra line or a later one, and it cannot make the peak wrong, because the peak never decreases.

The test kernel counts and does not print. The guest suite's transcript is a gate's input, and a third writer in the middle of it would split a test name. The interactive boot's record would also be the wrong yardstick for the suite's much larger workload.

Two rights vocabularies, one meaning

moho_abi::rights is the word that travels in a system call register, from the progenitor's grant tables to every SEND_CAPABILITY and CAPABILITY_INSERT in components/ and fixtures/. capability_table::Rights is what the kernel means by one. They are two arrays of numbers in two dependency-free crates that cannot see each other, so cap.rs compares them at compile time.

The failure this closes is a right added to one crate and not the other. A bit in moho_abi::rights missing from Rights::ALL is a right userspace can name that Rights::from_bits masks to zero, so a delegation asking for it succeeds and confers nothing. A bit in ALL with no ABI name is a right the kernel honors that no caller can ask for, which is how a hand-listed set drifts into granting more than any manifest says. The system call path narrows with a1 as u32, so a right at bit 32 or above would be truncated to nothing on the way in; an assertion stops anyone defining one.

What a budget's rights mean

A retype mints the budget's rights (calef's ruling (a), 2026-10-07 UTC, PR #1798; milestone 824 (a retype mints no right its budget lacks)). What a budget carries is therefore what everything carved from it carries.

A leaf's budget is every right but GRANT. With WRITE alone a leaf could not wait on its own notification, receive on its own rendezvous or join its own process. On the region itself READ and BIND are consulted by no method, and ENUMERATE only by MemoryRegion::USAGE, which answers what the holder's own budget was spent on, so the extra rights confer nothing over the region. GRANT is the one left out: a leaf cannot lend its budget or anything it carves from it. A builder that must lend what it makes gets a budget with GRANT.

The root budget the progenitor receives carries Rights::ALL, so it is where every right on every object comes from: the progenitor's processes need BIND to hand a std program its own process. ALL rather than a list, because a list stops being full the next time a right is added. Rights only narrow below the root: a SPLIT child inherits its parent's, through the mint_child the split_never_widens_rights proof covers, and CAPABILITY_INSERT narrows again. ENUMERATE flows down every split, so the progenitor can hand a job budget's holder a view narrowed to ENUMERATE alone, which is free's "yours" line. A holder that could already spend, split and destroy the region learns nothing new by asking what it spent, the argument §114 (pmap gets its listing) made for the address-space object.

BUGS