Proposal: improve ca-continuous-pr-reviewer — run stale PR cleanup on first cycle after startup #3079

Open
opened 2026-04-05 05:24:39 +00:00 by freemo · 2 comments
Owner

Agent Improvement Proposal

Pattern Detected

Type: workflow_fix
Affected Agent: ca-continuous-pr-reviewer
Evidence:

As of 2026-04-05, 11 out of 20 open PRs have mergeable: false (merge conflicts), with many dating back to March 25–31 (5–11 days old):

PR Title Created Mergeable
#1155 feat(ci): implement TDD bug tag quality gate Mar 25
#1160 test: add TDD bug-capture test for #990 Mar 25
#1162 feat(events): wire domain services to emit missing EventBus events Mar 26
#1167 fix(db): add missing link_type, FK constraints Mar 26
#1168 fix(config): resolve database_url relative to CLEVERAGENTS_HOME Mar 27
#1175 feat(plan): implement LLM-powered Strategy Actor Mar 28
#1193 feat(cli): implement RendererRegistry Mar 29
#1202 fix(invariant): persist standalone invariants Mar 29
#1211 fix: add missing validations/unit-tests.yaml Mar 30
#1221 fix(persistence): handle corrupt JSON Mar 31
#1224 fix(audit): protect AuditService._ensure_session() Mar 31

The continuous PR reviewer already has a "Dead PR Cleanup" step that handles stale PRs with merge conflicts (closing them after 6 hours with no rebase). However, this cleanup only runs every 5th cycle (if cycle % 5 == 0). This means:

  1. On cycle 1 (first cycle after startup), cleanup does NOT run
  2. If the reviewer was offline for days (session gap), stale PRs accumulate
  3. The reviewer won't start cleaning them until cycle 5 (~2.5 minutes after startup with 30s sleep)

While 2.5 minutes isn't catastrophic, the real issue is that session gaps cause stale PR accumulation and the reviewer should prioritize cleanup immediately on startup to clear the backlog before starting new reviews.

Proposed Change

Modify the Dead PR Cleanup trigger condition in ca-continuous-pr-reviewer.md from:

if cycle % 5 == 0:

to:

if cycle == 1 or cycle % 5 == 0:

This ensures that on the very first cycle after startup, the reviewer immediately scans for and closes stale PRs before dispatching any new reviews. This is especially important after session gaps where many PRs may have accumulated merge conflicts.

Expected Impact

  • Immediate cleanup of stale PRs on startup: After a session gap, the reviewer will immediately close PRs with merge conflicts >6 hours old, freeing up the review queue for active, mergeable PRs.
  • Reduced reviewer waste: Without this fix, the reviewer may dispatch reviewers for unmergeable PRs in cycles 1–4, wasting review capacity. With the fix, stale PRs are cleaned up first.
  • Faster throughput recovery: After a session restart, the system reaches steady-state faster because the stale PR backlog is cleared immediately.

Risk Assessment

  • Very low risk: This change only affects WHEN cleanup runs (adding cycle 1), not HOW it runs. The cleanup logic itself is unchanged.
  • No false positives: The cleanup criteria (merge conflicts >6h with no rebase, superseded PRs, linked issue closed, CI failing >48h) are already well-defined and conservative.
  • Potential concern: If the reviewer starts and immediately closes many stale PRs, it could generate a burst of Forgejo notifications. This is acceptable because the alternative (leaving stale PRs open) is worse.

This is a proposal from the agent evolver. A human must approve this issue before the change will be implemented. To approve: remove the needs feedback label, add State/Verified, or comment with approval.


Automated by CleverAgents Bot
Supervisor: Agent Evolver | Agent: ca-agent-evolver

## Agent Improvement Proposal ### Pattern Detected **Type**: workflow_fix **Affected Agent**: ca-continuous-pr-reviewer **Evidence**: As of 2026-04-05, **11 out of 20 open PRs have `mergeable: false`** (merge conflicts), with many dating back to March 25–31 (5–11 days old): | PR | Title | Created | Mergeable | |----|-------|---------|-----------| | #1155 | feat(ci): implement TDD bug tag quality gate | Mar 25 | ❌ | | #1160 | test: add TDD bug-capture test for #990 | Mar 25 | ❌ | | #1162 | feat(events): wire domain services to emit missing EventBus events | Mar 26 | ❌ | | #1167 | fix(db): add missing link_type, FK constraints | Mar 26 | ❌ | | #1168 | fix(config): resolve database_url relative to CLEVERAGENTS_HOME | Mar 27 | ❌ | | #1175 | feat(plan): implement LLM-powered Strategy Actor | Mar 28 | ❌ | | #1193 | feat(cli): implement RendererRegistry | Mar 29 | ❌ | | #1202 | fix(invariant): persist standalone invariants | Mar 29 | ❌ | | #1211 | fix: add missing validations/unit-tests.yaml | Mar 30 | ❌ | | #1221 | fix(persistence): handle corrupt JSON | Mar 31 | ❌ | | #1224 | fix(audit): protect AuditService._ensure_session() | Mar 31 | ❌ | The continuous PR reviewer already has a "Dead PR Cleanup" step that handles stale PRs with merge conflicts (closing them after 6 hours with no rebase). However, this cleanup only runs **every 5th cycle** (`if cycle % 5 == 0`). This means: 1. On cycle 1 (first cycle after startup), cleanup does NOT run 2. If the reviewer was offline for days (session gap), stale PRs accumulate 3. The reviewer won't start cleaning them until cycle 5 (~2.5 minutes after startup with 30s sleep) While 2.5 minutes isn't catastrophic, the real issue is that **session gaps cause stale PR accumulation** and the reviewer should prioritize cleanup immediately on startup to clear the backlog before starting new reviews. ### Proposed Change Modify the Dead PR Cleanup trigger condition in `ca-continuous-pr-reviewer.md` from: ``` if cycle % 5 == 0: ``` to: ``` if cycle == 1 or cycle % 5 == 0: ``` This ensures that on the very first cycle after startup, the reviewer immediately scans for and closes stale PRs before dispatching any new reviews. This is especially important after session gaps where many PRs may have accumulated merge conflicts. ### Expected Impact - **Immediate cleanup of stale PRs on startup**: After a session gap, the reviewer will immediately close PRs with merge conflicts >6 hours old, freeing up the review queue for active, mergeable PRs. - **Reduced reviewer waste**: Without this fix, the reviewer may dispatch reviewers for unmergeable PRs in cycles 1–4, wasting review capacity. With the fix, stale PRs are cleaned up first. - **Faster throughput recovery**: After a session restart, the system reaches steady-state faster because the stale PR backlog is cleared immediately. ### Risk Assessment - **Very low risk**: This change only affects WHEN cleanup runs (adding cycle 1), not HOW it runs. The cleanup logic itself is unchanged. - **No false positives**: The cleanup criteria (merge conflicts >6h with no rebase, superseded PRs, linked issue closed, CI failing >48h) are already well-defined and conservative. - **Potential concern**: If the reviewer starts and immediately closes many stale PRs, it could generate a burst of Forgejo notifications. This is acceptable because the alternative (leaving stale PRs open) is worse. --- *This is a proposal from the agent evolver. A human must approve this issue before the change will be implemented. To approve: remove the `needs feedback` label, add `State/Verified`, or comment with approval.* --- **Automated by CleverAgents Bot** Supervisor: Agent Evolver | Agent: ca-agent-evolver
Author
Owner

approved

approved
Author
Owner

Human approval acknowledged. Issue verified and transitioned to State/Verified.

  • State: State/UnverifiedState/Verified
  • Approved by: CTO (human review)
  • Scope: Modify the Dead PR Cleanup trigger in ca-continuous-pr-reviewer to also run on cycle 1 (if cycle == 1 or cycle % 5 == 0), ensuring stale PRs are cleaned up immediately after startup.
  • Next step: This issue is ready for implementation.

Automated by CleverAgents Bot
Supervisor: Human Liaison | Agent: ca-human-liaison

Human approval acknowledged. Issue verified and transitioned to `State/Verified`. - **State**: `State/Unverified` → `State/Verified` - **Approved by**: CTO (human review) - **Scope**: Modify the Dead PR Cleanup trigger in `ca-continuous-pr-reviewer` to also run on cycle 1 (`if cycle == 1 or cycle % 5 == 0`), ensuring stale PRs are cleaned up immediately after startup. - **Next step**: This issue is ready for implementation. --- **Automated by CleverAgents Bot** Supervisor: Human Liaison | Agent: ca-human-liaison
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#3079
No description provided.