feat(plan): implement git worktree sandbox for execute and merge-based apply #5998
No reviewers
Labels
No labels
auto/needs-reevaluation
controller-managed
auto/blocked-by-deps
auto/ci-timeout
auto/claimed-implementer
auto/claimed-merge
auto/claimed-reviewer
auto/driver-down
auto/invariant-violation
auto/last-attempt-tier-0
auto/last-attempt-tier-1
auto/last-attempt-tier-2
auto/last-attempt-tier-min
Automation Tracking
auto/needs-conflict-resolution
auto/needs-implementer
auto/postmortem
auto/ready-to-merge
auto/restart-throttled
auto/revert
auto/sentinel
auto/stale-inactivity
auto/unstable
Blocked
Bounty
$100
Bounty
$1000
Bounty
$10000
Bounty
$20
Bounty
$2000
Bounty
$250
Bounty
$50
Bounty
$500
Bounty
$5000
Bounty
$750
MoSCoW
Could have
MoSCoW
Must have
MoSCoW
Should have
Needs Feedback
Points
1
Points
13
Points
2
Points
21
Points
3
Points
34
Points
5
Points
55
Points
8
Points
88
Priority
Backlog
Priority
CI Blocker
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
State
Completed
State
Duplicate
State
In Progress
State
In Review
State
Paused
State
Unverified
State
Verified
State
Wont Do
Type
Automation
Type
Bug
Type
Discussion
Type
Documentation
Type
Epic
Type
Feature
Type
Legendary
Type
Refactor
Type
Support
Type
Task
Type
Testing
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
cleveragents/cleveragents-core!5998
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/git-worktree-apply"
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?
Summary
Implement spec-aligned git worktree sandbox for the plan execute/apply lifecycle (specification.md §13225-13276).
Execute phase: creates an isolated git worktree via
GitWorktreeSandboxfor the plan's linked git-checkout resource. LLM file output is written to the worktree and committed on branchcleveragents/plan-<plan_id>— no merge yet.Apply phase: merges the worktree branch into the project's current branch via
git merge. Prints spec-aligned panels:Non-git projects fall back to the original flat directory sandbox with
shutil.copy2.Also fixes
ContextFragmentmetadata values (detail_depth,relevance_score) must be strings, not int/float. Pydantic validation errors crashed the context assembler, leaving the LLM with zero file context._handle_plan_executenow checks if the plan has already reached execute/apply phase before attempting a transition, eliminating the noisy "Invalid phase transition from execute to execute" error.execute_context_assembly_failedwarning now includes the actual error string.Changed files
src/cleveragents/cli/commands/plan.py— sandbox creation, worktree apply, spec panels, facade notify reordersrc/cleveragents/a2a/facade.py— idempotent_handle_plan_executesrc/cleveragents/application/services/context_tier_hydrator.py— metadata type fixsrc/cleveragents/application/services/llm_actors.py— error string in assembly warningfeatures/git_worktree_apply.feature+ step file — 6 Behave scenariosCHANGELOG.md— updatedTesting
m1-plan-lifecycle-okCloses #4454
Closes #2265
Thank you for this contribution, @hamza.khyari. I have reviewed PR #5998 and the linked issue #4454.
Summary of Changes
This PR wires
sandbox_rootintoPlanExecutorvia_get_plan_executor()so that the execute phase writes LLM-generated file output to.cleveragents/sandbox/. Without this wiring,PlanExecutorreceivedsandbox_root=None, causing LLM code changes to be discarded after execute completed.Assessment
The change is targeted and addresses a clear gap: the sandbox wiring was missing, preventing the execute phase from persisting LLM output. The M1 E2E test confirmation (
Applied 2 file(s) from sandbox to project.) demonstrates the fix works end-to-end.Observations
Needs Feedbacklabel. Per project policy, issues withNeeds Feedbackare proposals awaiting human review. The PR closes this issue, which suggests the feedback has been addressed. Please confirm whether theNeeds Feedbacklabel on #4454 can be removed.Next Steps
This PR will be reviewed by the implementation team once CI checks complete. I will monitor the CI status and provide updates.
Automated by CleverAgents Bot
Supervisor: Human Liaison | Agent: human-liaison
9a20c91928185bebe323Thank you for this contribution, @hamza.khyari. I am reviewing PR #5998.
Summary: This PR wires
sandbox_rootintoPlanExecutorvia_get_plan_executor()so that the execute phase writes LLM-generated file output to.cleveragents/sandbox/. This addresses a critical gap wherePlanExecutorreceivedsandbox_root=None, causing LLM code changes to be discarded after execute completed.Linked Issue: #4454 — Note that issue #4454 has a "Needs Feedback" label, indicating it is a proposal awaiting human review. The PR can proceed through CI and review, but the linked issue's "Needs Feedback" label should be addressed by a human reviewer before the issue is considered fully verified.
Current CI Status:
linttypecheckqualitysecurityintegration_testse2e_testsbuildhelmunit_testscoverageThe
unit_testsjob is failing. I will fetch the CI logs to determine the root cause and follow up.Automated by CleverAgents Bot
Supervisor: Human Liaison | Agent: human-liaison
185bebe323751261213d751261213d06428a5db6HAL9000 referenced this pull request2026-04-09 18:14:00 +00:00
_cleveragents/plan/executeidempotency check misses terminal plan states — raises instead of acknowledging #6625HAL9000 referenced this pull request2026-04-10 04:31:47 +00:00
HAL9000 referenced this pull request2026-04-10 06:11:31 +00:00
HAL9000 referenced this pull request2026-04-10 18:10:04 +00:00
HAL9000 referenced this pull request2026-04-10 19:16:54 +00:00