Skip to content

[Phase 1a] Stabilize EEG session contracts - #68

Merged
suraj-ranganath merged 2 commits into
feature/eeglab-completionfrom
phase/1a-contract-foundation
May 27, 2026
Merged

suraj-ranganath merged 2 commits into
feature/eeglab-completionfrom
phase/1a-contract-foundation

Conversation

@suraj-ranganath

@suraj-ranganath suraj-ranganath commented May 27, 2026 •

Copy link
Copy Markdown
Member

Stabilize the shared EEG/session/data contracts needed before parallel EEGLAB parity phases proceed. Adds documented EEG field, CURRENTSET, history, and placeholder inventory rules, plus reusable sample/session/history test helpers and contract tests for console/session/menu behavior. Invalid CURRENTSET entries now fail fast instead of being silently filtered.

Closes #61

@claude

claude Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @suraj-ranganath's task in 4m 36s —— View job


Claude PR Review — #68 (Phase 1a: Stabilize EEG session contracts)

  • Read PR diff against origin/feature/eeglab-completion
  • Read changed files (session, console, menu_placeholders, fixtures, new tests, docs)
  • Cross-check tests against documented contracts
  • Post inline review comments
  • Post review summary

Summary

Solid foundation PR. The contract is well-defined in docs (docs/source/development.rst + AGENTS.md), the helper extraction into normalize_dataset_indices is centralized correctly, and the placeholder inventory is now machine-readable with phase/exclusion metadata. Tests cover the headline contracts (sample-data shape, single/multi-selection, console namespace sync, EEGBrowser exclusion).

Nothing blocking. Findings are minor — see inline comments for specifics.

Strengths

  • Single source of truth for selection normalization: EEGPrepSession.retrieve, EEGPrepSession.store_current, and console _normalize_currentset all funnel through normalize_dataset_indices. The allow_empty toggle cleanly separates session-internal (False, must have a selection) from console-edit (True, 0/""/None legal) semantics.
  • Placeholder metadata model: PlaceholderMetadata(phase, excluded_reason) + XOR test (bool(phase) ^ bool(excluded_reason)) gives later phases a programmatic handle on what's planned vs. intentionally excluded, and pop_eegplot is correctly carved out as eegbrowser.
  • Contracts are testable: test_session_contracts.py exercises the documented invariants end-to-end (sample dataset shape, CURRENTSET ∈ {0, n, [n,...]} console projection, duplicate rejection through after_execute). test_menu_placeholder_inventory.py enforces that every menu action is classified (no unknown).
  • Docs alignment: Both AGENTS.md and docs/source/development.rst reflect the new contracts; runtime/EEGLAB-tree-independence rule is restated.

Findings (inline)

  1. tests/fixtures.py:19 — Importing _console_python_command (private) into a shared test fixture couples downstream tests to console internals. Consider a local import or a public wrapper.
  2. tests/test_session_contracts.py:131 — Hard-asserting the exact MATLAB→Python converted string locks the test to the full conversion pipeline. A structural check (AST shape) would be more resilient.
  3. src/eegprep/functions/guifunc/session.py:62–66 — The index == 0 empty-selection carve-out treats both bare 0 and the single-element list [0] as empty but rejects [0, 1]. Worth pinning down in the docstring which form is canonical for "empty selection."
  4. src/eegprep/functions/adminfunc/console.py:1088–1092 — Behavior change: the old _normalize_currentset silently filtered non-positive integers ([1,-1,2] → [1,2], -1 → []); now those raise. Stricter is fine, but flag in PR notes and consider adding an explicit test for the negative-entry rejection path.

Other notes (non-blocking)

  • placeholder_message returns the generic "not yet available" message when called with an unregistered action (i.e., metadata is None). Callers are expected to gate on is_placeholder_action; pre-existing contract, just confirming.
  • The deepcopy in fresh_sample_eeg is belt-and-suspenders (since pop_loadset returns a fresh dict) but harmless.
  • normalize_dataset_indices is a small module-level util with clear type hints, so the single-line docstring is reasonable, though AGENTS.md recommends Google-style for new public functions. Not worth changing for this size.
    · branch phase/1a-contract-foundation

Comment thread tests/fixtures.py Resolved
Comment thread tests/test_session_contracts.py Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant