notes

What a nife package is, and what still cannot be done with one

Milestone 198 (a package manager, and the trivial install that makes a second customer possible)'s rung 3a has two halves. This note is the producer half and the format both halves share, built 2026-09-23, and the first part of the consumer half, built 2026-09-24. A target fetches a package over plain HTTP and accepts it only by a digest its own image vouches for. Since 2026-09-26 an installed program runs by its bytes (DECISIONS §219 option D), and the target installs, removes and rolls back packages itself, fetched by name. What is missing is in "Where this stops" below.

The two decisions this is downstream of

DECISIONS §197 (a package is one archive file), in its own file, ruled the container: one archive file per package, identified by name and version, the shape .deb, .apk and .hpkg all use. It accepted a cost: a container is bytes a target must parse: "the reader owes a fuzz target and the Kani treatment crates/nifefs and crates/static_elf already carry."

DECISIONS §195 (a reviewed recipe vouches for a package), in its own file, ruled trust. A package's digest lives in a version-controlled recipe changed by human review. Trust is scoped per source the owner opted into, and the owner may overrule. Homebrew is also §197's worked example of the pairing.

What installing one does was the third fork, and DECISIONS §208 (installing a package is granting it, and the installed programs are versioned) ruled it on 2026-09-23.

The format

crates/package_archive holds it, and holds it once: the host tool writes a package with the code a target reads one with, the arrangement crates/nifefs has for the boot archive. The crate's own documentation carries the byte layout; three choices a reader comparing this against .hpkg will ask about:

The encoding and the crate's name are provisional. §197 ruled the container, not these offsets. Its manifest question was ruled 2026-09-26: an ELF note inside the executable, not a member. §197 says the day somebody outside this repository fetches a package is the day the format is fixed; nobody has.

How a digest is written

As sha256:<64 hex>, through measured_boot alone (DECISIONS §197 (a package is one archive file), 2026-10-07); anything else is refused.

The producer

cargo xtask package <recipe> turns a reviewed recipe into one package file, a digest, and a catalog line. packages/uptime.recipe.toml is the worked example and a real recipe rather than a fixture.

Recipes are TOML since calef's ruling of 2026-09-27. xtask reads them with the toml crate, a dependency under §46 (thin primitives or whole subsystems): host-only, never shipped, parsing a format calef chose, correct by exposure. No target reads a recipe; it reads the catalog.

$ cargo build -p components --bin uptime --target aarch64-unknown-none-softfloat
$ cargo xtask package packages/uptime.recipe.toml
uptime 0.1.0 aarch64, 2 members, 90491 bytes
  uptime                       89168 bytes  sha256:d801cd2b65dbfbd4982226394c8ad5de471d4f782f39eb16c5ee06cd71bcef26
  uptime.licence                1067 bytes  sha256:dba2f854c33606c0a4f028f88baf9d9bcef8d30714e29c8f3314dd5eeebf1c14
digest sha256:d74f8eb3ecc14b43b9f55b2113c830ee856394eee4398b52da2da1614d426cd9  (the recipe records none; review it and add it)
wrote target/packages/uptime-0.1.0-aarch64.nifepkg
package: PASS

A program is packed stripped since 2026-09-24, the same bytes the image packs. The first run above read 881,152 bytes for uptime, nearly all of it debug sections, against a job region of 40 pages (160 KiB). An installed program is bytes something on the target must read into memory to build a process from, and nothing there reads DWARF. The digests in this note's history changed with it; nobody had fetched one.

Three things in that run are the mechanism.

It reads its own output back with the target's parser before writing, since a producer that could emit a file its consumer refuses ships one no target-side gate would catch.

A recipe's recorded digest is checked before anything is written. A rebuild that does not reproduce the reviewed line is exactly the failure §195's arrangement exists to make visible, so the tool prints both digests and writes nothing. A package nothing accepts, on disk beside a catalog entry vouching for it, would be the tool disagreeing with itself.

The catalog line is measured_boot's manifest shape, a name, a space, a labeled digest, which the progenitor already reads to decide whether a program may run: §195 makes the image's measurement table the first source of trust.

The bytes are a function of the inputs alone, with no timestamp, ordering pass or non-zero padding. the_same_inputs_give_the_same_bytes holds that, because a reviewed digest is worth nothing if two hosts disagree.

packages/uptime.recipe.toml deliberately records no digest, and the comment in it says why. The program it names is rebuilt by this checkout whenever anything it links changes, so a recorded digest would fail for the next reader. A wrong recorded number is worse than an absent one. The line goes in when there is a release to pin it to, which is rung 4.

What proves the producer, and what running and installing cost, is in the appendix.

The consumer's first half: fetch, and verify against the image

Built 2026-09-24 by the rung 3a consumer lane, in three pieces:

EXAMPLES

$ script/test --arch aarch64 --test package
running 1 of 359 tests (filter: package)
test kernel::user::tests::a_package_fetched_over_http_is_accepted_only_by_the_image_digest ... ok
test result: ok. 1 passed
$ cat target/packages/catalog
uptime-0.1.0-aarch64 sha256:d74f8eb3ecc14b43b9f55b2113c830ee856394eee4398b52da2da1614d426cd9

