Skip to content

Phase 1a: EEG/session/data contract foundation #61

Closed

Description

@suraj-ranganath

🤖 Phase issue for the EEGLAB completion epic.

Goal

Stabilize the shared foundations that other phases need before broad EEGLAB feature work proceeds in parallel: EEG dict contracts, session/workspace synchronization, history command conventions, menu/action inventory rules, placeholder exclusion policy, multi-dataset selection state contracts, and reusable parity/test scaffolding.

Target branch and PR flow

  • Create the phase branch from feature/eeglab-completion.
  • Open the phase PR back into feature/eeglab-completion.
  • The phase PR should close this issue.

Parallelization

This phase should land before Phases 1b, 2, 3, and 4 start heavy implementation. Once merged, Phases 1b, 2, 3, and 4 can proceed in parallel against stable shared contracts. Phase 5 should also use these contracts before expanding STUDY workflows, including reading multi-dataset selection state.

In scope

  • Define and document EEG dict field invariants needed across phases, including event, urevent, epoch, history, ICA fields, channel locations, and 1-based user-facing indices versus Python internals.
  • Stabilize EEGPrepSession usage rules for GUI/menu actions and eegprep-console shared workspace behavior.
  • Define the multi-dataset selection state contract: shape, 1-based user-facing numbering, empty/single/multiple semantics, session propagation, console visibility, and how STUDY code should read it. Do not implement the user-facing selection mutator here.
  • Define history command requirements: return_com=True, valid Python console echoes, EEGLAB-style history where relevant, and no duplicate history entries.
  • Audit menu inventory and placeholder policy so later phases can distinguish implementable items from explicit EEGBrowser/external exclusions.
  • Add or improve reusable test/parity scaffolding for sample_data workflows, MATLAB parity checks, visual parity inventory, multi-dataset selection contract checks, and console/GUI synchronization.
  • Update docs or development notes that future phase agents must follow.

Out of scope

  • Porting the actual File/Edit metadata features; that is Phase 1b.
  • Implementing the GUI/menu mutator for multi-dataset selection; Phase 1a only defines and tests the shape/propagation contract so Phase 5 can design against it.
  • Implementing filtering, ICA/rejection, plotting, or STUDY workflows; those are later phases.
  • EEGBrowser/eegplot scrolling-browser workflows.
  • Runtime dependence on src/eegprep/eeglab.

Acceptance criteria

  • Shared EEG/session/history/menu contracts are documented in code, tests, docs, issue notes, or AGENTS/skill guidance where appropriate.
  • The multi-dataset selection contract is explicit and testable, including 1-based visible indices, internal representation, propagation through EEGPrepSession, and read access for future STUDY workflows.
  • Existing implemented GUI/menu/console workflows still pass and conform to the shared contracts.
  • Placeholder and exclusion policy is explicit enough that phase agents do not implement browser-only workflows accidentally.
  • Reusable tests or helpers exist for sample_data loading, session/history synchronization, action inventory, multi-dataset selection contract behavior, and MATLAB parity scaffolding where appropriate.
  • Required checks pass: focused tests for session/menu/history scaffolding, uv run --no-sync ruff check ., uv run --no-sync ruff format --check ., uv run --no-sync ty check, and the non-slow pytest suite unless a documented external blocker exists.

/goal prompt

/goal Stabilize EEGPrep's shared EEGLAB-parity foundations so Phases 1b, 2, 3, 4, and Phase 5 design work can proceed in parallel: document and test EEG dict invariants, EEGPrepSession and eegprep-console synchronization, multi-dataset selection state shape and propagation rules, history command conventions, menu/action inventory rules, placeholder/exclusion policy, sample_data/MATLAB parity scaffolding, and GUI/console test helpers. Verify by running focused session/menu/history/selection-contract tests, ruff/format/ty, and the non-slow pytest suite, and do not port the actual File/Edit metadata features or the user-facing multi-dataset selection mutator in this phase.

