Skip to content

Add Sekka Installer for Mac, the updatable Mac image and first-boot setup - #336

Open
bitemyapp wants to merge 190 commits into
fix/apple-silicon-aizomefrom
feat/apple-silicon-installer
Open

bitemyapp wants to merge 190 commits into
fix/apple-silicon-aizomefrom
feat/apple-silicon-installer

Conversation

@bitemyapp

Copy link
Copy Markdown
Owner

Implements the Apple Silicon installer plan (docs/apple-silicon-installer-plan.md, phases 0–11) for the 14-inch MacBook Pro with an M3 Pro (J514S). Stacked on #164; the diff below is only this work.

What's in it

  • Sekka Installer for Mac (installer/genkan/macos), a Rust workspace:
    • sekka-installer, a native AppKit app in Rust and objc2, in the style of omperor. It checks the Mac, plans the space, downloads and verifies the release, and authorizes the installation. It can show a full simulation and screenshots (--simulate, --screenshots).
    • sekka-installer-helper, the root daemon registered with SMAppService, reached over XPC with code-signing requirements on each side. It verifies the catalog and plan for itself, imports the downloads into private staging, and keeps a crash-safe, hash-chained journal of each installation. Reconcile brings that journal up to date from the helper's own look at the disk, for example after Recovery or after a manual removal.
    • "Finish Installing Sekka", the Recovery app (bputil, kmutil configure-boot, bless), with the PTY driver adapted from Omarchy's.
    • The contract crate: canonical JSON, versioned schemas, the install state machine, and the engine protocol. Also the trust, staging and journal crates, and sekka-mac-tool for catalogs, signing and the qualification ledger.
  • The engine (installer/genkan/macos/engine): an adapter on the pinned Asahi installer v0.9.2, packed reproducibly.
    • Its inspection mounts other systems read-only and recognises existing, partial and developer Sekka installs.
    • Execution mounts writable only the volumes it creates.
    • Apple's restore inputs are fetched in a stage of their own, inside the room the plan reserved.
    • The startup-disk retry first re-checks the whole ESP inventory.
  • The updatable Mac image (nix/apple-silicon):
    • Product and developer variants with separate disk identities. The product mounts by the partition identities its installer hands off, with an initrd check that stops with a message.
    • /etc/nixos ships with its exact lock and the sources an offline rebuild needs.
    • m1n1's boot.bin is replaced so it is never missing on FAT.
    • A sekka.mac.manifest/1 that the engine's own reader accepts.
  • First-boot setup (installer/genkan/first-boot, Aizome's greeter): the product image has no account and no password. The owner sets the computer up on the login screen, with Genkan's validation, a recoverable transaction, and no secrets left behind.
  • Genkan on PCs: a durable installation record, a bootloader retry, and the disk claimed before erasing is recorded.
  • Packaging and release (packaging/): app and Recovery build scripts, notarization, the DMG, provenance, a Mach-O audit, and a publish dry run. Nothing publishes; the release workflow is untouched.
  • Decisions and runbooks: encryption is deferred and disclosed (docs/apple-silicon/encryption.md), removal and new boards are scoped (removal-and-boards.md), and there is a Mac qualification skill and ledger (.agents/skills/sekka-mac-qualification).
  • Flake: packages.aarch64-linux.{mac-engine, mac-engine-tests, mac-installer-{checks,icon,tool,source}, mac-release-j514s…}, and legacyPackages.*.first-boot. checks.x86_64-linux gains mac-installer and mac-engine.

How it was checked

All of this ran on the J514S under linux-aurora. Nothing touched its disks.

  • Reviews: three adversarial multi-agent reviews (59, 31 and 25 confirmed findings), each fixed and reviewed again.
  • Rust: 253 tests across the installer workspace. cargo clippy -D warnings is clean for aarch64-linux and for aarch64-apple-darwin; the AppKit code type-checks.
  • Python: the engine's 115 tests against fake Macs, with the contract's transcript validator, and the packaging scripts' 14 tests.
  • Nix builds of every new Mac output, plus first-boot.helper (36 tests) and first-boot.configuration. Genkan builds for aarch64 with its tests.
  • VM tests (KVM, no network, disk files only):
    • The product image built from 3d43a5c passed all 77 checks. In every boot the login screen came up, with the VM's GPU standing in for the Mac's, and stayed up. The checks also cover:
      • its own partitions mounted beside an identical disk and a developer disk;
      • the store registered once;
      • offline rebuilds, including with setup's choices;
      • boot.bin replace and restore on FAT;
      • an update and a rollback.
    • The developer image passed both of its boots.
    • First-boot setup's VM test passed all ten subtests: setup on the login screen, a wrong and the right password, lock, logout, the other desktop, and a reboot.
  • Engine and image together: the engine's reader accepts the real built release, and computes the same ESP inventory digest.

Not verified: needs a Mac

  • Building and running on macOS: the app, helper and Recovery app have never been compiled, linked or run on macOS. Here they only type-check.
  • The engine against real tools: it hasn't run against real diskutil, bputil, kmutil or bless. The read-only mount handling is modelled, not observed.
  • Notarization: whether it accepts Asahi's ad-hoc-signed libffi inside the engine archive. The audit allows exactly that file, by its digest.
  • A physical installation: m1n1, U-Boot, the T6030 display and GPU handoff, Recovery, and the whole qualification ledger.
  • x86_64: the new checks.x86_64-linux entries weren't run here, because there is no x86_64 builder.

🤖 Generated with Claude Code

bitemyapp and others added 30 commits November 6, 2026 20:59
installer/genkan/macos is a new Cargo workspace for Sekka's installer for
Apple Silicon Macs. Its first crate, sekka-mac-contract, defines the
documents the app, helper, engine, Recovery app and first-boot setup pass
between them, each canonical JSON with a versioned schema checked first:
hardware profile, signed catalog, inspection, plan and confirmation,
journal record, engine transcript, helper protocol, Recovery configuration
and first-boot handoff. Plans are derived deterministically and bound to the
machine, disk layout and release bytes; the journal's state machine encodes
the plan's recovery table, and never replays an interrupted resize.

profiles/j514s.json separates what was observed on the reference J514S
(from its device tree, running devices and session) from what omacom/
linux-aurora#138 reported and what is untested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the disk

Apple's restore-image parts are downloaded and authenticated in the
AppleInputs stage, after the helper imports Sekka's downloads and before
the first stage that changes the disk, so a failed download never leaves a
half-changed Mac. examples/canonicalize prints any document's canonical
form and digests, for the engine's tests to compare against.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sekka-mac-trust accepts a release catalog only when its Ed25519 signature
(strict verification over domain-separated canonical bytes) comes from a
trust root valid for its channel and issue time, every artifact is on a
Sekka download host, this Mac's clock is within its validity (a clock
that is behind is reported as such), and it is no older than the catalog
already accepted on its channel. The accepted store is replaced
atomically and reported, never reset, when damaged. Production builds
trust no key yet: a production key is a reviewed, offline addition. The
development key's private half is in the repository on purpose and is
trusted only by development builds, only for the development channel.