The test fetches twice through one net_stack: the genuine package, which must be accepted, then the tampered copy, which must be refused. The tampered response is a complete, correct HTTP exchange of the right length, so only the digest can tell, and a client that accepted whatever arrived would pass the first half too. They share one spawn because every net_stack a test starts holds a virtio slot for the rest of the boot; this lane took the table's tenth bump (MAXIMUM_DEVICES, to 34) and filed the unregister it keeps deferring as design/roadmap/0647-a-virtio-slot-comes-back-when-its-driver-dies.md. riscv64 runs the same test as a twin in system_tests/src/user/riscv64_virtual_io_tests.rs.

The versioned table, as logic

crates/installed_programs (provisional name) is §208's second clause as a pure, host-tested crate. A generation is a text file of digest-keyed rows, <digest> <program> <version> <package>, and default pointer lines, never rewritten. A one-line current names the live one, and install, upgrade and remove each produce the next generation. Its test a_rollback_restores_the_whole_set is the property calef asked for by name. The progenitor reads and writes it on the target (below).

Running what was installed, by its bytes

DECISIONS §219 (how the shell names an installed program to the spawner) was ruled on 2026-09-26: option D, the executable's bytes as frames the caller owns, with gate D2. Both are built.

A command word with a / in it is a file. The shell binds the line against the manifest the file carries as an ELF note, or uptime's if it has none: milestone 597 (a program carries its manifest in an ELF note). It opens the file and sends spawn_protocol::request(len, ..) with IMAGE_BIT set: word 0 is the byte length, then one SEND_CAPABILITY per page narrowed to READ, then the grants as today, holding one frame at a time.

The progenitor maps each frame through the loader's scratch window (process_builder::map_scratch), copies it into a page of its own, and deletes the capability before taking the next. It copies because the caller could change its frames between a hash and a build. It hashes the copy, reads activation/current and then that generation through the file service it already held, and looks the digest up (installed_programs::lookup_digest). A hit is built from the copy and endowed from its note. A miss runs only for a session presenting D2's capability, with its grants and two pages; otherwise it gets SPAWN_UNVOUCHED. D2 is packages/running-unvouched.md.

The digest is the member's, since the spawner is handed the executable and the table of contents carries one per member. Installing still checks the recipe's digest over the whole file (§195 (a reviewed recipe vouches for a package)) first.

A bare word runs an installed program, never a vouch (§229 (how a bare name at the prompt reaches an installed program), B2; see swish::bare).

Installing on the target

Built 2026-09-26; a program, jig, since milestone 809 (the package client becomes a program). Each verb is one request to the progenitor and one reply naming the live generation. Files are installed from inside downloads (packages/jig.md, radon):

$ cd downloads
$ jig install ./tampered.nifepkg
  refused: neither this image's catalog nor its index copy vouches for those bytes; nothing is installed
$ jig install ./uptime.nifepkg
  refused: the image carries the program uptime; a new base updates it, not install; nothing is installed
$ jig install ./noteless.nifepkg
  installed; generation 1 is live
$ cd /
$ packages/noteless/0.1.0/noteless
  noteless: installed, and carrying no manifest note
$ installed/unvouched
  network: refused (no capability at slot 10)
  entropy: refused (no capability at slot 9)
  domain: refused (no capability at slot 7)
  slots held: 0 1 2

And on the next boot, from the same disk:

$ packages/noteless/0.1.0/noteless
  noteless: installed, and carrying no manifest note
$ jig remove noteless
  removed; generation 2 is live
$ caps packages/noteless/0.1.0/noteless
  packages/noteless/0.1.0/noteless would grant the new process, and nothing else:
    ...
    provenance: unvouched (digest sha256:...)
    runs on this session's capability to run unvouched bytes (slot 62)
$ jig rollback
  rolled back; generation 1 is live
$ packages/noteless/0.1.0/noteless
  noteless: installed, and carrying no manifest note

Install refuses an image program's name, as uptime shows, and a name another package provides (§229, amended 2026-09-27). A package may carry several programs: packages/several-programs.md.

The progenitor is the installer, not a program, for §208's own reason: the authority that decides which version is active performs the swap, and §219 already made it the table's reader. It holds the file service with WRITE, the image's catalog in its archive, and the frame-staging path an image request built. The client is jig (milestone 809 (the package client becomes a program), packages/jig.md). It sends spawn_protocol::ACTIVATION_BIT (provisional) on an installer endpoint (§270 (a package manager holds an installer endpoint, not the spawn endpoint)), and each row records it as the manager.

Install stages the package as an image is staged, so the progenitor checks its own copy. package_archive::installable is the whole decision on bytes, host-tested: the file's digest must be the image catalog's line for the stem in its header, and the member named after the package is the program. Its bytes go to packages/<name>/<version>/<program>, one component per field. Remove writes a generation without the entry and leaves the bytes, which is what lets a rollback bring them back. Rollback points current one generation below the live one and writes nothing else.

All three share one commit order: the new generation is created and written whole, current is written to current.next and renamed over current, and the device is synced before the reply. A generation is never rewritten, and current never names one that was not written whole.

What proves it

script/swish-check boots twice per architecture against one disk and types both transcripts above, green on aarch64, riscv64 and x86_64 (under OVMF) on 2026-09-26. Its setup and the five falsifications are in packages/measurements.md.

Fetching by name, and a program the image never carried

jig install <name> fetches over the network and installs, and greeting, which no archive packs, is what the gate fetches: packages/fetching.md.

Where this stops

Rung 3a's exit criterion (fetched, verified, installed, run, kept across a reboot, rolled back, removed) is met, and so is §219's gate D2. The boot prompt is the owner's console, which may write activation/ and vouch for a build: packages/vouching.md.

BUGS