Skip to content

fix(dist_bump): tolerate macro-based Release fields - #100

Merged
2 commits merged into
projectbluefin:mainfrom
kylerankin:fix/dist-bump-macro-release
Sep 18, 2026
Merged

2 commits merged into
projectbluefin:mainfrom
kylerankin:fix/dist-bump-macro-release

Conversation

@kylerankin

Copy link
Copy Markdown
Contributor

Problem

tools/dist_bump.py raised BumpError on any Release: containing a macro,
which the CLI turned into an exit 1 that broke .github/workflows/build-stage.yml
at python3 tools/dist_bump.py "$PACKAGE". Any of these packages needing a
dist_bump in config/upstream-sources.json to outrank Hummingbird or Fedora
would crash the build:

  • bootc, libical: Release: %{autorelease}
  • pipewire: Release: %{baserelease}%{?snapdate:...}%{?dist}
  • firefox: Release: 1%{?pre_tag}%{?dist}
  • libXcursor, libXfixes, libXinerama, libXrandr, libinput, libratbag: Release: N%{?gitdate:...}%{?dist}

Fix

spec_release now takes the literal release that precedes the first unexpanded
macro -- the stable segment a recorded baseline compares against. So firefox
(1) and the X11 libraries (5, 8, 11, ...) support real dist bumps. A
release that is only macros (%autorelease, %{baserelease}) has nothing
literal to compare, so the bump is skipped (empty suffix) instead of crashing.

Tests

tests/test_dist_bump.py: leading-segment extraction and the pure-macro
no-bump path replace the old refuse-to-parse test. Full suite, validate and
factory_contract all pass.

— hive: backend=pi model=lemonade/Ornith-1.5-35B-A3B-GGUF-Q6_K

🐝 Hive Agent: contributor | SHA: 3b8d574

tools/dist_bump.py raised BumpError on any Release: containing a macro,
which the CLI turned into an exit 1 that broke build-stage.yml for any
package with a dist_bump configured -- bootc, libical (%autorelease),
pipewire (%{baserelease}...), firefox (1%{?pre_tag}...) and the X11
libraries (5%{?gitdate:...}...).

spec_release now takes the literal release that precedes the first
unexpanded macro -- the stable segment a recorded baseline compares
against -- so firefox and the X11 libs support real dist bumps. A release
that is only macros has nothing literal to compare, so the bump is
skipped (empty suffix) instead of crashing.

Covered by tests/test_dist_bump.py: leading-segment extraction and the
pure-macro no-bump path replace the old refuse-to-parse test.

Signed-off-by: kylerankin <kylerankin@users.noreply.github.com>

@hanthor hanthor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The parsing is correct and the direction is defensible, but it reverses a deliberate safety decision quietly, leaves the documented contract contradicting the code, and has a test gap over the dominant real-world case.

It does fix a real over-refusal