sekka-mac-journal writes each record to a synchronized temporary file and
publishes it with a hard link, then synchronizes the directory, so a
power loss leaves the journal as it was or one complete record longer.
Readers check the whole hash chain and refuse damage rather than repair
it; appends are checked against the state machine before writing; two
copies reconcile only when one extends the other. A fault-injection test
interrupts every storage operation of an append in three ways.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sekka-mac-stage downloads in 16 MiB ranged requests through a transport
the app provides (NSURLSession on macOS, so downloads use Apple's trust
store, proxies and idle timeouts, and no third-party TLS stack ships in
the app). Each part's Content-Range is checked and the part synchronized,
so an interrupted download resumes at its last whole part; failing parts
are retried with bounded backoff; a server that ignores ranges or answers
the wrong range is refused. Only the whole file's digest against the
catalog promotes a .partial to its final name, a corrupt file gets one
fresh download and is then refused, and a file from an earlier run is
hashed again before reuse. The staging folder must be private.

The helper's import copies a staged file into its own staging as root,
trusting nothing the app says about it: the path must lie inside the
app's staging with no link along the way and nothing others can write,
the file must be a plain file of the requesting user with one link and the
catalog's size, and it must hash to the catalog's digest as it is copied.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sekka-installer-helper is a root launchd daemon the app registers with
SMAppService. On every connection it requires Sekka Installer's code
signature (release builds name the signing team; the build refuses to
produce a production helper without one), and it trusts nothing a request
claims: it verifies the catalog with its own trust roots and accepted
store, checks the owner is an administrator and volume owner with a
password checked through PAM, inspects the Mac itself as root, derives the
plan itself and starts only if its digest is the one the owner confirmed,
and copies the app's downloads into its own staging while hashing them
against the catalog. One installation runs at a time, and an earlier one
that left the disk changed, or whose record can't be read, blocks another.

The engine announces each stage and waits; the helper makes the intent
durable in the journal before acknowledging it, and a cancel takes the
same lock as that decision, so nothing changes on disk that the journal
doesn't expect and a cancel can't slip in after it. Cancelling is refused
once a stage that changes the disk has begun. Only setting the startup
disk may be retried, after its failure, with the owner's password again.
The owner's password reaches the engine on a private pipe, never in an
argument, the environment or a file. Diagnostics name no account or home
folder.

The macOS layer (XPC, PAM, bless, the engine's process) is type-checked
for aarch64-apple-darwin here; it needs a Mac to build and run. The rest
is tested end to end against a fake platform and a scripted engine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The app's behavior is a model with no AppKit in it: screens for checking
this Mac, the unsupported and not-ready cases, an existing installation,
no release, choosing a size, downloading, the review, Login Items
approval, installing, finishing in Recovery and a stopped installation.
Every person's action and worker result is a message; every slow thing
(inspection, the catalog, downloads, the helper) is an effect run on a
worker thread, so the main thread only draws.

The plan the review shows is derived exactly as the helper will derive
it, from a fresh inspection after downloading (the downloads take space
macOS could otherwise give). Install needs the backup and every
acknowledgement the plan asks for; the password goes only into the begin
request's private channel; a wrong password is asked for again in place;
reopening the app reconnects to an installation rather than starting
another; a stopped installation offers exactly the next actions its
journal state permits.

Development builds carry a simulation of thirteen scenarios that touches
no disk, helper, network or account; production builds can't contain it.
Seventeen tests drive the model through each journey with the simulation
standing in for the Mac.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sekka-mac-engine unpacks the engine archive the app carries (refusing it
unless its digest is the one expected), starts it as python3 -I -m
sekka_engine with a fixed argument list, a cleared environment and the
interpreter the archive's engine-lock.json names inside itself, and reads
its transcript. The app runs its inspection as the person using it before
any password is asked for; the helper runs it again as root.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The app is AppKit through objc2: no web view, no SwiftUI. A journey down
the left shows all six steps, including the two the owner takes after the
app (finishing in Recovery, creating the account), so nobody mistakes
the end of the app's part for an installed system. Pages are built from
the model when their structure changes and updated in place otherwise, so
dragging and focus are never interrupted; a main-thread timer drains
worker results and nothing on the main thread waits.

Sekka's size is chosen by dragging the divider between macOS and Sekka on
a picture of the disk, or with the arrow keys; to VoiceOver the divider is
a slider. The crest is drawn from the brand's geometry with real cut-outs,
in the crest blue for the appearance; status always has a mark and words.
The password sheet clears its field at once and hands the password only
to the begin request. Quitting during installation explains that it
carries on without the app.

Downloads use NSURLSession with Range requests (Apple's trust store and
proxies); the catalog is verified and its serial recorded before use;
the helper is registered with SMAppService, with a guided wait for its
approval in Login Items. Production builds refuse arguments, contain no
simulation, trust only production keys, and must name the team whose
helper they accept. Development builds add --simulate SCENARIO and
--screenshots DIR, which renders every screen of every scenario in light
and dark through AppKit itself.

The interface is type-checked here for aarch64-apple-darwin; it has not
been built, linked or run on a Mac yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sekka-mac-appkit holds the closure action targets, label, button and
stack helpers, Sekka's appearance-aware colors, the crest, status marks
and the disk bar, so the Recovery app looks and behaves like the
installer without either depending on the other.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Genkan now writes a versioned, hash-chained record of each installation
(record.rs): an intent before every stage that changes the disk, and its
result after it was read back from the target. The live copy is root's,
under /run/sekka-install; once the new root filesystem is created with
its chosen identity, checked and mounted, every entry is also written to
/var/log/sekka-install on it, which keeps the evidence after a restart.
Each copy is replaced atomically (temporary file, fsync, rename, fsync of
the directory), records are bounded, and after a failed write nothing
more is written, so a change never starts without its intent on disk.
Records are parsed line by line and checked again (chain, sequence,
canonical form, a closed set of facts, the stage order); they hold
identities, sizes and digests, and the configuration only by digest, so
no password, hash, passphrase, Wi-Fi secret or key can reach them.

After a failure once the installation was confirmed, the helper tells the
window what the record shows changed and the next safe action. Only the
bootloader is ever repeated, and only within the same session, at most
three times, after storage, files and copy completed with their checks:
the helper keeps the target mounted, offers a retry naming the record's
last entry, and on a matching answer reads both copies back, compares the
record with the plan in memory and with the real disk (identity,
partition geometry, superblock identities, mounts, configuration digests
and the target store's closure) before running nixos-install again. A
changed target, a changed or foreign record or an answer for another
record is refused and recorded. Every installation now runs the same
check before it is handed over. The window shows the record's account
under a failed installation, offers "Try the Bootloader Again" when the
helper does, and Copy Details includes the record with serial numbers and
names left out. InstallPlan, the typed confirmation, the pre-erase checks
and the deferred build are unchanged.

The VM fixture's session closes stdin after confirming, so an offer can't
leave it waiting, and its verify step checks the installed record.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Where the record lives during and after the live session, its format and
write order, what each stage's evidence claims, the retry protocol and
its refusals, what the support copy leaves out, what the component tests
cover, and the VM and ISO runs still needed, including a precise
interrupted-bootloader VM case. Written to be merged into DEVELOPERS.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the owner starts up from Sekka's own Recovery, recoveryOS opens this
app (programmatic AppKit, nothing Recovery stubs lack). Before asking for
anything it checks that it is on the volume its configuration names, that
the ESP's handoff names the same installation, and that the boot object
and firmware beside it are the bytes the installation wrote; then that it
is in Sekka's paired Recovery, reached by holding the power button.

With the owner's password it allows Sekka's startup software (bputil -nc
for this volume group only), installs the checked boot object (kmutil
configure-boot), stops Recovery opening the app at startup and makes Sekka
the startup disk (bless), reading the selection back. A receipt beside its
data records each step as started before and completed after; a step
found started is settled by reading the Mac's actual policy, and a retry
repeats only these steps, with the same boot object checked again. It
cannot resize, partition or write Linux. A refused password changes
nothing and is asked for again in place.

The pseudo-terminal that answers bputil's, kmutil's and bless's prompts
follows the rules omacom/omarchy-mac-installer's Recovery found on real
Macs (MIT): the user prompt, waiting for kmutil to turn echo off before
the password, kmutil's one confirmation, and bputil's refusal lines; the
password is redacted from everything shown. Its tests drive it against
scripted terminals here; the window is type-checked for macOS and needs
a Mac (and a Recovery boot) to run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The helper read an installation's journal before reading whether it was
still running. A run that finished between the two reads was reported as
not running with its last records missing, which the app would have shown
as an installation that stopped part way. Whether it runs is now read
first, so a run ending in between is reported as running once more. Found
by the helper's end-to-end tests under load.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sekka-mac-tool makes an unsigned catalog from a specification (checked
like any catalog), signs it with a key file or the development key,
verifies it with this build's trust roots, describes a file as a catalog
artifact, makes signing keys (never overwriting one), and starts and
checks a candidate's qualification ledger. The ledger has one row for
every required case of gates M0 to M9; a pass needs what was observed and
where the evidence is, a failure needs a reason and an issue, and a
candidate is complete only when every case passed or doesn't apply.
Nothing here publishes anything.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…shing

packaging/ assembles Sekka Installer.app (the app, its helper and the
SMAppService launchd plist that runs the helper from inside the bundle,
the engine archive and the icon) and Sekka Recovery.app (minimum macOS 13,
with the localized display name Recovery opens it by), signs them inside
out with their own identifiers, zips the Recovery app as the release
artifact the engine places on the stub, and records a Mach-O audit and a
provenance document beside them. Development builds are signed ad hoc and
say so; --release builds the production features from a clean checkout,
signs with the named Developer ID and the hardened runtime, and refuses
to run without a team and identity. notarize.sh and make-dmg.sh finish a
release on the maintainer's Mac.

audit-macho.py finds every Mach-O, including inside nested zip and tar
archives, and on macOS checks each is signed by the release's team.
provenance.py records the source revision, every locked crate, the engine
lock, the toolchain and every artifact's digest. publish-dry-run.py checks
a candidate for promotion (a complete ledger, every artifact's bytes
against the catalog, immutable release paths, a newer catalog serial) and
prints the uploads it would make, catalog last; it has no upload code and
no credentials. Its tests, and the audit's and provenance's, run here; the
build, signing and notarization need a Mac.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…unbook

docs/apple-silicon/encryption.md compares encrypting before the system is
written with converting in place at first boot, recommends converting in
the initrd before setup creates any data, lists the evidence needed first,
and records the decision: the first Mac release doesn't offer encryption,
and says so on Sekka Installer's review screen rather than offering a
toggle that does nothing. Gate M7 is not applicable until then.

docs/apple-silicon/removal-and-boards.md records what this release does
(recognize existing and partial installations and stop with an accurate
explanation) and what removal, replacement and another Mac each need
before they can be offered.

The sekka-mac-qualification skill extends the ISO skill's coordinator and
evidence contract to a Mac candidate set: the ledger comes from
sekka-mac-tool, each gate has its reference, hardware steps are the
owner's with a verified backup, and promotion is a dry run until the user
explicitly asks to publish.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
installer/genkan/macos/default.nix runs the whole workspace's tests and
the packaging scripts' tests on Linux, builds sekka-mac-tool, renders the
app icon from the brand's application icon, and archives the workspace as
the Mac build takes it. The pseudo-terminal tests now find stty by
absolute path, since the commands they drive run with a fixed PATH that a
build sandbox doesn't populate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DEVELOPERS.md now describes the Mac installer's workspace, how an
installation goes from the app through the helper and engine to Recovery,
where state lives, trust and signing, building, simulation and
screenshots, catalogs, qualification, and what has and hasn't been run on
a Mac. NOTICE credits the Asahi installer the engine runs and the
Omarchy Recovery code the prompt handling is adapted from.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ng installation

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The helper filed each imported download under the base name of the path
the app sent. Its content was checked against the right role's digest,
but a file could have been filed under another role's name, which the
engine would then read as that role. The helper now names each file
itself, from its role.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…them

Copying the payload doubled the space it took on the macOS volume while
installing, which could leave macOS unable to give the space a plan near
its maximum asked for, after the helper had approved that plan. On macOS
the helper now takes an APFS clone of the opened file (never through a
link), makes it root's own and private, and hashes the clone it will use;
it falls back to copying where cloning isn't possible.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ailable yet

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The engine records the installation's identity in the handoff and the
Recovery configuration it writes, so the helper passes the identity it
journals under (--installation) when it starts execute.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RecoveryConfig::check refused any two equal identities among the stub's
container, volume group, System and Data volumes, ESP and root. But a volume
group made with `diskutil apfs addVolume … -groupWith`, as Asahi's installer
makes the stub's, takes its Data volume's UUID: Omarchy's recorded M1 Pro stub
has 0BF26A61-… as both. Every real Sekka stub would have been refused by the
Recovery app. The group may now equal the Data volume; every other pair must
still differ, and the group still can't be the owner's own macOS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sekka_engine is Sekka's adapter over the Asahi installer v0.9.2, which stays a
pinned external dependency: the adapter imports Asahi's modules from the
extracted release tarball at run time and routes every command they run
through one Host, which starts only a fixed list of Apple's tools from the
system directories. It speaks the contract's sekka.mac.engine/1 transcript,
with canonical JSON written byte for byte as canonical.rs writes it.

inspect builds the contract's Inspection from Asahi's own model (SystemInfo,
DiskUtil, OSEnum): the machine and its binding, macOS and its SFR, the GPT
disk GUID from IOGUIDPartitionScheme, partitions, containers and snapshots,
Asahi's resize rule (macOS keeps 38 GB free) as the minimum, free and
shrinkable candidates, power and FileVault. It recognizes Sekka by its stub's
Recovery configuration and its ESP's handoff, other Asahi installations by
Asahi's marks, and reports anything else as unknown or partial without
guessing how to repair it. Run unprivileged, it mounts read-only, unmounts
what it mounted, and reports what only root can read.

execute refuses before anything changes unless the plan is canonical and
consistent, the bundled profile and every asset are the plan's, a fresh
inspection agrees on machine, disk, layout and admission, and every action
agrees with Asahi's arithmetic. It then runs macos_stages in order, each only
after the helper acknowledges its intent: Apple's restore-image members are
spooled before the disk changes, the resize keeps diskutil's own words, the
stub, ESP and root come from Asahi's own code, the ESP gets the real partition
UUIDs in its boot entry and the first-boot handoff, the root image is read
back from the raw partition, the Recovery app replaces Asahi's step2 flow, and
the startup selection is read back two ways after bless. Failures report
whether the disk differs from the plan's, after looking again.

The tests run the engine against a fake Mac that answers Asahi's commands from
one model (with Omarchy's recorded M1 Pro outputs, MIT, among the scenarios),
and tests/vectors records documents and transcripts whose bytes and digests
the Rust crate computed. The contract crate's engine_vectors test and its new
validate_transcript example check them with the helper's Transcript.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
installer/genkan/macos/engine/default.nix takes { pkgs } and returns the
engine archive and its tests. The archive fetches Asahi's installer v0.9.2 by
its SRI hash, adds sekka_engine, the J514S profile and engine-lock.json
(Asahi's version, commit and tarball digest, the adapter's digest and files,
the profile's digest), and packs it with sorted names, owner 0:0, fixed modes
and time, beside engine.json with its size and SHA-256. Nothing of Asahi's is
dropped or changed; its runtime's code signature seals site-packages, so the
engine runs by its entry point's path rather than being added there. A rebuild
reproduces the archive bit for bit. The tests run the unittest suite under
Python 3.13 with the contract crate's transcript validator, after building
that crate and running its tests.

source-lock.json records the Asahi tag, commit and tarball, the modules the
adapter uses, and the Omarchy code and fixtures adapted with their license.
docs/apple-silicon/engine.md describes the modes, the command line, every
stage and what it verifies, what Apple's inputs' authenticity rests on, what
the fake Mac covers, and what only the J514S can show.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Setting the startup disk is more than bless: Asahi's step restores the
stub's SystemVersion before it and hides it again (arming
.IAPhysicalMedia) after, so the stub starts into Recovery and opens the
Recovery app. Retrying it outside the engine would skip that. The engine's
startup-disk mode runs only that stage, for an installation whose payload
is already verified, under the same intent-and-acknowledgement protocol.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The engine archive names its interpreter and entry point in
engine-lock.json; the bundled Python.framework's signature seals its
site-packages, so the adapter is run by path (python3.13 -I
sekka_engine/__main__.py) with the framework environment Asahi's own
install.sh sets, rather than as a module.

The helper's startup-disk retry no longer runs bless itself: that skipped
Asahi's preparation around bless, which makes the stub start into Recovery
and open the Recovery app. It starts the engine's startup-disk mode under
the same intent-and-acknowledgement loop, with the journal's own plan, and
journals only that stage. The password handed to the engine is limited to
what it reads (1 KiB).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After execute's startup-disk stage fails, the payload is in place and
verified and only the startup selection is missing. Retrying bless alone
skips Asahi's prepare_for_bless and prepare_for_step2, and the stub would
then start normally instead of into Recovery and the Recovery app. The
engine's new startup-disk mode runs stage_startup_disk exactly as execute
does, and nothing else, for the helper's bounded retry:

    … -I ROOT/sekka_engine/__main__.py startup-disk --plan FILE
        --installation UUID --owner SHORTNAME     (password on fd 3)

Before its one intent, with nothing changed, it refuses unless the plan and
profile check out as in execute, a fresh inspection agrees on the machine,
the GPT disk and the running macOS (not the layout, which the installation
itself changed), the owner is an administrator, exactly one stub's
recovery.json names this installation, and everything that configuration
names is still there: the stub's container, group and volumes, the ESP and
root partitions, boot.bin and the firmware baseline by digest, the Recovery
app and its launch marker, and the ESP's handoff.

The tests run it on the Mac an execute run leaves when bless fails, either
outright or by exiting 0 without changing the selection. The new transcripts
are vectors the contract's Transcript::startup_disk accepts, and
validate_transcript takes a startup-disk mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The root helper hashed the engine archive in the app bundle, then had tar
open the same path again. The bundle belongs to the person running the
app, so code running as them could swap the file between the two reads
(or put a FIFO there and feed the genuine bytes to the hash) and have its
own engine unpacked, cached and run as root, with the owner's password on
its descriptor 3.

The archive is now opened once, without following links and without
blocking on a FIFO, refused unless it is a regular file, and copied into
the private cache while it is hashed; only that copy is compared with the
expected digest and extracted. An engine already unpacked for the
installation's digest is reused, so a startup-disk retry still works after
the app that installed it was replaced. A stuck inspection is stopped
after five minutes.

Found by the adversarial review (critical).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bitemyapp and others added 30 commits November 7, 2026 03:27
Until the first update the running system is the image's, which
configures no host name, so Settings offered to rename the computer. But
setup.nix declares the name and the flake names its only system after it:
after a rename, nixos-rebuild found no system for the new name and Yukimi
built the declared one, quietly putting the old name back. Once setup.nix
exists, sekka-setup-hostname.service now keeps the name in the store, as a
configured name is, so Settings shows it as the configuration's until the
update replaces /etc/hostname with its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
syncfs flushes nothing on vfat, which has no sync_fs, and the Mac's NVMe
caches writes, so the target entry syncfs wrote could still be in the
drive's cache when closing the replaced file freed its FAT chain. The next
fsync, or writeback, could store that FAT change first, and a power cut
then left boot.bin naming freed clusters, or boot.bin.previous's new
entry unwritten. commit now fsyncs the directory again after syncfs,
whose flush makes the entry durable, and closes the replaced file only
once all of that succeeded.

FatModel now keeps what syncfs wrote as uncertain until the next flush,
which every fsync ends in; closing the replaced file right after syncfs
is the new failing control.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
/boot is fsck pass 2, so after a power cut systemd runs fsck.vfat -a on
the ESP before boot_bin.py ever sees it, and in the one state where a
file and its staged copy share clusters it truncates one of the two. The
shared-cluster refusal therefore never ran on a Mac, and when fsck
truncated boot.bin, the system that had just started from it ran on
while m1n1 would find nothing at the next start, until an installation
finished the replacement.

mark-booted, at every start, now finishes or gives up an interrupted
replacement after recording which copy started, as the next installation
would. Where fsck truncated the record instead, its staged copy is the
newer record: it is read in its place and renamed over it, so a retried
restore-previous no longer swaps the restored copy back. The refusal
stays for an ESP mounted unchecked, and its message now says so.

FatModel's recovery now mounts every state as fsck.vfat leaves it,
either name of a shared pair truncated, as well as unchecked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An installation staged the active copy as boot.bin.previous.new whenever
it became the previous copy, and the commit then skipped
boot.bin.previous, which had those bytes already (after a rollback to an
extraFiles generation, or `release` after a hold), leaving the 12 MB
staged copy behind. Without FIBMAP, the next run counted that leftover,
with its target's bytes, as sharing its clusters and refused every
installation. Such a copy is no longer staged, and a commit that skips a
name removes its staged copy at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
switch-to-configuration installs the boot loader first, then restarts
changed units and starts the ones active targets newly want. So the
first switch onto a system with sekka-boot-bin.service, and every switch
that changed its ExecStart (a new Python or boot_bin.py), ran
mark-booted on the boot.bin that switch had just installed, which never
booted. The next boot.bin-changing installation before a restart then
made it boot.bin.previous, and the copy that had booted was gone.

The unit is no longer restarted when it changes, and mark-booted records
nothing while /run/current-system isn't /run/booted-system, which covers
its start as a new unit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A held copy's warning, restore-previous and mark-booted told the owner
to run `boot_bin.py release --esp /boot`, and image.md named
restore-previous and status the same way, but the system had boot_bin.py
only as a store path inside the boot loader installation and the unit.
Every calamares.appleSilicon system now has a sekka-boot-bin command,
which the installation and sekka-boot-bin.service run too, and the
messages and image.md name it with the ESP they were run on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
image.nix modelled setup's result by forcing the default desktop over
configuration.nix's plain one with lib.mkForce, which setup can't write,
so it couldn't see that a second normal-priority definition of the enum
conflicts. It now evaluates the shipped configuration.nix itself, with
the one edit setup makes (its default desktop replaced in place, which
first-boot setup now does with Yukimi's own set_string, leaving setup.nix
without one), beside identity.nix and a setup.nix as they are written,
for an owner of every desktop setup offers, and asserts that the chosen
desktop is defined once, by configuration.nix. mac-image-tests evaluates
each of those systems, and yukimi-edits.rs holds set_string's result,
setup's and then Yukimi's, to that replacement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…choices

nixpkgs builds glibc's locale archive from i18n.supportedLocales as
written, and its default list puts the default locale first: so choosing
any language but English (US or UK) at setup made the first rebuild
compile glibc's locales, which no cache has and which can't be built
offline. The module now lists every offered locale in one fixed order,
the image's own, whatever the default.

i18n.imperativeLocale, which keeps the language the system's own, also
leaves /etc/vconsole.conf as first seeded, so the console never took the
keyboard setup chose, though the docs said it would at the first rebuild.
The keyboard isn't imperative (setup.nix's xkb layout is the
configuration's), so the module keeps /etc/vconsole.conf NixOS's own.

setup.nix now says that the language, like the time zone, is the system's
own setting: its i18n.defaultLocale only seeds /etc/locale.conf, and
editing it changes nothing a rebuild applies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The module asserted mutable users, Aizome's login screen and no
autologin whenever it was enabled, and the product configuration keeps it
enabled for good. So once setup was over and its helper gone, an owner
who chose GDM or Plasma Login in Yukimi, or autologin, or declared users
with a password, had the rebuild refused with a message about a computer
that has no account. They only matter while setup waits for its owner;
NixOS's own check still refuses a system nobody can log in to.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The helper read the password into zeroizing buffers, but a password with
a quote or a backslash, both allowed, is unescaped by serde_json into a
scratch buffer of its own, which grows by reallocating and is freed
without being zeroed. The helper now allocates through an allocator that
zeroes every block it frees and moves a block that grows, so no buffer it
doesn't own keeps a copy either. It also makes itself undumpable, and its
unit sets LimitCORE=0, since it aborts on a panic.

The greeter serialised each request into a Vec that grew as it was
written, leaving earlier copies behind; it now measures the request first
and writes it into a buffer of exactly that size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
setup.nix forced the root and ESP mounts to the handoff's partitions with
lib.mkForce, while identity.nix derives both the mounts and the kernel's
sekka.root=/sekka.esp= from calamares.appleSilicon.identity. Nothing
compared the two, so a setup.nix copied from another installation would
mount that installation's root behind an initrd check that passed for
this one. identity.nix is now the only source: setup.nix says nothing
about the disk, and the helper no longer reads the handoff's partitions.

The account's shell is now named by the path it was made with: naming
users.defaultUserShell's package a second time (root's already installs
it) changed the system's package set, so the first rebuild had to rebuild
system-path, dbus and everything built from them, whose inputs the image
doesn't hold.

The default desktop is set at mkOverride 900: over the image's mkDefault,
and under a plain value in configuration.nix, which is where Yukimi
changes it. At normal priority any such value conflicted with setup.nix's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A failure after useradd but before chpasswd (shadow locked, the 60 s
limit) told the owner their account was ready and offered Log In, though
its shadow entry was still locked. Pressing it left setup for a login
screen where no password works, with no way back short of a restart.

Failures and an interrupted status now say apart whether the account
exists (setup can only be finished, so Back is gone) and whether it can
be logged in to (it has a password), and the greeter offers Log In only
for the second. The account's groups and home are also completed before
it's given its password, so no one logs in to an account setup hasn't
finished making.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ale hash

When setup failed after the account had its password, the owner was told
to log in, and the login screen sent a retry by itself each time it
started again. The retry put the host name, time zone and language back
to the staged values and rewrote any setup.nix that differed, so a time
zone or language set in Settings, or a hand edit to setup.nix, was lost
at the next logout.

Each part after the account (its groups and home, the password, the host
name, time zone, locale, keyboards and setup.nix) is now recorded in
staged.json as it's done, after what it changed is synced, and a retry
never does a recorded part again. A part not yet done changes its setting
only from the value it had when setup was staged: one changed since is
the person's, and stays. Each part checks its own result; verify checks
the account and evaluates the flake.

The staged password hash also outlived setup: tidying ran only when a
setup began or was resumed, and neither happens once the marker is
written, or once an update builds setup.nix after a failed check. The
credential is now deleted as soon as the password is recorded, the
helper tidies a finished setup's leftovers as it starts, and once setup
is applied, tmpfiles removes whatever an unfinished one left.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…imits

The developer doc said setup.nix named the partitions, that no
intermediate buffer kept the password, that Log In came with the account,
and that the console keymap followed at the first rebuild, which it
didn't. It now describes the parts and their records, the retry that
keeps the owner's changes, the language as the system's own, the desktop's
priority, the assertions only while waiting, what a typical setup.nix
makes the first rebuild build (measured against the product image), and
the 7 November results, the VM test among what wasn't run again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…anges it

