Skip to content

fix: make wrap_up PR action work reliably#3

Draft
Ragazoor wants to merge 9 commits into
mainfrom
382-wrapup-pr
Draft

fix: make wrap_up PR action work reliably#3
Ragazoor wants to merge 9 commits into
mainfrom
382-wrapup-pr

Conversation

@Ragazoor
Copy link
Copy Markdown
Owner

Summary

  • create_pr is now idempotent: if gh pr create fails with "already exists", extracts and returns the existing PR URL instead of erroring
  • create_pr now pushes from the worktree directory (not repo root) so the pre-push hook runs in the clean worktree context, avoiding spurious dirty-file failures
  • Fixed incorrect wrap_up tool description: was "task moves to done / runs in background"; now correctly says task moves to Review and the call blocks
  • Removed incorrect claim in wrap-up skill that a /code-review command is injected after PR creation

Root cause

When an agent called wrap_up pr, it saw task status change to Review (not Done as the tool description claimed) and assumed the call failed, then retried. The retry hit gh pr create's "already exists" error, which was treated as a hard failure — so the agent kept looping.

Test plan

  • cargo test dispatch::tests::create_pr — unit tests for idempotent create_pr and push-dir behaviour
  • cargo test mcp::handlers::tests::wrap_up — includes new wrap_up_pr_returns_existing_url_on_duplicate test

Ragazoor and others added 9 commits April 27, 2026 23:01
…ce (WP3)

Migration v40 creates the `learnings` table with scope/scope_ref consistency
CHECK constraint. LearningStore is a narrow sub-trait added to TaskStore.
LearningService mirrors TaskService with status-transition guards and
scope-consistency validation. Tests cover migration, CRUD, dispatch retrieval
ordering, and all service validation paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Root cause: the wrap_up tool description said "moved to done on success" and
"returns immediately in the background", both incorrect for the pr action.
Agents seeing the task in Review (not Done) after a successful PR creation
would retry, causing gh pr create to fail with "already exists".

- create_pr: detect "already exists" stderr from gh, extract the URL,
  and return success — makes wrap_up pr safe to call multiple times
- Correct the wrap_up tool description: blocks until done; pr action moves
  task to Review (not Done); mentions idempotency
- Remove incorrect "code-review command will be injected" claim from skill
- Rename wrap_up_pr_returns_started → wrap_up_pr_succeeds_with_complete_message
- Fix stale // detect_default_branch comments in wrap_up tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ailure

The pre-push hook runs `cargo clippy --fix` which refuses to run when
there are uncommitted changes. When `create_pr` ran `git push` from
`repo_path`, the hook saw dirty files belonging to other worktrees and
failed. Fix: use the worktree path (push_dir) for both git push and
remote get-url, so the hook runs in the worktree's clean context.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant