feat(watcher): Wake on automated PR reviews - #16
Conversation
The watcher's PR poll wakes firstmate only on merge. Extend fm-pr-poll.sh so a new automated-reviewer review (CodeRabbit or any Bot-type GitHub account) also wakes firstmate, surfacing review feedback promptly instead of only at merge time. - fm-pr-poll.sh emits a distinct bot-review token when the highest Bot-authored review id exceeds the last one surfaced, deduping through a private state/<id>.pr-review-seen sidecar. merged takes priority and short-circuits; the poll stays armed after a bot-review wake. GitHub only (glab has no reviews API); every failure path stays silent. The seen sidecar is derived from the check basename in standalone mode and passed as the seventh validated argument by the watcher. - fm-watch.sh passes the per-task seen path to the validated poll. - fm-teardown.sh removes the seen sidecar with the other poll artifacts. - Extend the PR-check security suite with a bot-review wake test (silence, dedup, id advance, reviews-API failure, merged priority, and an end-to-end watcher-bounded run that stays armed) and cover seen-sidecar teardown. - Record the new sidecar in the AGENTS.md state inventory.
|
Warning Review limit reached
Next review available in: 41 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: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
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 |
…ills (#22) * Add night-ops-directive and coderabbit-pr-gate skills Salvage the still-relevant content from stale/broken PR #5, reshipped clean through no-mistakes rather than reopening it. Carried forward: - night-ops-directive: standing autonomous-dispatch directive (delegator discipline during unattended work, the watcher-heartbeat wake cadence since ScheduleWakeup/CronCreate are blocked for the primary session, human-only task triage via bd transfer). - coderabbit-pr-gate: CodeRabbit-clean-plus-green merge gating (react to actionable review comments beyond bare pass/fail, treat rate limits as a paused external wait). - AGENTS.md yolo reversibility clarification: the qualifying test for a routine yolo-covered gate, including a PR merge, is reversibility. Dropped as already covered by work landed the same day: - PR #5's general fork-first-push line in AGENTS.md section 7 is dropped; fork-first-brief-08 already implemented and documented (section 11) an automatic fork-first push rule injected into every push-mode ship brief via fm-brief.sh, which fully covers this case. - coderabbit-pr-gate is kept, not dropped, despite PR #16 (pr-review- comment-wake) landing the same day: PR #16 only added the wake mechanism (state/<id>.pr-review-seen) for a new bot review comment. It added no reaction policy, so coderabbit-pr-gate is complementary, not duplicative; the skill now cross-references that wake mechanism instead of re-describing it. * no-mistakes(test): Register two new SKILL.md files in documentation-audiences.json
Intent
Extend firstmate's watcher PR poll so it wakes firstmate when an automated reviewer (CodeRabbit, or any Bot-type GitHub account) posts a new PR review, not only on merge/CI, so review feedback is surfaced promptly.
Design decisions made while implementing:
Testing: extended the existing PR-check security suite (tests/fm-pr-check-security.test.sh) with a bot-review wake test (silence with no reviews, wake+seen on a new id, dedup, id advance on a newer id, silence on reviews-API failure, merged priority, and an end-to-end watcher-bounded run that produces exactly one bot-review wake and leaves the poll armed) plus seen-sidecar teardown coverage; added a reviews case to the fake gh. Clean full suite run was 37 ok / 0 failures. Two unrelated watcher timing tests flake under load but reproduce identically on unmodified fm-watch.sh and pass in isolation, so they are pre-existing environmental flakiness, not from this change.
What Changed
pr-review-seensidecar file to prevent re-waking on the same review ID, with silent-on-error design matching the poll's safety modelgh api reviews; GitLab MR continues with merge-only wakes, as glab lacks a reviews API equivalentRisk Assessment
✅ Low: The change is well-bounded, introduces a new non-terminal wake signal that gracefully degrades on error, uses atomic file operations for safety, includes defense-in-depth validation, and is thoroughly tested with 10+ test cases covering happy paths, edge cases, and error conditions.
Testing
All core bot-review functionality verified: new reviews emit distinct 'bot-review' wake token, deduplication prevents duplicate wakes, seen sidecar is created/updated/removed correctly, merged takes priority, GitHub-only scope is enforced, and integration with watcher/teardown works end-to-end. Manual tests confirm output contracts and file state transitions. Test suite includes comprehensive coverage of all scenarios. Pre-existing flaky watcher timing tests are environmental and unrelated to this change.
Evidence: Bot-Review Test Evidence
Evidence: Implementation Summary
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
Manual unit test: bot-review wake on new review IDManual unit test: deduplication on same review IDsManual unit test: wake on newer review ID with seen file advancementManual unit test: merged PR priority doesn't emit bot-reviewtest_bot_review_wake from fm-pr-check-security.test.shtest_teardown_removes_poll_artifacts coverage of pr-review-seen sidecarCode review: fm-pr-poll.sh emit_new_bot_review() implementationCode review: fm-watch.sh 7th argument passingCode review: fm-teardown.sh cleanup inclusionCode review: AGENTS.md state inventory documentation✅ **Document** - passed
✅ No issues found.
🔧 **Lint** - 1 issue found → auto-fixed ✅
🔧 Fix: Remove unused ROWS_AFFECTED variable assignment
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.