refactor(operator-trend): collapse hotspot selectors onto a parametrized base (T3-2 phase 6c)#84
Merged
Conversation
…zed base (T3-2 phase 6c) Third structural collapse: the rebuild and rererestore hotspot selectors share one group/dedup/filter/sort algorithm differing only in the per-tier persistence/churn keys, the just-* mode token, and the holding/sustained status set. Extract _hotspots_base + a _HotspotsTierSpec; both public selectors become thin wrappers. The two tiers had also drifted on defensive coercion (rebuild wrapped score/age/ label in float()/int()/str(); rererestore was bare) -- identical on real numeric data. The base unifies on rebuild's safer coercion; verified byte-identical. Public signatures unchanged -> callers (summaries that read these keys, apply-chain) untouched. Net -72 lines. Verified: differential test (real selectors vs base+spec over targets x all modes, byte-identical both tiers) + composer golden byte-identical to main + full suite (2539 passed). ruff + mypy clean.
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.
What
Third structural collapse. The
rebuildandrererestorehotspot selectors share one group/dedup/filter/sort algorithm differing only in the per-tier persistence/churn keys, thejust-*mode token, and the holding/sustained status set. Extract_hotspots_base+ a_HotspotsTierSpec; both public selectors become thin wrappers.The two tiers had also drifted on defensive coercion — rebuild wrapped score/age/label in
float()/int()/str(); rererestore was bare. Identical on real numeric data; the base unifies on rebuild's safer coercion (verified byte-identical).−72 net lines.
Verified (three proofs)
main— a correct collapse changes no output.2539 passed, 2 skipped.ruff+mypyclean. Public signatures unchanged, so callers (the summaries that read these keys, the apply-chain) are untouched.Campaign progress
Three of four clean rebuild↔rererestore families collapsed: persistence (#82), churn (#83), hotspots (this).
refresh_recoveryremains — it's the genuinely complex one (intricate branching, implicit-concat reason strings, output-keys-that-are-also-vars), so it gets a dedicated careful pass rather than a rushed one.