refactor: extract guess/rank/score into _guess.py#43
Open
Wolfvin wants to merge 1 commit into
Open
Conversation
…ss.py Decomposition refactoring of the god object __common__.py (1510 lines): BEFORE: - __common__.py: 1510 lines — contained codec registration, guess/rank/score, utilities, error handling, language detection, and more in a single file AFTER: - __common__.py: 1182 lines — codec registration, utilities, error handling - _guess.py: 343 lines — guess/rank/score logic as a cohesive module This refactoring follows the single responsibility principle: - _guess.py owns all guessing/ranking/scoring functionality - __common__.py owns codec registration and utility functions Changes: - Extracted _detect(), _lang(), _load_lang_backend(), _validate() - Extracted __guess(), __make_encodings_dict(), __rank() - Extracted _Text class and __score() - Extracted public guess() and rank() functions - Maintained all imports and monkey-patching (codecs.guess, codecs.rank) - No behavioral changes — all 27 regression test clusters pass Verified with output-based regression testing (Regrets tool): - V1: All 27 cluster fingerprints GREEN - V2: Direct output comparison identical to pre-refactor baseline - V3: Cross-fingerprint verification matches saved truth - Drift: 5 consecutive runs — all STABLE, zero drift
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.
Summary
Decomposition refactoring of common.py (1510 lines to 1182 + 343 lines), extracting guess/rank/score logic into a dedicated _guess.py module.
What Changed
Why
Regression Testing Proof
Validated with output-based regression testing (27 clusters across Morse, Braille, DNA, Galactic, Kenny, Affine, Vigenere, Atbash, ROT13, Hexagram, Rick Astley, Bacon, Barbie, Navajo, Baudot, Base32):