Skip to content

feat(update): tell system package installs about new releases, sooner - #314

Merged
pjcdawkins merged 16 commits into
mainfrom
claude/cli-update-notification-frequency-6d413d
Nov 19, 2026
Merged

pjcdawkins merged 16 commits into
mainfrom
claude/cli-update-notification-frequency-6d413d

Conversation

@pjcdawkins

@pjcdawkins pjcdawkins commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

CLIs installed from the apt, yum/dnf or apk repositories did not check for or announce new releases, on the assumption that the OS updates them. Third-party repositories are not covered by unattended upgrades by default, so these users only got a release when they happened to upgrade.

Changes

  • Package installs are notified. The package manager is the one whose database owns the executable (dpkg-query -S, rpm -qf, apk info --who-owns), asked only before printing a notice. For RPM it is dnf if on PATH, or else yum. The install methods are now apt, dnf, yum and apk; package remains for an unknown package manager, which gets the generic link.

  • Downloaded packages get the generic link. A package installed with dpkg -i, rpm -i or apk add --allow-untrusted cannot be upgraded with the package manager. So the method is package unless the package manager reports, without network access, that the package is installed and comes from an enabled repository:

    • apt: apt-cache policy lists /var/lib/dpkg/status (the package is installed) and another source
    • apk: apk --no-network policy lists lib/apk/db/installed (the package is installed) and another source
    • dnf: the installed package's from_repo is in dnf -C repolist --enabled
    • yum: the From repo of yum -C info installed is in yum -C repolist enabled

    For dnf and yum, this is the repository the package was installed from, so a package installed with rpm -i, from a repository added later, gets the generic link.

    Without an index (apt's package lists, apk's cache), apt and apk do not list the repository, so the generic link is shown.

  • New config key wrapper.package_name. The suggested command refreshes the index and upgrades the package, with sudo unless running as root (or doas, if it is installed and sudo is not):

    • apt update && apt install --only-upgrade upsun-cli
    • dnf upgrade --refresh upsun-cli
    • yum clean expire-cache && yum upgrade upsun-cli
    • apk add --upgrade --update-cache upsun-cli
  • Per-version throttle. A version newer than the one last announced (notified_version in the state) is announced without waiting for the weekly interval, which now only applies to reminders.

  • Same-run notice. If the background check finishes before the command exits (it was already waited for, for up to 1 second), a release it found is announced at the end of that run, rather than on the next one.

The package repositories are updated by the release workflow straight after the GitHub release (for v5.17.0, all three within a minute), so the GitHub check is used as is. If that upload fails, the suggested command finds nothing to upgrade.

Behavior changes

  • <PREFIX>INSTALL_METHOD=apt (or dnf, yum, apk) now selects that command, instead of silencing the notice. <PREFIX>UPDATES_CHECK=0 still disables checks.
  • --version can be followed by a notice on stderr, in an interactive terminal.

Verification

A build versioned 5.16.0, placed over a 5.16.0 package install in debian:stable-slim, fedora:latest, amazonlinux:2 and alpine:latest containers: each showed its command at the end of the first run, nothing on the second, and the command upgraded the CLI to 5.17.0. A downloaded .deb without the repository got the generic link, and a non-root user on Alpine with only doas got a doas command.

The repository check was tested with the 5.17.0 packages in debian:stable-slim, fedora:latest (dnf 5), rockylinux:9 (dnf 4), amazonlinux:2 (yum), alpine:latest (apk 3) and alpine:3.20 (apk 2): a repository install got the package manager's command, also after dnf/yum clean all; a downloaded package (dpkg -i, rpm -i, apk add --allow-untrusted), a disabled dnf/yum repository, or removed apt lists or apk cache got the generic link.

Timings there for version, in a terminal:

Run Time
No check due, no notice 30–40 ms
Notice from the cached version (includes the ownership query) 30–40 ms
Check due, release found and announced at exit 190–410 ms

The ownership query alone took 6–36 ms.

🤖 Generated with Claude Code

CLIs installed from the apt, yum/dnf or apk repositories did not check
for or announce new releases, on the assumption that the OS updates
them. Third-party repositories are not covered by unattended upgrades by
default, so these users only got a release when they happened to upgrade.

- Check and notify for package installs. The package manager is the one
  whose database owns the executable (dpkg, rpm, apk), asked only before
  printing a notice; for RPM it is dnf if on PATH, or else yum. The
  install methods are now apt, dnf, yum and apk, with "package" for an
  unknown package manager (generic link).
- Add the wrapper.package_name config key, and suggest a command that
  refreshes the index and upgrades the package, with sudo unless root.
- Make the weekly throttle per version: a version newer than the one
  last announced (notified_version in the state) is announced at once.
- Announce a release at the end of the run whose background check found
  it, if the check finished in time, rather than on the next run.

