feat(mux): out-of-tree backend discovery via bmad_loop.mux_backends entry points#145
Conversation
…ntry points An adapter package co-installed with bmad-loop (uv tool install --with / same-venv pip) now registers its backend with no config step: _select() and detect_multiplexers() scan the bmad_loop.mux_backends entry-point group after the builtin load and import each advertised module, whose import-time register_multiplexer() call does the rest. Builtins register first, so tmux keeps first-wins on a name collision and default selection is unchanged by installing an adapter. A broken distribution can never break selection: each ep.load() failure (and a failing scan itself) is recorded in _EXTERNAL_ERRORS and surfaced — a warning line under the `bmad-loop mux` table and an advisory note in the validate preflight (external_backend_errors()). The loaded-flag is set up front, unlike _BUILTINS_LOADED: a third-party import failure is not transient, and retrying would re-import (and re-fail) on every selection. fresh_registry parks the scan as already-done (installed adapters must not leak into builtin-selection tests); the discovery tests re-arm it explicitly, and one exercises a real *.dist-info on sys.path to prove the group/value convention against genuine packaging metadata. Docs: 'Shipping out-of-tree' section in porting-to-a-new-os.md (+ authoring- guide cross-link) naming pbean/bmad-loop-adapter-herdr as the reference external adapter.
|
@CodeRabbit review |
✅ Action performedReview finished.
|
|
Warning Review limit reached
Next review available in: 50 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughAdds entry-point discovery for out-of-tree multiplexer backends, loading them before selection and recording import failures. CLI mux and validate commands surface those failures as warnings or notes, with tests covering discovery, precedence, degradation, isolation, and real package metadata. ChangesExternal multiplexer backends
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/test_external_backends.py`:
- Around line 166-186: Update test_mux_command_surfaces_load_failures to discard
the unused first value from scan_registry while retaining the arm helper used to
register the broken entry point; do not change the test’s assertions or command
behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b02c0d29-ce62-47c1-8b39-02dabeb19d2f
📒 Files selected for processing (7)
CHANGELOG.mddocs/adapter-authoring-guide.mddocs/porting-to-a-new-os.mdsrc/bmad_loop/adapters/multiplexer.pysrc/bmad_loop/cli.pytests/test_backend_registry.pytests/test_external_backends.py
Summary
Adds the discovery seam that lets an adapter package co-installed with bmad-loop (
uv tool install --with .../ same-venv pip) register its multiplexer backend with no config step:_select()anddetect_multiplexers()scan thebmad_loop.mux_backendsentry-point group after the builtin load and import each advertised module, whose import-timeregister_multiplexer()call does the rest.This is the first of two PRs moving the herdr backend out-of-tree to pbean/bmad-loop-adapter-herdr (the extraction PR follows once this lands).
Design points
ep.load()failure (and a failing scan itself) is recorded in_EXTERNAL_ERRORSand surfaced — awarning:line under thebmad-loop muxtable and a non-fatal advisory note in thevalidatepreflight (external_backend_errors())._BUILTINS_LOADED: a third-party import failure is not transient, and retrying would re-import (and re-fail) on every selection. Documented inline.Tests
tests/test_external_backends.py(8 tests): fake entry point registers a stub → listed bydetect_multiplexers+ selectable viaBMAD_LOOP_MUX_BACKEND;ep.load()raises → tmux still selected, error recorded,muxoutput shows the warning;entry_points()itself raises → graceful degrade; externals-load-after-builtins ordering; plus one test placing a real*.dist-infoonsys.pathto prove the group/value convention against genuine packaging metadata.fresh_registryextended to park_EXTERNALS_LOADED=Trueby default so installed adapters can't leak into builtin-selection tests; the discovery tests re-arm it explicitly.Docs
porting-to-a-new-os.md(+ authoring-guide cross-link) naming pbean/bmad-loop-adapter-herdr as the reference external adapter.Summary by CodeRabbit
New Features
bmad-loop muxandvalidatenow surface advisory warnings.Documentation