-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Supervisor post-PR lifecycle (t128.8) #392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Workers exit after PR creation due to context limits. The supervisor now detects complete tasks with PR URLs and handles remaining stages directly in the pulse cycle: wait for CI, merge (squash), postflight, deploy, and worktree cleanup. New states: pr_review, merging, merged, deploying, deployed New commands: pr-lifecycle, pr-check, pr-merge Pulse Phase 3: automatic post-PR processing for all eligible tasks Schema migration: existing databases auto-upgraded on first access Zero ShellCheck violations. Full state transition tests pass.
|
Caution Review failedThe pull request is closed. WalkthroughAdds a post-PR lifecycle to the supervisor script: new public commands (pr-lifecycle, pr-check, pr-merge), expanded state machine and DB migration for post-PR states, GitHub PR checks and merge logic, postflight/deploy/cleanup orchestration, and pulse-loop integration. Changes
Sequence DiagramsequenceDiagram
actor Supervisor
participant Processor as Post-PR Processor
participant GitHub as GitHub API
participant DB as State DB
participant Deployer as Deployment System
participant Cleanup as Cleanup Handler
Supervisor->>Processor: process_post_pr_lifecycle()
loop per eligible task
Processor->>GitHub: check_pr_status(task)
GitHub-->>Processor: PR status (ready/ci/draft/changes)
Processor->>DB: transition -> pr_review
alt ready_to_merge
Processor->>GitHub: merge_task_pr (gh pr merge --squash)
GitHub-->>Processor: merged
Processor->>DB: transition pr_review -> merging -> merged
Processor->>Deployer: run_postflight_for_task (verify main)
Deployer-->>Processor: postflight result
Processor->>Deployer: run_deploy_for_task
Deployer-->>Processor: deployed
Processor->>DB: transition merged -> deploying -> deployed
Processor->>Cleanup: cleanup_after_merge
Cleanup-->>Processor: cleanup done
else not_ready
Processor->>DB: record PR state (ci_pending / changes_requested / draft)
end
end
Processor-->>Supervisor: lifecycle pass complete
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Summary of ChangesHello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the supervisor's capabilities by introducing an automated post-Pull Request lifecycle. Previously, workers would exit after PR creation, leaving subsequent steps like CI monitoring, merging, deployment, and cleanup to manual intervention or separate processes. The supervisor now takes over these stages, managing tasks through new states such as Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Fri Feb 6 15:17:07 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a significant and well-designed feature for handling the post-PR lifecycle of tasks directly within the supervisor. The new state machine, commands, and pulse cycle enhancements are comprehensive. The database migration logic is robust. My review focuses on improving the script's debuggability and maintainability by addressing the widespread suppression of error messages, which could make troubleshooting difficult in a production environment.
…ssing Address code review feedback: - merge_task_pr: capture gh merge stderr for debugging - run_deploy_for_task: capture setup.sh output on failure - pr-lifecycle: log warnings for non-critical failures instead of suppressing all stderr with 2>/dev/null
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Fri Feb 6 15:21:21 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.agent/scripts/supervisor-helper.sh (1)
648-659:⚠️ Potential issue | 🟡 MinorORDER BY CASE doesn't include the new post-PR states.
The
cmd_statusquery (and the analogous one incmd_listat lines 858-868) doesn't includepr_review,merging,merged,deploying, ordeployedin the sort CASE. These states get a NULL sort key, so they appear in an undefined position.🔧 Proposed fix — add new states to sort order
CASE status WHEN 'running' THEN 1 WHEN 'dispatched' THEN 2 WHEN 'evaluating' THEN 3 WHEN 'retrying' THEN 4 WHEN 'queued' THEN 5 - WHEN 'blocked' THEN 6 - WHEN 'failed' THEN 7 - WHEN 'complete' THEN 8 - WHEN 'cancelled' THEN 9 + WHEN 'pr_review' THEN 6 + WHEN 'merging' THEN 7 + WHEN 'deploying' THEN 8 + WHEN 'blocked' THEN 9 + WHEN 'failed' THEN 10 + WHEN 'complete' THEN 11 + WHEN 'merged' THEN 12 + WHEN 'deployed' THEN 13 + WHEN 'cancelled' THEN 14 END;Apply the same change to the
cmd_listCASE at lines 858-868.
🤖 Fix all issues with AI agents
In @.agent/scripts/supervisor-helper.sh:
- Around line 95-108: The PR lifecycle list in supervisor-helper.sh is missing
the "pr_review:deployed" transition which causes cmd_pr_lifecycle (called from
cmd_pr_lifecycle and using check_pr_status) to attempt a pr_review → deployed
transition that cmd_transition cannot perform; add the string
"pr_review:deployed" into the Post-PR lifecycle transitions block (the same list
containing "complete:pr_review", "merged:deploying", etc.) so cmd_transition can
succeed and tasks won't get stuck in pr_review.
- Around line 2022-2033: The fallback PR lookup calls gh pr view from the wrong
directory and may pass an empty $repo_slug; change the logic around the gh
invocation (referencing variables pr_number, repo_slug, tworktree,
SUPERVISOR_DB, escaped_id) so gh runs inside the task's worktree (e.g., run gh
in a subshell or use pushd/popd to cd into "$tworktree") and only pass --repo
"$repo_slug" if $repo_slug is non-empty (otherwise rely on the repo inferred
from the worktree); ensure you restore/avoid changing the outer shell's cwd
after the lookup.
- Around line 2497-2523: The block that runs cmd_transition "$task_id"
"deploying" then calls run_postflight_for_task, run_deploy_for_task and
cleanup_after_merge currently swallows all errors with "|| true" and always
transitions to "deployed"; remove the unconditional suppression and instead
check each command's exit status (or use set -e semantics) so failures are
detected, call cmd_transition "$task_id" "deploying:failed" (or the existing
"deploying:failed" transition) and send a failure notification if any step
fails, only calling cmd_transition "$task_id" "deployed", send_task_notification
and store_success_pattern when all steps succeed; also add handling at the top
to resume tasks already in "deploying" state by re-running the same guarded
sequence (or verifying current state before transitioning) so interrupted
deployments exercise the "deploying:failed" path correctly.
🧹 Nitpick comments (3)
.agent/scripts/supervisor-helper.sh (3)
2194-2203:gh pr mergestderr suppressed — merge failure details lost.Redirecting
2>/dev/nullon the merge command discards the error reason (e.g., "merge requirements not met", "branch protection", "network error"). This makes it difficult to diagnose why a merge failed — the task simply transitions toblockedwith a generic "Merge failed" message.🔧 Proposed fix — capture and log stderr
- if gh pr merge "$pr_number" --repo "$repo_slug" --squash 2>/dev/null; then + local merge_stderr + if merge_stderr=$(gh pr merge "$pr_number" --repo "$repo_slug" --squash 2>&1); then log_success "PR #$pr_number merged successfully" return 0 else - log_error "Failed to merge PR #$pr_number" + log_error "Failed to merge PR #$pr_number: $merge_stderr" return 1 fi
2296-2303: Deploy stderr suppressed and no execution timeout.
2>/dev/nullon./setup.shhides deploy errors. A hungsetup.shwould block the entire pulse cycle indefinitely since there's no timeout.🔧 Proposed fix — log errors and add timeout
log_info "Running setup.sh for $task_id..." - if (cd "$repo" && ./setup.sh) 2>/dev/null; then + local deploy_log="$SUPERVISOR_DIR/logs/${task_id}-deploy-$(date +%Y%m%d%H%M%S).log" + if (cd "$repo" && timeout 300 ./setup.sh) > "$deploy_log" 2>&1; then log_success "Deploy complete for $task_id" return 0 else - log_warn "Deploy (setup.sh) returned non-zero for $task_id" + log_warn "Deploy (setup.sh) returned non-zero for $task_id (see $deploy_log)" return 1 fi
2569-2580: Lifecycle output entirely suppressed — consider logging instead.
cmd_pr_lifecycle "$tid" 2>/dev/nulldiscards all logging and error output from the lifecycle processing. Combined with the2>/dev/null || truepatterns insidecmd_pr_lifecycle, this creates a debugging black hole during pulse runs. When a task silently fails to advance, there's no trail to investigate.Consider redirecting to the task's log file or the supervisor cron log instead:
- if cmd_pr_lifecycle "$tid" 2>/dev/null; then + if cmd_pr_lifecycle "$tid" >> "$SUPERVISOR_DIR/post-pr.log" 2>&1; then
…y errors (t147.2) - Add post-PR states to ORDER BY CASE in cmd_status and cmd_list - Add 300s timeout to deploy setup.sh with portable fallback - Deploy failures now transition to 'failed' instead of silently marking 'deployed' - Redirect cmd_pr_lifecycle output to post-pr.log instead of /dev/null - Fix missing $SUPERVISOR_DB arg in db() calls for no_pr retry counter - Remove unused no_pr_key variable Dismissed 3 of 6 review threads as already fixed or invalid: - gh pr merge stderr: already uses 2>&1 - Fallback PR lookup: already uses git -C and gh pr list --repo - Missing pr_review:deployed transition: not needed, complete:deployed handles it
…y errors (t147.2) (#451) * chore: mark t142 complete in TODO.md (#449) * chore: mark t135.9 complete in TODO.md (#448) * fix(supervisor): triage PR #392 review feedback - stderr, sort, deploy errors (t147.2) - Add post-PR states to ORDER BY CASE in cmd_status and cmd_list - Add 300s timeout to deploy setup.sh with portable fallback - Deploy failures now transition to 'failed' instead of silently marking 'deployed' - Redirect cmd_pr_lifecycle output to post-pr.log instead of /dev/null - Fix missing $SUPERVISOR_DB arg in db() calls for no_pr retry counter - Remove unused no_pr_key variable Dismissed 3 of 6 review threads as already fixed or invalid: - gh pr merge stderr: already uses 2>&1 - Fallback PR lookup: already uses git -C and gh pr list --repo - Missing pr_review:deployed transition: not needed, complete:deployed handles it



Summary
pr_review,merging,merged,deploying,deployed) and 3 new commands (pr-lifecycle,pr-check,pr-merge) tosupervisor-helper.sh.completestate with PR URLs through the full post-PR lifecycle.Changes
New State Machine Extension
New Commands
pr-check <task_id>- Check PR CI/review status viaghCLIpr-merge <task_id> [--dry-run]- Squash merge a task's PRpr-lifecycle <task_id> [--dry-run]- Full post-PR lifecycle (CI wait, merge, postflight, deploy, cleanup)Pulse Cycle Enhancement
Schema Migration
Quality
completestate still works, post-PR lifecycle is additiveTask
Closes t128.8 (Supervisor post-PR lifecycle - merge, postflight, deploy)
Summary by CodeRabbit