[compound-engineering] Bug: ce-work native fallback units never clean up their worktree and transport ref
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 reachedcleaned, withworkspace_removed: trueandref_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 viaclaim-fallback→ native commit →complete-fallback. The manifest recordsstate: native-completed,integration.canonical_commit: nullandcleanup: null. - Both of those unit workspaces are still in
git worktree listas detached HEADs once-work transport <run>/<unit>commits. Bothrefs/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-fallbackperforms the cleanup itself, orreferences/cross-model-execution.md§ "Resume and fallback exactly once" tells the host to callunit-workspace.py cleanupafterFALLBACK_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
- Run
ce-workwith a cross-model route on a plan with more than one unit. - Have one unit's transport fail controller integration (for example, authoritative verification rejects it), so the controller restores exactly and releases the lock.
- Claim the fallback, implement the unit natively, commit, and call
complete-fallback. - Finish the run (
verify-run→RUN_VERIFIED). - Run
git worktree list --porcelainandgit for-each-ref refs/ce-work/: the fallback unit's workspace and transport ref are still there, and its manifest entry hascleanup: null.
Error Messages
None. The run reports success.
Additional Context
- Code: in 3.36.0,
cmd_complete_fallbacksetsunit["state"] = "native-completed", records events and returns, with no workspace or ref removal.cmd_cleanuphandlesnative-completedbut is only reached from theintegratepath. - Workaround:
git worktree remove <workspace>, thengit update-ref -d refs/ce-work/<run>/<attempt>, thengit worktree prune. Or callunit-workspace.py cleanupfor the unit by hand.
Reported via /ce-report-bug skill