refactor(operator-trend): collapse refresh-recovery builders onto a parametrized base (T3-2 phase 6d)#85
Merged
Conversation
…arametrized base (T3-2 phase 6d) Fourth and final clean rebuild<->rererestore family. The two refresh-recovery builders (~250 lines each) share one algorithm differing only in the per-event reset/freshness keys, the recovery + next-tier restore status tokens, their reason prose, and output keys. Extract _recovery_for_target_base + a _RecoveryTierSpec (22 tier fields); both public builders become thin wrappers. This one earned a stronger proof than the others. Its branch coverage is too wide for a corpus differential alone, so correctness is established by STRUCTURAL AST-equivalence: the base with each tier's spec substituted back in is AST-identical to the original function -> byte-identical for the entire input space, not just corpus-exercised paths. (Plus the composer golden is byte-identical to main and the full suite passes.) Public signatures unchanged. Net -156 lines. Verified: structural AST-equivalence (both tiers) + composer golden byte-identical + full suite (2539 passed). ruff + mypy clean.
saagpatel
added a commit
that referenced
this pull request
Jun 20, 2026
… base (T3-2 phase 6e) (#86) The recovery base (#85) parametrized the rebuild + rererestore refresh-recovery tiers. The shallower reset_reentry tier is a structural clone of that same algorithm (same signature, same control flow; it only differs in its per-tier reset/freshness keys, its rebuild-tier status vocabulary, reason prose, and output keys). Add a _RESET_REENTRY_RECOVERY_SPEC and make closure_forecast_reset_reentry_refresh_recovery_for_target a thin wrapper -- a third tier on one base. The spec was extracted by a paired structural AST traversal of base-vs-tier (which also proves structural identity: the traversal aligns every node, recording the literal wherever the base reads spec.X). Public signature unchanged. Net -200 lines. Note: the reset_refresh recovery tier is NOT absorbed -- it takes target_class_key instead of ordered_events, so it is a genuinely different shape, not a clone. Verified: paired-traversal structural identity + 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
Fourth and final clean rebuild↔rererestore family. The two
refresh_recoverybuilders (~250 lines each) share one algorithm differing only in the per-event reset/freshness keys, the recovery + next-tier restore status tokens, reason prose, and output keys. Extract_recovery_for_target_base+ a_RecoveryTierSpec(22 tier fields); both public builders become thin wrappers.−156 net lines — the biggest family of the four.
A stronger proof for the gnarly one
Recovery's branch coverage is too wide for a corpus differential to be airtight on its own (restoring/recovering/restored/pending × confirmation/clearance, plus blocked/reversing). So correctness here is established by structural AST-equivalence: the base with each tier's spec substituted back in is AST-identical to the original function — i.e. byte-identical for the entire input space, not just corpus-exercised paths.
Three proofs total:
main.2539 passed, 2 skipped.ruff+mypyclean. Public signatures unchanged.Campaign: rebuild↔rererestore pair complete
All four clean families now collapsed onto parametrized bases:
−389 lines across the four, every one proven byte-identical, behind unchanged public signatures.