154. A process that holds two directory capabilities
Built 2026-09-26 (PR #1346), for the mechanism. Minted 2026-08-23, proposed
independently by two milestones that converge on the same gap: milestone 47's bind ("It is
blocked on a second grant") and milestone 64's File::open fork ("tier two, anything that
traverses, needs a namespace to resolve against, and that is 47's unbuilt half"). Built
2026-08-23: one process holding and resolving against two directory capabilities, on the real
wire. §126 (a real, single, moving cwd), in
design/decisions, decided 2026-08-25 that the holder has one
real, moving position. Built 2026-09-26: the real shell and its grant planner across two trees,
presented as calef ruled that day, "one tree with other trees mounted at names in it" ("The shell
across two trees" below).
Not wired into the boot shell, on calef's instruction: that lands with the first real second filesystem, and it is 0660-a-second-filesystem-mounts-in-the-boot-shell.md.
The gap, in both milestones' own words
47: "A shell holds one directory capability, so a namespace assembled from what it holds has
exactly one member and every bind is an alias inside one tree. The interesting case, and the only
one that pays for the mechanism, is a union of two grants... Nothing in this system grants a
second directory capability to one process. fs_service::start_granted_dir starts one caretaker and
hands one endpoint; a second means a second caretaker, a second slot, and a spawn-protocol position
to say which is which."
64: "Tier two, anything that traverses, needs a namespace to resolve against, and that is 47's
unbuilt half. Path::new("assets").join("x.png"), an absolute path, or a program wanting two
directories all land here."
The deliverable
Both milestones already name it identically: one process, two subtrees, /a/x and /b/y both
resolving, /a/../b refused, and neither caretaker able to see the other's tree. Concretely:
- A second
fs_subtree_caretaker(or equivalent), a second cspace slot, and a spawn-protocol position to say which directory a grant is (an endowment question, per 47's own environment section, "expensive" in the same sense that section already prices). - The negative control that only a union can state:
/a/../brefused, proving neither subtree can name the other's parent. capsgains a namespace section with more than one row, which 47's own text says is currently empty precisely because one root has one row.
What it unblocks
- Milestone 47's
bindfalls out as a name on aCwdper entry once this exists; the mount table itself is "the cheap half" per 47's own finding, already priced. - Milestone 64 (enough
stdto run somebody else's crate): its tier-twoFile::open, anything that joins a path or wants more than the one granted directory, gets a namespace to resolve against. - Milestone 47's
PATHwork, which is the same question scaled to programs rather than files, needs this before its own four open sub-questions are worth deciding in detail.
What this does not decide
The spawn-protocol encoding for "which directory is which" is a real wire-format question (two
programs, the shell and init, must agree), in the same category 47's environment-variable section
already prices as reversible-but-real. Left to whoever builds this, following the existing
DIR_BIT/GRANT_WORDS precedent rather than inventing a new shape.
What was built
Two second-level pieces, host-tested and guest-tested rather than left as design:
grant_plan::nav::TwoRoots(provisional name), pure and host-tested incrates/grant_plan: composes exactly two labeled directory roots. Each label selects one grant's root by an exact match on an absolute path's first component; everything after that resolves through the existingCwd::apply/Cwd::ascend, unmodified. That is the whole mechanism, and it is why/a/../brefuses for free: selectingaleaves nothing abovea's own root to pop, sobis never reached to be a question. It is deliberately notbind: it composes two fixed labels, not an ordered, shadowable union, and 47's four open questions (shadowing, enumeration, whether$PATHsurvives as a string) are untouched.kernel::user::fs_service::start_granted_two_dirs, the endowment mechanism itself: wires a secondfs_subtree_caretakeralongside the first, for one confined program, and delivers both narrowed endpoints into two distinct cspace slots. Slot 0 is always the first grant, slot 1 the second, and that ordering is the spawn-protocol position this milestone decides, deliberately the smallest possible answer rather than a new wire word. Both caretakers share the one FS server a boot has, and both narrowed endpoints map the same shared file-channel frame, safe for the reasonnarrow_dir's own doc already gives one level narrower. The confined program is one thread of control with at most oneCALLin flight.- The guest proof,
kernel/src/user/multi_dir_namespace_tests.rs(one module for both ISAs,dir_capability_tests' reason): a newfs_test_clientrole (ROLE_TWO_DIR) holds both grants at once, told nothing beyond which cspace slot is which. It proves the deliverable literally:/a/innerand/b/secret(the roadmap block's/a/xand/b/y) each resolve throughTwoRootsand then open for real over the caretaker that resolution named./a/../bis refused byTwoRoots::resolvebefore any request is sent. And, independent ofTwoRootsentirely, grant A's endpoint cannot open the name that exists only in grant B's subtree and the reverse. That is the wire-level witness that the endpoint is the boundary (notes/dir-capability.md's structural finding), demonstrated here with two live caretakers instead of inferred from one.
What is now decided, and what is still open
Kept as the 2026-08-25 record. Its labeled presentation (/a/..., /b/..., two labeled caps
rows) was replaced on 2026-09-26 by calef's one-tree ruling; see "The shell across two trees".
DECISIONS §126 closed an ambiguity in the first bullet
below. A two-grant shell gets a real, single, moving cwd. State (which, pos)
in place of one-grant Holdings' bare Cwd, a bare relative name resolves against pos inside
whichever tree which currently names, an absolute /a/...//b/... path both resolves and moves
between trees. .. at either tree's own root refuses exactly the way one-grant Cwd::apply
already refuses at its own root today. That is a real, single answer, not a per-caller choice, and
it does not answer 47's four open questions (unions and shadowing across more than two labeled
sources, enumeration, the compile-time-set-to-runtime-lookup gap, whether $PATH survives as a
string). Those stay exactly as open as they were, since this decision only ever concerned two
disjoint, individually-labeled trees with one position at a time.
-
caps's display andHoldingsare extended, host-tested, to §126's shape (2026-08-25).grant_plan::Holdingsgainssecond: Option<SecondDir>(provisional name), carrying both labels andwhichbeside the existingcwd/pos; a one-grantHoldings(second: None) resolves and prints exactly as it always has, byte for byte (pinned bya_one_grant_holdings_resolves_exactly_as_beforeandholding_a_directory_changes_exactly_one_line_of_the_endowment).Holdings::resolveis the(which, pos)combinator itself, built on a newnav::TwoRoots::resolve_from/apply_frompair (relative stays in the current tree, absolute crosses by label,..refuses at either tree's own root; each a host test incrates/grant_plan/src/nav.rs).crates/swish::write_holdingsprints two directory rows and a namespace section with both labels whensecondisSome. It marks which treecwdcurrently stands in and printing the other at its own root (there is only one remembered position, per §126's "real, single, moving" cwd). This is milestone 154's own line, "capsgains a namespace section with more than one row", made real and tested (a_second_grant_prints_two_rows_and_a_namespace_section).What this increment did not reach, per-command grants carrying their tree, was closed on 2026-09-26 by "The shell across two trees" below.
-
crates/system_initializer::bootcan construct and deliver a second, disjoint directory capability to the shell at boot, mechanically, for real (2026-08-25).boottakes a newsecond_dir: Option<SecondDirGrant>parameter.Somebuilds a secondfs_subtree_caretaker(build_caretaker, the same functionspawn_service's dynamicrm-style grants already use) narrowed toSecondDirGrant::name, and delivers its endpoint into the shell's capability table at the slot after the filesystem pair. It pushes the clock (already told to the shell numerically rather than assumed, per its own existing convention) one slot further out. This is the real init both boards run (user/src/system_initializer.rs,fixtures/src/hello.rs'sinit_bootrole), not a kernel-side test harness.Both real entry points pass
None. What the second subtree should be remains an architect's boot-time policy call (DECISIONS §126), unanswered by this increment on purpose. Two further gaps, recorded rather than hidden. First, this exact path is unverified against a real boot.script/swish-checkis the only thing that runs a real init, nothing types a second grant through it. The capability-table headroom at the point this builds a caretaker is the same spot a past bug already found tight (boot's own# BUGSnote says so). Watch for "reaches userspace and prints nothing" first. Second, and this is the sharper gap: nothing tells the shell process it has a second grant at all._start's threeSTARTwords (role, argument, clock slot) are already fully spoken for, so a shell built with a second grant today would hold a capability its ownNavhas no way to learn the label or slot of.components/src/swish.rs'sholdings()therefore still always reportssecond: None. Closing that gap is a real shell-to-init wire question of its own (a fourthSTARTword, or packing the clock slot and a second-dir slot into the same word). It deserves its own decision rather than a quick encoding chosen under this lane's time pressure. -
The shell-to-init spawn-protocol encoding is built (2026-08-25), following
DIR_BIT's own precedent exactly as this block said it should.grant_plan::spawnprotogainsDIR2_BITandWiring::dir2, a second bit rather than a count, round-tripping independent of the other six flags (host-tested,the_wiring_flags_do_not_collideextended anda_second_directory_grant_is_a_second_bit_not_a_countadded).crates/system_initializer::spawn_service's init-side decode is not yet extended to build a second caretaker whendir2is set: nothing on the shell side ever constructs a two-directoryEndowmentto set the bit with (no manifest declares two directory operands). So this is the wire format alone, ahead of an emitter, in exactly the shapeDIR_BITitself was built in before anything could construct a one-directory grant either.
The shell across two trees, built 2026-09-26
Lane milestone/154-two-directories. The detail is notes/two-trees.md
(provisional name).
- The presentation is calef's 2026-09-26 ruling: one root, and the second tree at a mount point.
pwdprints the mount path.cd ..from a mount point reaches its parent, which is this lane's choice pending an architect (the written ruling leaves it open). An earlier cut of this lane printed per-tree labels (/b/logs) and was replaced the same day. - One resolver.
grant_plan::Holdings::anchorsays where a path starts (where the shell stands, a bound name, or the root),Cwd::applyapplies it, andHoldings::locatesays which tree serves the result. The shell's walk, itsplan_pathand the planner'sdesignateall use it, which also fixedwc /recent/xignoring a bind thatls /recenthonored. - Per-command grants carry their tree:
FileGrantandDirGrantgain a requiredwhich. - A walk carries its endpoint.
swish'sNavholds a secondTree, and every request on a walk's handles goes to that tree's slot, because two caretakers number handles independently. - A correction:
nav::Cwd::ascendleft the popped component behind the depth, so the derivedPartialEqcalled two routes to one position different. - The guest proof is a new
swishrole (ROLE_TWO_TREES, provisional) overstart_granted_two_dirs' caretakers:a_shell_holding_two_trees_moves_between_them_and_crosses_neither, an exact twelve-bit set with four never-allowed bits, on every ISA with an initrd. - A surprise, recorded where it happened: a second, identical pair of caretakers filled the
suite's 256-slot region table, and an unrelated later test failed to load.
start_granted_two_dirsnow reuses a pair asked for twice.
Follow-on
- Milestone 660. Milestone 660 (a second filesystem mounts in the boot shell). Wiring a second filesystem into the boot shell at a mount point, with the transport
calef chose (a named slot and a shared constant holding the mount path). The Gone-and-go-home
behavior for a dead mount, and
rmunder a mount. Its trigger is the first real second filesystem:design/roadmap/0660-a-second-filesystem-mounts-in-the-boot-shell.md. - Milestone 683. Milestone 683 (what
..does at a mount point). What..does at a mount point, which the written ruling leaves open: the shell goes to the mount point's parent, as Unix and Plan 9 do, and an architect is asked to confirm:design/roadmap/0683-what-dot-dot-does-at-a-mount-point.md. - Recorded.
spawnproto::DIR2_BIThas no emitter and no decoder in init, because no manifest declares two directory operands and §170 (how a foreign program is told what to do), as ruled 2026-09-26, grants a named directory per the manifest. Innotes/two-trees.md's BUGS. - Recorded. The planner passes an ~1 KiB
Holdingsby value through four frames, so the globbing witness needed a seventh stack page when it grew. Innotes/two-trees.md's BUGS. - Done.
bindwas built by milestone 47 (navigation and naming) on 2026-08-26 and now points through a mount point: the two-tree witness binds a name to/secondand lists it. - Milestone 47. The four open namespace questions (shadowing across more than two labeled
sources, enumeration, the compile-time-to-runtime lookup gap, and whether
$PATHsurvives as a string) are untouched here and stay 47's, which its own block confirms. - Recorded. The two-root type, the second-directory type and its grant ship as provisional
names, said so where they live, and naming is an architect's. So do this lane's:
Holdings::anchor,locate,place,SecondDir::mounted_at,swish'sTreeandROLE_TWO_TREES, thefixture::twotreesbits, andnotes/two-trees.md.
Index row
Milestones 47 (bind) and 64 (tier-two File::open) independently named the same missing
primitive: nothing granted a second directory capability to one process. BUILT 2026-09-26: one
process holding two trees, and the real shell presenting them as one tree with the second mounted
in it, per calef's ruling. The boot shell gets a second tree with the first real second filesystem.