The package repositories are updated by the release workflow within a
minute of the GitHub release, so the GitHub check is used as is.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@upsun-dispatch upsun-dispatch Bot 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.

Warning

Changes suggested — 🟡 2 warnings · 🔵 2 minor points

🔍 Full review · 14 files reviewed

Verification
  • StartUpdateCheck saves KnownLatestVersion before close(done), so when Wait returns true, the exit-time PendingNotification reads the new version.
  • The shown flag stops the exit-time call from repeating a notice already shown before the command's output, and quiet mode skips both calls.
  • notificationFromState throttles a version for a week only when NotifiedVersion is at least as new; an empty NotifiedVersion keeps the old weekly behaviour.
  • No caller of the removed AutoUpdating/IsAutoUpdating/pkgOwned symbols remains in the tree.
  • rpmFrontend prefers dnf over yum and falls back to package when neither is on PATH (e.g. zypper).

The diff adds unit tests for upgradeCommandFor/packageUpgradeCommand, detectInstallMethod with an injected pkgManager, rpmFrontend, parseMethod, the per-version throttle and Wait's return value; CI's make test-go step in ci.yml runs them. Nothing tests the real owningPackageManager subprocess queries or the exit-time notice path in finishUpdateCheck.

Review details
  • Commit: 1eaf5e5
  • Model: claude-opus-5-5

Review 1 of 10 for this pull request · View the full run

Comment thread internal/install.go Resolved
Comment thread commands/root.go Resolved
Comment thread commands/root.go Resolved
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

CLI builds

Built from 3b2876f (merged into the base branch). Downloads need a GitHub login, and expire after 7 days.

Platform Download
linux-amd64 cli-linux-amd64
linux-arm64 cli-linux-arm64
darwin-amd64 cli-darwin-amd64
darwin-arm64 cli-darwin-arm64
windows-amd64 cli-windows-amd64

Or download one with the GitHub CLI, e.g.:

gh run download 44599565815 -R upsun/cli -n cli-linux-amd64
chmod +x upsun
./upsun --version

On macOS, if you downloaded it with a browser, remove the quarantine attribute before running it: xattr -d com.apple.quarantine upsun.

Address review findings on the package install notice:

- A downloaded package (installed with dpkg -i, rpm -i or apk add
  --allow-untrusted) is owned by the package database, but cannot be
  upgraded with the package manager. The method is now only apt, dnf,
  yum or apk if the package manager's configuration mentions the host
  of the repository (the new wrapper.package_repository config key).
  Otherwise it is "package", which gets the generic link.
- The yum command now runs "yum clean expire-cache" first, as yum
  otherwise uses its cached metadata for hours.
- Suggest doas instead of sudo if doas is installed and sudo is not, as
  is usual on Alpine.
- Correct the design document on manual package installs.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@upsun-dispatch upsun-dispatch Bot 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.

Warning

Changes suggested — 🟡 1 warning

🔁 Incremental · 9 files reviewed

Verification
  • packageMethod returns before calling repoInUse when pkgRepo is empty or the owner is unknown/package, so test probes without repoInUse never call a nil func.
  • installer.sh writes https://repositories.upsun.com into upsun.list, upsun.repo and /etc/apk/repositories, so the substring wrapper.package_repository: repositories.upsun.com matches what the installer configures.
  • privilegeCommand returns doas only when sudo is missing and doas is present, and returns no prefix for root; TestPrivilegeCommand covers all four combinations.
  • The yum command now starts with yum clean expire-cache, and both parts get the privilege prefix, as the updated TestUpgradeCommandFor case expects.

This diff adds or updates unit tests: TestDetectInstallMethod gains cases for a repository that is not in use and for a missing repository config, plus new TestAnyFileContains, TestPrivilegeCommand and TestPackageUpgradeCommandPrivilege. They run under make test-go. No test covers commented-out or disabled repository entries.

Review details

Review 2 of 10 for this pull request · View the full run

Comment thread internal/install.go Resolved
The repository counted as in use if its host appeared anywhere in the
package manager's configuration, including in entries that a release
upgrade commented out, in backup files, and in disabled repositories.

- Skip comment lines.
- Only read the files that apt and apk read (*.list, *.sources).
- Skip a file that disables a repository (enabled=0, Enabled: no). The
  file is not parsed to find out which one, so this errs towards the
  generic link.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@upsun-dispatch upsun-dispatch Bot 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.

Note

Reviewed — No blocking findings · 🔵 1 minor point

🔁 Incremental · 4 files reviewed

