# Repository-backed Host Extensions (experimental implementation) ## Local package import (D-094) — daemon path `archipelago extension add ./package.pkg.tar.zst` (and the explicit `extension add --file PATH`) routes through `archipelagod`: `HostExtensions.ImportPackage` over the protected Unix-FD path, then one `PrepareChange` covering every requested name and archive, then `Manager.Stage`. The CLI never hands the daemon a path; it opens the file and the daemon copies the exact bytes into root-owned storage, hashes the copy, parses `.PKGINFO` and cross-checks the identity with `pacman`. Import runs no scriptlets, does not enable the feature and stages nothing. `extension import PATH` and `extension add-local INPUT_ID` remain available as the explicit two-step form. A local archive keeps `source=local`, its retained checksum and `signature_verified=false`; it is never reclassified as a repository package, needs the separate `org.archipelago.system.extension-local` authorization, and leaves the resulting composition unsupported. Repository packages keep mandatory signature checks. ### Package database inheritance Every composition starts from the selected managed base commit, never from the booted `/var/lib/pacman` and never from the previous mutated extension database: - the staging root is an OSTree checkout of `managed_base`; its `/usr/lib/archipelago/package-db` (local + sync) is inherited as-is; - libalpm opens exactly that DBPath, the sync databases are bound to the base snapshot and are never refreshed (`-Sy`/`-Syu` are not run); - missing dependencies resolve against the base snapshot and the exact imported local archives, not the rolling mirror; - installation runs `pacman` in the isolated tree with explicit `--config`, `--dbpath` and cache arguments; no pacman command may rely on `/var/lib/pacman`, which does not exist on an installed OSTree host; - the composed commit keeps the complete base-plus-extensions database, and the generation records the exact archives, checksums, dependency closure and base identity; - a base update recomposes from the new base DB; an old mutated DB is never carried forward. Disposable staging trees live under `/var/lib/archipelago/service/package-work/`. The whole workspace is removed after each operation — success, failure, cancellation and timeout — and an entry untouched for a day is treated as orphaned and purged, so private copies of processed archives cannot accumulate. D-088 adds `extension remove NAME...` and separates support from customization. Repository-name additions retain support on a distribution-signed base; `customed` lists sorted effective additions (including dependencies), ten names then `… +N packages`. Custom overlays, local files and unknown legacy provenance do not gain support. Base signature verification uses a separate cache and the embedded distribution key; unavailable verification yields `unknown`, not `supported`. Metadata v2 retains `requested` names and a `request_sources` mapping. Old metadata is read conservatively as unknown provenance, never inferred from names. The legacy `src/extensions.rs` adapter refuses to replay local/unknown sources; remove those requests explicitly before composing a repository-only set. The installed-host path is the daemon (`archipelagod` HostExtensions), which does support exact local inputs. Removing the final request stages the original managed base, preserving history and user data. Update plan v3 retains the mapping; earlier plans must be recreated. Booted and pending are reported separately. Out-of-band mutation detection remains outside this private adapter. The CLI accepts `extension add NAME...` and local archives (`extension add ./file.pkg.tar.zst`, `--file PATH`). This implements the D-037 requested-set model: resolve against the base image's retained sync databases; download exact packages; compose the entire explicit set against the immutable base and its ALPM database. Dependencies remain resolved state, not explicit user requests. Selection starts with the staged deployment when present, otherwise the booted deployment. Extension metadata identifies the original managed base (including Managed Overlays), rather than treating the preceding extension image as the base. Repeated requests are idempotent. Successful additions replace the staged candidate only after composition and checks succeed. OSTree retains booted/rollback deployments; each generation has independent refs for its base and result. There is no automatic reboot, removal of old generation inputs, or package/database refresh (`-Sy/-Syu`). Prototype storage (not a stable schema): ``` /var/lib/archipelago/host-extensions/generations// base, requested, snapshot, base-packages, resolved, plan, inputs/, logs/ package-db/, result, failure /usr/lib/archipelago/extensions.json # per-image base + explicit requests ``` The base's retained repository databases pin available versions/checksums. The mirror is only transport: if an exact archive disappears, installation fails; a rolling sync must not repair it. Monthly snapshot publication remains separate. An optional `/etc/archipelago/extensions-mirrorlist` changes download transport without changing the selected database or relaxing signatures/checksums. Dependencies, signatures and transaction ordering are handled by pacman. Downloads run in a staging container; the actual `pacman -S` transaction and finalization run without network, with retained inputs. Base package replacement is rejected. Package hooks/scriptlets need snapshot-specific classification (RFC-0005). Known base hooks are captured by checksum when building Core; new unclassified actions require an adapter before deployment. `/opt` and persistent-file payload adapters and alternate kernel profiles remain open contracts; these cases must fail explicitly rather than discard payload or mutate the live system. This is general name/dependency resolution, not a claim that every Arch package is already adapted. Acceptance includes multiple additions before reboot, further additions after activation, duplicate requests, dependencies, failure with an existing pending deployment, retained inputs/history, and preservation of the managed overlay. ## Experimental DKMS adapter DKMS packages (including `broadcom-wl-dkms` and `v4l2loopback-dkms`) use the same cumulative request path. D-097 removes the package-name/archive-hash allowlist. An archive supplying `/usr/src//dkms.conf` is a DKMS source input; the native `dkms` package is the framework. Initial execution scope is x86_64 Archipelago images without Secure Boot; the target kernel is whatever the image ships (Core `linux`, Desktop `linux-zen`), not a fixed package name. This is not universal DKMS support. - Resolve `-headers=` against retained sync DBs. Generated transaction targets stay separate from explicit requests. - DKMS source/framework package scriptlets and hooks are admitted to isolated staging without per-package approval. Replace the three native framework hooks with the offline finalizer: native helper can skip a failed build and still return zero. - DKMS source archives may contribute `/usr/src`. A header package is recognized structurally by `usr/lib/modules//build/include/config/kernel.release`, so `linux-zen-headers` and `linux-lts-headers` need no separate rule; it may contribute that build tree, vDSO objects and one convenience link below `usr/src` (for example `usr/src/linux` or `usr/src/linux-zen`) pointing into the same build tree. A second real source tree is still rejected. Non-DKMS unclassified package actions still fail. Signatures/checksums and exact snapshot inputs remain mandatory. Configurations are never sourced on the live host during archive inspection. - A second transaction pass (adding exact `-headers` for DKMS) must not reuse package objects from the released first transaction: `alpm_trans_release` frees the packages loaded from local archives, and the next `prepare()` then sorted a freed package and crashed in `strcmp`. The pass is rebuilt from the durable request rows (repository identity or retained archive checksum) plus the header names/versions; a mismatch between passes fails explicitly. - `extension add` imports every archive as its own durable request. One command keeps one request id for the plan and Stage, but each `ImportPackage` call uses a token derived from it (trailing hex digits), because the journal refuses one request id with different canonical inputs. - Offline staging explicitly adds/builds/installs each source for each image kernel, with bounded commands. Validate matching headers, installed status, nonempty module outputs and vermagic; preserve preexisting modules. Then run depmod and regenerate initramfs before committing/staging. - Preserve kernel input hashes, per-module hashes/vermagic and DKMS status/logs/state under generation `logs/dkms`; publish module provenance at `/usr/lib/archipelago/dkms-modules.tsv`. Disposable `/var/lib/dkms` and generated signing keys are not shipped into the deployment or shared with the running host. - Every recomposition builds from the managed base plus the full requested set. A required failure prevents staging and retains previous pending/booted state. Activation and module loading occur only in the target lifecycle after explicit reboot. Live module loading/building is not part of `extension add`. VM acceptance (`core_iso_acceptance.py --dkms`) checks build/staging, duplicate and failed-request preservation, post-reboot modprobe and `/dev/video0`, then another cumulative addition and reboot. Hardware-driver coverage, module signing for Secure Boot, updates to another kernel and the stable shared action engine need further work. 2026-11-09 D-097 source checks: `python3 tests/dkms_inputs.py` passed four tests on terra in a disposable tools container with libarchive-tools: arbitrary DKMS names/configurations and framework revisions, retained payload boundaries, and target-version header resolution/failure. Shell syntax checks passed. The daemon resolver now includes exact headers in its checked dependency closure (previously only the legacy CLI download path added them). These are next-build source changes; Broadcom compilation/activation and installed-image acceptance remain unverified. ### Broadcom sideload evidence, 2026-11-09 On `marchipelago-fuck-1000`, a separately compiled diagnostic CLI/daemon from D-097 sources was installed under `/opt/archipelago-diagnostics/dkms-621a8bb`. Only a runtime systemd drop-in selected the diagnostic daemon; immutable system binaries and the active terra release pipeline were not replaced. First test exposed a second defect: pyalpm's handle does not expose hook-directory configuration and ignored `/etc/pacman.d/hooks` masks. Native DKMS ran before the explicit finalizer, which failed with duplicate registration. The adapter now uses native `pacman -U` for installation of the exact checksum/signature-verified closure, after libalpm plan validation and releasing its transaction lock. This honors staging hook masks; the outer adapter still rejects failed package actions. A local Host Extension has no detached signature by design (D-115), while the image config sets `LocalFileSigLevel = Required`. The service therefore renders a private `/run/archipelago-package-install.conf` with `LocalFileSigLevel = Optional` for that one `-U` transaction. Repository `.sig` files remain present and are still verified; the image's `/etc/pacman.conf` is never changed. Without this, an unsigned local archive was rejected as "package missing required signature" even though its exact bytes and `.PKGINFO` identity had already been checked. A second composition-only failure appeared once the signature policy was fixed: `36-systemd-modules-load.hook` calls `/usr/bin/systemctl --system restart` directly, and the isolated root has no target systemd bus. The adapter now masks every base hook whose `Exec` calls `systemctl` directly (currently modules-load and the sshd restart marker); hooks routed through `systemd-hook` already detect a chroot and skip. The target boot still loads modules and starts services from the installed configuration. An unrelated existing hook is never overwritten: a real file is a composition error. Retry operation `6245b28b175df563140d6087779d3dff` succeeded and staged `a8b738f3fcb904ad763a2420631db7f4f007b502c649e460c4518e3dcb8b5c66`. Verified `broadcom-wl-dkms 6.30.223.271-50`, `dkms 3.4.4-1`, matching `linux`/`linux-headers 7.2.14.arch1-1`, preserved mc/nano/tailscale, DKMS exit 0 and installed status, module `wl.ko.zst` with vermagic `7.2.14-arch1-1`. Module SHA256: `1bab8a1ea22752977a5ac7c0f0f6ce6bb9f0169a16482c0d87fd5f36f36a25cd`. Booted deployment remained `39e63333e8c0ae0925fe029b03b3d840c5027d8f40d5bda20363a3fde34e65da`. No reboot or live module load was performed; hardware Wi-Fi activation is unverified. Successful diagnostic binaries are in the kit's `hookfix/` subdirectory; logs, before/after status and SHA256SUMS are retained there. Runtime drop-in: `/run/systemd/system/archipelagod.service.d/dkms-diagnostic.conf`; it expires on reboot. The staged image retains its original packaged CLI/daemon. The source fix must also ship in a subsequent OS build for persistent management support.