notes

The interactive boot, migrated

Name: provisional.

An appendix to notes/trusted-init.md, which summarizes it.

The tree in supervision-tree.md proves the pattern with programs written for it. This is the same discipline applied to the boot path a person actually types at: system_initializer (riscv) and hello's init_boot role (aarch64), which until now held the kernel's whole construction budget for life.

The shape, and why it is not the one that was predicted

The prediction recorded here was: the spawn service becomes a sub-server holding the archive and a budget, the progenitor wires the shell to it, and the progenitor drops what it no longer needs. That was not built, and the reason is worth keeping rather than quietly diverging from.

The spawn service is the ELF loader, and the ELF loader is the archive. Moving it out means the sub-server holds the initrd, which is every program in the system. So "it can build exactly one program" (the property that makes spawner worth having) does not survive the move. The sub-server would hold strictly more than the progenitor does today, and the progenitor would hold nothing but a pipe. That is a relocation of the authority, not a reduction of it, and it costs an IPC hop on every capability the shell delegates, because spawn_protocol moves capabilities and not just words.

So the interactive progenitor keeps the loader and gives up three other things instead.

  1. The root construction budget. It carves PROGENITOR_RESERVED_PAGES (128, for its own scratch page tables) and JOBS_BUDGET_PAGES (240, the job pool) off the root untyped and deletes the root. After that it can spend at most those two, and it cannot reach the rest of what the kernel gave it or delegate the root to anything it builds.
  2. The device authority. The UART device capability and the UART receive interrupt go back as soon as the console and input drivers are built, along with aarch64's test SGI and the kernel's report endpoint, which were never part of the interactive system. A progenitor that kept the device could hand the UART to anything it later builds.
  3. Anything that reaches a live job's memory. Each job is built in a region split off the pool, and the progenitor deletes that region capability as soon as the job starts. Since §32 the reap does not need it.

The job pool is bounded because it is renewable

Bounding the progenitor's budget would be a bad trade on its own: a prompt that runs out of memory after thirty commands is worse than a prompt whose progenitor holds too much. What makes it cheap is that the pages come back. Every job is born supervised (§26's spawn-slot convention: a READ view of one endpoint in the reserved fault slot, which START reads and clears), and job_undertaker collects the corpse through Endpoint::REAP. Its entire authority is that one endpoint capability: no untyped, no frame, no TCB, nothing it could build with. The reclaimed region returns to the progenitor's pool, because §13 says a region belongs to whoever owns it and the progenitor is the one who split it. A process that can free a job's memory and can never spend it is exactly what §32 was decided for, and this is its first non-test consumer.

Why a second process rather than the progenitor collecting its own children. There is no non-blocking receive, and the progenitor is parked in RECEIVE on the shell's spawn channel for its whole life. Multiplexing deaths onto that same endpoint was considered and rejected: the shell holds WRITE on it, so a compromised shell could forge death messages, and EVENT_FAULT/EVENT_EXIT (1 and 2) collide with the program ids spawn_protocol already sends in word 0.

Proven, both ISAs

BUGS

One progenitor, and one loader (milestone 96)

This increment left two duplications behind on purpose, and both are gone now.

The larger one was the system itself. user::initial_ramdisk() loaded an archive entry called init. That was fixtures/src/hello.rs's init_boot role on aarch64 and a separate program on riscv64 (milestone 266 (one progenitor, on all three architectures, and init stops being a role) later collapsed both the alias and the two programs into one progenitor). Everything on this page (the six boot components, the giveaway, the negative control, the spawn service) was written once in each. That was about three hundred near-identical lines, and the failure mode is the reason it mattered rather than the line count. A fix that lands in one and not the other is a boot that reaches userspace and prints nothing at all, with no fault and no message. That cost three separate lanes an evening each. It is now crates/system_initializer, and the boot entry is the table of slot numbers its own kernel granted plus a call into it. Those tables are the one thing the boards genuinely disagree about. aarch64's boot path is shared with the test roles of milestone 19d (granular verbs and userspace init). So it grants a report endpoint and a test SGI the interactive system never uses, and numbers everything after them differently. That is data the crate takes (BootEndowment::unused), not code it repeats.

The smaller one was the loader. crates/supervision_contract's child builder was a generalization of the two inits' build_child, so the logic existed three times. This increment added the fault slot to all three rather than unifying them. Unifying loaders and migrating the boot path in one pass would have made a boot failure ambiguous. Milestone 96 (one init: the spawn service written twice) did both, in that order, with script/swish-check between them. supervision_contract's is the tree's only loader now; what it grew is what the inits needed, a capability placed at a named slot (§67's diagnostic stream) and a stack size the caller states. The stack is a field rather than a constant because the two callers honestly differ: four pages is enough for the supervision tree, and a child at the prompt gets twelve because the shell's redirection path found the wall twice.

What the boot keeps, and what it says before the prompt

system_initializer::boot ends by holding a few capabilities for the life of the boot and printing a few sentences. Each has a reason the code cannot show, and they are here.

The file service stays. A directory grant has one delivery mechanism, a caretaker, and the caretaker must hold the file service to attenuate it. The shell's copy carries no GRANT, so only the progenitor can build one. A program spawned without the capability its command line named would be the worst failure this model has. The two slots sit on the progenitor's capability peak for the whole boot, and kernel::cap::CAPABILITY_TABLE_PEAK_MEASURED keeps that account.

The boot terminal's endpoint stays too, and its output page does not. A graphical_terminal session with no virtio keyboard takes its keystrokes from the boot's own line discipline, in raw mode. Only the progenitor can grant a session that endpoint. The shell's copy carries no GRANT, so nothing typed at the prompt can hand the terminal, with its OPERATION_READLINE, to any program it likes. That widening is what milestone 50 (pipes and redirection)'s sink adapter exists to avoid. So the spawn service holds WRITE | GRANT on an endpoint it never receives on, the same shape as the file service pair.

The sentences are printed through the shell's output page, mapped into the progenitor only once the first one is said. So the entropy, network and login outcomes are decided early in boot and said together at the end. The measurement sentence is the load-bearing one. A measured boot's natural bug is for the check to vanish when the build step does not run, and a boot that says nothing looks like one that measured everything. script/swish-check reads the sentence, so a boot that stopped measuring fails the gate. The sentence about how directory grants are delivered is there for the same gate.

The login sentence names its evidence. It reports that identity_provisioner answered IDP_RPT_OK: a credential store exists and holds this identity and secret. It does not claim that login is alive. Knowing that would need login to say so, which is a message, an endpoint and a wait the progenitor does not have. A boot that blocks on a child's readiness hangs when that child is the broken thing. The survival claim lives in script/swish-check instead, which fails a boot whose kernel reported killing a user thread. The password is printed once, because the progenitor's own copy is wiped once identity_provisioner has used it.

The undertaker gets three capabilities and nothing else. READ on the supervision endpoint lets it free a job's memory and never spend it. WRITE on the result endpoint lets it say the one word a killed job cannot say for itself, JOB_FAULTED. WRITE on a copy of the spawn endpoint, badged UNDERTAKER_BADGE, lets it say which job it reaped. Neither WRITE carries GRANT.