0137: Tagged git plugins update automatically, with what they need¶
- Implementation built
Context and Problem Statement¶
ADR 0116 leaves every plugin from git to be
updated by hand. A catalog plugin is installed from git, pinned to one commit
(name @ git+https://github.com/OWNER/REPO@<commit>#subdirectory=plugins/<name>), so the automatic updater left
exactly the plugins people install most often where they were, without a word. Plugins have their own versions and
their own tags, <distribution>/vX.Y.Z (ADR 0094), and one
plugin can need a newer release of another. How do such plugins update as safely as the ones from PyPI, and how do
plugins that need each other move without one of them holding back hz or the rest?
Decision Drivers¶
- The same safety as for PyPI: stable releases only, a minimum age, exact versions, verified from metadata, and everything put back on any failure.
- A git tag can move; what is installed must be the commit announced.
- One resolver run for everything that moves; nothing is ever run to learn what a plugin needs.
- ADR 0094 independence: one plugin that can't move holds back only the plugins that need it, never hz or others.
Considered Options¶
- Follow the release tags of plugins pinned to a GitHub commit, and move each with the plugins it needs (chosen)
- Follow the default branch: moves on every commit, no version, nothing to age.
- Keep git plugins by hand (ADR 0116): the catalog's plugins never update by themselves.
Decision Outcome¶
Chosen option: follow the release tags, because a tag names a version and a commit that can be aged, recorded and checked again, exactly like hz's own release tag.
- Announce. A plugin pinned to a full commit of a GitHub repository is asked through the GitHub API (the gh login,
or the plugin settings' token), in bounded requests: one listing of its tags
<distribution>/v, then the commit the newest stable one names and its date. Pre-releases, development releases and other tag shapes are ignored. The release counts once it is as old asauto_update_plugin_min_age_hours, by the later of its commit date and, for an annotated tag, the tag's date. The commit is recorded with the news. The project table at that commit must name the tag's version. A failed check keeps the news from before, as for PyPI. - Apply.
system.apply-announcedinstalls such a plugin at exactly the recorded commit, asks only it again (--refresh-package,--reinstall-package) and holds everything else as ADR 0116 does. Before anything is installed, its tag must still name the recorded commit, or nothing is installed and one message says so. Afterwards its metadata must name the announced version and itsdirect_url.jsonthe recorded commit, or the tool folder is put back. The receipt names the new commit: the plugin stays pinned. - Plugins that need plugins. What each installed plugin requires of another is read from its metadata
(
Requires-Dist); what a new release requires, from PyPI's release JSON or the project table at the tagged commit. A release that needs another plugin newer moves only together with that plugin's own release, in the same uv run, dependencies first in the news. If that release can't move (too new, held back, not released), the plugin that needs it waits too, and so does a release an installed plugin doesn't allow; one line in the log and in the Updates status (plugins_held) says so. Only that closure waits: hz and unrelated plugins update as before. - Plugins from a git branch, another host, a folder or a URL, and git plugins whose repository has no such tags, stay updated by hand; the Updates pane names only those.
Consequences¶
- Good, because catalog plugins update by themselves with the same checks as PyPI plugins and hz.
- Good, because plugins that need each other never land half updated, and never hold back hz.
- Bad, because a lightweight tag set today on an old commit counts as old as the commit: git records no date for it.
- Bad, because whether a new plugin release allows the new hz is still left to uv: a conflict puts everything back.
Confirmation¶
Unit tests fake GitHub's answers: tag listing, a moved tag refused, a release too new, pre-releases ignored, a dependency closure announced together, a dependent held when its dependency can't move, and hz and unrelated plugins unaffected; the apply tests check the commit installed and verified.
Amendment, 12 Nov: an update run by hand follows the same releases, once the person agrees.
hz system update and the app's Update all used to keep every plugin at the exact version or commit
hz system plugin add recorded ("pinned; newer releases not checked"), although automatic updates already moved the
same plugins. A pin made by an add records what was installed; it is not a decision to stay there. So an update a
person agreed to (the question on a terminal, --yes, or the app's confirmation) asks the same sources: a plugin
pinned to a commit of a GitHub repository goes to the commit of its newest stable release tag, and one pinned to an
exact index version follows the index from then on. It never moves back, and never guesses: a plugin whose repository
tags no releases, or whose releases can't be asked, stays and the plan says why.
Without agreement (a script,
--json, the REST API without yes) pins stay as before, and --keep-pins keeps them on purpose. The update shows
its plan first (--preview shows only that) and can bring an installed desktop app along with hz app install.
Amendment, 28 Nov: a tagged release is as old as its published GitHub Release. Git dates are set by whoever
makes the commit or the tag, so a backdated commit aged at once. A tagged release now counts from the
published_at of its GitHub Release (/releases/tags/<distribution>/v<version>), never earlier than its commit or,
for an annotated tag, the tag. A tag without a published Release (none, or a draft) is not announced, and the Updates
status says so in plugins_held; an update run by hand still offers it once a person agrees. A recorded commit must
be exactly 40 hexadecimal characters (a trailing newline is refused). This supersedes "by the later of its commit date
and the tag's date" above, and the consequence about lightweight tags.
Amendment, 28 Nov: a moved or unreadable plugin tag holds only its closure. Before anything is installed, the
tag of each announced plugin is asked again. A plugin whose tag now names another commit, or can't be asked, is taken
out of the news together with every announced plugin whose release needs it (the same closure as at announce time),
with one line each in plugins_held; hz and the other plugins apply. Only a moved tag of hz itself fails the plan,
and so does a plugin tag when nothing else is left to apply. This replaces "nothing is installed and one message says
so" under Apply for plugins.