Repository navigation
Description
Salvage agent work before destroying the worktree, and diagnose push rejections
Context
When an implementation or follow-up run finishes, ProPR commits, pushes and opens/updates the PR, then deletes the worktree (WORKTREE_RETENTION_STRATEGY, default always_delete, in packages/core/src/git/worktreeOperations.ts; containers run with docker run --rm). If the push fails — a GitHub ruleset or secret-scanning push protection rejects it, the installation token expired, a non-fast-forward because someone pushed to the branch, a network error — the work the agent produced is lost with the worktree, and the task fails with a generic message. There is PR publication checkpointing (src/jobs/prPublicationRecovery.ts, migrations add_pr_publication_checkpoint / _completion) and the reconciler marks orphaned tasks failed (src/taskStateReconciler.ts), but nothing preserves the commits themselves when the push is the failing step.
Requirements
- Salvage ladder when the final push fails (apply to implementation runs, PR follow-ups,
/fix, ultrafix cycles and merge-conflict jobs — every path that pushes from a worktree insrc/jobs/):- Retry the push once after refreshing the git credential (installation tokens are short-lived; see
packages/core/src/agents/agentGitAccess.tsand the existing token refresh used byfix: refresh GitHub credentials for issue publication). - If it still fails, push the same commits to a rescue ref
refs/propr/rescue/<taskId>on the same remote (this succeeds on non-fast-forward failures because the ref is new; it does not help with push-protection rejections). - If that fails, write a git bundle (
git bundle create) of the branch to durable local storage under the ProPR data directory (e.g.<data>/rescue/<repo>/<taskId>.bundle), with retention/cleanup consistent with how failed-task worktree retention is handled. - If all of the above fail, keep the worktree (override
always_deletefor this task) and write.retention-info.jsonas the failed-task retention path already does.
Record which rung succeeded in a task timeline event, and include the exact recovery instruction in the task's failure summary and GitHub comment (the rescue ref name, the bundle path, or the retained worktree path).
- Retry the push once after refreshing the git credential (installation tokens are short-lived; see
- Push-rejection diagnosis. Parse git's push error output and classify it into at least:
push_protection(GitHub secret scanning — include the unblock URL GitHub prints),ruleset_or_branch_protection(rule violations),non_fast_forward,auth(401/403/expired token),network,unknown. Store the classification on the task (afailure_reasondetail is fine if a dedicated column is not justified), show it in the task detail UI, inpropr task get, and in the GitHub failure comment so a reviewer can act without reading logs. Forpush_protection, the comment must include the unblock URL verbatim. - Rescue ref hygiene. Provide a maintenance path to delete rescue refs older than N days (default 14) — a daemon maintenance job or a
proprmaintenance command, whichever matches existing maintenance patterns indocs/docs/operations/maintenance.md. Rescue refs must never be picked up as task branches by the daemon or by branch-naming logic. - Do not change the success path's timing or the worktree lock semantics ("follow-up cleanup finishes before the worktree lock is released").
Documentation
docs/docs/operations/maintenance.mdanddocs/docs/operations/troubleshooting.md: describe the salvage ladder, the rescue ref, the bundle location and how to recover each.docs/docs/architecture/git-management.md: one section on the salvage flow.docs/docs/operations/configuration-reference.mdfor any new env/settings (rescue retention days, bundle directory).- CHANGELOG.md Unreleased entry.
Tests
- Unit tests for the push-error classifier with real-world sample outputs for each class (secret scanning push protection text with its unblock URL, ruleset violation text,
! [rejected] ... (non-fast-forward), 401/403 text, connection reset). - Tests for the salvage ladder using a fake git/remote: step 1 succeeds → no rescue; step 2 succeeds → rescue ref recorded; step 3 succeeds → bundle path recorded; all fail → worktree retained and
.retention-info.jsonwritten. - A test that rescue refs are ignored by the daemon's branch discovery.
- Run
npm run lint,npm run typecheckand the affected suites; keep existing tests passing.
Submitted by @integry through ProPR.
Activity
propr-dev commentedon Oct 5, 2026
🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.
I'll analyze the problem and work on a solution. This may take a few minutes.
Processing Details:
claudeclaude-opus-5-52736/claude-opus-5-5-salvage-agent-work-before-20261005-2330-aitmainissue-2736-20261005-2330-claude-opus-5-5-ait🔍 Track Task Execution
I've implemented #2736. When the final push from a worktree fails, Pr…