Skip to content

Phase 1: Parity matrix, staleness triage, and porting contracts #132

Closed

Description

@suraj-ranganath

🤖

Phase 1: Parity Matrix, Staleness Triage, And Porting Contracts

Summary

Build the audit foundation for the remaining EEGLAB core parity epic. This phase does not port features. It creates the machine-readable map that tells later phases what to port, what to consolidate, and what to intentionally skip.

This phase must merge before Phases 2-7 begin.

Scope

Create a committed parity matrix from vendored EEGLAB source to EEGPrep for the first seven items in .notes/eeglab-migration-gap-audit.md:

  1. Long-tail helper coverage
  2. Missing or legacy pop_* entry points
  3. Unsupported options in implemented functions
  4. STUDY depth
  5. Statistics package
  6. Time-frequency internals
  7. File format and channel-location long tail

The matrix should be audit-driven, not a same-name port checklist.

Required Status Values

Each row must use one of these statuses:

  • implemented: EEGPrep already covers the behavior.
  • partial: EEGPrep has an implementation but important EEGLAB behavior or options remain.
  • port: should be ported in this epic.
  • consolidated: behavior exists under a different EEGPrep module/function.
  • stale_skip: stale, obsolete, not user-facing, not workflow-required, and not worth porting.
  • matlab_runtime_skip: MATLAB-specific runtime/helper behavior that should not exist in standalone EEGPrep.
  • external_dependency_skip: depends on external toolboxes/plugins outside this epic.

Staleness Policy

Define stale functions concretely. A function can be stale_skip only when all are true:

  • not main-menu reachable;
  • not documented as a user API in current EEGLAB docs/help;
  • not called by in-scope EEGPrep workflows;
  • not required by MATLAB parity tests;
  • not needed as a helper for phases 2-7;
  • not a compatibility alias users are likely to type.

When in doubt, mark partial or port and leave notes for the responsible phase.

Acceptance Criteria

  • Add a committed parity matrix under docs or tooling.
  • Add a small validation test/tool that fails when an EEGLAB public/semi-public function in scope has no classification.
  • Document the standalone runtime rule: package code must not depend on src/eegprep/eeglab.
  • Document how later phase agents should update the matrix when implementing or intentionally skipping rows.
  • Record decisions in .notes/implementation-notes.html while working.

Verification

Run:

  • uv run --no-sync pytest <new parity matrix tests>
  • uv run --no-sync ruff check .
  • uv run --no-sync ruff format --check .
  • uv run --no-sync ty check
  • ./pre-commit.py --changed-from origin/develop

/goal Prompt

/goal Build the audit and contract foundation for the remaining EEGLAB core parity epic. Create a machine-readable parity matrix for gaps 1-7, classify functions as port/consolidate/skip with explicit reasons, document stale-function policy, add validation tests, and keep EEGPrep standalone with no runtime dependency on the vendored EEGLAB tree. Do not port feature behavior in this phase; make the result reliable enough for Phases 2-7 to run from it.

