Repository navigation
fix(herdr): filter firstmate-owned agents from the spur completion channel - #59
Conversation
`herdr agent list` reports every agent in the session, including the panes firstmate itself spawned, and the spur bridge treated all of them as external. A firstmate-owned agent therefore woke firstmate TWICE per turn-end - once legitimately through its state/<id>.status append and turn-end hook, once spuriously through a `check: herdr-spur:<pane>` wake claiming it had "no firstmate status file". The noise scaled with fleet size and destroyed the one property the channel exists for: that a spur means an agent firstmate cannot otherwise see. The mapping was always available - herdr records `window=<session>:<pane-id>` in state/<id>.meta - but the bridge never did the reverse lookup, and window_to_task could not answer it anyway: it always returns something, so "nobody owns this pane" was not expressible. - fm-classify-lib.sh: split the strict metadata scan out as window_owner_task, which prints the owning task or returns 1 printing nothing. window_to_task now calls it and keeps its own always-something fallback, so every existing caller is unchanged. - fm-herdr-spur.sh: resolve each finish edge's pane back to a firstmate task before enqueuing, and drop the edge when one owns it. Both the bare pane id and the session-qualified "<session>:<pane-id>" shape are tried, since the event stream and `herdr agent list` report the bare form while meta records the qualified one - that mismatch is why a lookup would have failed even if the bridge had attempted it. Checked at the edge, not at subscribe time, so a task spawned or torn down mid-stream is classified against current metadata. tests/fm-herdr-spur.test.sh covers the strict lookup and drives the bridge --once against a stubbed herdr: an external pane still spurs, an owned pane (qualified or bare window=) never does, and a mixed pass emits exactly one wake. Without the bridge change the owned case reproduces the reported line verbatim.
|
Warning Review limit reached
Next review available in: 22 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. 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: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
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 |
What Changed
window_owner_tasktofm-classify-lib.sh— a strict ownership lookup that returns non-zero (printing nothing) when no task's metadata records the target, unlikewindow_to_task's always-something fallback;window_to_taskis refactored to delegate to it.fm-herdr-spur.shto callfm_herdr_spur_spur_or_skip(replacing directfm_herdr_spur_enqueuecalls) at both the poll-reconcile and event-stream finish-edge sites; the new function resolves the bare pane id against current state metadata — trying both bare and session-qualified shapes — and drops the edge when a firstmate task owns the pane.tests/fm-herdr-spur.test.shcovering strict ownership semantics, the backend-qualified vs. bare pane-id mismatch that was the root defect, and mixed-fleet passes where the owned agent is absent from the wake queue while the external agent still fires.Risk Assessment
✅ Low: The change is well-bounded — it fixes a concrete defect (owned-agent spurious double-waking), the refactored window_to_task preserves all existing call site semantics, the two-shape ownership probe is correct, and behavioral tests cover the stated scenarios.
Testing
Ran the new targeted test suite (7 assertions) plus the backend and transition-lib suites that exercise the refactored
window_to_task— all pass. The tests exercise both the strictwindow_owner_taskownership API and the bridge's end-to-end filtering behavior across external-only, owned-only, and mixed-fleet scenarios.Evidence: fm-herdr-spur.test.sh output
ok - window_owner_task resolves a recorded window target to its owning task ok - window_owner_task returns non-zero and prints nothing when no task owns the target ok - window_to_task keeps its fallback while window_owner_task stays strict ok - a pane no firstmate task records still spurs on working->idle ok - a bare pane id matching a backend-qualified window= is recognized as owned and never spurs ok - an unqualified recorded window= is recognized as owned too ok - a mixed pass spurs only the external agent # fm-herdr-spur.test.sh: all assertions passedPipeline
Updates from git push no-mistakes
⏭️ **intent** - skipped
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
tests/fm-herdr-spur.test.sh:64- The spur_run test helper embeds the $agents variable inside single quotes in the generated herdr stub script (printf '%s\n' '$agents'). If agents JSON ever contains a literal single quote, the stub would have broken shell syntax. Current test data is safe, but the pattern is fragile if test coverage expands.✅ **Test** - passed
✅ No issues found.
bash tests/fm-herdr-spur.test.shbash tests/fm-backend.test.shbash tests/fm-transition-lib.test.sh✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.