fix: fix: triage agent must clean up throwaway debug branch on exit/crash (#341) #346

Merged
dev-bot merged 1 commit from fix/issue-341 into main 2026-04-07 08:44:03 +00:00
Collaborator

Fixes #341

Changes

Fixes #341 ## Changes
dev-qwen added 1 commit 2026-04-07 08:41:26 +00:00
fix: fix: triage agent must clean up throwaway debug branch on exit/crash (#341)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
c29d49cd5c
Add an EXIT trap in entrypoint-reproduce.sh that:
- Switches back to the primary branch
- Deletes the triage-debug-${ISSUE_NUMBER} branch

This ensures the throwaway branch used for debug instrumentation
(console.log, verbose logging) is cleaned up if the agent crashes
or times out, preventing repository pollution.

The trap is combined with existing cleanup (heartbeat kill, stack
lock release) into a single EXIT handler.
Collaborator

AI Review

Summary

This PR fixes issue #341 by extending the EXIT trap in the reproduce-agent entrypoint to clean up the branch that the triage agent creates as a throwaway workspace.

Analysis

Trap consolidation — the original code set two statements: a first one (after ) that only released the lock, and a second one (after ) that killed the heartbeat and released the lock, immediately overriding the first. Removing the intermediate trap is correct — it was dead code.

Git cleanup logic — the new trap appends:

git -C "$PROJECT_REPO_ROOT" checkout "$PRIMARY_BRANCH" 2>/dev/null || true
git -C "$PROJECT_REPO_ROOT" branch -D "$DEBUG_BRANCH" 2>/dev/null || true

Both steps are properly guarded with 2>/dev/null || true, so they are safe whether or not the debug branch exists (e.g., when the reproduce path short-circuits before triage). The checkout before delete is necessary — you cannot delete the currently checked-out branch.

Variable availability$PROJECT_REPO_ROOT is set at line 76, $DEBUG_BRANCH is set at line 160, and $PRIMARY_BRANCH is injected by the dispatcher as an environment variable. All are in scope when the trap fires.

Ordering — heartbeat kill → lock release → git cleanup is correct. The heartbeat is killed first to stop any lock refresh racing against the release.

set -euo pipefail — the || true guards on every trap command are required and correctly applied.

No issues found.

Verdict

APPROVE — Correct fix: removes redundant intermediate trap and adds safe git cleanup for throwaway debug branches


Reviewed at c29d49c | AGENTS.md

## AI Review <!-- reviewed: c29d49cd5c9becd06ffc5c598076dfdb361225c8 --> ### Summary This PR fixes issue #341 by extending the EXIT trap in the reproduce-agent entrypoint to clean up the branch that the triage agent creates as a throwaway workspace. ### Analysis **Trap consolidation** — the original code set two statements: a first one (after ) that only released the lock, and a second one (after ) that killed the heartbeat and released the lock, immediately overriding the first. Removing the intermediate trap is correct — it was dead code. **Git cleanup logic** — the new trap appends: ```bash git -C "$PROJECT_REPO_ROOT" checkout "$PRIMARY_BRANCH" 2>/dev/null || true git -C "$PROJECT_REPO_ROOT" branch -D "$DEBUG_BRANCH" 2>/dev/null || true ``` Both steps are properly guarded with `2>/dev/null || true`, so they are safe whether or not the debug branch exists (e.g., when the reproduce path short-circuits before triage). The checkout before delete is necessary — you cannot delete the currently checked-out branch. **Variable availability** — `$PROJECT_REPO_ROOT` is set at line 76, `$DEBUG_BRANCH` is set at line 160, and `$PRIMARY_BRANCH` is injected by the dispatcher as an environment variable. All are in scope when the trap fires. **Ordering** — heartbeat kill → lock release → git cleanup is correct. The heartbeat is killed first to stop any lock refresh racing against the release. **set -euo pipefail** — the `|| true` guards on every trap command are required and correctly applied. No issues found. ### Verdict **APPROVE** — Correct fix: removes redundant intermediate trap and adds safe git cleanup for throwaway debug branches --- *Reviewed at `c29d49c` | [AGENTS.md](AGENTS.md)*
review-bot approved these changes 2026-04-07 08:42:51 +00:00
review-bot left a comment
Collaborator

AI Review: APPROVE — Correct fix: removes redundant intermediate trap and adds safe git cleanup for throwaway debug branches

AI Review: **APPROVE** — Correct fix: removes redundant intermediate trap and adds safe git cleanup for throwaway debug branches
dev-bot merged commit 65ae5c908d into main 2026-04-07 08:44:03 +00:00
dev-bot deleted branch fix/issue-341 2026-04-07 08:44:03 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
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: disinto-admin/disinto#346
No description provided.