🔵 Minor point

  • internal/install.go:178 — repoDisabled only recognises 0|no|false. dnf/libdnf also accepts off for enabled=, and apt's deb822 Enabled: field also accepts off and disable. Take a repo file that contains baseurl=https://repositories.upsun.com/... and enabled=off, or a .sources stanza with Enabled: off: enablesRepo still returns true. packageMethod then returns dnf/yum/apt instead of package, and the notice suggests an upgrade command that finds nothing to upgrade.
Verification
  • The apt globs now take only *.list and *.sources, so *.list.distUpgrade backups no longer count (tested by TestAnyFileEnablesRepo).
  • enablesRepo trims each line before testing for #, so indented comment lines in /etc/apk/repositories are skipped.
  • The Upsun repo files written by installer.sh and docs/install.md have a single section with enabled=1, so the 'any disabled section voids the file' rule does not misclassify them.
  • Removing the bytes import leaves nothing that still uses it; regexp is now imported and used.

New table-driven TestEnablesRepo and the rewritten TestAnyFileEnablesRepo in internal/install_test.go cover comments, disabled deb822/yum entries and backup-file exclusion; they run under make test-go. Nothing tests the other ways of writing 'disabled' (such as off) or files that hold several repos.

Review details

Review 3 of 10 for this pull request · View the full run

dnf also accepts "off" for enabled=, and apt's deb822 Enabled: field
also accepts "off" and "disable".

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@upsun-dispatch upsun-dispatch Bot 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.

Warning

Changes suggested — 🟡 1 warning

🔁 Incremental · 2 files reviewed

Verification
  • The widened repoDisabled regex is still anchored with ^…$ and (?i), so enabled=off and Enabled: disable match only as whole lines, ignoring case.
  • The two new TestEnablesRepo cases both put a matching repository URL first and a disabling line after it. They show that a disabling line wins over an earlier mention.

TestEnablesRepo gets two new table cases in internal/install_test.go, covering enabled=off (yum) and Enabled: disable (deb822). CI runs them through make test-go. Nothing covers apt's without spelling.

Review details

Review 4 of 10 for this pull request · View the full run

Comment thread internal/install.go Resolved
pjcdawkins and others added 2 commits November 16, 2026 09:32
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
With DNF 5, "dnf config-manager" disables a repository in
/etc/dnf/repos.override.d rather than in its file in /etc/yum.repos.d,
so a disabled repository still got the dnf upgrade command. For dnf,
the override files (also in /usr/share/dnf5/repos.override.d) are now
read as DNF applies them: by file name, section names as glob patterns,
and the last "enabled" setting wins.

Also make TestUpgradeCommandFor independent of whether the host has
sudo or doas, and update two comments on install-method detection.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@upsun-dispatch upsun-dispatch Bot 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.

Warning

Changes suggested — 🟡 1 warning

🔁 Incremental · 5 files reviewed

Verification
  • TestUpgradeCommandFor now stubs lookPath, so its expected sudo strings no longer depend on whether the test host has sudo or doas installed.
  • In privilegeCommand, the parameter named lookPath shadows the new package variable, and the caller passes the variable in explicitly, so behaviour is unchanged.
  • repoSections resets section after its first match, so each section ID appears once. Commented lines are skipped, matching enablesRepo.
  • anyFileEnablesRepo keeps the old behaviour when no override patterns are given, because len(overrides) == 0 returns true straight away.

This increment adds TestAnyFileEnablesRepoWithOverrides, which runs table-driven cases against temporary directories: override files that disable or re-enable the repository, glob section names, ordering by file name across the two directories, and non-.repo files. It updates TestAnyFileEnablesRepo and TestUpgradeCommandFor. No test covers two override files with the same name.

Review details

Review 6 of 10 for this pull request · View the full run

Comment thread internal/install.go Resolved
pjcdawkins and others added 3 commits November 16, 2026 12:02
DNF 5 reads only the /etc/dnf/repos.override.d file when a file of the
same name exists in /usr/share/dnf5/repos.override.d. Both were read,
so a repository disabled in a masked file counted as disabled.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…n files

The update message code moves from commands/root.go to
commands/update_message.go. The closure that showed the message becomes
a type, updateNotifier, with tests for: the message before or after the
command's output, showing it once, quiet mode, and recording a version
whose message was not printed.

The parsing of package repository configuration moves from
internal/install.go to internal/package_repo.go, with its tests.

No change in behavior.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Split owningPackageManager into packageOwner, which takes the command
lookup and runner as arguments, and test its query order, the choice of
dnf or yum for an RPM, and a timeout counting as owned.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@upsun-dispatch upsun-dispatch Bot 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.

Note

Reviewed — No blocking findings · 🔵 1 minor point

🔍 Full review · 18 files reviewed

🔵 Minor point

  • internal/update.go:68 — The doc comment on StartUpdateCheck, just above this hunk ("The result is cached in the state, for PendingNotification to read in a later invocation"), is now out of date. finishUpdateCheck calls PendingNotification in the same run once Wait reports the check finished, so the result is no longer read only by a later invocation. The PR rewrote the matching comment in commands/root.go but left this one unchanged.