Activity

  1. added
    phase
    on Jun 5, 2026
  2. claude commented on Jun 5, 2026

    @claude
    Contributor

    🤖 Plan:

    • Read issue, AGENTS.md, fix-issue/pull-request skills
    • Duplicate-work preflight (none found; PR Fix EEGBrowser visual parity axes #130 unrelated)
    • Inventory existing audit + tooling foundations
    • Post research + proposed approach (this comment)
    • Await human review before implementation (scope > 100 LOC)

    Research

    Phase 1 is infrastructure, not a bug fix. It must produce a committed machine-readable parity matrix covering audit categories 1–7, a validator that fails on unclassified in-scope EEGLAB functions, a documented standalone-runtime rule, and guidance for later phases on updating rows. Audit input data already exists in `.notes/eeglab-migration-gap-audit.md`; enumeration source-of-truth is the vendored `src/eegprep/eeglab/` tree (currently empty in CI clone — Phase 1 tooling must handle that). The existing `menu_placeholders` pattern is the closest precedent for a typed, machine-readable, test-validated inventory.

    Relevant code

    Proposed Approach (design, not a fix)

    Scope clearly exceeds the 100-LOC self-contained-bug threshold (hundreds of classifications, new tooling, new tests, new docs), so this is an analysis comment for human review before implementation, per fix-issue policy.

    1. Matrix storage. Commit one JSON file per audit area under `tools/parity_matrix/` (`adminfunc.json`, `guifunc.json`, `miscfunc.json`, `popfunc.json`, `sigprocfunc.json`, `statistics.json`, `studyfunc.json`, `timefreqfunc.json`, plus `unsupported_options.json` for category 3 and `file_formats.json` for category 7 where rows are option-level rather than function-level). JSON not YAML: stdlib-only, diff-friendly, validator-trivial. Row schema:

    ```json
    {
    "eeglab_path": "functions/popfunc/pop_averef.m",
    "name": "pop_averef",
    "status": "consolidated",
    "eegprep_path": "src/eegprep/functions/popfunc/pop_reref.py",
    "surface": "menu|console|api|internal|none",
    "phase": "2|3|4|5|6|7|null",
    "reason": "<≤140 char rationale, required for *_skip statuses>",
    "unsupported_options": ["option_name", ...],
    "notes": ""
    }
    ```

    Statuses are the seven from the issue. `reason` is mandatory for all `*_skip` rows so staleness decisions are auditable.

    2. Python loader + validator. Add `tools/parity_matrix/init.py` exposing `load_matrix()` (returns dict keyed by area) and `enumerate_eeglab_functions(area)` (filesystem walk of `src/eegprep/eeglab/functions//*.m`, gracefully empty when the vendored tree is absent). Validator function `unclassified_functions(area)` returns the set of `.m` filenames present in the vendored tree but absent from the matrix. Pure stdlib; stays under `tools/` so it is not part of the installed `eegprep` package per AGENTS.md.

    3. Tests. New `tests/test_parity_matrix.py` with: (a) schema validation per row, (b) status enum check, (c) reason required for `*_skip`, (d) when vendored EEGLAB present, `unclassified_functions(area) == set()` for each in-scope area, (e) when vendored tree empty, the enumeration test is `pytest.skip`-ed (mirrors `EEGPREP_SKIP_MATLAB` skip pattern). No marker needed; pure-Python.

    4. Initial population. Use the missing-by-name lists already enumerated at the bottom of `.notes/eeglab-migration-gap-audit.md` as the starting row set. Each row gets an initial classification:

    • functions whose Python equivalent is identified in the audit's false-positive examples → `consolidated` with `eegprep_path`
    • functions explicitly assigned to a later phase → `port` with `phase`
    • MATLAB-runtime-only helpers (`ismatlab`, `iseeglabdeployed`, `bc` compatibility aliases, `plugin*` web installers, deploy/compile helpers) → `matlab_runtime_skip` with reason
    • external-toolbox helpers → `external_dependency_skip`
    • `stale_skip` only when all six AGENTS-defined criteria hold; default to `partial`/`port` when uncertain (matches issue's "when in doubt" rule)

    5. Docs. Add `docs/source/development/parity_matrix.md` (or extend an existing dev doc) covering: schema, status semantics, the six-condition staleness rule verbatim from the issue, how phase agents update rows on implementation, and the AGENTS-aligned standalone-runtime restatement ("package runtime code must not read from `src/eegprep/eeglab/`; the matrix and validator live under `tools/` and run only in development/CI"). Add a pointer from `AGENTS.md`'s Repo Map to `tools/parity_matrix/`.

    6. Implementation notes. Append decisions to `.notes/implementation-notes.html` per acceptance criteria (will create if absent).

    Branching. Per epic #131, target `feature/eeglab-core-parity-completion` (epic branch), not `develop`. Branch name per fix-issue skill: `agent/20260605-fix-132`.

    Estimated scope. ~10 JSON files (~600+ rows total once filled), ~150 LOC loader/validator, ~80 LOC tests, ~80 LOC docs. Function-row count is the variable cost; the framework itself is small.

    Open questions for human reviewer before I proceed:

    1. JSON-per-area vs single `parity_matrix.json` — preference? (per-area scales better for phase-owned PR diffs)
    2. `tools/parity_matrix/` vs `docs/parity_matrix/` vs `.notes/parity_matrix/` — which fits the project's "committed but not installed" intent best?
    3. Should the validator block CI (fail on new unclassified `.m` files) or only run locally? CI gating is stronger but couples CI to the optional vendored tree.
    4. `unsupported_options` (category 3) — populate exhaustively in Phase 1, or just stub rows for affected functions and let Phase 5 fill the option lists?
    5. Target branch confirmation: `feature/eeglab-core-parity-completion` per epic Epic: Complete EEGPrep remaining EEGLAB core parity gaps #131, not `develop`?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

phase

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions