fix(scripts): use one whole-history first landing for release tags

Why: the untagged-run branch looked for an earlier run of a version only
from the start of the wanted range, while tag validation used the first
landing across all history. After a backfill, a revert to a pre-backfill
version was tagged on the revert commit, and the next dry run reported
that tag as a later landing: exit 2, blocking --apply for every plugin.

Implementation Notes:
- first_run() returns the first valid run of a version over the whole
  first-parent history; tag validation, the tagged-elsewhere check, the
  backfill start and the untagged-run check all use it.
- An untagged version whose first landing lies before the wanted range
  reports RELEASED with a "before the tagged range; not tagged" note; no
  tag is created and the exit code is unaffected.
- Preflight rejects a plugin name whose tag git check-ref-format refuses
  (e.g. a..b, a*) before any history is read, so a glob character never
  reaches a pathspec or ref pattern; tags are listed once and filtered by
  exact prefix instead of a for-each-ref glob.
- git rev-list failure and an empty run list now exit 2 with a FAIL
  message instead of being read as no history or crashing.
- The error footer addresses agents (stop and report, AGENTS.md) and the
  maintainer (fix by hand, ADR-0033) separately.

Impact: ADR-0033 defines first landing precisely, documents the preflight,
and documents the maintainer escape from an INVALID run (hand-cut tag on
the next valid version; --apply stays all-or-nothing). New tests cover the
revert repro, a backfill range holding a pre-range version, the INVALID
escape, rev-list failure/empty history, a glob plugin name, and the footer.

Refs: #223
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
Defame1297andClaude Opus 5.5 committed 2026-11-27 19:25:16 +00:00
1 parent 0a52c8597d
commit 62650543ec
3 files changed
+219 -52

No files matched your search

@@ -32,7 +32,9 @@ Two facts limit where enforcement can live:
- **Name.** `<plugin>` is the directory under `plugins/` and must equal that `apm.yml`'s `name`.
`<version>` is the strict `MAJOR.MINOR.PATCH` from the same file. Example: `git-v1.3.9`. The
repo-level `v*` tags stay as they are.
repo-level `v*` tags stay as they are. A plugin directory whose name starts with `-`, or whose
`<plugin>-v<version>` `git check-ref-format` rejects (`a..b`, `a*`), can never be tagged, so the
script rejects it before reading any history.
- **Target.** The tag goes on the oldest commit, in `main`'s first-parent history, of the
contiguous run carrying that version. That is the merge or squash commit where the version first
landed on `main`, never a feature-branch commit. An `apm.yml` edit that leaves `version:` alone
@@ -42,11 +44,19 @@ Two facts limit where enforcement can live:
first is reported as an error for a human to resolve. Every
reachable `<plugin>-v*` tag is checked this way, not only those of the wanted runs, and an
invalid one never decides where the wanted runs start, so it cannot hide the versions before it.
- **A version is released once, at its first landing.** When a version comes back (a reverted
bump, or an `apm.yml` deleted and re-added), the later run is not tagged again: its tag already
exists on the earlier run, so the script reports that run `RELEASED` and it blocks nothing. An
untagged version that recurs within the wanted runs is tagged at its first landing there, and
the later runs report `RELEASED`.
- **A version is released once, at its first landing.** A version's first landing is the oldest
run carrying it anywhere in `main`'s first-parent history, not only among the wanted runs. The
script uses this one definition both to validate existing tags and to decide which tags to
create. When a version comes back (a reverted bump, or an `apm.yml` deleted and re-added), the
later run is never tagged: the script reports it `RELEASED`, and it blocks nothing. There are
three cases:
- The version's tag exists: it must be on the first landing.
- The version is untagged and its first landing is among the wanted runs: that run is the one
tagged (`MISSING` until then).
- The version is untagged and its first landing lies before the wanted runs: the version shipped
before the tagging start point. It stays untagged, like the rest of the history the backfill
leaves out, and the later run reports `RELEASED` with a note naming the first landing. Tagging
the later run instead would cut a tag the next run reports as an error.
- **Mechanism.** `scripts/tag-plugin-releases.sh` computes the targets from `origin/main`'s
history and cuts the tags after merge. Without arguments it is a dry run: it prints a
`plugin version commit status` table and exits 1 if any tag is missing. `--apply` creates the
@@ -62,6 +72,15 @@ Two facts limit where enforcement can live:
first landing anywhere in history and any later run of it reports `RELEASED`; when the current
version never recurred, that is the current run alone. That second rule is the backfill: older
history is not tagged retroactively.
- **An invalid version blocks `--apply` until a maintainer resolves it.** A run in the wanted range
whose `version:` is not strict `MAJOR.MINOR.PATCH` is an error row, and because `--apply` is all
or nothing it blocks every plugin's tags, not only that plugin's. The script does not skip it,
since silently skipping a run would hide whatever version shipped there. The escape path belongs
to the maintainer: cut by hand the annotated tag of the first valid version after the invalid
run, on that version's first landing. That tag becomes the plugin's start point, the invalid
run is no longer wanted, and the next `--apply` proceeds. Any version between the old start
point and the invalid run is then the maintainer's to tag by hand too, if it is wanted at all.
An agent that hits this stops and reports, like any other exit 2.
- **One deliberate exception to the backfill: git's previous version, `git-v1.3.8`, is also
tagged**, on `32fbe39fb8923854ca8e743a0d2cad81720c736c`, where 1.3.8 first landed on `main`. This
gives a consumer pinned to an older git tag something real to check `apm outdated` against. It is