Files
cleveragents-core/features/git_worktree_apply.feature
hamza.khyari 06428a5db6
CI / push-validation (pull_request) Successful in 16s
CI / helm (pull_request) Successful in 23s
CI / build (pull_request) Successful in 24s
CI / lint (pull_request) Successful in 48s
CI / typecheck (pull_request) Successful in 53s
CI / security (pull_request) Successful in 53s
CI / quality (pull_request) Successful in 51s
CI / e2e_tests (pull_request) Successful in 3m27s
CI / integration_tests (pull_request) Successful in 7m14s
CI / unit_tests (pull_request) Successful in 8m34s
CI / docker (pull_request) Successful in 1m20s
CI / coverage (pull_request) Successful in 14m36s
CI / status-check (pull_request) Successful in 1s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Successful in 57m55s
feat(plan): implement git worktree sandbox for execute and merge-based apply
Replace flat shutil.copy2 apply with spec-aligned git worktree flow
(specification.md §13225-13276):

Execute phase: creates an isolated git worktree via GitWorktreeSandbox
for the plan's linked git-checkout resource.  LLM file output is
written to the worktree and committed on branch
cleveragents/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:
  - Apply Summary: Plan ID, artifacts count, insertions/deletions,
    project name, applied-at timestamp
  - Sandbox Cleanup: worktree removed, branch merged to main
  - Footer: ✓ OK Changes applied

Non-git projects (fs-directory resources) fall back to the original
flat directory sandbox with shutil.copy2.

Also fixes:
- context_tier_hydrator metadata types (int/float → string) that
  caused Pydantic validation errors during context assembly
- A2A facade duplicate execute dispatch (idempotent handler)
- Logs actual error from context assembly failures

ISSUES CLOSED: #4454
2026-04-09 14:17:50 +00:00

43 lines
2.1 KiB
Gherkin

@git-worktree-apply
Feature: Git worktree sandbox apply lifecycle (#4454)
Verifies that the apply phase merges LLM output from a git worktree
branch back into the project's main branch.
Scenario: Create worktree sandbox for git-checkout resource for wt_apply
Given a temp git project with 1 file for wt_apply
When I create a sandbox for the project for wt_apply
Then the sandbox path should be a directory for wt_apply
And the sandbox path should differ from the project path for wt_apply
Scenario: Worktree branch exists after sandbox creation for wt_apply
Given a temp git project with 1 file for wt_apply
When I create a sandbox for the project for wt_apply
Then the branch "cleveragents/plan-01TEST00000000000000000099" should exist for wt_apply
Scenario: Files written to sandbox appear on worktree branch for wt_apply
Given a temp git project with 1 file for wt_apply
And I create a sandbox for the project for wt_apply
When I write "fixed.py" to the sandbox for wt_apply
And I commit the sandbox for wt_apply
Then "fixed.py" should exist on branch "cleveragents/plan-01TEST00000000000000000099" for wt_apply
Scenario: Merge applies changes to main branch for wt_apply
Given a temp git project with 1 file for wt_apply
And I create a sandbox for the project for wt_apply
And I write "fixed.py" to the sandbox for wt_apply
And I commit the sandbox for wt_apply
When I merge the sandbox branch into main for wt_apply
Then "fixed.py" should exist in the project root for wt_apply
Scenario: Cleanup removes worktree and branch for wt_apply
Given a temp git project with 1 file for wt_apply
And I create a sandbox for the project for wt_apply
When I cleanup the sandbox for wt_apply
Then the sandbox path should not exist for wt_apply
And the branch "cleveragents/plan-01TEST00000000000000000099" should not exist for wt_apply
Scenario: Fallback to flat copy for non-git directory for wt_apply
Given a temp non-git directory with 1 file for wt_apply
When I copy files from sandbox to project for wt_apply
Then the project should have the copied file for wt_apply