setup.nix named the desktop at lib.mkOverride 900 over the image's
lib.mkDefault, so Yukimi, whose Default desktop choice rewrites only a
plain string in configuration.nix, refused the change on every Mac, and
removing the default desktop from Desktops failed with it. A plain value
there would instead override setup.nix and lose the owner's choice.

The image now names the default desktop as a plain string, and setup
changes that string with Yukimi's own edit (yukimi-config, by path), as a
recorded part that keeps a value the owner changed meanwhile and leaves
one named some other way alone. setup.nix no longer names it. The
configuration check evaluates the image's form and setup's result, which
helper tests hold to the edit, and proves setup.nix defines no default
desktop; the VM test checks the edit too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The owner may log in once setup has given the account its password and
rename the computer in Settings while setup waits to finish. The retry
kept their name on the running system, but setup.nix still named the
staged one and the check evaluated that, so nixos-rebuild, which looks
the system up by the running name, found none, and the first update put
the staged name back.

setup.nix now names the host name the computer has when it is written,
and the check evaluates that system; a name the configuration can't hold
(not one DNS label) gives way to the chosen one, which the first update
sets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
staged.json gained the shell, the settings setup replaces and the parts
done, and lost the partitions, under the same name, and its strict
reading refused the first helper's file. A test installation of an
earlier image, interrupted after its account was made and then updated,
could therefore never finish setup and stayed in its pre-setup
configuration.