Checked against Release: lines that actually appear in packages/*/*.spec:

Release: line main this PR
%autorelease BumpError ''
%autorelease -b3 BumpError ''
%{samba_release} BumpError ''
5%{?gitdate:.%{gitdate}git%{gitversion}}%{?dist} BumpError '5'
1%{?pre_tag}%{?dist} BumpError '1'
0.bootstrap%{?dist} '0.bootstrap' '0.bootstrap'
2%{?dist} '2' '2'

Nine specs carry that mixed literal+sub-macro shape (firefox, libXcursor, libXfixes, libXinerama, libXrandr, libinput, libratbag, pipewire, pulseaudio), and 107 have a purely-macro Release:. The old blanket refusal really was over-broad. Gates: 173 passed, 27 subtests vs 172 passed, 27 subtests on main; validated 192 source RPMs; quoting clean.

Test gap on the dominant case

I mutated split("%", 1) to split("%{", 1) and all 12 tests still passed. Under that mutant Release: %autorelease returns '%autorelease' instead of ''. test_returns_no_release_for_a_purely_macro_release only covers braced forms — %{krb5_release}, %{autorelease}, %{baserelease} — but 103 of this repo's 107 purely-macro specs use bare %autorelease, and one uses %autorelease -b3. Please add "Release: %autorelease\n" and "Release: %autorelease -b3\n" to that list.

The other mutants are caught: dropping the split fails 3, neutering the baseline comparison fails 2, turning the no-Release: error into a return fails 1.

The skip is silent

suffix() does return "" when release is "" (confirmed, as long as baseline isn't itself ""), so the skip works. But main() prints nothing and build-stage.yml:75 just captures an empty string, so a recorded dist_bump on an %autorelease package is discarded with no trace, where previously the build stopped with a message. The counter exists specifically to make a rebuild outrank a prior one; dropping it quietly produces an RPM that doesn't supersede, and nobody finds out. A print(..., file=sys.stderr) on the empty-release path costs nothing and keeps the skip observable.

A narrower version of what the old code refused still survives

5%{?dist} and 5%{?gitdate:.20260101gitabc}%{?dist} both reduce to '5'. If Fedora bolts on a snapshot suffix without moving the leading integer, the recorded baseline still matches and the stale counter is still emitted. The module's whole argument is that a moved baseline retires the counter; a moved sub-macro now doesn't. I don't think that blocks this — it's a far smaller window than refusing 107 specs — but the docstring's "stable across rebuilds of the same Fedora release" is stronger than what the code guarantees.

Docs now contradict the code

docs/targeting-hummingbird.md:239-241 still reads: "A Release: built from macros — krb5_release, nodejs, and kernel-headers's specrelease — is refused by both, rather than compared as a string that is not a release." That paragraph needs to move with the behaviour, including a note that we now diverge from Hummingbird's bump_release() on the mixed case.

Minor: .strip() after match.group(1) is dead — a (\S+) capture can't contain whitespace.

No entry in config/upstream-sources.json carries a dist_bump today, so none of this changes current output. That's an argument for fixing the docs and the diagnostic now, while it's cheap.


Generated by Claude Code

… docs

- Cover bare %autorelease (and %autorelease -b3) in the purely-macro test;
  103/107 purely-macro specs use the bare form, not the braced one.
- Log the empty-release skip on stderr so build-stage.yml does not drop a
  rebuild silently (a silent "" ships an RPM that does not supersede).
- Drop the dead .strip(): a (\\S+) capture carries no whitespace.
- Re-target the docs at the extract-leading-literal behaviour and note the
  divergence from Hummingbird's bump_release().

@kylerankin kylerankin left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

All four addressed, tests green (12 passed):

  1. Test gap — added bare %autorelease and %autorelease -b3 to test_returns_no_release_for_a_purely_macro_release (the dominant form; 103/107 purely-macro specs). Your mutant split("%{", 1) now fails, as expected.

  2. Silent skip — main() now prints the empty-release skip to sys.stderr. build-stage.yml captures stdout, so without this the bump was dropped with no trace. The "moved baseline" path still returns "" silently, which is correct (no rebuild needed) — only the macro-skip is now logged.

  3. Docs — rewrote the targeting-hummingbird.md paragraph around the extract-leading-literal behaviour and added the explicit note that we diverge from Hummingbird's bump_release() (it refuses macro lines; we extract the leading literal).

  4. .strip() — removed; a (\S+) capture cannot contain whitespace.

@hanthor hanthor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is the approach I'd take over #118 — the literal leading segment is the only thing a baseline can honestly be compared with, and skipping with a stderr line beats a homemade macro expander. One thing broke underneath it since it was opened.

main now has tools/rebuild_plan.py (from #70), whose expected_release() calls spec_release() and treats None as "no comparable release". With this branch merged onto main, one test fails:

FAIL: test_an_autorelease_recipe_falls_back_to_the_version (test_rebuild_plan.PublishedComparisonTests)
  File "tests/test_rebuild_plan.py", line 120
    self.assertIsNone(expected_release(root, entry))
AssertionError: '' is not None

Your spec_release returns "" for a macro-only release; the plan expects None. Returning None there (and keeping the if not release: skip in main(), which already handles either) makes the suite pass — 268 tests otherwise green on the merged tree, and validate still reports 340. Please rebase and make that one change and I'll merge it.


Generated by Claude Code

@hanthor

hanthor commented Sep 18, 2026

Copy link
Copy Markdown
Member

Your branch is on a fork so I couldn't push the one-line fix to it; #138 carries your two commits (authorship preserved) plus a merge of main and the None-instead-of-"" change from the review, and is merging now. Closing this one in its favour — thanks, this is the version that landed.


Generated by Claude Code

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.

2 participants