Skip to content

refactor(flavors): make flavors.py the only flavor-to-image-name map - #44

Closed
hivecommons-hive[bot] wants to merge 1 commit into
testingfrom
arch/flavor-set-single-source
Closed

hivecommons-hive[bot] wants to merge 1 commit into
testingfrom
arch/flavor-set-single-source

Conversation

@hivecommons-hive

@hivecommons-hive hivecommons-hive Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Collapses the flavor → image-name mapping onto scripts/flavors.py, the file that already declares itself the single source for the flavor set.

What was wrong

The mapping was written three times:

# Location Read by
1 scripts/flavors.py IMAGE dict promote matrix, release matrix
2 Justfile image_name gen-sbom, secureboot, reusable build workflow
3 Justfile build-ghcr (identical case, not a call to #2) the actual tag-and-push

gen-sbom and secureboot already delegate to image_name. build-ghcr — the recipe that tags and pushes the image — carried its own copy.

The duplication is dangerous rather than merely untidy because copies 1 and 2/3 are read on different paths. A disagreement does not fail the build: it produces a build that pushes utah-<a> while the promote matrix looks for utah-<b>, and the failure surfaces one workflow later inside reusable-promote-squash as a tag that does not exist.

What this does

  • Adds flavors.py image FLAVOR. It resolves against the configured flavor set, so it rejects a flavor missing from config/flavors.json — not merely one missing from a case arm, which is what the old code checked.
  • image_name and build-ghcr both call it. Copies 2 and 3 are gone.
  • Adds flavors.py count, needed by the promotion-gate fix ([architect] :testing promotion gate hardcodes the flavor count — a fifth literal outside config/flavors.json #42).
  • Extends the just check guard. It already refused flavored image names under .github/workflows/, but never scanned the Justfile — where two of the three copies lived. The guard skips its own grep lines, which necessarily quote the names.

Verification

$ python3 scripts/flavors.py image nvidia-gaming
utah-nvidia-gaming
$ python3 scripts/flavors.py image bogus
unknown Utah image flavor: bogus     # exit 1
$ just image_name utah testing gaming
utah-gaming

The new guard was confirmed to fail against the case statements this PR removes, and to pass after. Behaviour is unchanged for all four current flavors.

Not included

The related fix to .github/workflows/post-testing-e2e.yml — which hardcodes test "$count" -eq 4 — is not in this PR. The agent App token lacks the workflows permission and the push is rejected. flavors.py count is added here so that fix is a two-line change once a human can push it. A just check assertion for it is left commented in place rather than silently omitted.

Closes #43. Groundwork for #42.

🛑 hold — for maintainer review.

The mapping was written three times: the IMAGE dict in scripts/flavors.py,
the case in the `image_name` recipe, and a second identical case inside
build-ghcr. gen-sbom and secureboot already delegate to `image_name`;
build-ghcr -- the recipe that actually tags and pushes the image -- did not.

These copies are read on different paths, which is what makes the duplication
dangerous rather than merely untidy. `flavors.py images` and `flavors.py
releases` feed the promote and release matrices; `image_name` and build-ghcr
decide what the build tags and pushes. A disagreement between them does not
fail the build. It produces a build that pushes one name and a promote matrix
that looks for another, surfacing a workflow later as a tag that
reusable-promote-squash cannot find.

Both cases now call a new `flavors.py image FLAVOR`, which resolves against
the configured flavor set -- so it rejects a flavor that is absent from
config/flavors.json, not merely one absent from a case arm.

`just check` already refused flavored image names under .github/workflows/,
but never scanned the Justfile, where two of the three copies lived. That
guard is extended to the Justfile; it was confirmed to fail against the case
statements this commit removes. A `flavors.py count` query is added here for
the promotion gate, which is the subject of a separate issue.

Co-authored-by: Copilot <223556219+Copilot@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 red check is pre-existing, and the static gate that matters passed

Recording this so the failing Build Utah isn't held against the change. This PR's run 34026114549, job build_main / image:

install: cannot create regular file '/usr/local/libexec/utah-install-packages': No such file or directory
Error: building at STEP "RUN for pair in install-packages.py:utah-install-packages ..."
error: recipe `build-ghcr` failed with exit code 1

Identical failure on the unmodified base — main@636b48e, run 34654001732, same step, same message. This is Containerfile:81 (#55/#56), not anything in this PR, which touches only Justfile and scripts/flavors.py.

The contract job — which runs just check and therefore the new flavor-literal guard — passed. For a PR whose entire surface is a Justfile recipe and a Python CLI, that is the job that matters, and it is green.

The reasoning in the description is the strongest part. The point that copies 1 and 2/3 are read on different paths, so a disagreement doesn't fail the build but instead produces a push to utah-<a> while the promote matrix looks for utah-<b>, surfacing a workflow later inside reusable-promote-squash as a missing tag — that is a correct and non-obvious failure analysis. Resolving image against the configured flavor set rather than a case arm is the right strengthening, since it catches a flavor missing from config/flavors.json rather than merely one missing from a shell branch.

Confirmed the Justfile really did carry two independent copies of the mapping on main (image_name, and build-ghcr with its own case), and that just check's existing guard only scanned .github/workflows/ — so two of the three copies were never covered. Extending it to the Justfile closes the actual hole.

Conflicts with #64 — these two were designed as a pair and both grew the same half

#64 also adds flavors.py count and also adds guards to the check recipe. They collide:

$ git apply /tmp/pr64.diff && git apply --check /tmp/pr44.diff
error: patch failed: Justfile:79
error: Justfile: patch does not apply

This PR's "Not included" section explains why: the post-testing-e2e.yml fix was left out because the agent App token lacked workflows permission, with flavors.py count added here as groundwork. #64 is that follow-up — but it added its own count rather than depending on this one.

Cleanest sequence is #44 first, then #64 rebased to drop its duplicate flavors.py hunk and keep only the workflow edit plus guard. Worth noting #40 also touches the check recipe and adds tests for flavors.py, so it is a third party to the same region; if #40 lands first, count gets test coverage for free.

Two small things

The commented-out assertion. Leaving the post-testing-e2e.yml guard commented in place rather than silently omitting it is the right instinct. But a commented assertion is invisible to just check and easy to lose — worth making sure #42/#64 actually uncomments it rather than writing a third version.

Base branch is testing, not main. This PR targets testing while #64, #40 and most of the queue target main. Given sync-main-to-testing.yml pushes main → testing, landing this on testing first means it arrives on main only via the promotion path. Worth confirming that is intended, since the Justfile changes it makes are wanted on both.

Both hold and the red base are what's actually blocking here; the change itself looks sound.


Generated by Claude Code

@hanthor

hanthor commented Sep 18, 2026

Copy link
Copy Markdown
Member

Closing: this conflicts with main's Justfile (#91 and #40-era edits landed around the same lines) and the hive agent doesn't rebase, so it can't move on its own. The refactor is still worth doing — flavors.py as the only flavor→image-name map — and #2 tracks it; a fresh PR against main picks it up cleanly.


Generated by Claude Code

@hanthor hanthor closed this Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent/architect Filed or owned by the architect agent. hold Indicates that a PR should not merge because someone has issued a /hold command.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant