refactor(operator-trend): collapse _side_from_status clone family (T3-2 phase 2)#75
Closed
saagpatel wants to merge 2 commits into
Closed
Conversation
…olve_side Seventeen reset/reentry/rebuild/restore side classifiers each hand-spelled a confirmation member set plus its clearance mirror (the same strings with the side word swapped), cloning identical control flow seventeen ways. Replace them with a shared _resolve_side(status, *confirmation_members) helper that derives the clearance mirror once (cached); each classifier is now a one-line delegator. Proven byte-identical by the restore-tier golden contract + full suite. Second scalar-primitive slice of the operator_resolution_trend fractal collapse.
…r-trend-side-collapse
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
Second phased slice of the
operator_resolution_trendrestore-tier fractal collapse. Stacked on #74 (base =refactor/operator-trend-collapse).Seventeen
_side_from_statusclassifiers in the reset/reentry/rebuild/restore families each hand-spelled a confirmation-member set and its clearance mirror — the same strings with the side word swapped — cloning identical control flow seventeen ways. Replaced with a shared_resolve_side(status, *confirmation_members)helper that derives the clearance mirror once (cached vialru_cache, matching the original compiler-folded constant-set perf). Each classifier is now a one-line delegator.Why
Pure structural duplication: 17 functions, one logic shape, mirror sets typed out by hand (a typo in any clearance string was a silent side-misclassification waiting to happen). One helper + the confirmation members as data removes the entire clone class.
How (and the safety in it)
The rewrite was a mechanical AST transform that read each confirmation set straight from source (no hardcoding) and asserted behavioral equivalence before writing — specifically that
(clearance - confirmation) == (mirror(confirmation) - confirmation), which holds even for the one set that includes a confirmation-only token (just-rererestored). The transform script was run once and removed; it is not part of the diff.Proof
ruff check: clean (incl. import ordering for the newfunctoolsimport).Scope / follow-ups (not in this PR)
closure_forecast_reset_side_from_status,closure_forecast_reacquisition_side_from_status) match the same shape but are lone instances in their own modules; sharing_resolve_sideacross module boundaries is a Phase 3 cleanup, marginal gain.