158. A program is declared once: the archives read Cargo.toml, and the shell's table is one macro
Milestone 150 (adding a program should not need eight hand-maintained lists) chose this as a reversible implementation choice inside its own milestone (AGENTS.md: a reversible decision is made by whoever is holding the problem). Two things it touches are calef's and are not decided here; they are listed under "Not decided" below.
What was decided
Adding a program to this tree meant writing the same fact into eight hand-maintained places, and
three successive stranger-test runs named that as the highest-value defect a newcomer could fix
(milestone 150's block has the history). After this section a program is declared in one place,
its [[bin]] block, plus one row in crates/grant_plan if the shell can spawn it. Everything
else is generated from those or checked against them.
- The archive list is the
[[bin]]blocks.xtask'sdeclared_programs()reads the[[bin]]blocks ofcomponents/andfixtures/, and all three initrd builders pack that list. The per-architectureentriestables are deleted. The reader refuses a[[bin]]key it does not know rather than silently dropping a program. - Every archive packs every program. When the two tables were deleted they disagreed about
three programs (
serial_driver,jh7110_entropy,pmap) and none of the differences was a decision. A test that cannot run on an architectureskip!()s with its reason, as before. - The shell's program table is one
macro_rules!declaration (programs!, provisional name), generating theProgenum,name(),id(),from_id(),from_name(),Prog::ALLandPROG_COUNT.manifest()stays a hand-written match, because the compiler already demands its arm and the arms are the most commented code in the crate (rustfmtdoes not format inside a macro). - Wire ids are written, never positional. The thirteen ids shipped before 2026-09-19 are pinned
by a test that refuses renumbering and reuse.
PROG_COUNTis one past the highest id, so removing a program leaves a hole rather than renumbering its successors, which would be a wire-format change dressed as a deletion. - The count gate is three relationship checks, not a pinned number: a spawnable program with no
binary, a program the tree loads by name with no binary, and a spawnable program no
SWISH_CHECK_SCRIPTline runs. A pinned total would be one more hand-maintained number, failing on every legitimate addition. swish's exhaustive render match became a wildcard, backed by a test that every program answering in words renders its answer. Eleven of its thirteen arms were empty, so the compile error asked for a keystroke rather than a decision. This is rung two in place of rung one, on purpose, and it is the one place the milestone went down the ladder.
xtask now depends on grant_plan. That is an in-tree crate with no external dependencies, so it
is not a §46 dependency decision.
What was considered and why each lost
- A shared crate holding a
consttable of programs. Still a second list besideCargo.toml, gated rather than hand-copied, so adding a program stays two edits. It would earn its place only if the kernel needed the list at runtime, and everything that loads a program looks it up by name. cargo metadatainstead of readingCargo.toml. Correct by construction, but JSON, andxtaskhas no JSON parser; §46 refusesserde_jsonortomlfor one list. Hand-scanning JSON is no less fragile than scanning the four keys this tree writes in a[[bin]]block.- Per-architecture tables gated against each other. They had already diverged without anyone deciding it, and the shared table's own comment said not to filter by architecture.
- A derive crate that counts variants (
strumand the like). A proc-macro dependency in a crate the kernel and the progenitor link, for one count, is what §46 exists to refuse. - A
consttable of(Prog, id, name)beside a hand-written enum. Still two lists; a variant without a row is the original bug moved one line down. manifest()inside the macro. One fewer edit, but the edit it removes was never silent, and it would take the crate's most-read code out ofrustfmt's reach.- Ids from declaration order. Refused for the wire-format reason in item 4.
Not decided here, and whose they are
PROG_COUNT's name. It now means "one past the highest id", not a count of programs. Renaming it is a naming decision and calef's (design/naming.md).- Whether a program may take both an argument and an input. Kept as today's behavior;
design/roadmap/0498-a-program-that-takes-an-argument-and-an-input.mdcarries the options and recommends keeping it. - Every name the milestone introduced (
programs!,Prog::ALL,declared_programs,declared_program_blobs,bin_names,check_declared_programs,PROGRAM_PACKAGES) is provisional.
Reversibility
The mechanism is code and can be rewritten in an afternoon. The one irreversible fact near it is the wire ids, and item 4 is what keeps them where they were. Milestone 198 (the package manager) is the consumer most likely to want this changed, since installing a program is exactly "add a declaration"; whatever 198 decides about the package format supersedes item 1 without disturbing item 4.
BUGS
Recorded beside the feature in notes/adding-a-program.md's BUGS: a removed program's
SWISH_CHECK_SCRIPT line is caught only by script/swish-check. The removal gate is a text scan
and misses names built at runtime. The wire-id pin covers only ids shipped before 2026-09-19. The
[[bin]] reader knows four keys. Every archive now carries pmap, which nothing spawns.