Skip to content

fix(features): apply RequisiteFeatures= as an AND gate in every feature path - #469

Merged
bketelsen merged 3 commits into
mainfrom
lucilla/requisite-features-gate
Oct 26, 2026
Merged

bketelsen merged 3 commits into
mainfrom
lucilla/requisite-features-gate

Conversation

@frostyard-machines

Copy link
Copy Markdown
Contributor

Summary

Fixes #455. RequisiteFeatures= was parsed but not enforced: every feature command selected transfers with config.GetTransfersForFeature (feature in Features= or RequisiteFeatures=). updex now applies the systemd sysupdate.d(5) activation rule in every feature path (ADR-0017):

A transfer is active when Features= is empty or one listed feature is enabled (OR), and every RequisiteFeatures= entry is enabled (AND). A feature that does not exist, is disabled or is masked is not enabled.

  • config.CheckTransferActivation is the single implementation of the rule (FilterTransfersByFeatures now uses it). GetTransfersForFeature stays as the association lookup only.
  • updex/activation.go splitFeatureTransfers splits a feature's associated transfers into active and inactive over the loaded domain's enabled set, with the feature forced enabled (update, check, enable, rollback, the hold read in Features) or disabled (disable).
  • features update / check: act only on active transfers. Inactive ones are not downloaded, linked or vacuumed, and are reported (inactive in JSON, one inactive: line in text).
  • features enable --now (and dry run): installs only transfers that are active with the feature enabled; reports the ones still waiting (FeatureActionResult.Inactive). Enabling lodge --now installs Features=maild RequisiteFeatures=lodge when maild is already enabled.
  • features disable --now (and dry run): a transfer that another enabled feature in its Features= still activates is kept (FeatureActionResult.Kept): no unlink, no removal, not in the merged-state --force check. Only the transfers the disable makes inactive are removed. With nothing left to remove, it runs no unmerge, no refresh and no refresh-gate preflight; only the drop-in is written.
  • Rollback holds: collectRollbackHolds, rollbackHoldReason and deleteFinishedRollbackRecords get the acted-on (active) set, so a record that applies only to a transfer a feature does not act on no longer holds that feature. rollbackFeaturesOf (which records are read) stays the association: it reads more records, never fewer. RollbackFeature rolls back and records only active transfers, and fails with feature '<name>' has no active transfers to roll back: … when there is none.
  • CatalogRemove: unchanged. RenderTransfer replaces Features= with Features=<name>, so a catalog transfer is never kept.

Docs: docs/specs/config-reference.md and docs/design/overview.md now agree (and sdk-api.md, README.md, AGENTS.md). New ADR-0017.

Compatibility

  • New JSON fields are additive: inactive (update, check, enable), kept (disable).
  • Behaviour change (the point of the fix): a transfer gated by a disabled requisite is no longer downloaded or linked by update/enable --now; disable --now no longer removes a transfer that another enabled feature activates.
  • An inactive transfer that an older updex already installed keeps its link and images: update does not remove them (as systemd-sysupdate, removal is a separate action); disable --now of a feature it names removes it.

Checks

  • make fmt
  • make ci (passed locally at this head; coverage 90.0%, baseline raised 89.7 → 90.0)
  • go test -race ./updex/ ./config/ ./cmd/updex/
  • CLI tests for text and JSON output of update, check, enable --now, disable --now
  • Focused tests, including failure paths: see below

New tests (updex/requisite_test.go, config/transfer_test.go, cmd/updex/features_requisite_test.go): the 3 activation cases for update and check; unknown and masked requisite; dry run; enable --now waits / installs the waiting transfer / no enabled Features= entry; disable --now keeps a transfer that another enabled feature activates (real and dry run, merged image, no unmerge/refresh); nothing-to-remove runs no preflight; disable removes what it makes inactive; mixed keep + remove; rollback hold of a transfer not acted on does not hold; hold of an acted-on transfer still holds; rollback rolls back only active transfers; no active transfers fails. No existing test changed.

Risk classification

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

Rationale: it changes which images updex downloads, links and removes (disable --now is a destructive operation run as root) and which features a rollback record holds. No file under sysext/, systemd/, download/ or .github/workflows/ changes, so not Tier 4.

