compound-engineering-plugin icon indicating copy to clipboard operation
compound-engineering-plugin copied to clipboard

[compound-engineering] Bug: ce-work native fallback units never clean up their worktree and transport ref

Open davefano opened this issue 3 weeks ago • 0 comments

Bug Description

Component: Skill - ce-work (cross-model execution controller, unit-workspace.py) Summary: A unit that goes through the native fallback path ends in state native-completed with cleanup: null. Its unit workspace stays a registered git worktree, detached on the synthetic transport commit, and its refs/ce-work/... transport ref stays too. Nothing in the documented flow calls cleanup for these units.

Environment

  • Plugin Version: observed on 3.35.0; the same code path is still present in 3.36.0
  • Agent Platform: Claude Code
  • Agent Version: 2.1.319
  • OS: Darwin 25.5.0 arm64

What Happened

Two cross-model runs on one branch, seven units in total:

  • Five units went through integrate. Each one was committed and then reached cleaned, with workspace_removed: true and ref_removed: true.
  • In each run, one unit failed controller integration. The tracked-state restore succeeded (restore.exact: true), and the unit was then finished natively via claim-fallback → native commit → complete-fallback. The manifest records state: native-completed, integration.canonical_commit: null and cleanup: null.
  • Both of those unit workspaces are still in git worktree list as detached HEADs on ce-work transport <run>/<unit> commits. Both refs/ce-work/<run>/<attempt> transport refs still exist.

The leftover worktrees show up in worktree-aware tools (Orca, IDE git panels) long after the run is done. To the user they look like abandoned work that might still matter.

Expected Behavior

Once complete-fallback returns FALLBACK_COMPLETED, the unit's workspace and transport ref should be cleaned up the same way the integrate path does it. Either:

  • complete-fallback performs the cleanup itself, or
  • references/cross-model-execution.md § "Resume and fallback exactly once" tells the host to call unit-workspace.py cleanup after FALLBACK_COMPLETED.

cmd_cleanup in unit_workspace_lifecycle.py already accepts native-completed units (it keeps that state when finalizing). The missing piece is the call.

Steps to Reproduce

  1. Run ce-work with a cross-model route on a plan with more than one unit.
  2. Have one unit's transport fail controller integration (for example, authoritative verification rejects it), so the controller restores exactly and releases the lock.
  3. Claim the fallback, implement the unit natively, commit, and call complete-fallback.
  4. Finish the run (verify-run → RUN_VERIFIED).
  5. Run git worktree list --porcelain and git for-each-ref refs/ce-work/: the fallback unit's workspace and transport ref are still there, and its manifest entry has cleanup: null.

Error Messages

None. The run reports success.

Additional Context

  • Code: in 3.36.0, cmd_complete_fallback sets unit["state"] = "native-completed", records events and returns, with no workspace or ref removal. cmd_cleanup handles native-completed but is only reached from the integrate path.
  • Workaround: git worktree remove <workspace>, then git update-ref -d refs/ce-work/<run>/<attempt>, then git worktree prune. Or call unit-workspace.py cleanup for the unit by hand.

Reported via /ce-report-bug skill

davefano avatar Nov 09 '26 00:11 davefano