Repository navigation
Description
Epic: Fable 5 Findings — Whole-Codebase Code-Quality Review
🤖 This epic tracks remediation of a thermo-nuclear (strict maintainability) code-quality review of the entire EEGPrep codebase, run at commit 8ba958e (tip of PR #190 fix/async-ica-progress).
What was reviewed
All of src/eegprep (~83k lines across 432 modules, excluding the vendored src/eegprep/eeglab/ reference), the tests/ suite (~49k lines), tools/, the Sphinx docs, and packaging. The review judged the code against EEGPrep's three goals: it must work standalone in Python (no runtime dependency on the vendored MATLAB reference), stay familiar to EEGLAB users (pop_* semantics, 1-based user-facing indices, history commands), and be a delight for EEG researchers.
Method
19 scoped reviewer agents covered every subsystem plus cross-cutting sweeps (vendored-EEGLAB runtime leaks, 1-based/0-based index boundaries, duplicate helpers, GUI/console/session atomicity, test quality, packaging/UX). Every finding was then put through an independent adversarial verification pass (a separate agent prompted to refute it against the working tree); findings that could not be defended, were parity-justified, or had already been fixed were dropped. Raw findings → 6 refuted → 12 merged duplicates → 123 confirmed findings.
Findings by category
| Category | Count |
|---|---|
| 1 — Structural regression / bug risk | 48 |
| 2 — Missed major simplification | 7 |
| 3 — Wrong ownership / duplicated helper | 38 |
| 4 — Session/history atomicity | 3 |
| 5 — File sprawl | 3 |
| 6 — Legibility with real cost | 24 |
| Total | 123 |
Phases
Findings are grouped into 5 phase issues, ordered so each phase makes the next one safe. Recommended execution order is 1 → 5: the test suite is made honest first (so numeric fixes are guarded), then data-integrity and correctness bugs, then structural refactors, then packaging/polish.
- Phase 1 — Test-suite integrity: make CI able to fail (7 findings) — [Fable 5 Findings] Phase 1 — Test-suite integrity: make CI able to fail #194
- Phase 2 — EEG data integrity: stop mutating the caller & preserve ICA invariants (15 findings) — [Fable 5 Findings] Phase 2 — EEG data integrity: stop mutating the caller & preserve ICA invariants #195
- Phase 3 — Correctness bugs, silent failures & misleading contracts (38 findings) — [Fable 5 Findings] Phase 3 — Correctness bugs, silent failures & misleading contracts #196
- Phase 4 — Architecture: kill duplication, fix ownership & decompose sprawl (45 findings) — [Fable 5 Findings] Phase 4 — Architecture: kill duplication, fix ownership & decompose sprawl #197
- Phase 5 — Standalone packaging, dependencies, docs & dead-code cleanup (18 findings) — [Fable 5 Findings] Phase 5 — Standalone packaging, dependencies, docs & dead-code cleanup #198
The five highest-impact items (start here)
pop_savesetcorrupts the live EEG dict — saving rewritesurchan/ureventto 1-based on the caller's own objects; a second save double-increments. (Phase 2)pop_loadset/pop_fileiosilent fallbacks — a malformed.setis silently reinterpreted (HDF5 retry, then anonymous data matrix) and surfaces as a cryptic unrelated error. (Phase 3)eeg_from_dataguesses channel-vs-sample orientation fromshape[0] > shape[1]— a tall high-density import silently transposes channels and time. (Phase 2)- ~152 core-numeric tests can never fail — assertions are wrapped in
try/except -> skipTest, so regressions report as skips and CI stays green. (Phase 1) - The CLI implements the transform pipeline twice with divergent validation — a notch the subcommand rejects passes through the pipeline path as a negative cutoff. (Phases 3 + 4)
Scope & limitations
- Reviewers were read-only and did not execute the test suite; numerical findings are reasoned from code and the EEGLAB oracle, not reproduced at runtime. Verify each finding from first principles before fixing.
- The vendored
src/eegprep/eeglab/tree was treated as reference only and not reviewed (but runtime code depending on it was flagged). - The full per-finding report (with verifier notes and complete evidence snippets) is in
THERMO_NUCLEAR_REVIEW.mdon the review branchthermo-nuclear-full-codebase-review.
Generated by an automated multi-agent review at the maintainer's request. Each phase issue lists its findings as a checklist.
Delivery status (PRs)
Each phase is implemented in an isolated worktree branched from fix/fresh-uv-console and opened as its own PR. PRs were verified green (relevant pytest + ruff + pre-commit) and adversarially reviewed; every fix carries a reproducing/regression test, and an integration branch (fable5/integration) confirms the phases compose.
- Phase 1 — Test-suite integrity → [tests] Make the test suite able to fail (Fable 5 Phase 1) #200 (merge first; un-skips ~152 swallowed tests)
- Phase 2 — EEG data integrity → [core] Stop mutating caller EEG and fix ICA sign-flip invariant (Fable 5 Phase 2) #202 (copy-on-entry; ICA posact invariant)
- Phase 3 — Correctness, silent failures & contracts → [core] Fix correctness bugs, silent failures & misleading contracts (Fable 5 Phase 3) #203 (38 findings, reproduce-then-fix)
- Phase 4 — Architecture/dedup → [arch] Kill duplication, fix ownership & layering (Fable 5 Phase 4) #204 (~23 done + ~8 partial, behavior-preserving; based on
fable5/integration) - Phase 5 — Packaging, deps, docs & dead code → [pkg] Move dev tooling out of the wheel and clean dead code (Fable 5 Phase 5) #201
- Phase 4b — Large-file decomposition & behavior-changing consolidations → [Fable 5 Findings] Phase 4b — large-file decomposition & behavior-changing consolidations #205 (follow-up: 4 mega-decompositions + ~18 deferred dedups that need a behavior decision)
Recommended merge order: 1 → 2 → 3 → 5, then rebase #204 onto the result and merge, then tackle #205. The only cross-phase merge conflict observed was a single ASR test file (resolved); a Phase 2 picard test was hardened (in #202) so it composes with Phase 1's shared fixture.
Merge staging (epic branch model)
Epic branch: fable5/epic (off fix/fresh-uv-console). Epic PR to develop: #206 (advisor human review; do not auto-merge — supersedes #199).
Flow: the five phase PRs merge into fable5/epic first, then #206 carries the epic to develop.
- Into
fable5/epic: [tests] Make the test suite able to fail (Fable 5 Phase 1) #200 → [core] Stop mutating caller EEG and fix ICA sign-flip invariant (Fable 5 Phase 2) #202 → [core] Fix correctness bugs, silent failures & misleading contracts (Fable 5 Phase 3) #203 → [pkg] Move dev tooling out of the wheel and clean dead code (Fable 5 Phase 5) #201, then rebase [arch] Kill duplication, fix ownership & layering (Fable 5 Phase 4) #204 ontofable5/epicand merge last. - One expected conflict:
tests/test_utils_asr.py(combine phases' ASR tests; keep the fail-loud version). - [arch] Kill duplication, fix ownership & layering (Fable 5 Phase 4) #204 is currently based on
fable5/integration(a snapshot of phases 1/2/3/5); rebase it ontofable5/epiconce 1/2/3/5 land, then merge.
Activity
claude commentedon Jun 12, 2026
🤖 Plan:
Analysis
#193 is the tracking epic for the Fable 5 review, not a single fix candidate. The 123 findings are already decomposed into five child issues (#194–#198), each of which is the right unit for a branch + PR. Opening a PR against #193 itself would either duplicate that decomposition or silently re-scope it; per AGENTS.md "make the smallest change that solves the request", the right move is to land work against the phase issues and let this epic close when all five are checked off.
Preflight (open PRs touching phases 1–5): none.
gh pr list --state openreturns only PR #191 (unrelated torch lockfile bump). No parallel implementation is in flight, so a maintainer can assign phases independently without merge conflicts on the epic itself.Recommended execution order (already stated in the epic body): #194 → #195 → #196 → #197 → #198. Phase 1 first because ~152 tests currently
skipTeston assertion failure (`tests/conftest.py` and individual test files wrap asserts intry/except), so CI cannot fail until that's fixed — landing later numeric fixes before Phase 1 means regressions show as skips, not failures.Top 5 (from the epic body, ranked by blast radius):
src/eegprep/functions/popfunc/pop_saveset.py— rewritesurchan/ureventon the caller's live EEG dict; second save double-increments. (Phase 2 / [Fable 5 Findings] Phase 2 — EEG data integrity: stop mutating the caller & preserve ICA invariants #195)src/eegprep/functions/popfunc/pop_loadset.py,pop_fileio.py— silent HDF5 retry then anonymous-matrix fallback masks malformed.setfiles. (Phase 3 / [Fable 5 Findings] Phase 3 — Correctness bugs, silent failures & misleading contracts #196)eeg_from_data— orientation guessed fromshape[0] > shape[1]; high-density tall imports silently transpose. (Phase 2 / [Fable 5 Findings] Phase 2 — EEG data integrity: stop mutating the caller & preserve ICA invariants #195)try/except → skipTest. (Phase 1 / [Fable 5 Findings] Phase 1 — Test-suite integrity: make CI able to fail #194)Recommendation: leave #193 open as the tracking checklist; do not open a PR against it. Direct fix-issue agents at #194 first, then walk forward. If you want a single agent to drive the whole epic, that's a meta-orchestration request and should be scoped explicitly — it's well past the >100-line / multi-module threshold for autonomous PR work.
Phase 4: kill duplication, fix ownership & layering (behavior-preserv…
suraj-ranganath commentedon Jun 12, 2026
🤖 Phase integration is complete on fable5/epic. PRs #200, #202, #203, #201, and #204 are merged into the epic branch; #206 now contains the composed remediation plus integration fixes from the final review pass. Local verification passed: ruff check, ruff format --check, ty check, ./pre-commit.py --changed-from origin/develop, and EEGPREP_SKIP_MATLAB=1 uv run --no-sync pytest -m "not slow" (2023 passed, 249 skipped, 16 deselected, 1 expected xfail). Phase 4b remains tracked separately in #205 and is not a blocker for #206.
Phase 5: standalone packaging, deps, docs & dead-code cleanup
Phase 1: test-suite integrity — make CI able to fail
Phase 2: EEG data integrity — stop mutating the caller, fix ICA invar…
Phase 3: correctness bugs, silent failures & misleading contracts