Repository navigation
Closed
Labels
phaseEpic implementation phase
Description
Summary
Wire registered extensions into the real EEGPrep user experience: main-window menus, action dispatch, help resources, pop_* public functions, eegprep-console, EEGPrepSession, and history.
Key Work
- Let extension specs contribute
MenuItemSpecitems by stable menu path/tag instead of direct Qt mutation. - Let extension specs register GUI actions and
pop_*callables through a registry-backed dispatcher. - Ensure extension
pop_*functions can supportreturn_com=Trueand valid Python console command echo. - Expose registered extension
pop_*functions ineegprep-consolewrappers with the same auto-store/history behavior as built-in functions. - Add help-resource lookup for extension-packaged Markdown resources.
- Refactor bundled plugin menu contributions to use the same extension path where practical, without broad unrelated churn.
- Preserve
include_plugins=Falseand--no-pluginsbehavior. - Keep GUI refresh and session synchronization centralized through
EEGPrepSessionhelpers.
Edge Cases To Cover
- Extension menu action enabled/disabled state across startup, no dataset, continuous, epoched, ICA present/absent, STUDY, and multi-dataset states.
- Extension action raises after the menu is clicked.
- Extension action returns EEG only,
(EEG, com), command only, or no mutation. - Extension help resource missing or malformed.
- Extension command should be shown in console and history exactly once.
- Two extensions try to add the same menu/action.
- Extension contributes a menu under a missing path.
Acceptance Criteria
- A fake test extension can add a menu item, run an action, update
EEG, append history, and refresh the GUI/session. - The same fake extension works from
eegprep-consolewith bare and assignedpop_*calls. - Built-in bundled plugins still appear and behave as before.
--no-pluginshides extension contributions without hiding core menus.- Tests cover menu inventory, dispatcher behavior, console namespace/history, help lookup, and failure handling.
- GUI-visible changes use visual parity checks where menus/dialogs change.
/goal Prompt
/goal Integrate registered EEGPrep extensions into menu construction, action dispatch, help resources, eegprep-console, EEGPrepSession synchronization, and history. Refactor bundled plugins only as needed to share the extension path. Verify with fake extension tests, bundled plugin regression tests, GUI/menu inventory tests, console/history tests, visual checks for visible changes, and lint/type/focused pytest.
Metadata
Metadata
Assignees
Labels
phaseEpic implementation phase
Activity
claude commentedon Jun 2, 2026
🤖 Plan:
Research
Phase 2 wires a registry-backed extension system into menus, dispatch, help, console, and history. It depends on the Phase 1 SDK (#113), which is still open and not present in the codebase — there is no
ExtensionSpec, no registry module, noeegprep.extensionsentry-point group, and nopyproject.tomlentry-point group declaration. Today's only "extension" surface is a hardcoded bundled-plugin inventory plus dispatcher branches; everything Phase 2 lists ("registered extensions", "registry-backed dispatcher", "extension help-resource lookup") presumes the Phase 1 contract.Today's integration points Phase 2 must extend (all currently hardcoded for the five bundled plugins):
Relevant code
src/eegprep/functions/adminfunc/plugin_menu.py#L14-L80— frozen tuple of bundled plugin records (no discovery)src/eegprep/functions/guifunc/eeglab_menu.py#L380-L455—eeglab_menus(..., include_plugins=...); plugin items spliced by hardcoded_insert_*helperssrc/eegprep/functions/guifunc/menu_spec.py#L12-L29—MenuItemSpec(already hasorigin,tag; suitable contribution unit)src/eegprep/functions/guifunc/menu_actions.py#L208-L436—MenuActionDispatcher.dispatchis a longif base == ...chain; no registry hooksrc/eegprep/functions/adminfunc/console.py#L345-L389— namespace bind iterateseegprep.__all__; only built-inpop_*getConsolePopFunctionwrapperssrc/eegprep/functions/guifunc/pophelp.py#L12-L93— help lookup is hardwired toeegprep.resources.helppackage, no per-extension fallbacksrc/eegprep/functions/adminfunc/eeglab.py#L19-L112andconsole.py#L443-L462—--no-plugins/include_pluginsalready plumbed intoeeglab_menus; Phase 2 needs to honor this for extensions tooProposed Approach
Scope is multi-module (menus, dispatcher, console, help, session) and almost certainly >500 LOC across
src/eegprep/functions/{adminfunc,guifunc}/plus tests. Per fix-issue/SKILL.md this requires a design comment, not a PR. Phase 2 should not start until Phase 1 (#113) merges, because every section below names a Phase 1 type.Design sketch:
Registry contract (consumed, not defined here). Phase 1 owns
ExtensionSpec(name, version, api_version, package, menus, actions, pop_funcs, help_resources, status) and a registry that exposesiter_active_extensions()and lazyload_action(name). Phase 2 only imports those and never reads entry points directly. If Phase 1 lands with a different shape, the integration points below adapt; the structure does not change.Menu contribution by path/tag. Each
ExtensionSpeccontributes a list of(parent_path, MenuItemSpec)whereparent_pathis a stable tag tuple like("file", "import")or("tools", "filter"). Add anapply_extension_menus(core_menus, extensions)helper next toeeglab_menusthat walks the spec tree and inserts contributions immutably (mirrors today's_insert_*helpers but data-driven).eeglab_menus(include_plugins=False)already skips bundled inserts; gate extension inserts on the same flag. Two extensions hitting the same parent path append in deterministic (name, version) order; missing path logs a warning and skips that contribution (per Phase 1 failure-isolation rule). Mark extension-origin items withorigin="extension:<name>"somenu_to_inventoryand visual-parity tests can distinguish them.Action dispatcher hook. Replace the long
if base == ...ladder for extension actions with a registry lookup at the top ofdispatch(): ifbaseis an extension-registered action and not a core/bundled action, callregistry.load_action(base)(self.session, parent, variant=variant, return_com=True). Core actions are untouched. The handler contract is(EEG_or_None, command_or_None):(EEG, com)→session.store_current(eeg, command=com)EEGalone →store_current(eeg, command="")and synthesizeEEG = <name>(EEG, ...)history (mirrors_run_pop_function)(None, com)→session.add_history(com)only (no mutation)None→ log and exit, no historydispatch_guitry/exceptalready shows the warning; logs include the extension nameBundled plugins keep their dedicated branches; the comment from issue 114 explicitly says refactor those "without broad unrelated churn" — only migrate one (e.g.
pop_iclabel) opportunistically as proof-of-concept.Console namespace and history. Extend
EEGPrepConsoleWorkspace._bind_exports(console.py#L349-L359) so after bindingeegprep.__all__it also iterates active extensions and binds each registeredpop_*callable throughConsolePopFunction(name, self, fn). This automatically gives barepop_foo(EEG, ...)auto-store, history echo, andreturn_comhandling becauseConsolePopFunctionalready does that. Update_restore_imported_wrappersto recognizefrom <ext_pkg> import pop_fooaliases too (use the registry to know which import paths are extensionpop_*).Help-resource lookup. Add an optional
packageargument topophelp_text(function_name, *, package=None)defaulting toHELP_PACKAGE. For extension-owned functions, the registry mapspop_<name>→ declaring package's help subpackage (e.g.myext.resources.help); call sites in extensionpop_*use the samepophelp('<name>')string. Missing/malformed resources stay loud per AGENTS.md ("missing help resources should fail clearly").Session synchronization. All session writes already go through
store_current,add_history,notify_changed— Phase 2 must not introduce GUI-only mutation paths. Add aMenuActionDispatcherhelper_run_extension_action(name, parent, variant)that mirrors_run_pop_functionso refresh, history, and command echo behave identically.include_plugins=False/--no-plugins. Already gates bundled menu inserts ineeglab_menus; extend the same gate to extension contributions and to the console namespace bind (skip extensionpop_*wrappers under the flag). Core menus remain untouched in both modes.Tests (extend, do not duplicate):
tests/test_eeglab_menu.py— fake extension with one menu item under each top-level path; duplicate contribution; missing path;include_plugins=Falseparitytests/test_menu_actions.py— fake extension action exercising all four return shapes plus the raise case;agent-generatedhistory string checktests/test_console_workspace.py— barepop_fakeext(EEG)auto-stores;from fakeext import pop_fakeext as faliases through_restore_imported_wrappers; command echoed exactly oncetests/test_pophelp.py(or nearest) — extension-packaged Markdown found; missing resource raises cleanlytests/test_plugin_menu.py— bundled inventory regression unchangedtools/visual_parity/for any menu the extension touchesOut of scope for this issue. Extension Manager UX (Phase 3: Extension Manager UX, curated catalog metadata, and safe install guidance #115), curated catalog (Phase 5: Governance, security, catalog validation, compatibility policy, and extension test harness #117), authoring toolkit (Phase 4: Researcher authoring toolkit, template package, examples, and scaffolding #116), full bundled-plugin migration to the new path. Mention bundled-plugin migration as follow-up.
Open questions for the human reviewer before implementation:
feature/eegprep-extension-completionbranch as the epic (Epic: Build EEGPrep external extension ecosystem #112) suggests?firfiltbecause its menu insertion is the cleanest.pop_*functions appear ineegprep.__all__/dir(eegprep)automatically, or stay namespaced undereegprep.extensions.<name>? Affects discoverability vs. namespace pollution.extensionsbranch at the top ofdispatch()that delegates to the registry, or (b) a precomputedaction_handlers: dict[str, Callable]map built once at dispatcher construction? (b) is cleaner but requires registry events when extensions are enabled/disabled at runtime — is runtime enable/disable in scope for Phase 2 or deferred to Phase 3: Extension Manager UX, curated catalog metadata, and safe install guidance #115?Awaiting reviewer direction before opening a PR.