feat: non-destructive lock recovery for pushed branches (Closes #440)
Adds structured issue-branch ownership parsing, wires it into lock adoption and gitea_lock_issue validation, documents the restart recovery workflow, and adds regression tests for adoption, durable create_pr resolution, and open-PR blocking without remote branch deletion. Built on keyed persistent lock store and own-branch adoption (#443 / #442). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
@@ -293,6 +293,28 @@ adoption rebinds the session when the issue's exact branch already exists (#442)
|
||||
`gitea_create_pr` resolves the durable keyed lock by session pointer or by
|
||||
matching `head` branch without unsafe manual seeding.
|
||||
|
||||
### Non-destructive lock recovery after push (#440)
|
||||
|
||||
When work is pushed but the in-memory MCP session lock is lost (server restart,
|
||||
crashed process, or stale session pointer):
|
||||
|
||||
1. **Do not delete the remote branch.** Branch deletion is not a normal recovery
|
||||
step and can destroy the only copy of unmerged work.
|
||||
2. **Re-run `gitea_lock_issue`** with the same `issue_number`, exact
|
||||
`branch_name`, and active `branches/` worktree. Own-branch adoption
|
||||
reacquires the lease when the remote branch is the caller's exact branch and
|
||||
no open PR or competing same-issue branch exists.
|
||||
3. **Call `gitea_create_pr`** with the same `head` branch. The server resolves
|
||||
the durable keyed lock file even when the session pointer was cleared at
|
||||
restart.
|
||||
4. **Stop fail-closed** when another actor owns a competing branch, an open PR
|
||||
already exists, or a live foreign lease blocks takeover — never adopt their
|
||||
branch.
|
||||
|
||||
Branch ownership uses structured evidence
|
||||
`(fix|feat|docs|chore)/issue-<n>-<desc>` — not broad substring matches on
|
||||
`issue-<n>`.
|
||||
|
||||
Remote branches matching the issue number are also treated as active work unless
|
||||
the recovery review proves the branch is abandoned or superseded. Never delete
|
||||
or clean up a branch when it has an active lease, dirty worktree, open PR, or is
|
||||
|
||||
Reference in New Issue
Block a user