The new shape is /2. A /1 file is finished as the helper that wrote it
would have: the partitions ignored, the configuration's shell, and every
part not yet the choice done from the settings as they are. A kind the
helper doesn't know is reported, and its tidying as it starts no longer
fails on one, leaving it and its credential in place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
image.md still said first-boot setup's setup.nix names / and /boot by
partition UUID with mkForce. setup.nix no longer says anything about the
disk, so identity.nix alone sets the mounts and the kernel's sekka.root=
and sekka.esp=.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Says what was run for the default desktop's move to configuration.nix,
the host name setup.nix names and the staged schema, what changed in the
images' systems, and that the VM test was evaluated but not run, with
the limit of a default desktop named other than as a plain string.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…does

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two of the installed flake's inputs can have the same contents. Nix's
lazy trees make them one store path only once a derivation uses them,
so lib.unique kept both and the link farm's second link failed inside
the first's read-only target. Each source is now linked once, at build
time. The file is formatted with nixfmt, as the rest of the tree is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Layout only: the first-boot helper, configuration and VM test, and this
Mac's own system evaluate to the same derivations, and the shipped
/etc/nixos is byte for byte the same apart from Sekka's own lock entry,
which follows the tree's revision.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ide it

Sekka's developer image, which install-sekka.sh installs with the
unmodified Asahi installer (as on the reference J514S), writes no handoff
and no Recovery configuration. The inspection classed it as another Asahi
system and let the product be installed beside it, although a developer
install mounts its ESP by a fixed FAT serial and its root by label.

