refactor: split metrics.render and the D-ranked functions, pinned by a golden exposition (#39) - #46
Merged
Merged
Conversation
…a golden exposition (#39)
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.
Fixes #39
Acceptance criterion (verbatim):
Route: the issue left the split open; the maintainer asked for it with
fix #39. The approach: pin the output first, then refactor under that pin.1. The pin:
tests/test_metrics_golden.py+tests/golden/metrics.promrender:# HELP/# TYPElines included, as one string. It covers 222 lines and all 51 families.mainbefore any refactor. The module docstring gives the one-liner that regenerates it after a deliberate exposition change, so the diff becomes the review.2. The refactor (no behaviour change)
metrics.renderrepos.loadGitHub.latest_runsmetrics.py:rendernow yields the fleet-wide families from_health, then fills a_Familiesholder repo by repo. The fillers are_add_identity,_add_protection,_add_alerts,_add_drift,_add_ci,_add_pulls,_add_merged,_add_localand_add_size, andin_exposition_order()yields them. The 44 family definitions were moved by script, not retyped, so no HELP string or label list could drift. The yield order is taken from the oldyield from (...)tuple. Every comment moved with its code. The largest new block is_add_localat C (11).repos.py: file reading and validation move to_read_entries, and the "listed twice" message moves to_listed_twice. The error messages are unchanged.github.py: the feed scan becomes_newest_per_workflow(pure), and one backfill call becomes_newest_conclusive. The insertion order intonewest, and so the returned order, is unchanged.uvx radon cc jq_collector -ncnow lists only C blocks, 11 in all, the worst at 18.Checks (run locally from
collector/, as CI does)ruff check/ruff format --check/mypy: passorigin/main'smetrics.pyin a scratch copy, the golden test passes. So the golden file is the old output, and the new code reproduces it."Stash entries."→"Stash entries") fails it.Not addressed
localgit.scan_repoat 18, and_folderand_entryinrepos.pyat 17. The criterion stops at C.render.Closes #39
🤖 Generated with Claude Code