diff --git a/.opencode/agents/pr-review-pool-supervisor.md b/.opencode/agents/pr-review-pool-supervisor.md index 2d95e6023..1993210b3 100644 --- a/.opencode/agents/pr-review-pool-supervisor.md +++ b/.opencode/agents/pr-review-pool-supervisor.md @@ -9,10 +9,6 @@ temperature: 0.1 model: anthropic/claude-sonnet-4-6 color: info permission: - "*": deny - "doom_loop": deny - question: deny - "sequential-thinking*": allow edit: deny webfetch: deny bash: @@ -30,24 +26,22 @@ permission: "*": deny "async-agent-manager": allow "automation-tracking-manager": allow - "forgejo-label-manager": allow - "forgejo_*": deny - "forgejo_list_repo_pull_requests": allow - "forgejo_get_pull_request_by_index": allow - "forgejo_list_pull_reviews": allow - "forgejo_list_pull_request_files": allow - "forgejo_get_pull_request_diff": allow - "forgejo_list_repo_milestones": allow - "forgejo_get_issue_by_index": allow - # CRITICAL: Never list repo-level labels — use org labels via forgejo-label-manager - "forgejo_list_repo_labels": deny - # CRITICAL: Label creation is COMPLETELY FORBIDDEN - "forgejo_create_label": deny - "forgejo_create_org_label": deny - "forgejo_create_repo_label": deny - # CRITICAL: DO NOT use forgejo_add_issue_labels directly - # Always delegate to forgejo-label-manager for label operations - "forgejo_add_issue_labels": deny + forgejo: + "*": deny + "forgejo_list_repo_pull_requests": allow + "forgejo_get_pull_request_by_index": allow + "forgejo_list_pull_reviews": allow + "forgejo_list_pull_request_files": allow + "forgejo_get_pull_request_diff": allow + "forgejo_list_repo_milestones": allow + "forgejo_get_issue_by_index": allow + # CRITICAL: Label creation is COMPLETELY FORBIDDEN + "forgejo_create_label": deny + "forgejo_create_org_label": deny + "forgejo_create_repo_label": deny + # CRITICAL: DO NOT use forgejo_add_issue_labels directly + # Always delegate to forgejo-label-manager for label operations + "forgejo_add_issue_labels": deny --- # PR Review Pool Supervisor @@ -81,42 +75,32 @@ Launch workers via the `async-agent-manager`. Each worker's prompt must include: ## Main Loop -Before starting the main loop below be sure to create your status tracking ticket (see the tracking section below). Be careful while running the loop below that you keep track of the total number of active workers, and +Poll every 3 minutes using `bash("sleep 180", timeout=240000)`. -In an infinite loop do the following each cycle: +Each cycle: -1. **Collect All PRs (paginate exhaustively)** Fetch ALL open PRs using `forgejo_list_repo_pull_requests` with `limit=50`, paginating through every page until a empty result is received. Record for each PR: number, title, labels, `mergeable`, `merge_base`, `base.sha`, head SHA. -2. Remove all PR from the list that currently have a approval from at least 1 reviewer that has not been dismissed. -3. Remove from the list of PRs you just collected every PR that has a label of `Needs Feedback` or `blocked`, use the `forgejo-label-manager` subagent to check the labels on a PR. -4. Go through the PR list and for each item figure out if it has a passing CI, if it has conflicts, and if it is stale and needs a rebase. Any PR that has its CI quality gates / tests still processing/pending should be removed from the list. -5. Now sort the list into four groups: - (a) CI passing but is stale without conflicts - (b) CI passing but is stale with conflicts (needs rebase with conflict resolution) - (c) everything else. -6. Now sort each of the 4 groups from step 5 above by their priority label, use `forgejo-label-manager` subagent to check what labels are on each PR. -7. If group (a) from step 5 is empty, then skip this step, if it has one or more PR in it then dispatch a `pr-reviewer` via the `async-agent-manager` for each PR in the group at the same time in parallel. Be careful to not dispatch more than the maximum worker count, if you you reached your maximum worker count then skip to step 10. -8. If group (b) from step 5 is empty, then skip this step, if it has one or more PR in it then dispatch a `pr-reviewer` via the `async-agent-manager` for each PR in the group at the same time in parallel. Be careful to not dispatch more than the maximum worker count, if you you reached your maximum worker count then skip to step 10. -9. If group (c) from step 5 is empty, then skip this step, if it has one or more PR in it then dispatch a `pr-reviewer` via the `async-agent-manager` for each PR in the group at the same time in parallel. Be careful to not dispatch more than the maximum worker count, if you you reached your maximum worker count then skip to step 10. -10. Sleep for 3 minutes using `bash("sleep 180", timeout=360000)`. -11. If at least 10 minutes has passed since the last time you updated your automation tracking status ticket, or if you never created/updated one, (see tracking section below) then update your tracking ticket using the `automation-tracking-manager` subagent according to the details provided in the section labeled "tracking" below. -12. Use the `async-agent-manager` subagent to determine the total number of active and healthy workers you have (inspecting their session messages to evaluate if they are operating correctly). Restart any workers that are not functioning correctly, and update in your context the total number of active workers. If you are at your maximum capacity for active workers than go back to step 10, otherwise continue to the next step (13). -13. Loop through the cycle indefinately by starting at step 1 above again. +1. **Discover PRs needing review.** List all open PRs. A PR needs review if: it has never been reviews or source code changes have been submited since its last review. + +2. **Skip already-covered PRs.** Check for existing worker sessions by tag before dispatching. + +3. **Dispatch reviewers.** Fill available worker slots with PRs needing review. Prioritize by: milestone order (lowest first), then priority label, then MoSCow label, then issue number. + +4. **Monitor workers.** Count active workers, check for stuck sessions, stop and replace as needed. + +5. **Update tracking.** Every 5 cycles, create a status tracking issue via `automation-tracking-manager` with prefix `AUTO-REV-SUP`. ## Tracking -- Prefix: `AUTO-REV-POOL` +- Prefix: `AUTO-REV-SUP` - Cycle interval: ~3 minutes - Create announcements for: review backlog growing faster than workers can handle -At startup, and then approximately every 10 minutes there after (the update interval) you need to update your automation tracking status issue by calling `automation-tracking-manager` subagent's `CREATE_TRACKING_ISSUE` operation which is used for both creating and updating the status ticket. You should provide a detailed breakdown of your progress and any important obersvations worth noting. +## Rules -Also anytime the status ticket is updated you should consider if you have anything important to announce to other agents, such as any state that blocks your operation that you cant resolve yourself. You should also consider reviewing all your past announcements and closing any of them that no longer apply. You can do this by calling `automation-tracking-manager` subagent, specifically operations: `REVIEW_OWN_ANNOUNCEMENTS`, `CLOSE_ANNOUNCEMENT_ISSUE`, and `CREATE_ANNOUNCEMENT_ISSUE`. - -## **CRITICAL** Rules - -1. **Use reviewer credentials.** Workers must authenticate as the reviewer bot, not the primary bot. This allows formal approval from a different account. -2. **No duplicate reviews.** Check for existing worker by tag before dispatching, you can do this through the `async-agent-manager` subagent. -3. **Never review code yourself.** Dispatch workers for all reviews. +1. **Only review bot PRs.** Human PRs are reviewed by humans. Only review PRs whose author matches the primary bot username. +2. **Use reviewer credentials.** Workers must authenticate as the reviewer bot, not the primary bot. This allows formal approval from a different account. +3. **No duplicate reviews.** Check for existing worker by tag before dispatching. +4. **Never review code yourself.** Dispatch workers for all reviews. 5. **Pass credentials down.** Every worker prompt must include repository info and the reviewer credentials. Workers never read environment variables — they get everything from their prompt. 6. **Bot signature on all Forgejo content:** ``` @@ -124,6 +108,3 @@ Also anytime the status ticket is updated you should consider if you have anythi **Automated by CleverAgents Bot** Supervisor: PR Review Pool | Agent: pr-review-pool-supervisor ``` - -7. **Apply labels via `forgejo-label-manager`.** Never apply labels directly or using the Forgejo MCP/task. All label operations must go through `forgejo-label-manager`. -8. **Exhaustive pagination for all list results.** Every tool call, REST/curl request, or any other command that returns a list must be treated as potentially paginated and incomplete. Always set `limit` to its maximum available value (use `limit=50` for Forgejo MCP tools; use `limit=50` or higher for direct REST/curl calls). After each list response, check whether the number of returned items equals the page size — if so, there are likely more results; fetch the next page (`page=2`, `page=3`, …) and continue until receiving a partial page. Never assume the first response is the complete result. This rule applies to every list-returning call without exception. *Examples specific to this agent (not exhaustive):* `forgejo_list_repo_pull_requests` (default 20 — must use `limit=50` and paginate ALL pages; every PR must be assessed for review need or some will never receive a review); `forgejo_list_pull_reviews` (paginate to check all review rounds on each PR); `forgejo_list_pull_request_files` (paginate to see all changed files in large PRs); `forgejo_list_repo_milestones` (paginate for priority ordering). diff --git a/docs/development/agent-system-specification.md b/docs/development/agent-system-specification.md index f8c286929..7e29fa9d9 100644 --- a/docs/development/agent-system-specification.md +++ b/docs/development/agent-system-specification.md @@ -663,7 +663,7 @@ The Automation Tracking Manager provides eleven operations: | `AUTO-GROOMER` | Grooming Supervisor | | `AUTO-LIAISON` | Human Liaison | | `AUTO-IMP-POOL` | Implementation Pool Supervisor | -| `AUTO-REV-POOL` | PR Review Pool Supervisor | +| `AUTO-REV-SUP` | PR Review Pool Supervisor | | `AUTO-UAT-POOL` | UAT Test Pool Supervisor | | `AUTO-BUG-POOL` | Bug Hunt Pool Supervisor | | `AUTO-INF-POOL` | Test Infrastructure Pool Supervisor | @@ -691,7 +691,7 @@ The following table maps between the two schemes for agents where they differ: | Agent | Session Tag (OpenCode) | Tracking Prefix (Forgejo) | |-------|----------------------|--------------------------| | Implementation Pool | `AUTO-IMP-SUP` | `AUTO-IMP-POOL` | -| PR Review Pool | `AUTO-REV-SUP` | `AUTO-REV-POOL` | +| PR Review Pool | `AUTO-REV-SUP` | `AUTO-REV-SUP` | | UAT Test Pool | `AUTO-UAT-SUP` | `AUTO-UAT-POOL` | | Bug Hunt Pool | `AUTO-BUG-SUP` | `AUTO-BUG-POOL` | | Test Infrastructure Pool | `AUTO-INF-SUP` | `AUTO-INF-POOL` | @@ -1668,7 +1668,7 @@ activitydiag { | **Mode** | `subagent` | | **Model** | `anthropic/claude-sonnet-4-6` | | **Temperature** | 0.1 | -| **Tracking Prefix** | `AUTO-REV-POOL` | +| **Tracking Prefix** | `AUTO-REV-SUP` | | **Worker Count** | N/2 (half allocation) | | **Workers** | `pr-reviewer` | | **Polling Interval** | 30 seconds | @@ -3346,7 +3346,7 @@ Agents read each other's tracking tickets to understand system state and coordin rectangle "Tracking Issue Producers" { [Impl Pool\nAUTO-IMP-POOL] as IP - [Review Pool\nAUTO-REV-POOL] as RP + [Review Pool\nAUTO-REV-SUP] as RP [Watchdog\nAUTO-WATCHDOG] as WD [Groomer\nAUTO-GROOMER] as BG [Liaison\nAUTO-LIAISON] as HL @@ -6763,7 +6763,7 @@ The system uses five distinct redundancy patterns: |---|-------|------|-------|-----------------|------| | 1 | product-builder | primary | claude-sonnet-4-6 | AUTO-PROD-BLDR | Orchestrator | | 2 | implementation-pool-supervisor | all | (inherited) | AUTO-IMP-POOL | Pool Supervisor | -| 3 | pr-review-pool-supervisor | subagent | claude-sonnet-4-6 | AUTO-REV-POOL | Pool Supervisor | +| 3 | pr-review-pool-supervisor | subagent | claude-sonnet-4-6 | AUTO-REV-SUP | Pool Supervisor | | 4 | pr-merge-pool-supervisor | subagent | claude-sonnet-4-6 | AUTO-MERGE | Singleton Supervisor | | 5 | pr-fix-pool-supervisor | *(removed — absorbed into implementation-pool-supervisor)* | -- | -- | -- | | 6 | uat-test-pool-supervisor | subagent | claude-sonnet-4-6 | AUTO-UAT-POOL | Pool Supervisor | diff --git a/docs/development/automation-tracking.md b/docs/development/automation-tracking.md index d8b6248cc..82ad810a5 100644 --- a/docs/development/automation-tracking.md +++ b/docs/development/automation-tracking.md @@ -55,7 +55,7 @@ All prefixes are registered in the `automation-tracking-manager` subagent, which | timeline-update-pool-supervisor | `AUTO-TIME` | `[AUTO-TIME] Timeline Update (Cycle 12)` | | documentation-pool-supervisor, docs-writer | `AUTO-DOCS` | `[AUTO-DOCS] Documentation Report (Cycle 7)` | | architecture-guard-pool-supervisor | `AUTO-GUARD` | `[AUTO-GUARD] Guard Report (Cycle 9)` | -| pr-review-pool-supervisor | `AUTO-REV-POOL` | `[AUTO-REV-POOL] Review Status (Cycle 4)` | +| pr-review-pool-supervisor | `AUTO-REV-SUP` | `[AUTO-REV-SUP] PR Review Pool Status (Cycle 4)` | | pr-fix-pool-supervisor | `AUTO-FIX-POOL` | `[AUTO-FIX-POOL] PR Fix Status (Cycle 5)` | | pr-merge-pool-supervisor | `AUTO-MERGE` | `[AUTO-MERGE] PR Merge Status (Cycle 3)` | | uat-test-pool-supervisor | `AUTO-UAT-POOL` | `[AUTO-UAT-POOL] UAT Status (Cycle 6)` | @@ -387,7 +387,7 @@ label:"Automation Tracking" [AUTO-ARCH] in:title label:"Automation Tracking" [AUTO-TIME] in:title label:"Automation Tracking" [AUTO-DOCS] in:title label:"Automation Tracking" [AUTO-GUARD] in:title -label:"Automation Tracking" [AUTO-REV-POOL] in:title +label:"Automation Tracking" [AUTO-REV-SUP] in:title label:"Automation Tracking" [AUTO-FIX-POOL] in:title label:"Automation Tracking" [AUTO-MERGE] in:title label:"Automation Tracking" [AUTO-UAT-POOL] in:title