Repository navigation
Description
🛑 Problem Statement
We previously root-caused several producer/consumer bugs (#364, #374, #375, and the rest of the #325 dead-key-auditor epic) where a consumer read a dict key the producer never wrote, or wrote under a different name. Investigated whether mypy in CI would have caught that class of bug: mostly no -- the affected structures (domain_context, ghost_meta, equations, APERTURE_CONFIG) are typed as Dict[str, Any] / Dict[str, int], under which d["AI Threat Score"] and d["AI Threat Confidence"] are equally valid to mypy. tests/dead_key_audit.py (already built and wired into CI) is the better-fit tool for that specific bug class.
That said, mypy still has real, independent value -- catching None-handling bugs, wrong argument types, incompatible return types -- and there's evidence of a prior ad hoc mypy cleanup pass in the git history (#293-#301) that was never wired into CI as an enforced gate, so it's drifted since.
📊 Current State (measured, not estimated)
Ran mypy gitgalaxy/ --ignore-missing-imports against current main:
235 errors across 31 files. Heavily concentrated: 5 files (signal_processor.py 60, record_keeper.py 48, language_lens.py 27, prism.py 27, detector.py 27) account for ~80% of the total.
Significant fan-out from a small number of root causes rather than 235 independent problems -- e.g. RECORDING_SCHEMAS dict values are typed as Collection[str] instead of List[str], which alone produces dozens of cascading "Collection[str]" has no attribute "index" errors across multiple files.
By error code:
| Code | Count | Nature |
|---|---|---|
| attr-defined | 80 | Mostly the Collection[str]/.index() fan-out above |
| var-annotated | 36 | Missing annotations on empty containers -- mechanical |
| operator | 23 | Mostly "object" types from unannotated heterogeneous dict literals |
| assignment | 22 | Mixed -- some look like real bugs (e.g. None assigned to a float-typed var) |
| arg-type | 18 | Mixed |
| index | 15 | Mixed |
| return-value | 13 | Mixed |
| call-overload | 12 | Cascades from the operator/object root cause |
| misc / union-attr / other | 16 | Long tail |
🎯 Objective
Wire mypy into CI as a baseline-gated check (same pattern as dead_key_audit.py -- fails only on new errors, doesn't demand the existing 235 be fixed on day one), then work down the baseline in reviewable chunks, prioritizing root causes with high fan-out first.
📋 Sub-Issues
- [CI/CD] Wire mypy into CI as a baseline-gated regression check #430 [CI/CD] Wire mypy into CI as a baseline-gated regression check
- [REFACTOR] Fix root-cause type annotations causing mypy error fan-out #431 [REFACTOR] Fix root-cause type annotations causing error fan-out
- [REFACTOR] Fix mypy type errors in the core parsing engine #432 [REFACTOR] Fix type errors in the core parsing engine (signal_processor, record_keeper, language_lens, prism, detector)
- [REFACTOR] Fix mypy type errors in tools/recorders/misc modules #433 [REFACTOR] Fix type errors in tools/recorders/misc modules (the long tail)
Activity
squid-protocol commentedon Jul 25, 2026
Status update: #430 and #431 done and closed. #432 (core engine) is 2/5 files cleared; #433 (long tail) has 2 incidental files cleared, otherwise not started.
Overall: 228 → 126 unique mypy errors (45% reduction) since this epic started, all verified via the now-live `mypy-audit.yml` gate rather than estimated. Sequencing continues one file per session, largest-remaining-file first: `signal_processor.py` (22) and `detector.py` (18) are next up.
Clear all 18 mypy errors in detector.py (#432 session 6) (#446)
squid-protocol commentedon Jul 25, 2026
Epic complete. `mypy gitgalaxy/ --ignore-missing-imports` went from 228 (as first seeded into tests/mypy_audit_baseline.json) to 0.
Summary
Was it just cosmetic?
Mostly, but not entirely -- a handful of genuine (if mostly latent, non-currently-manifesting) bugs turned up along the way, each called out explicitly in its PR rather than silently annotated away:
All 16 PRs (#438 onward through #467) were individually verified: full `mypy` run (fresh cache, CI-matching minimal venv) with fan-out check, `flake8`, `dead_key_audit.py --ci`, full `pytest` suite (866 tests), and live CI (including the new `mypy-audit` gate itself) before merge.