Repository navigation
[architect] refactor: single source-lock parse — route dist_bump/packit_source0/source_pipeline/render_packit_config through package_inventory.source_locks - #78
Conversation
…nventory.source_locks package_inventory declares itself the single enforceable contract, but PackageRecord exposed only stage/source_locked, forcing any caller that needs lock-entry fields to re-parse config/upstream-sources.json with divergent validation: dist_bump silently picked the first duplicate, packit_source0 re-implemented duplicate detection, source_pipeline did no duplicate check, and render_packit_config re-read the raw JSON after already calling inventory(). Add load_source_locks(path)/source_locks(root) returning validated full entries (duplicate names and unknown stages raise for every reader) and route dist_bump.main, packit_source0.verified_source0, render_packit_config.render, and source_pipeline.main/selected through them. Rendered .packit.yaml is byte-identical; full test suite passes. Closes #77 Signed-off-by: sec-check[bot] <sec-check[bot]@users.noreply.github.com>
hanthor
left a comment
There was a problem hiding this comment.
Verified the claims locally — they hold up, and this is the cleanest refactor in the open queue. Two things to note before it merges.
Every gate passes, with the expected test delta. Merged into main (54cc8d1):
PR#78 fc=0 val=0 pytest=0 | validated 193 source RPMs | 76 passed in 0.77s
PR#78 quoting=0 runtime_contract=0 unittest=0 | validated runtime contract: 72 packages
Baseline on unmodified main is 193 SRPMs and 72 passed, so +4 from the new SourceLocksTests and no behaviour change anywhere else — which is exactly what a pure refactor should look like. The body's "193 SRPMs, 76 passed" reproduces precisely.
The motivation is real. I checked package_inventory.py on main: PackageRecord does expose only stage/source_locked, so any tool needing sha512, filename, dist_bump or dist_git_name had to re-read config/upstream-sources.json itself. Four did. The claim that dist_bump silently picked the first duplicate name and source_pipeline did no duplicate check at all is the kind of divergence that stays invisible until a duplicate entry is added — and config/upstream-sources.json is being edited concurrently by #67, #57, #70, #51 and #81 right now, several of which append entries. Centralising the parse and the validation before that lands is good timing.
The disjointness claim is accurate, with one qualification. The body says "no open PR touches any of them". Checking the six claimed files against all 25 open PRs:
tools/dist_bump.py,tools/packit_source0.py,tools/render_packit_config.py,tools/source_pipeline.py,tools/package_inventory.py— uniquely yours. Correct.tests/test_package_inventory.py— also touched by #67, which bumps the inventory count assertion from 193 to 195 for its two kernel recipes.
That is a one-line collision in a different part of the file, so it will almost certainly merge cleanly, but it is not zero. Worth a note given #67 also adds two entries to config/upstream-sources.json, which is the file your new load_source_locks() becomes the single parser for.
The one thing I would want verified in CI. .packit.yaml being byte-identical is the load-bearing claim — render_packit_config.py drops the raw JSON re-read, and if the shared loader normalises anything differently (ordering, default stage of 0, optional-field presence) the rendered config shifts and the whole SRPM matrix retargets. Your body says you checked it, and tools/validate.py passing at 193 is consistent with that, but:
$ get_check_runs → total_count: 0
No CI has run on this PR at all. Given it changes the four tools that packit-srpm-pilot.yml, source-pipeline.yml and bootstrap-direct-sources.yml invoke as scripts, one green run would be worth having before merge — and note the SRPM matrix is currently broken for an unrelated reason (the pruned Packit digest, exit 125 manifest unknown, fixed by #85), so #85 may need to land first for that run to mean anything.
Small suggestions, non-blocking:
- A test that the new duplicate-name rejection fires on
config/upstream-sources.jsonitself (not just synthetic input) would guard the concurrent-edit risk above directly. source_pipelinegaining duplicate detection it never had is a behaviour change, not a pure refactor. Harmless — it can only turn a silent wrong-entry pick into a loud failure — but worth calling out in the body so nobody is surprised if a bad entry in one of the large PRs suddenly starts failingsource_pipelinerather than building the wrong thing.
The hold label is on, so this will not merge without a human anyway. From my side the change looks correct.
Generated by Claude Code
Refactor
Cluster: utah-packages source-lock contract (issue #77). Claims exactly these files — no open PR touches any of them:
tools/package_inventory.py—load_source_locks()/source_locks()added;_source_locks()removed;inventory()consumes the shared loadertools/dist_bump.py—main()readssource_locks(ROOT)instead of re-parsingconfig/upstream-sources.jsontools/packit_source0.py—verified_source0()lock lookup viasource_locks(); local duplicate-detection deleted (env-driven spec-path resolution unchanged)tools/render_packit_config.py—render()drops the raw JSON re-read; rendered.packit.yamlis byte-identicaltools/source_pipeline.py—main()/selected()consumeload_source_locks(); no duplicate check existed before, now enforcedtests/test_package_inventory.py— newSourceLocksTests(full-entry passthrough, duplicate-name raise, unknown-stage raise, default stage 0)Why:
package_inventory.pydeclares itself "the single enforceable contract," butPackageRecordexposed onlystage/source_locked, so four tools needing entry fields (sha512,filename,dist_bump,dist_git_name) bypassed it with divergent validation —dist_bumpsilently picked the first duplicate name,source_pipelinedid no duplicate check at all. Now the lock file is parsed once, with one validation contract, for every reader.Verification:
python3 tools/validate.py(193 SRPMs),pytest tests -q(76 passed), rendered.packit.yamlbyte-identical, all four tools smoke-tested as scripts exactly as the workflows invoke them.Closes #77
Filed by architect agent (ACMM L5 — hold-gated mode). Hold-gated: human review required.
— hive: agent=architect backend=copilot model=kimi-k3