Skip to content

fix(updex): fail loud on an empty specifier and link the running suite at boot - #516

Merged
bketelsen merged 5 commits into
mainfrom
fix/511-suite-switch
Nov 14, 2026
Merged

bketelsen merged 5 commits into
mainfrom
fix/511-suite-switch

Conversation

@frostyard-machines

@frostyard-machines frostyard-machines commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #511. Decision: ADR-0021.

Merge after #515. This branch carries an identical copy of #515's first commit (3a1038a = 88752b3, the any-suite target patterns). After #515 merges, this branch is rebased: that commit drops out and 4 files need a merge (config/transfer.go, config/transfer_test.go, docs/specs/config-reference.md, updex/install.go).

Part A: an empty specifier fails loud (8d8315f)

expandSpecifiers (config/transfer.go) wrote "" for a missing os-release key, so %w on a host without VERSION_ID (Debian forky before its release) gave a pattern that matched nothing, and the run failed with no versions available (updex/install.go:80). Now an empty expansion in a Source/Target MatchPattern is recorded on the transfer (Transfer.SpecifierError, class config), for example Target MatchPattern "foo_@v_%w_%a.raw": specifier %w is empty: os-release has no VERSION_ID. The config load still succeeds, so native OS transfers in the default directory (partition, UKI) that use specifiers do not break updex. getAvailableVersions (update, check, enable --now) fails with the message, features list shows it, the last-run record gets class config. disable and the vacuum still work. An empty ProtectVersion= specifier is a warning only: the rest of the expanded value stays in effect, and only an empty expanded value protects nothing.

Part B: close the suite-switch window (3f46e43)

Facts: LinkedVersionAt (sysext/manager.go) reports "" for a link to a file the current pattern does not match. After bootc switch to the other suite, the 1st boot finds /var/lib/extensions/<component>.raw pointing to the old suite's image; systemd-sysext refuses it (VERSION_ID differs), so the feature is missing. The timer service runs features update --no-refresh (ADR-0016: updates apply at the next boot), so the right image was merged only at the 2nd boot.

  • features update --suite-switch (UpdateFeaturesOptions.SuiteSwitchOnly) selects only enabled features whose link points to another suite's image (sysext.LinkedOtherSuiteAt: the link target matches Target.AnySuitePatterns but no current pattern). It updates exactly those features through installTransfers (all gates), then refreshes through refreshGate and runner.Refresh(): that extension is not merged at all on this boot, so the refresh adds it. With no such link it does nothing: no lock, no download, no refresh, no last-run record. It refuses feature names and --no-refresh. Under systemd a busy lock is an error for it, not a skip.
  • The unlocked scan is a fast path only: under the lock the run loads the definitions and selects again before any download (an empty selection downloads, refreshes and records nothing), and a domain load failure is recorded as a failed run (class config).
  • The refresh never changes what ADR-0016 leaves for the next boot. The run keeps its new links and skips the refresh (RefreshSkipped, last-run refresh: skipped, a warning, not an error) when another sysext has a pending activation or a pending deactivation (merged but not linked), when a state cannot be read, or when the host's definitions do not load (pendingActivationLinksHost returns that failure; the other callers keep the warning and fallback). The suite switch then takes effect at the next boot.
  • New packaged unit updex-suite-switch.service (from updex.SuiteSwitchUnit(), written by scripts/units.sh, shipped by .goreleaser.yaml at /usr/lib/systemd/system/): oneshot, After=network-online.target, Before=updex-update.service shutdown.target, Conflicts=shutdown.target, DefaultDependencies=no (boot does not wait for a download), WantedBy=multi-user.target. Its sandbox keeps only the lines that need no mount namespace (RefreshSandboxDirectives): a private namespace would hide the merged images from the host, and the other lines would block the loop devices, module loads and /etc writes that a refresh with sysusers and tmpfiles needs. The package enables nothing; updex daemon enable/disable/status handle the unit with the timer.
  • Rejected alternative (in the ADR): expand %w from the staged bootc deployment's os-release before the reboot. The path is backend-specific, and it links an image that the running system refuses, so any refresh before the reboot drops that feature.

Trixie-only hosts: the unit runs once per boot and does nothing (no link to another suite). A transfer without %w never matches the any-suite check.

Checks

  • make fmt
  • make ci — green locally (coverage 90.7%, floor 90.2%)
  • CLI/e2e changes: go test -v ./cmd/updex ./tests/e2e/... (in make ci)
  • New or changed behavior has focused tests, including failure paths

Risk tier

  • Tier 1: Low
  • Tier 2: Moderate
  • Tier 3: High
  • Tier 4: Critical

Rationale: matched paths of .github/risk-paths.json:

  • .github/workflows/** (ci.yml, L1): the units job also runs systemd-analyze verify on the new unit. No permission or secret change.
  • .goreleaser.yaml (L1): 1 new nfpms.contents entry (mode 0644); no maintainer script, nothing enabled.
  • scripts/{units,check-deb-units}.sh (L1): write and check the 3rd unit file.
  • systemd/** (L1): unit generation and enable/disable of the new unit, through the same mockable runner.
  • config/transfer.go, updex/list.go (L1): Part A; MatchPatterns expansion is unchanged for non-empty values.
  • sysext/** (L1): new read-only helper LinkedOtherSuiteAt.
  • updex/{install,features,daemon}.go (L1): the selection runs read-only before the lock; the selected features go through installTransfers and refreshGate like every update.

Docs housekeeping

  • ADR-0021 from TEMPLATE.md, indexed in docs/README.md
  • AGENTS.md, docs/design/overview.md, docs/specs/{cli-reference,config-reference,sdk-api,last-run-record}.md updated
  • Conformance aliases untouched

Verification

  • node scripts/check-docs.mjs green (in make ci)
  • Revert tests (scratch worktree, tests kept): Part A: TestSpecifierErrorEmptyValue, TestEmptySpecifierFailsLoud fail. Part B: with no feature selected, TestUpdateFeatures_SuiteSwitchLinksRunningSuite, TestUpdateFeatures_SuiteSwitchRelinksStagedImage, TestRunFeaturesUpdate_SuiteSwitchLockHeldUnderSystemdFails fail; with the link check disabled, TestLinkedOtherSuiteAt fails; with the unit not written, TestUnitsHookMatchesGenerator, TestDaemonEnableDisableSuiteSwitchUnit, TestDaemonPackagedSuiteSwitchUnit fail.
  • Review fixes, each with a test that fails without it and a .memory/corrections/2026-11-13-pr-516-*.json record: TestUpdateFeatures_SuiteSwitchKeepsOtherActivationsForNextBoot/{other_update_linked_by_the_timer,other_image_merged_but_not_linked}, TestUpdateFeatures_SuiteSwitchSelectsAgainUnderLock, TestUpdateFeatures_SuiteSwitchRecordsDomainFailure, TestUpdateFeatures_SuiteSwitchHostDefinitionsUnreadable; and TestProtectVersionWarningNamesExpandedValue/literal_and_specifier (the ProtectVersion= warning names the expanded value).
  • Image builders must enable the unit with a preset line (enable updex-suite-switch.service); until then only updex daemon enable turns it on.

A transfer that selects its suite with %w (os-release VERSION_ID) matches
only the images of the running suite. Cleanup of the other suite's images
(#512) and suite-switch detection (#511) need to match the images of every
suite.

config keeps, for each target pattern that contains %w, an any-suite
variant in TargetSection.AnySuitePatterns: every other specifier expanded
as before, %w replaced by version.SuiteWildcard. It is nil when no target
pattern contains %w; "%%w" stays a literal "%w".

version.SuiteWildcard is a NUL byte. A Linux file name cannot hold one, so
no pattern that config text spells out can mean it; config builds no
any-suite variant when the text or an expanded value already holds a NUL.
Only the new version.ParseAnySuitePattern gives it a meaning; ParsePattern
and every existing pattern (a literal "@w" included) parse as before.

The wildcard matches 1 or more of [0-9a-z.~-], and @v in an any-suite
pattern excludes '_', so "foo_@v_%w_%a.raw" never matches an image of a
component "foo_bar". Pattern.Suite and version.ExtractSuiteParsed report
the suite a file name matched.
…ble"

A specifier that expands to an empty string leaves a MatchPattern that
matches no published image. On a host whose os-release has no VERSION_ID
(Debian testing or unstable before its release), %w is empty, so
foo_@v_%w_%a.raw becomes foo_@v__x86-64.raw and every run ends with
"no versions available", which hides the cause.

The load now records the first empty specifier of a Source or Target
MatchPattern on the transfer, as config.Transfer.SpecifierError, marked
fault.Config:

  Target MatchPattern "foo_@v_%w_%a.raw": specifier %w is empty:
  os-release has no VERSION_ID

The load does not fail, so listing, disable and the vacuum keep working.
getAvailableVersions returns the error, so update, check and enable --now
fail for that transfer with that message (the last-run record gets the
class config), and the transfer status carries it, so features list shows
it. An empty specifier in ProtectVersion= is recorded separately as
ProtectVersionError and is only a warning: ProtectVersion protects
nothing, as before.

Refs #511
…itch

A transfer whose target pattern has %w links the image of the running
Debian suite (VERSION_ID 13 on trixie, 14 on forky). After a bootc switch
from trixie to forky, the link still names the trixie image on the first
forky boot, and systemd-sysext refuses it, so the feature is missing. The
timer links the forky image only at its next run and never refreshes
(ADR-0016), so the feature comes back only at the following boot.

Design (ADR-0021):

- UpdateFeaturesOptions.SuiteSwitchOnly, CLI `features update
  --suite-switch`, selects the enabled features with an active transfer
  whose link points to an image of another suite: the link target
  matches the any-suite pattern (%w as a wildcard) and not the current
  pattern (sysext.LinkedOtherSuiteAt). With none, the run does nothing:
  no lock, no download, no refresh, no last-run record. With some, it is
  a named update of exactly those features through every gate (lock,
  rollback holds, minimum image, refresh gate), then the normal refresh.
  It refuses names and NoRefresh; under systemd a busy lock is an error
  for it, because there is no later run on this boot.
- A new packaged unit, updex-suite-switch.service, from
  updex.SuiteSwitchUnit and scripts/units.sh: a oneshot that runs the
  command once per boot, Wants/After network-online.target,
  Before updex-update.service, DefaultDependencies=no (so
  multi-user.target does not wait for a download), WantedBy
  multi-user.target, no AC-power condition. It refreshes, so it takes
  only systemd.RefreshSandboxDirectives: a private mount namespace
  (ProtectSystem, ProtectHome, PrivateTmp) would hide the merged images
  from the host, and the other dropped lines block loop devices, module
  loads, the namespace of systemd-sysext and the /etc writes of
  systemd-sysusers and systemd-tmpfiles.
- daemon enable enables it (never starts it), daemon disable disables it
  and removes it only when updex wrote it, daemon status reports it. The
  .deb ships it disabled; CI verifies it with systemd-analyze and the
  nightly checks the .deb listing.

Rejected: expanding %w from the staged bootc deployment's os-release
before the reboot. It is specific to the bootc backend, and the running
system would refuse the linked image of the new suite, so any refresh
before the reboot would drop the feature on the old suite.

A transfer without %w is never selected, and a host whose links all name
its own suite behaves as before.

Fixes #511
@github-actions github-actions Bot added documentation Improvements or additions to documentation go Pull requests that update go code github_actions Pull requests that update GitHub Actions code level:L1 Read every line risk:high Touches a path in .github/risk-paths.json labels Nov 13, 2026
@codecov

codecov Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Review fixes for the suite-switch run (ADR-0021, #511):

- Its refresh activates only its own links. The systemd-sysext refresh
  merges every pending link of the host, so before it refreshes the run
  checks the other pending activations (pendingActivationLinks and
  activationLinks: a link whose merged version is not known to equal it,
  or whose state cannot be read). When one exists, for example a newer
  image that the timer linked with --no-refresh earlier on this boot and
  that ADR-0016 holds for the next boot, the run keeps its new links,
  skips the refresh and reports RefreshSkipped ("refresh skipped:
  <component> has an update that waits for the next boot; the suite
  switch takes effect at the next boot"); it is not an error. A pending
  deactivation does not count: updex cannot tell it from an image that
  another systemd-sysext directory provides.
- The selection before the lock is only a fast path. Under the lock the
  run loads the domain and selects again before any download; an empty
  selection then ends the run with no download, no refresh and no
  last-run record. Client.afterSuiteSwitchScan is the test seam between
  both scans.
- A domain that the unlocked scan cannot load goes on to the locked path,
  which records the failed run with class config (ADR-0020). Refused
  options and a confirmed empty selection still write nothing. A
  suite-switch run is always recorded as a selected run.
- A ProtectVersion= value with an empty specifier keeps its literal part
  (1%w with %w empty is 1). The warning now names the expanded value and
  says that nothing is protected only when the value is empty.

ADR-0021 no longer permits the collateral activation; the CLI, SDK,
last-run, configuration and design docs and AGENTS.md follow. Each
blocking finding has a record in .memory/corrections/ (core ADR-0081)
that names its guard test.

Refs #511
…itch refresh

Review fixes for the suite-switch run (ADR-0021, #511):

- A pending deactivation stops the refresh. A sysext that is merged but
  has no usable link is unmerged by a refresh unless another
  systemd-sysext directory provides the image, which updex cannot prove.
  A suite-switch run now keeps its links, skips the refresh and reports
  "refresh skipped: <component> is merged but not linked; the suite
  switch takes effect at the next boot" (RefreshSkipped, last-run
  refresh "skipped", not an error).
- A failed host-wide enumeration stops the refresh. pendingActivationLinks
  warned and fell back to the scoped transfers when the host's
  definitions did not load, so a run scoped to 1 component could refresh
  over an unrelated pending update it never saw. The new
  pendingActivationLinksHost returns that failure (the other callers keep
  the warning only), and a suite-switch run skips the refresh when the
  host's pending state is unknown.
- The ProtectVersionError field comment says that the expanded value
  stays in effect and that only an empty value protects nothing.

ADR-0021, the CLI, SDK, last-run and design docs, AGENTS.md and the
correction record of the first finding follow; a new record covers the
host enumeration.

Refs #511
@frostyard-machines

Copy link
Copy Markdown
Contributor Author

Cross-review record

  • Reviewer: openai/gpt-6.1-sol (coder: anthropic/claude-opus-5-5)
  • Base: 6d399badd5fc0267de8892dfccabbd1ec7dab54a. The copy of fix(sysext): clean up other-suite images in vacuum and disable #515's commit 88752b3 (3a1038a) is reviewed on fix(sysext): clean up other-suite images in vacuum and disable #515, not here.
  • Initial review at 3f46e437d9f8aa9bc24cf91ec8976108b0f38afd: Not ready, 3 blocking and 1 non-blocking finding, all accepted:
    1. The suite-switch refresh could activate another update that the timer linked for the next boot → it skips the refresh when another activation is pending.
    2. The selection ran only before the lock → it selects again under the lock before any download.
    3. A domain load failure wrote no last-run record → recorded as a failed run, class config.
    4. (non-blocking) The ProtectVersion= warning named the wrong value → it names the expanded value.
  • Re-review 1 at 8baafd674e858841f311d72e267c25bf3c9b16f8: Not ready, 2 blocking and 1 low finding, all accepted:
    1. A pending deactivation (merged but not linked) did not stop the refresh → it now does (fail closed).
    2. A host-wide definition load failure fell back to the scoped transfers → pendingActivationLinksHost returns the failure, and the suite-switch run skips the refresh.
    3. (low) The ProtectVersionError field comment was out of date → corrected.
  • Re-review 2 at ccdd69922910a296ea85214d549599d5e568b6b7: Ready. Findings: none. Blocking: none.

Guards (each fails with its fix reverted; 1 .memory/corrections/2026-11-13-pr-516-*.json record per blocking finding):

  • TestUpdateFeatures_SuiteSwitchKeepsOtherActivationsForNextBoot/{other_update_linked_by_the_timer,other_image_merged_but_not_linked}
  • TestUpdateFeatures_SuiteSwitchSelectsAgainUnderLock
  • TestUpdateFeatures_SuiteSwitchRecordsDomainFailure
  • TestUpdateFeatures_SuiteSwitchHostDefinitionsUnreadable
  • TestProtectVersionWarningNamesExpandedValue/literal_and_specifier

Checks: make ci green locally at the head (coverage 90.7%); all CI checks green at ccdd699.

Merge order: merge #515 first. This branch is then rebased (commit 3a1038a drops out; config/transfer.go, config/transfer_test.go, docs/specs/config-reference.md and updex/install.go need a merge), so the rebased head needs green CI and a new review of the conflict resolution before it is ready again.

@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation github_actions Pull requests that update GitHub Actions code go Pull requests that update go code level:L1 Read every line ready-for-human Reviewed, CI green: ready for Brian to review and merge risk:high Touches a path in .github/risk-paths.json

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suite switch: a sysext is missing until the 2nd boot, and an empty %w fails silently

2 participants