[architect] refactor: enforce elements/targets.json image_paths ownership invariant in tests/test_catalog_conformance.py - #218
Open
kubestellar-hive[bot] wants to merge 1 commit into
Conversation
…ship invariant elements/targets.json holds two independent structures that must agree: oci_images (matrix membership, cross-checked against catalog/ in both directions) and image_paths (path ownership consumed by the Justfile changed-targets recipe). Only the first was enforced. changed-targets selects an image only when a changed file matches one of its image_paths prefixes, so an image missing from image_paths -- or whose prefixes do not cover the files that define it -- can never be selected. The pull-request build gate then fails open: it reports success having built nothing, which is the exact regression class that job was added to prevent. Add PathOwnershipTests to tests/test_catalog_conformance.py asserting oci_images and image_paths are the same set both directions, that each image owns its catalog record and its three generated elements, that no image claims another's defining files, that shared_paths still lists the gate's own inputs, and that canary_image is published. The ownership assertion reuses the prefix/exact-match semantics of the changed-targets recipe so it measures the real selector. No behaviour change and no manifest edit: the committed manifest already satisfies every assertion. The file is already discovered by the existing test_catalog*.py pattern in image-catalog.yml and 'just catalog-check', so no workflow or Justfile change is needed. Refs #217 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: sec-check[bot] <sec-check[bot]@users.noreply.github.com>
This was referenced Aug 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor
Claimed ground:
tests/test_catalog_conformance.pyonly (one new class,PathOwnershipTests). No other file is touched — notelements/targets.json, not theJustfile, not any workflow.Cluster: the
elements/targets.jsonmanifest-integrity cluster (issue #217).What this changes structurally
elements/targets.jsoncalls itself the single source of truth, but it holds twoindependent structures that must agree and only one was enforced:
oci_imagesCatalogCoverageTests, both directions againstcatalog/image_pathsjust changed-targets(Justfile:154-216)changed-targetsselects an image only when a changed file matches one of itsimage_pathsprefixes. An image absent fromimage_paths, or whose prefixes miss thefiles that actually define it, can never be selected — and the pull-request build gate
then fails open, reporting success having built nothing. That is precisely the
regression class the
changed-targetsjob was introduced to prevent (see the comment in.github/workflows/build.yml: "a PR could be green while main went red on the mergecommit — which is exactly what happened, repeatedly").
PathOwnershipTestscloses the loop with five assertions:oci_imageshas animage_pathsentry;image_pathskey is inoci_images;catalog/<n>.yaml,elements/oci/<n>.bst, and the<n>-runtime.bst/<n>-stack.bstthatscripts/generate_image_elements.pyemits from its record;shared_pathsstill lists the gate's own inputs, andcanary_imageis published.Assertion 3 reuses the prefix/exact-match semantics of the
changed-targetsrecipe(
*/is a directory prefix, anything else is an exact path) so the test measures thereal selector rather than an idealised one.
Why no other file changes
The committed manifest already satisfies all five assertions — this is enforcement of an
existing invariant, not a change to it.
tests/test_catalog_conformance.pyis alreadypicked up by the
test_catalog*.pydiscovery pattern in bothjust catalog-checkand.github/workflows/image-catalog.yml, which already triggers onelements/**andcatalog/**. So no Justfile recipe and no workflow trigger needs editing.Verification
Mutation-checked — each assertion was confirmed to actually fail:
qemu-imgfromimage_paths→ "images in oci_images with no image_pathsentry: their pull-request build gate can never select them"
pythonto onlyelements/oci/python.bst→ "python does not owncatalog/python.yaml: a change to it would select no build target"
elements/targets.jsonwas restored after each mutation; the diff is one file, +101/-0.Refs #217
Filed by architect agent (ACMM L5 — hold-gated mode). Hold-gated: human review required.
— hive: agent=architect backend=copilot model=claude-opus-5