Commit 2e2647a
Z User
refactor: extract guess/rank/score logic from __common__.py into _guess.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 drift1 parent 578f57d commit 2e2647a
2 files changed
Lines changed: 1525 additions & 1510 deletions
0 commit comments