feat(relay): shared event-write primitive + bmad-loop relay <Event>#238
Draft
pbean wants to merge 1 commit into
Draft
feat(relay): shared event-write primitive + bmad-loop relay <Event>#238pbean wants to merge 1 commit into
bmad-loop relay <Event>#238pbean wants to merge 1 commit into
Conversation
The event-write body was duplicated between data/bmad_loop_hook.py and PR #226's hermes_hooks.relay_event (identical env-gating, casing-tolerant field extraction, atomic events/<ts>-<task>-<event>.json write). Factor the schema + write into one core primitive, bmad_loop.events.write_relay_event, and add a general `bmad-loop relay <Event>` command over it that reads the hook payload from stdin. This is the general, in-tree counterpart to bmad_loop_hook.py for global/user-scoped-hook adapters: such an adapter (e.g. an out-of-tree Hermes package) points its native hook at `bmad-loop relay Stop` and needs zero per-adapter relay code. Not Hermes-specific. data/bmad_loop_hook.py keeps its own inlined copy on purpose — it is installed into target projects as a lone, stdlib-only file and run as a bare subprocess where the bmad_loop package need not be importable, so it cannot import the primitive. Its behavior is unchanged; a parity test in tests/test_relay_event.py pins the inlined copy and the primitive to the same schema across every payload dialect so they cannot drift. Event choices come from CANONICAL_EVENTS (never a hardcoded set). Tests cover the active-env write, the no-env no-op, the CLI stdin path, event-name gating, and standalone/primitive schema parity.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Factor the relay event-write logic — already duplicated between
data/bmad_loop_hook.pyand PR #226'shermes_hooks.relay_event(identical env-gating, casing-tolerant field extraction, atomicevents/<ts>-<task>-<event>.jsonwrite) — into one core primitive that owns the event schema, and add a generalbmad-loop relay <Event>command over it.This is the general, in-tree counterpart to
bmad_loop_hook.pyfor global/user-scoped-hook adapters — NOT Hermes-specific. An out-of-tree adapter whose CLI registers a single user-scoped hook (rather than copying the per-project script) points that hook atbmad-loop relay Stopand needs zero per-adapter relay code.Changes
src/bmad_loop/events.py—write_relay_event(event_name, payload, environ) -> Path | None(+build_event). Owns the canonical schema (ts,event,task_id,session_id,transcript_path,cwd) and the env-gated (BMAD_LOOP_RUN_DIR+BMAD_LOOP_TASK_ID), atomic write. No-ops outside an active bmad-loop session.bmad-loop relay <Event>incli.py— reads the hook payload from stdin and defers to the primitive.eventchoices come fromCANONICAL_EVENTS(never a hardcoded set).data/bmad_loop_hook.py— behavior unchanged. It keeps its own inlined copy on purpose: it is installed into target projects as a lone, stdlib-only file and run as a bare subprocess where thebmad_looppackage need not be importable, so it cannot import the primitive. Added a docstring note documenting the deliberate duplication and the sync guard.Tests (
tests/test_relay_event.py)workspacePathsfallbacks, unusable-workspacePathsdegrades toNonetests/test_hook_script.pybehavior unchanged (incl.test_installed_copy_matches_source)Verification
pytestgreen in both TMUX states (TMUX-unset and inside a real tmux session): 2717 passed, 7 skipped. The one failure (test_tui_app.py::test_validate_findings_multiline_message_keeps_column_alignment) is pre-existing and unrelated — an environment-sensitive TUI rendering-width test that fails identically on untouchedmain.trunk check— no issues.Context
Session 2 of the PR #226 review plan (make the coding-CLI adapter axis extensible out-of-tree). Independent of the other sessions. The out-of-tree Hermes package (a later session) is where
hermes_hooks.relay_eventgets deleted in favor of pointing its hook at this command.