Activity

  1. added
    phase
    on May 27, 2026
  2. claude commented on May 27, 2026

    @claude
    Contributor

    🤖 Analysis (not opening a PR — phase epic spans ~9 placeholder actions across popfunc/, guifunc/, resources/help/, and tests; far above the 100-line single-PR threshold and should be split into per-function PRs targeting feature/eeglab-completion).

    Scope inventory

    Phase 1 Edit-menu actions currently routed to show_coming_soon via menu_actions.py#L144-L252 and registered in menu_placeholders.py#L9-L72:

    Menu label Action EEGLAB source to mirror Category
    Dataset info pop_editset pop_editset.m dataset metadata
    About this dataset pop_comments pop_comments.m dataset metadata
    Event fields pop_editeventfield pop_editeventfield.m event metadata
    Event values pop_editeventvals pop_editeventvals.m event metadata
    Select epochs or events pop_selectevent pop_selectevent.m event-based selection
    Channel locations pop_chanedit pop_chanedit.m channel metadata
    Copy current dataset pop_copyset pop_copyset.m multi-dataset state
    Append datasets pop_mergeset pop_mergeset.m multi-dataset state
    (Datasets menu) Select multiple datasets select_multiple_datasets eeglab.m cb_selectstudy region multi-dataset state

    Wiring already present in eeglab_menu.py#L125-L142 and #L336. pop_delset/pop_adjustevents already shipped; pop_select/pop_rmdat partially implemented. EEGLAB sources are not vendored under src/eegprep/eeglab/ in this checkout — implementers must pull from https://github.com/sccn/eeglab during the port.

    Infrastructure already in place

    • Session sync: EEGPrepSession.store_current, add_history, notify_changed, delete_current in adminfunc/console.py — new pop functions plug in via _run_pop_function (menu_actions.py#L226-L251) once added to the dispatch chain.
    • Help resources: drop <function_name>.md under src/eegprep/resources/help/ (currently has pop_reref.md, pop_select.md, etc.).
    • Placeholder removal: delete each action from PLACEHOLDER_ACTIONS in menu_placeholders.py and add a new branch in dispatch() per action.
    • Branch already exists: feature/eeglab-completion (currently equal to develop) — phase PRs target it per issue instructions.

    Proposed split (9 sub-PRs against feature/eeglab-completion)

    Sequencing is chosen so dataset/channel metadata land before multi-dataset operations that read them, and event field shape stabilizes before event-based selection:

    1. pop_comments — simplest, pure metadata string, good template PR.
    2. pop_editset — dataset-level metadata (setname, subject, condition, chanlocs ref, etc.); careful with eeg_checkset interactions.
    3. pop_editeventfield — add/rename/delete event struct fields; updates urevent correspondence.
    4. pop_editeventvals — per-row editor; uses eeg_checkset('eventconsistency') already in eeg_checkset.py.
    5. pop_selectevent — event-based epoch/data selection; reuses pop_select/pop_epoch plumbing.
    6. pop_chanedit — largest single dialog; channel struct editor with import/export and centering; gates Phase 4 plotting.
    7. pop_copyset — EEGPrepSession.store_current(copy=True, ...); mostly session-layer.
    8. pop_mergeset — multi-dataset concatenation; needs boundary-event insertion and urevent recompute (see existing eeg_findboundaries.py).
    9. select_multiple_datasets + Datasets menu multi-select state — surfaces session selection vector for downstream STUDY work.

    Each sub-PR must include: pop function in functions/popfunc/pop_<name>.py, GUI dialog spec via inputgui, return_com=True history string, Help Markdown, dispatch wiring + placeholder removal, console-flow test in tests/test_console_workspace.py, sample_data unit test, MATLAB parity test where deterministic, and visual parity capture under tools/visual_parity/ with side-by-side PR attachment.

    Open questions for a human before implementation

    1. Is the 9-PR split acceptable, or should related actions be grouped (e.g., the two event editors in one PR)?
    2. Should pop_mergeset accept the multi-dataset selection state from item 9 as input, requiring item 9 to land first?
    3. Are there parity tolerances pre-decided for pop_chanedit coordinate transforms (cart/sph/topo round-trip) and pop_mergeset boundary-event semantics?
    4. Should phase-level CI gating wait until all 9 sub-PRs merge into feature/eeglab-completion, or land each sub-PR with its own non-slow + parity subset?

    No duplicate work detected — gh pr list --search "phase 1" returns no open PRs.

  3. changed the title [-]Phase 1: File, dataset, event, and channel metadata parity[/-] [+]Phase 1a: EEG/session/data contract foundation[/+] on May 27, 2026
  4. suraj-ranganath commented on May 27, 2026

    @suraj-ranganath
    MemberAuthor

    @claude I have split phase 1 into 2 phases now 1a and 1b so 1b can now happen in parallel with 2,3,4. Any comments on that? Dont start any implementation yet.

  5. claude commented on May 27, 2026

    @claude
    Contributor

    Claude finished @suraj-ranganath's task in 1m 57s —— View job


    Comments on the 1a/1b split

    The split is the right shape — 1a is now pure contract/scaffolding (docs, helpers, invariants, inventory), 1b is the actual File/Edit feature port. That cleanly separates "things every phase reads" from "things only one phase writes", which is what enables safe parallelism with 2/3/4. A few specific observations and asks before any implementation starts:

    1. The split is sound, but parallelism with 2/3/4 only works if 1a freezes these seams

    These are the shared surfaces where 1b directly touches data Phases 2/3/4 also write. If 1a leaves any of them ambiguous, the parallel phases will fight in the same dict fields:

    Seam 1b writer 2/3/4 writer 1a must lock
    event/urevent field schema pop_editeventfield, pop_editeventvals, pop_selectevent Phase 2 boundary insertion (eeg_eegrej, merge), Phase 3 rejection-mark conversion required field set, type rules, urevent linkage rule, boundary-event identity
    chanlocs/chaninfo schema pop_chanedit Phase 4 topoplot/channel-on-head, Phase 3 DIPFIT coreg cart/sph/topo round-trip tolerance, label uniqueness, ref handling
    Multi-dataset state pop_copyset, pop_mergeset, select_multiple_datasets Phase 5 STUDY (ALLEEG/CURRENTSTUDY propagation) selection-vector shape, propagation rule into CURRENTSTUDY, boundary-event semantics on merge
    ICA invalidation policy pop_chanedit (channel removal/reorder), pop_mergeset, event/selection edits Phase 2 filtering/cleaning, Phase 3 component workflows single rule for when icaact/icaweights/icasphere/icawinv get cleared (mirror eeg_checkset)

    If 1a ships these as a tests/test_eeg_invariants.py that runs against sample_data, every later phase can pytest -k invariants to prove it didn't break the contract.

    2. Two contract risks that look small but multiply across 4 parallel phases

    • History string format. "Support return_com=True" is not enough — 1a should lock the string format (single line, valid Python expression, no EEG = prefix, exact argument-quoting rules, [] vs None for empty). Otherwise 1b ships 9 functions with slight variations and 2/3/4 mirror them, multiplying the cleanup. Recommend a assert_history_replayable(EEG, com) helper that the dispatcher tests pin to.
    • Placeholder/menu inventory granularity. menu_placeholders.py currently flags actions as placeholder vs not. For parallel work, the inventory needs why: phase target (1b/2/3/4), explicit EEGBrowser exclusion, or external-plugin exclusion. Without that, a 1b agent may legitimately delete a placeholder that Phase 2 still needs to dispatch through (e.g., event-related but called from filtering paths).

    3. Concrete deliverables I'd expect 1a to ship (so 1b/2/3/4 can actually parallelize)

    1. EEG dict invariants documented in AGENTS.md (or docs/source/dev/contracts.md) and enforced by tests/test_eeg_invariants.py against sample_data.
    2. Reusable session/history assertions — likely an extension of tests/fixtures.py or new tests/helpers/session_assertions.py: assert_history_replayable, assert_session_synced, assert_no_duplicate_history, fresh_session_with_sample().
    3. Machine-readable menu inventory — extend menu_placeholders.py entries to carry phase and excluded_reason fields; add a tests/test_menu_inventory.py that fails if an action is both implemented and still placeholder, or if an EEGBrowser-flagged action gets dispatched.
    4. A parametrized MATLAB parity harness around eeglabcompat.py — takes (pop_func_name, eeglab_call, python_call, fields_to_compare, tolerances) and yields a parity test, instead of every phase hand-rolling the boilerplate.
    5. Sample-data fixture that returns a fresh EEG + EEGPrepSession per test (currently each test reloads ad-hoc, which makes session-sync tests flaky once multi-dataset state is in play).

    4. Cleanup items the rename surfaces

    5. One open question for the human

    Should 1a's EEGPrepSession rules treat multi-dataset selection state (the vector Phase 1b's select_multiple_datasets exposes) as part of the 1a contract, or defer it to 1b? Phase 5 (STUDY) reads it, so leaving it undefined until 1b means Phase 5 can't start its design work in parallel even after 1a merges. My recommendation: pull just the shape and propagation rule into 1a (no behavior), so Phase 5 can write tests against the contract while 1b implements the mutator.


    No implementation started, as requested.

    • Re-read current 1a issue
    • Pulled 1b/2/3/4/5 + epic to verify the dependency graph
    • Sanity-checked EEGPrepSession, menu_placeholders.py, existing tests
    • Posted analysis
      · branch claude/issue-61-20260527-0114
  6. suraj-ranganath commented on May 27, 2026

    @suraj-ranganath
    MemberAuthor

    Accepted the above stated recommendation and included it in the scope for 1a.

  7. suraj-ranganath commented on May 27, 2026

    @suraj-ranganath
    MemberAuthor

    Merged to the epic branch.

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