fix: supervisor lifecycle gaps — Phase 3d and orphan PR adoption#2205
fix: supervisor lifecycle gaps — Phase 3d and orphan PR adoption#2205marcusquinn merged 1 commit intomainfrom
Conversation
…an PRs - Phase 3d: finds verified/deployed tasks with open PRs on GitHub and squash-merges them if CI is green, updates branch if behind, or logs if blocked. Runs on the same cooldown as Phase 3c. - adopt_untracked_prs: now extracts task IDs from branch names as fallback when PR title has no tNNN: prefix. - adopt_untracked_prs: creates synthetic task entries (prNNN) for orphan PRs with no task ID, allowing Phase 3 lifecycle to process them through review → merge → verify. - adopt_untracked_prs: logs verified/deployed tasks for Phase 3d handling instead of silently skipping.
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 improves the supervisor's ability to manage the lifecycle of pull requests, particularly those associated with tasks that have reached terminal states or those lacking explicit task identifiers. By introducing a new reconciliation phase and enhancing PR adoption mechanisms, the system can now automatically resolve lingering PRs and ensure all relevant changes are properly integrated, thereby streamlining the development workflow and reducing manual intervention. 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
|
WalkthroughThe pull request extends the pulse flow with Phase 3d, a new automated PR reconciliation phase that queries GitHub for merged PR states and performs squash merges, plus-updates branch handling for OPEN PRs. It also extends the adopt_untracked_prs function to extract task IDs from PR branch names via headRefName and create synthetic tasks for orphaned PRs. Changes
Sequence Diagram(s)sequenceDiagram
participant Supervisor as Supervisor<br/>(pulse.sh)
participant GitHub as GitHub API
participant DB as Task DB
participant Repo as Git Repo
rect rgba(100, 150, 200, 0.5)
Note over Supervisor,GitHub: Phase 3d: PR Reconciliation (when should_reconcile=true)
Supervisor->>DB: Scan verified/deployed tasks with PR URLs
DB-->>Supervisor: List of tasks with PR URLs
loop For each PR with valid URL
Supervisor->>GitHub: Query PR state (number, repo)
GitHub-->>Supervisor: PR state (OPEN/CLOSED, mergeStateStatus, CI status)
alt PR is OPEN & (CLEAN/UNSTABLE) & CI green
Supervisor->>GitHub: Attempt squash merge
GitHub-->>Supervisor: Merge successful/failed
opt Merge successful
Supervisor->>Repo: Pull main & cleanup worktrees
Repo-->>Supervisor: Complete
Supervisor->>DB: Log proof statement, increment merged counter
end
else PR is BEHIND
Supervisor->>GitHub: Update PR branch
GitHub-->>Supervisor: Update complete
else PR is BLOCKED/UNKNOWN
Supervisor->>Supervisor: Log as skipped
end
end
Supervisor->>Supervisor: Report merged/closed stats
end
rect rgba(150, 200, 100, 0.5)
Note over Supervisor,GitHub: Phase 3a Extended: Orphan PR Adoption & Linkage
Supervisor->>GitHub: List PRs with headRefName
GitHub-->>Supervisor: PR list (includes headRefName)
alt Task ID found in PR title or branch
Supervisor->>DB: Find existing task
DB-->>Supervisor: Existing task
Supervisor->>DB: Link PR to task (status=complete)
DB-->>Supervisor: Linked
opt Task in terminal state (verified/deployed/merged)
Supervisor->>Supervisor: Log Phase 3d will handle
end
else No task ID found
Supervisor->>DB: Create synthetic task (id pr<number>)
DB-->>Supervisor: Task created
Supervisor->>Supervisor: Log adoption, increment counter
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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 |
🔍 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: Tue Feb 24 04:44:47 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
There was a problem hiding this comment.
Code Review
This pull request introduces two significant improvements to the supervisor's lifecycle management: a new 'Phase 3d' to merge pull requests for already verified or deployed tasks, and an enhanced orphan PR adoption mechanism. The logic to address these gaps is sound. My review focuses on improving the implementation's robustness and performance by addressing the use of 2>/dev/null where it can hide important errors, while acknowledging specific exceptions for non-blocking SQLite writes, and by suggesting optimizations for repeated jq calls, in line with the repository's general rules.
| verified_with_prs=$(db -separator '|' "$SUPERVISOR_DB" " | ||
| SELECT id, status, pr_url, repo FROM tasks | ||
| WHERE status IN ('verified', 'deployed') | ||
| AND pr_url IS NOT NULL | ||
| AND pr_url != '' | ||
| AND pr_url != 'no_pr' | ||
| AND pr_url != 'task_only' | ||
| AND pr_url != 'verified_complete' | ||
| AND pr_url != 'task_obsolete' | ||
| ORDER BY updated_at DESC | ||
| LIMIT 50; | ||
| " 2>/dev/null || echo "") |
There was a problem hiding this comment.
Suppressing stderr with 2>/dev/null can hide important errors from the db command, such as SQL syntax errors or database connection issues. According to the repository's general rules, error suppression should be avoided to aid debugging. Please remove 2>/dev/null to ensure any potential database errors are visible.
| verified_with_prs=$(db -separator '|' "$SUPERVISOR_DB" " | |
| SELECT id, status, pr_url, repo FROM tasks | |
| WHERE status IN ('verified', 'deployed') | |
| AND pr_url IS NOT NULL | |
| AND pr_url != '' | |
| AND pr_url != 'no_pr' | |
| AND pr_url != 'task_only' | |
| AND pr_url != 'verified_complete' | |
| AND pr_url != 'task_obsolete' | |
| ORDER BY updated_at DESC | |
| LIMIT 50; | |
| " 2>/dev/null || echo "") | |
| verified_with_prs=$(db -separator '|' "$SUPERVISOR_DB" " | |
| SELECT id, status, pr_url, repo FROM tasks | |
| WHERE status IN ('verified', 'deployed') | |
| AND pr_url IS NOT NULL | |
| AND pr_url != '' | |
| AND pr_url != 'no_pr' | |
| AND pr_url != 'task_only' | |
| AND pr_url != 'verified_complete' | |
| AND pr_url != 'task_obsolete' | |
| ORDER BY updated_at DESC | |
| LIMIT 50; | |
| " || echo "") |
References
- Avoid using '2>/dev/null' for blanket suppression of command errors in shell scripts to ensure that authentication, syntax, or system issues remain visible for debugging.
| vt_pr_json=$(gh pr view "$vt_pr_number" --repo "$vt_repo_slug" \ | ||
| --json state,mergeStateStatus,mergeable 2>/dev/null || echo "") |
There was a problem hiding this comment.
Suppressing stderr with 2>/dev/null can hide important errors from the gh command, such as authentication failures, network issues, or if the PR/repo doesn't exist. According to the repository's general rules, error suppression should be avoided to aid debugging. Please remove 2>/dev/null.
| vt_pr_json=$(gh pr view "$vt_pr_number" --repo "$vt_repo_slug" \ | |
| --json state,mergeStateStatus,mergeable 2>/dev/null || echo "") | |
| vt_pr_json=$(gh pr view "$vt_pr_number" --repo "$vt_repo_slug" \ | |
| --json state,mergeStateStatus,mergeable || echo "") |
References
- Avoid using '2>/dev/null' for blanket suppression of command errors in shell scripts to ensure that authentication, syntax, or system issues remain visible for debugging.
| open_prs=$(gh pr list --repo "$repo_slug" --state open --limit 20 \ | ||
| --json number,title,url 2>/dev/null || echo "[]") | ||
| --json number,title,url,headRefName 2>/dev/null || echo "[]") |
There was a problem hiding this comment.
Suppressing stderr with 2>/dev/null can hide important errors from the gh command, such as authentication failures or network issues. According to the repository's general rules, error suppression should be avoided to aid debugging. Please remove 2>/dev/null.
| open_prs=$(gh pr list --repo "$repo_slug" --state open --limit 20 \ | |
| --json number,title,url 2>/dev/null || echo "[]") | |
| --json number,title,url,headRefName 2>/dev/null || echo "[]") | |
| open_prs=$(gh pr list --repo "$repo_slug" --state open --limit 20 \ | |
| --json number,title,url,headRefName || echo "[]") |
References
- Avoid using '2>/dev/null' for blanket suppression of command errors in shell scripts to ensure that authentication, syntax, or system issues remain visible for debugging.
| orphan_existing=$(db "$SUPERVISOR_DB" " | ||
| SELECT id FROM tasks WHERE pr_url = '$(sql_escape "$pr_url")' LIMIT 1; | ||
| " 2>/dev/null || echo "") |
There was a problem hiding this comment.
Suppressing stderr with 2>/dev/null can hide important errors from the db command, such as SQL syntax errors or database connection issues. According to the repository's general rules, error suppression should be avoided to aid debugging. Please remove 2>/dev/null.
| orphan_existing=$(db "$SUPERVISOR_DB" " | |
| SELECT id FROM tasks WHERE pr_url = '$(sql_escape "$pr_url")' LIMIT 1; | |
| " 2>/dev/null || echo "") | |
| orphan_existing=$(db "$SUPERVISOR_DB" " | |
| SELECT id FROM tasks WHERE pr_url = '$(sql_escape "$pr_url")' LIMIT 1; | |
| " || echo "") |
References
- Avoid using '2>/dev/null' for blanket suppression of command errors in shell scripts to ensure that authentication, syntax, or system issues remain visible for debugging.
| already_adopted=$(db "$SUPERVISOR_DB" " | ||
| SELECT id FROM tasks WHERE id = '$(sql_escape "$orphan_id")' LIMIT 1; | ||
| " 2>/dev/null || echo "") |
There was a problem hiding this comment.
Suppressing stderr with 2>/dev/null can hide important errors from the db command, such as SQL syntax errors or database connection issues. According to the repository's general rules, error suppression should be avoided to aid debugging. Please remove 2>/dev/null.
| already_adopted=$(db "$SUPERVISOR_DB" " | |
| SELECT id FROM tasks WHERE id = '$(sql_escape "$orphan_id")' LIMIT 1; | |
| " 2>/dev/null || echo "") | |
| already_adopted=$(db "$SUPERVISOR_DB" " | |
| SELECT id FROM tasks WHERE id = '$(sql_escape "$orphan_id")' LIMIT 1; | |
| " || echo "") |
References
- Avoid using '2>/dev/null' for blanket suppression of command errors in shell scripts to ensure that authentication, syntax, or system issues remain visible for debugging.
| [[ -z "$vt_pr_json" ]] && continue | ||
|
|
||
| local vt_pr_state | ||
| vt_pr_state=$(printf '%s' "$vt_pr_json" | jq -r '.state // "UNKNOWN"' 2>/dev/null || echo "UNKNOWN") |
There was a problem hiding this comment.
Suppressing stderr with 2>/dev/null can hide jq syntax errors or issues with the input JSON. The repository's general rules recommend using || true for optional lookups but keeping stderr visible for debugging. Please remove 2>/dev/null.
| vt_pr_state=$(printf '%s' "$vt_pr_json" | jq -r '.state // "UNKNOWN"' 2>/dev/null || echo "UNKNOWN") | |
| vt_pr_state=$(printf '%s' "$vt_pr_json" | jq -r '.state // "UNKNOWN"' || echo "UNKNOWN") |
References
- In shell scripts with 'set -e' enabled, use '|| true' to prevent the script from exiting when a command like 'jq' fails on an optional lookup. Do not suppress stderr with '2>/dev/null' so that actual syntax or system errors remain visible for debugging.
|
|
||
| if [[ "$vt_pr_state" == "OPEN" ]]; then | ||
| local vt_merge_state | ||
| vt_merge_state=$(printf '%s' "$vt_pr_json" | jq -r '.mergeStateStatus // "UNKNOWN"' 2>/dev/null || echo "UNKNOWN") |
There was a problem hiding this comment.
Suppressing stderr with 2>/dev/null can hide jq syntax errors or issues with the input JSON. The repository's general rules recommend using || true for optional lookups but keeping stderr visible for debugging. Please remove 2>/dev/null.
| vt_merge_state=$(printf '%s' "$vt_pr_json" | jq -r '.mergeStateStatus // "UNKNOWN"' 2>/dev/null || echo "UNKNOWN") | |
| vt_merge_state=$(printf '%s' "$vt_pr_json" | jq -r '.mergeStateStatus // "UNKNOWN"' || echo "UNKNOWN") |
References
- In shell scripts with 'set -e' enabled, use '|| true' to prevent the script from exiting when a command like 'jq' fails on an optional lookup. Do not suppress stderr with '2>/dev/null' so that actual syntax or system errors remain visible for debugging.
| write_proof_log --task "$vt_id" --event "phase3d_merge" --stage "phase_3d" \ | ||
| --decision "merged open PR for verified task" \ | ||
| --evidence "pr=#$vt_pr_number merge_state=$vt_merge_state task_status=$vt_status" \ | ||
| --maker "pulse:phase_3d" 2>/dev/null || true |
There was a problem hiding this comment.
Suppressing stderr with 2>/dev/null can hide important errors from write_proof_log, such as file permission issues or invalid arguments. The repository's general rules advise against this to aid debugging. Please remove 2>/dev/null.
| write_proof_log --task "$vt_id" --event "phase3d_merge" --stage "phase_3d" \ | |
| --decision "merged open PR for verified task" \ | |
| --evidence "pr=#$vt_pr_number merge_state=$vt_merge_state task_status=$vt_status" \ | |
| --maker "pulse:phase_3d" 2>/dev/null || true | |
| write_proof_log --task "$vt_id" --event "phase3d_merge" --stage "phase_3d" \ | |
| --decision "merged open PR for verified task" \ | |
| --evidence "pr=#$vt_pr_number merge_state=$vt_merge_state task_status=$vt_status" \ | |
| --maker "pulse:phase_3d" || true |
References
- Avoid using '2>/dev/null' for blanket suppression of command errors in shell scripts to ensure that authentication, syntax, or system issues remain visible for debugging.
| while [[ "$i" -lt "$pr_count" ]]; do | ||
| local pr_number pr_title pr_url | ||
| local pr_number pr_title pr_url pr_branch | ||
| pr_number=$(printf '%s' "$open_prs" | jq -r ".[$i].number" 2>/dev/null || echo "") | ||
| pr_title=$(printf '%s' "$open_prs" | jq -r ".[$i].title" 2>/dev/null || echo "") | ||
| pr_url=$(printf '%s' "$open_prs" | jq -r ".[$i].url" 2>/dev/null || echo "") | ||
| pr_branch=$(printf '%s' "$open_prs" | jq -r ".[$i].headRefName" 2>/dev/null || echo "") | ||
| i=$((i + 1)) |
There was a problem hiding this comment.
This loop makes multiple jq calls to extract different fields from the same JSON object, which is inefficient. The repository's general rules recommend consolidating multiple jq calls into a single pass. Additionally, suppressing stderr with 2>/dev/null hides potential jq errors.
A more efficient and robust approach would be to refactor the entire loop to let jq handle the iteration:
printf '%s' "$open_prs" | jq -c '.[]' | while IFS= read -r pr_json; do
local pr_number pr_title pr_url pr_branch
pr_number=$(printf '%s' "$pr_json" | jq -r '.number // ""')
pr_title=$(printf '%s' "$pr_json" | jq -r '.title // ""')
pr_url=$(printf '%s' "$pr_json" | jq -r '.url // ""')
pr_branch=$(printf '%s' "$pr_json" | jq -r '.headRefName // ""')
# ... rest of the loop logic ...
doneThis avoids the shell loop counter, repeated parsing of the large $open_prs variable, and allows for more graceful error handling.
References
- Consolidate multiple 'jq' calls into a single pass where possible to improve performance and script efficiency.
- In shell scripts with 'set -e' enabled, use '|| true' to prevent the script from exiting when a command like 'jq' fails on an optional lookup. Do not suppress stderr with '2>/dev/null' so that actual syntax or system errors remain visible for debugging.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.agents/scripts/supervisor/pulse.sh:
- Around line 3945-3950: The current branch skips adopting PRs when
existing_status matches verified|deployed|merged, leaving new PRs untracked;
update the conditional handling in pulse.sh so that when existing_status =~
^(verified|deployed|merged)$ you still detect whether the PR (pr_number) is
already linked to the task (task_id) and, if not, adopt it by invoking a linkage
routine (e.g., link_pr_to_task or create_synthetic_orphan_task) or create a
synthetic orphan task that records pr_number/task_id so Phase 3d can close/merge
it; ensure the new logic logs the adoption and preserves the original
log_verbose message for already-linked PRs.
- Around line 2307-2315: The current merge condition treats mergeStateStatus
"UNSTABLE" as acceptable; change the logic so only "CLEAN" allows merging:
update the check that inspects vt_merge_state (derived from
vt_pr_json/.mergeStateStatus) to permit merging only when vt_merge_state ==
"CLEAN" and treat "UNSTABLE" as a skip (log a skip message and do not call gh pr
merge for vt_pr_number in vt_repo_slug); ensure existing logging and
success/failure handling around gh pr merge remains consistent.
| if [[ "$vt_pr_state" == "OPEN" ]]; then | ||
| local vt_merge_state | ||
| vt_merge_state=$(printf '%s' "$vt_pr_json" | jq -r '.mergeStateStatus // "UNKNOWN"' 2>/dev/null || echo "UNKNOWN") | ||
|
|
||
| if [[ "$vt_merge_state" == "CLEAN" || "$vt_merge_state" == "UNSTABLE" ]]; then | ||
| # CI passed — squash merge the PR | ||
| log_info " Phase 3d: $vt_id ($vt_status) — PR #$vt_pr_number still open with CI green, merging" | ||
| if gh pr merge "$vt_pr_number" --repo "$vt_repo_slug" --squash --delete-branch 2>>"$SUPERVISOR_LOG"; then | ||
| log_success " Phase 3d: Merged PR #$vt_pr_number for $vt_id" |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
GitHub API mergeStateStatus CLEAN UNSTABLE meanings documentation
💡 Result:
In GitHub’s GraphQL API (PullRequest.mergeStateStatus, type MergeStateStatus):
CLEAN: The PR is mergeable and its commit status checks are passing. [1]UNSTABLE: The PR is mergeable, but its commit status checks are not passing (e.g., failing or not successful). [1]
Source: GitHub GraphQL enum docs for MergeStateStatus. [1]
References
- GitHub Docs –
MergeStateStatusenum (CLEAN,UNSTABLEdefinitions). [1]
🏁 Script executed:
# First, check the actual file and lines in question
wc -l .agents/scripts/supervisor/pulse.shRepository: marcusquinn/aidevops
Length of output: 104
🏁 Script executed:
# Read the section around lines 2307-2315
sed -n '2300,2330p' .agents/scripts/supervisor/pulse.shRepository: marcusquinn/aidevops
Length of output: 1722
🏁 Script executed:
# Run ShellCheck on the entire file
shellcheck .agents/scripts/supervisor/pulse.shRepository: marcusquinn/aidevops
Length of output: 46
Restrict merges to CLEAN merge state only; UNSTABLE indicates failing checks.
GitHub's mergeStateStatus=UNSTABLE means commit checks are not passing—contradicting the log message "CI passed." Merging here bypasses CI gating and breaks the automation guarantee. Restrict to CLEAN only and treat UNSTABLE as a skip condition.
Fix: Gate on CLEAN state exclusively
- if [[ "$vt_merge_state" == "CLEAN" || "$vt_merge_state" == "UNSTABLE" ]]; then
+ if [[ "$vt_merge_state" == "CLEAN" ]]; then
# CI passed — squash merge the PR
log_info " Phase 3d: $vt_id ($vt_status) — PR #$vt_pr_number still open with CI green, merging"
if gh pr merge "$vt_pr_number" --repo "$vt_repo_slug" --squash --delete-branch 2>>"$SUPERVISOR_LOG"; then
+ elif [[ "$vt_merge_state" == "UNSTABLE" ]]; then
+ log_verbose " Phase 3d: $vt_id — PR #$vt_pr_number has failing checks, skipping"
elif [[ "$vt_merge_state" == "BEHIND" ]]; then🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.agents/scripts/supervisor/pulse.sh around lines 2307 - 2315, The current
merge condition treats mergeStateStatus "UNSTABLE" as acceptable; change the
logic so only "CLEAN" allows merging: update the check that inspects
vt_merge_state (derived from vt_pr_json/.mergeStateStatus) to permit merging
only when vt_merge_state == "CLEAN" and treat "UNSTABLE" as a skip (log a skip
message and do not call gh pr merge for vt_pr_number in vt_repo_slug); ensure
existing logging and success/failure handling around gh pr merge remains
consistent.
| # For verified/deployed tasks: the PR is a new/different one for | ||
| # an already-completed task. Phase 3d will handle merging/closing | ||
| # open PRs for verified tasks, so just log and skip here. | ||
| if [[ "$existing_status" =~ ^(verified|deployed|merged)$ ]]; then | ||
| log_verbose "Phase 3a: PR #$pr_number for $task_id (status: $existing_status) — Phase 3d will handle" | ||
| fi |
There was a problem hiding this comment.
Terminal tasks with new PRs are left untracked.
When existing_status is verified/deployed/merged, the PR is only logged and skipped. If this is a new PR (e.g., interactive follow‑up), it never gets adopted and Phase 3d won’t act on it. Consider linking the PR for terminal tasks (or creating a synthetic orphan task) so the lifecycle can close it.
🔧 Minimal linkage option (keeps Phase 3d functional)
- if [[ "$existing_status" =~ ^(verified|deployed|merged)$ ]]; then
- log_verbose "Phase 3a: PR #$pr_number for $task_id (status: $existing_status) — Phase 3d will handle"
- fi
+ if [[ "$existing_status" =~ ^(verified|deployed|merged)$ ]]; then
+ # Link the PR so Phase 3d can act on it
+ db "$SUPERVISOR_DB" "
+ UPDATE tasks
+ SET pr_url = '$(sql_escape "$pr_url")',
+ updated_at = strftime('%Y-%m-%dT%H:%M:%SZ', 'now')
+ WHERE id = '$(sql_escape "$task_id")';
+ " 2>/dev/null || true
+ log_verbose "Phase 3a: PR #$pr_number linked to terminal task $task_id (status: $existing_status)"
+ fi📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # For verified/deployed tasks: the PR is a new/different one for | |
| # an already-completed task. Phase 3d will handle merging/closing | |
| # open PRs for verified tasks, so just log and skip here. | |
| if [[ "$existing_status" =~ ^(verified|deployed|merged)$ ]]; then | |
| log_verbose "Phase 3a: PR #$pr_number for $task_id (status: $existing_status) — Phase 3d will handle" | |
| fi | |
| # For verified/deployed tasks: the PR is a new/different one for | |
| # an already-completed task. Phase 3d will handle merging/closing | |
| # open PRs for verified tasks, so just log and skip here. | |
| if [[ "$existing_status" =~ ^(verified|deployed|merged)$ ]]; then | |
| # Link the PR so Phase 3d can act on it | |
| db "$SUPERVISOR_DB" " | |
| UPDATE tasks | |
| SET pr_url = '$(sql_escape "$pr_url")', | |
| updated_at = strftime('%Y-%m-%dT%H:%M:%SZ', 'now') | |
| WHERE id = '$(sql_escape "$task_id")'; | |
| " 2>/dev/null || true | |
| log_verbose "Phase 3a: PR #$pr_number linked to terminal task $task_id (status: $existing_status)" | |
| fi |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.agents/scripts/supervisor/pulse.sh around lines 3945 - 3950, The current
branch skips adopting PRs when existing_status matches verified|deployed|merged,
leaving new PRs untracked; update the conditional handling in pulse.sh so that
when existing_status =~ ^(verified|deployed|merged)$ you still detect whether
the PR (pr_number) is already linked to the task (task_id) and, if not, adopt it
by invoking a linkage routine (e.g., link_pr_to_task or
create_synthetic_orphan_task) or create a synthetic orphan task that records
pr_number/task_id so Phase 3d can close/merge it; ensure the new logic logs the
adoption and preserves the original log_verbose message for already-linked PRs.



Summary
verifiedstatus, its PR could stay open on GitHub indefinitely becauseprocess_ai_lifecycleonly processes active states.adopt_untracked_prsnow handles PRs without task IDs in the title by: (1) trying to extract task IDs from branch names as fallback, (2) creating syntheticprNNNtask entries for truly orphan PRs so the normal Phase 3 lifecycle can process them.Root Causes Fixed
process_ai_lifecycle()only processes tasks in statescomplete, pr_review, review_triage, merging, merged, deploying, blocked— NOTverifiedordeployed. Open PRs for verified tasks were invisible.adopt_untracked_prsdidcontinuewhen notNNN:prefix found in PR title (line 3853). PRs likechore: scrub private repo referenceswere invisible to the supervisor.Changes
pulse.sh: +157/-8 linesadopt_untracked_prswith branch-name task ID extraction and orphan PR adoptionTesting
Summary by CodeRabbit
New Features
Bug Fixes