Trust boundaries and failure modes

  • Input: .transfer/.feature definitions (root-owned search roots) and the enabled state from drop-ins. No new input.
  • Removal can only shrink: disable --now removes the associated transfers that are inactive without the feature; before, it removed every associated transfer. The kept set needs another feature that is enabled and not masked in the loaded domain.
  • Downloads can only shrink: update/enable act on a subset of what they acted on before.
  • Rollback holds: the records read are unchanged (association, fail closed). A record now holds a feature only through a transfer that feature acts on. A transfer the feature does not act on is never linked by it, so the hold had no effect there except to block the feature's other transfers.
  • Scope: the enabled set is the loaded domain's. With --component or -C, a requisite feature outside the loaded definitions is not enabled, so the transfer stays inactive (fail closed: fewer downloads; for disable, nothing is kept by a feature outside the domain).
  • Known edge: a feature's own rollback record that names a transfer which later becomes inactive stays until that transfer is active again and updates, or until rollback --clear. It does not hold the owner while a newer version of that component exists.

Rollback and recovery

Revert the PR. No file format, record format or unit changes. An image that this version did not download is downloaded by the old version at the next update; a transfer this version kept is removed by the old version's disable --now.

Review

Tier 3: explicit maintainer review of the reliability impact is requested. The cross-family AI review (see the comment) is advisory.

Docs housekeeping

  • README.md, docs/design/overview.md, docs/specs/* updated; AGENTS.md updated
  • New ADR-0017 from TEMPLATE.md, indexed in docs/README.md
  • Conformance aliases untouched

Verification

  • node scripts/check-docs.mjs green (part of make ci)
  • Checked against the PR review rubric

Note on #465

Not closed here. PR #468 (merged) fixed items 1, 2, 3, 4 and 6 (the --clear wording and the up to date row). Item 5 (a failed unit stays failed until the next success) is input for #459. The joined errors without a separator are rendered by fang through clix; that fix belongs in clix. #465 can be closed by a maintainer when #459 and clix track the rest.

…re path

A transfer is acted on only when it is active (sysupdate.d(5)): Features=
empty or one listed feature enabled, and every RequisiteFeatures= entry
enabled. update, check, enable --now and rollback act on active transfers
only and report the others; disable --now keeps a transfer that another
enabled feature still activates; rollback holds are computed over the
acted-on set. ADR-0017.

Fixes #455
@github-actions github-actions Bot added documentation Improvements or additions to documentation go Pull requests that update go code labels Oct 26, 2026
@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.31183% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
updex/features.go 93.33% 1 Missing and 3 partials ⚠️
updex/rollback.go 95.23% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

…ed rollback

A second rollback planned only the active transfers and replaced the
record, so it dropped an earlier rejection of a transfer that had become
inactive. When that transfer became active again, update could link the
rejected version. Keep those entries without moving the link.
@frostyard-machines

Copy link
Copy Markdown
Contributor Author

Cross-family AI review (advisory, not an approval)

  • Coder: github-copilot/claude-sonnet-5.5. Reviewer: openai/gpt-6.1-sol, read-only.
  • Base 37523f85816cb61d116cc33f2dcdaf32fb8ee1e3.
  • Initial review at 1f4bc40 (18 files, 2 batches): Not ready. 1 blocking finding: a repeated RollbackFeature replaced the record with entries for the active transfers only. It dropped an earlier rejection of a transfer that had become inactive (requisite disabled), so a later update could link the rejected version again after the requisite was enabled. Fixed in 1f4429d: preservedRejections keeps existing entries of inactive associated transfers without a link change. A regression test runs the exact sequence. 3 more tests cover the first rollback, the dry run and the restore after a link failure.
  • Re-review 1 at 1f4429d: Ready. 1 non-blocking docs finding: the rollback introduction in docs/design/overview.md was out of date. Fixed in 04ad146.
  • Re-review 2 at 04ad146 (the current head): Ready, Blocking: none.
  • Budget used: 1 review + 2 of 3 re-reviews.

Checks: uncached make ci passed locally at 1f4429d (coverage 90.0%). The commit after it changes docs only, and node scripts/check-docs.mjs passed on it. GitHub CI is green at 04ad146.

Tier 3: explicit maintainer review of the reliability impact is still required (docs/risk-tiers.md).

@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Oct 26, 2026

@bsherman bsherman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bketelsen
bketelsen added this pull request to the merge queue Oct 26, 2026
Merged via the queue into main with commit 8403ebf Oct 26, 2026
19 checks passed
@bketelsen
bketelsen deleted the lucilla/requisite-features-gate branch October 26, 2026 02:21
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 go Pull requests that update go code ready-for-human Reviewed, CI green: ready for Brian to review and merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RequisiteFeatures= is parsed but not enforced: feature commands treat it like Features=

3 participants