Verification
  • updateNotifier.shown stops a second notice: when the start-of-run notice has printed, the exit notice in finishUpdateCheck does not print again, even though Execute and exitWithError can both call it.
  • readOverrides keys override files by base name, reading /usr/share/dnf5 before /etc/dnf, so a same-named /etc file masks the vendor file as DNF 5 does.
  • packageMethod only returns apt/dnf/yum/apk when repoInUse finds the configured repository host, and otherwise returns package, which upgradeCommandFor turns into the generic link.
  • newerThanNotified treats an empty NotifiedVersion (state saved by an older CLI) as not newer, so the weekly throttle still applies after an upgrade from an older version.

New unit tests cover the change: TestUpdateNotifier, TestUpgradeCommandFor, TestPrivilegeCommand, TestPackageOwner, TestRPMFrontend, TestAnyFileEnablesRepo(WithOverrides), TestEnablesRepo and new throttle cases in TestNotificationFromState. They run in the test job of .github/workflows/ci.yml. Nothing automated tests the real dpkg/rpm/apk queries or the real files under /etc; the PR describes only manual container testing for those.

Review details
  • Commit: 7cb0a77
  • Model: claude-opus-5-5

Review 10 of 10 for this pull request · View the full run

pjcdawkins and others added 5 commits November 18, 2026 23:49
The cached result is now also read in the same run, once the check has
finished, not only in a later invocation.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…he package

Replace the scan of repository configuration files for the repository's host
with the package manager's own queries, run without network access:

- apt: `apt-cache policy` lists a source other than the dpkg status file
- apk: `apk --no-network policy` lists a source other than the installed database
- dnf: the installed package's `from_repo` is an enabled repository
- yum: `yum info installed` has a `From repo` that is an enabled repository

These use the package manager's parsing of its configuration, and dnf and yum
record where the package came from. Any enabled repository that provides the
package counts, so the `wrapper.package_repository` config key is removed.

Without an index (apt lists, apk's cache), apt and apk do not list the
repository, so the notice gets the generic link.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ownership query only finds that some package owns the executable. If it
was another package, and the configured package was available in a
repository, `apt-cache policy` and `apk policy` listed the repository, and the
notice suggested an upgrade command that does nothing.

Also require the dpkg status file (apt) or the installed database (apk) as a
source, as dnf and yum already query the installed package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dnf and yum check that the package was installed from a repository that is
still enabled, not that an enabled repository provides it: a package
installed with `rpm -i`, from a repository added later, gets the generic link.

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

Copy link
Copy Markdown
Contributor Author

@upsun-dispatch review

@upsun-dispatch upsun-dispatch Bot 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.

Note

Reviewed — No blocking findings · 🔵 1 minor point

🔍 Full review · 18 files reviewed · cc06b6d

Verification
  • updateNotifier.show sets shown before printing, so a notice shown at the start is not repeated by the exit-time call in finishUpdateCheck.
  • Each exit path (Execute, the exitError branch, both exitWithError branches, --version) calls finishUpdateCheck exactly once before os.Exit or return.
  • aptSource does not match version rows such as 5.16.0 500 or *** 5.17.0 100, and the isNumber guard skips a version that is all digits, so only source rows set installed/repo.
  • newerThanNotified treats an empty NotifiedVersion from older state files as not newer, so the old weekly throttle still applies after an upgrade.
  • IsAutoUpdating, AutoUpdating and pkgOwned have no remaining Go callers; only the historical sections of the design doc mention them.

New unit tests cover the new code: update_message_test.go (upgrade commands, privilege selection, notifier start and exit behaviour), install_test.go (packageOwner, rpmFrontend, override parsing), package_repo_test.go (apt/apk/dnf/yum output parsing, using captured output) and update_test.go (per-version throttle, Wait's return value), and they run under make test-go. No test runs the real package manager queries; the PR description reports manual checks in containers instead.


View the full run

Comment thread commands/update_message.go Resolved
A notice shown at exit ran the install method detection (package
manager queries of up to 3 seconds in total) after the command had
finished, on top of the 1 second wait for the check.

The background check now runs the detection itself when it finds a
release to announce, while the command runs. The wait for the check is
then the only delay at exit: if detection has not finished within it,
the notice is left for a later run.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@pjcdawkins
pjcdawkins enabled auto-merge (squash) November 19, 2026 19:35
@pjcdawkins
pjcdawkins merged commit 2ea4268 into main Nov 19, 2026
13 checks passed
@pjcdawkins
pjcdawkins deleted the claude/cli-update-notification-frequency-6d413d branch November 19, 2026 19:37
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