The inspection now recognizes it by its ESP's serial, 5ECC-A5E1, the one
sign of it macOS can see: diskutil has no ext4 support and reports no
label or UUID for the root. Nor does diskutil report a FAT serial, only
the VolumeUUID msdosfs derives from the boot sector's serial and sector
count, which the engine computes for the developer serial and the
partition's 4 KiB blocks. That derivation, from msdosfs's source, gives
the VolumeUUID recorded on Omarchy's M1 Pro for serial CEF8-B598, the
only 32-bit serial that does; no developer install's diskutil info has
been recorded.

A developer install is Sekka with no installation ID, in Asahi's state
or partial when its root or boot files are missing, and its blocking
existing-sekka (or partial-installation) issue says that it is a
developer installation and which partitions to delete in macOS first.
An ESP with Sekka's boot record but neither a handoff nor that serial is
Sekka's, but which installation it is isn't guessed: its state is
unknown and it stops installation too. So do an ESP with the serial that
no stub claims, and an empty stub container in front of one. A handoff
still identifies a product installation, also on an ESP with the
developer serial.

The fake Mac reports msdosfs's VolumeUUID for every FAT volume and
honours newfs_msdos -I. New tests cover the developer install alone,
beside free space (execute refuses a plan for it), missing parts and
left behind; Sekka's record without an identity; another Asahi install
on the J514S and the M1 Pro's, still other-linux; and a product install
by its handoff. The developer inspection is a new vector. tests.nix
holds the engine's serial to identities.json. engine.md describes the
recognition and its evidence, and removal-and-boards.md how to remove a
developer installation with Asahi's diskutil steps.

