Skip to content

refactor(operator-trend): collapse refresh-recovery builders onto a parametrized base (T3-2 phase 6d)#85

Merged
saagpatel merged 1 commit into
mainfrom
refactor/operator-trend-collapse-recovery2
Jun 20, 2026
Merged

refactor(operator-trend): collapse refresh-recovery builders onto a parametrized base (T3-2 phase 6d)#85
saagpatel merged 1 commit into
mainfrom
refactor/operator-trend-collapse-recovery2

Conversation

@saagpatel

Copy link
Copy Markdown
Owner

What

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, 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:

  1. Structural AST-equivalence — base[rebuild-spec] ≡ real rebuild, base[rererestore-spec] ≡ real rererestore (whole input space).
  2. Composer golden byte-identical to main.
  3. Full suite green2539 passed, 2 skipped.

ruff + mypy clean. Public signatures unchanged.

Campaign: rebuild↔rererestore pair complete

All four clean families now collapsed onto parametrized bases:

family PR LOC
persistence #82 −121
churn #83 −40
hotspots #84 −72
refresh_recovery this −156

−389 lines across the four, every one proven byte-identical, behind unchanged public signatures.

…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 saagpatel merged commit 09132d1 into main Jun 20, 2026
3 checks passed
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant