Skip to content

refactor(operator-trend): collapse _side_from_status clone family (T3-2 phase 2)#76

Merged
saagpatel merged 6 commits into
mainfrom
refactor/operator-trend-side-collapse
Jun 19, 2026
Merged

refactor(operator-trend): collapse _side_from_status clone family (T3-2 phase 2)#76
saagpatel merged 6 commits into
mainfrom
refactor/operator-trend-side-collapse

Conversation

@saagpatel

Copy link
Copy Markdown
Owner

Supersedes #75 (auto-closed when its stacked base branch was deleted on #74 merge). Same change, now based on main which already contains phase 1 (#74).

What

Seventeen _side_from_status classifiers 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 via lru_cache). Each classifier is now a one-line delegator.

How (and the safety in it)

Mechanical AST transform that read each confirmation set straight from source (no hardcoding) and asserted behavioral equivalence before writing: (clearance - confirmation) == (mirror(confirmation) - confirmation), which holds even for the one set containing a confirmation-only token (just-rererestored). Transform script run once and removed.

Proof

  • Restore-tier golden contract (from phase 1, now on main): 31 passed, byte-identical.
  • Full suite: 2,493 passed, 2 skipped.
  • ruff check: clean.
  • Net diff vs main: +79 / −139 (net −60), operator_resolution_trend.py only.

Follow-ups (not here)

  • 2 cross-module side classifiers match the same shape but are lone per-module instances — Phase 3.
  • Phase 3: dict-composer parametrization + deletion of per-depth clone modules and mirror tests.

…ontract

Pin the exact current output of every pure (status:str)->str classifier in the
restore-tier depth machinery (30 functions x 265 status inputs) to a golden file,
generated by executing the modules. Safety net for the upcoming recovery_state
depth-collapse: any change to depth-tier translation surfaces as a byte diff
before it can reach a consumer.
…itive

The four restore-tier translation shims hand-spelled every depth-shifted output
string (restore <-> rerestore <-> rererestore <-> rerererestore), cloning the tier
arithmetic four ways. Replace the spelled-out value maps with a single
_shift_restore_tier(token, delta) primitive plus recognized-input sets; the shims
become thin delegators. Proven byte-identical by the restore-tier golden contract
(30 classifiers x 265 inputs). First scalar-primitive slice of the
operator_resolution_trend fractal collapse.
…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.
@saagpatel saagpatel merged commit 3530976 into main Jun 19, 2026
2 checks passed
@saagpatel saagpatel deleted the refactor/operator-trend-side-collapse branch June 19, 2026 17:38
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