fix: fix: triage agent must clean up throwaway debug branch on exit/crash (#341)
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.
This commit is contained in:
parent
064366678b
commit
c29d49cd5c
1 changed files with 12 additions and 2 deletions
|
|
@ -140,7 +140,6 @@ log "Issue: ${ISSUE_TITLE}"
|
|||
# ---------------------------------------------------------------------------
|
||||
log "Acquiring stack lock for project ${PROJECT_NAME}..."
|
||||
stack_lock_acquire "$LOCK_HOLDER" "$PROJECT_NAME" 900
|
||||
trap 'stack_lock_release "$PROJECT_NAME" "$LOCK_HOLDER"; log "Stack lock released (trap)"' EXIT
|
||||
log "Stack lock acquired."
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
@ -154,7 +153,18 @@ heartbeat_loop() {
|
|||
}
|
||||
heartbeat_loop &
|
||||
HEARTBEAT_PID=$!
|
||||
trap 'kill "$HEARTBEAT_PID" 2>/dev/null; stack_lock_release "$PROJECT_NAME" "$LOCK_HOLDER"; log "Stack lock released (trap)"' EXIT
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Debug branch cleanup trap (for triage-agent throwaway branches)
|
||||
# ---------------------------------------------------------------------------
|
||||
DEBUG_BRANCH="triage-debug-${ISSUE_NUMBER}"
|
||||
|
||||
# Combined EXIT trap: heartbeat kill + stack lock release + debug branch cleanup
|
||||
trap 'kill "$HEARTBEAT_PID" 2>/dev/null || true
|
||||
stack_lock_release "$PROJECT_NAME" "$LOCK_HOLDER" || true
|
||||
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
|
||||
log "Cleanup completed (trap)"' EXIT
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Boot the project stack if formula declares stack_script
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue