Skip to content

feat(pr-check): make the per-PR poll comment-aware#415

Open
pmaeria wants to merge 1 commit into
kunchenguid:mainfrom
pmaeria:fm/pr-comment-polls-c2
Open

feat(pr-check): make the per-PR poll comment-aware#415
pmaeria wants to merge 1 commit into
kunchenguid:mainfrom
pmaeria:fm/pr-comment-polls-c2

Conversation

@pmaeria

@pmaeria pmaeria commented Jul 10, 2026

Copy link
Copy Markdown

What

The per-PR poll generated by bin/fm-pr-check.sh (state/<id>.check.sh) woke firstmate only when the PR merged. New review activity - an AI or human review, a PR issue comment, an inline review comment - sat unnoticed until someone happened to look.

This extends the poll so new review activity also wakes firstmate, within one poll cycle, while preserving the check contract (one line of stdout only when firstmate should wake, silence otherwise, bounded runtime).

Behavior

  • Each poll counts reviews + comments via gh pr view --json reviews,comments (gh's built-in jq), consistent with the existing gh pr view --json usage in the script family.
  • The last-seen total is persisted in a firstmate-owned marker state/<id>.pr-activity, following the naming/lifecycle of sibling per-task state files.
  • First poll initializes the baseline silently - activity predating the arm never wakes firstmate.
  • Increase prints exactly one line, new-review-activity: +<n> on <url>, and advances the marker.
  • No change stays silent.
  • Merge wins: a merged PR echoes only merged and skips the activity check, so each fire prints exactly one line.
  • API error: a gh failure (or any non-integer reading) stays silent and never touches the marker - retries next cycle.
  • No bot classification: any new activity wakes firstmate to triage - cheaper than getting bot-detection wrong. Noted in the script header.

bin/fm-teardown.sh removes state/<id>.pr-activity alongside its sibling state files (both the main-task and secondmate-child cleanup paths).

Notes

  • AGENTS.md untouched: the check-contract sentence ("print one line only when firstmate should wake, print nothing otherwise") still accurately describes the new behavior.
  • Mechanics documented in the script header per the coding-guidelines decision tree.

Tests

New colocated tests/fm-pr-check.test.sh covers baseline init, wake-on-increase, silence-on-no-change, merged-beats-activity, API-error silence (existing marker and first poll), and the fallen-count resync. shellcheck bin/*.sh bin/backends/*.sh tests/*.sh is clean; fm-teardown and fm-pr-merge suites still green.

The generated state/<id>.check.sh woke firstmate only on merge, so new
review activity - a review, a PR issue comment, an inline review comment -
sat unnoticed until someone looked.

Extend the poll to also count reviews + comments via gh pr view --json and
persist the last-seen total in state/<id>.pr-activity. On an increase it
wakes with one "new-review-activity: +N on <url>" line; the first poll
records the baseline silently, unchanged activity stays silent, and a gh
error stays silent without touching the marker. Merge wins: a merged PR
echoes only "merged", preserving the one-line check contract. No bot
classification - any new activity wakes firstmate to triage.

fm-teardown.sh removes the new marker alongside its sibling state files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant