Dataface Tasks

Improve merge flow guidance for worktree-bound local branches

IDM1-INFRA-019
Statuscompleted
Priorityp2
Milestonem1-ft-analytics-analyst-pilot
Ownerhead-of-engineering

Problem

When gh pr merge --delete-branch runs after a successful PR merge, git emits a warning that it cannot delete the local branch because it is checked out in a cbox worktree. The manager agent interprets this warning as a merge failure and initiates unnecessary recovery actions — even though the remote merge succeeded and the branch was deleted on GitHub. This false-negative pattern has caused repeated confusion during sandbox PR merges, wasting manager cycles on a benign, expected git behavior unique to worktree-based workflows.

Context

Possible Solutions

Plan

Implementation Progress

  • Detect and clarify benign local-delete failures for worktree-checked-out branches.
  • Ensure merge-success path distinguishes remote merge success from local cleanup warnings.
  • Add docs/tests for expected behavior.

  • Operators no longer misinterpret this warning as merge failure.

  • Merge automation can continue safely when remote merge succeeded.
  • cbox docs mention this behavior where relevant.

  • Source issue: repeated confusion during manager merges of sandbox PRs.

Implementation notes

  • _remove_worktree() in libs/cbox/cbox/cli.py now detects "checked out at" in git branch -d stderr and prints a dim informational note instead of a yellow warning.
  • Merge verification guidance uses gh pr view ... --json state --jq '.state' directly in docs.
  • 3 new tests in libs/cbox/test_cleanup.py cover _remove_worktree message handling.
  • Docs updated in docs/agent/cbox.md (new "Merge Flow" section) and libs/cbox/skills/master-plan-cbox-manager/SKILL.md (new "PR Merge" section).

Review Feedback

  • [ ] Review cleared