fix(build): idempotent resume for worktree/branch/PR (state-resume contract) #9
Reference in New Issue
Block a user
Delete Branch "fix/build-idempotency-recovery"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
ensure_worktreebranch-exists fallback (src/damascus/git_ops.py): whenfeat/<story_id>already exists on the remote, fall back togit worktree add <path> <branch>(no-b) instead of failing ongit worktree add -b <existing-branch>.open_pull_requestGET-then-POST (src/damascus/git_ops.py): checkGET /pulls?head=<branch>&state=allbefore POSTing; return existing PR URL if found, else POST as before.tests/contract/test_contracts_match_source.py): guard the no--bshape and the GET-then-POST shape against regressions.Why
State-resume-protocol.md "Idempotency contract" requires three pre-write checks in
build():worktree_path.exists()short-circuit)git worktree add -b <existing>after partial state)POST /pulls)The 3-txn split in PR #8 makes these gaps more likely to surface — a row in
buildwithclaimed_atwithin the stale-claim window is now more recoverable, sobuild()will hit partial-state recovery more often.Test
git worktree add -b <existing-branch> mainfails;git worktree add <path> <existing-branch>succeeds.