The app's wording is unchanged: its Existing page already says a Sekka
installation is on the disk and that none is installed beside it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s safely

The review of the developer recognition found that the owner never saw
what the engine said. A developer installation is Sekka with no
installation ID, so the app asked a Mac whose helper was never set up to
set it up, saying the helper keeps this installation's record, which it
can't; and the Existing page then said only that Sekka is on the disk,
told the owner to choose Sekka at startup where nothing was left to
choose, and offered no Check Again.

The inspection's installations now carry `developer`, set only by the
developer image's serial (Sekka, no installation ID; both checks hold it
to that). Where every Sekka installation on the disk is a developer one,
the app goes to its Existing page without asking for the helper. That
page says a developer installation is on the Mac, installed with
install-sekka.sh, and to remove it in macOS first, with the engine's
details and Check Again. What an installation left behind (no startup
volume, or parts missing) gets its own title, the details and Check
Again; the note on starting Sekka shows only for one with its startup
volume and its parts.

The engine no longer guesses an empty container in front of a developer
ESP is its stub: only one that could be (at most 4 volumes, and named
Sekka or no larger than a stub) is claimed. Otherwise the container stays
unrecognized and the ESP is reported on its own, claiming the Linux
partitions directly after it, as a developer ESP whose stub was removed
now does. The removal sentence names each partition by what diskutil
list shows (the stub's name, the ESP's volume name, sizes) with its
number at the time, says numbers can change once one is deleted and to
check each with diskutil list, and to make macOS the startup disk first.

A developer stub and root without their ESP, or a root alone, can't be
recognized from macOS; a test now pins that they are another system and
an unknown partition that stop nothing, and engine.md and
removal-and-boards.md say so. The tests' release no longer gives its ESP
the developer serial, which no product release has; engine.md's stage
table said the product formats its ESP with it, and now says
newfs_msdos chooses. The vectors are regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both images start Aizome's compositor on the Mac GPU's render node by
name, which a VM hasn't, so the login screen stopped at once and greetd
gave up after five tries. The product run only passed because its checks
ran before greetd had started. Now virtio-gpu gets a virtio 1.0
transport (Linux silently refuses QEMU's legacy virtio-mmio default),
the render node's name stands for the VM's own, and the login screen is
started afresh and must stay up 15 s without a restart, with greetd's
journal and tty1 kept when it doesn't.

The developer image's branch, never run on Linux before, also reads its
checks without the terminal's escapes, finds its disk by the root it
mounted (QEMU names disks in the order it finds them), and lists files
with the real ls rather than the account's eza alias. Both its boots now
pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The product image built from 3d43a5c passed all 77 checks of its VM
test, the login screen staying up in every boot, and the engine's own
reader accepted its manifest, payload and installer data. The developer
image passed both its boots. Earlier runs' "display manager active" is
recorded as read before greetd had started.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
All ten subtests passed, the check of setup's edit to configuration.nix
among them. The documented way to run it now names the checkout as a Git
flake: as a path flake, builtins.getFlake copies the whole directory into
the store, worktrees and build outputs included, which filled this Mac's
disk. engine.md points at the flake's mac-engine outputs for the same
reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
provenance.py reads Cargo.lock with tomllib, and macOS's own python3 is
3.9, so build-app.sh built everything and then failed at its last step.
It now checks first and says what to install; DEVELOPERS.md lists what a
Mac needs to build the app.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant