bug(plan): apply phase does not write changeset files to project — metadata transition only #4222

Closed
opened 2026-04-07 14:48:57 +00:00 by hamza.khyari · 2 comments
Member

Metadata

  • Commit Message: fix(plan): apply phase writes changeset files from sandbox to project directory
  • Branch: bugfix/m5-acms-cli-indexing-pipeline-wiring

Background

The specification states that the Apply phase materializes the changeset to the project's filesystem. However, the current implementation only transitions plan state from execute/complete to apply/applied without writing any files.

Root Cause

lifecycle_apply_plan() in cli/commands/plan.py calls service.apply_plan()service.start_apply()service.complete_apply(). All three methods are pure state transitions in plan_lifecycle_service.py. The comment in the CLI code says:

"Apply phase is a metadata transition (no LLM call)."

The execute phase writes LLM output to .cleveragents/sandbox/ (when sandbox_root is set), but the apply phase never copies those files to the project directory. Additionally, _get_plan_executor() was not passing sandbox_root, so even the execute phase wasn't writing files.

Two Gaps

  1. sandbox_root not passed to PlanExecutor_get_plan_executor() constructs PlanExecutor without sandbox_root, so _write_to_sandbox() is never called during execute and LLM file output is discarded
  2. Apply doesn't write fileslifecycle_apply_plan() transitions state but never copies files from sandbox to project directory

Fix (in PR #4219)

  1. _get_plan_executor() now passes sandbox_root=.cleveragents/sandbox/
  2. lifecycle_apply_plan() now walks .cleveragents/sandbox/, copies files to project directory, and reports "Applied N file(s) from sandbox to project"

Acceptance Criteria

  • _get_plan_executor() passes sandbox_root to PlanExecutor
  • LLM file output (FILE: blocks) written to .cleveragents/sandbox/ during execute
  • agents plan apply copies files from sandbox to project directory
  • Apply reports number of files applied
  • End-to-end: plan execute + apply produces real file changes in the project

Definition of Done

This issue is complete when:

  • All acceptance criteria are met.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
## Metadata - **Commit Message**: `fix(plan): apply phase writes changeset files from sandbox to project directory` - **Branch**: `bugfix/m5-acms-cli-indexing-pipeline-wiring` ## Background The specification states that the Apply phase materializes the changeset to the project's filesystem. However, the current implementation only transitions plan state from `execute/complete` to `apply/applied` without writing any files. ## Root Cause `lifecycle_apply_plan()` in `cli/commands/plan.py` calls `service.apply_plan()` → `service.start_apply()` → `service.complete_apply()`. All three methods are pure state transitions in `plan_lifecycle_service.py`. The comment in the CLI code says: > "Apply phase is a metadata transition (no LLM call)." The execute phase writes LLM output to `.cleveragents/sandbox/` (when `sandbox_root` is set), but the apply phase never copies those files to the project directory. Additionally, `_get_plan_executor()` was not passing `sandbox_root`, so even the execute phase wasn't writing files. ## Two Gaps 1. **`sandbox_root` not passed to PlanExecutor** — `_get_plan_executor()` constructs `PlanExecutor` without `sandbox_root`, so `_write_to_sandbox()` is never called during execute and LLM file output is discarded 2. **Apply doesn't write files** — `lifecycle_apply_plan()` transitions state but never copies files from sandbox to project directory ## Fix (in PR #4219) 1. `_get_plan_executor()` now passes `sandbox_root=.cleveragents/sandbox/` 2. `lifecycle_apply_plan()` now walks `.cleveragents/sandbox/`, copies files to project directory, and reports "Applied N file(s) from sandbox to project" ## Acceptance Criteria - [ ] `_get_plan_executor()` passes `sandbox_root` to PlanExecutor - [ ] LLM file output (FILE: blocks) written to `.cleveragents/sandbox/` during execute - [ ] `agents plan apply` copies files from sandbox to project directory - [ ] Apply reports number of files applied - [ ] End-to-end: plan execute + apply produces real file changes in the project ## Definition of Done This issue is complete when: - All acceptance criteria are met. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done.
Owner

Issue reviewed and triaged.

This issue is well-formed: it has clear root cause analysis (two specific gaps identified), expected behavior, acceptance criteria, complete metadata (commit message + branch), and a Definition of Done. A fix PR (#4219) is referenced.

  • Priority: High — the Apply phase is a core lifecycle operation; without it, plan execution produces no file changes in the project directory.
  • Story Points: 3 (M) — two distinct gaps to fix (sandbox_root wiring + file copy in apply).
  • State: This issue is missing State/* labels. Adding State/Verified since the issue is well-formed and the fix is already in PR #4219.
  • Next step: Verify PR #4219 status and ensure it is progressing.

Transitioning to State/Verified.


Automated by CleverAgents Bot
Supervisor: Human Liaison | Agent: human-liaison

Issue reviewed and triaged. This issue is well-formed: it has clear root cause analysis (two specific gaps identified), expected behavior, acceptance criteria, complete metadata (commit message + branch), and a Definition of Done. A fix PR (#4219) is referenced. - **Priority**: High — the Apply phase is a core lifecycle operation; without it, plan execution produces no file changes in the project directory. - **Story Points**: 3 (M) — two distinct gaps to fix (sandbox_root wiring + file copy in apply). - **State**: This issue is missing `State/*` labels. Adding `State/Verified` since the issue is well-formed and the fix is already in PR #4219. - **Next step**: Verify PR #4219 status and ensure it is progressing. Transitioning to `State/Verified`. --- **Automated by CleverAgents Bot** Supervisor: Human Liaison | Agent: human-liaison
HAL9000 self-assigned this 2026-04-08 12:11:00 +00:00
HAL9000 added this to the v3.2.0 milestone 2026-04-08 12:11:00 +00:00
Owner

State label reconciliation:

  • Previous state: State/Verified
  • Corrected to: State/Completed
  • Reason: Issue is closed but had incorrect/missing terminal state label. Work was completed via merged PR #4219.

Automated by CleverAgents Bot
Supervisor: Backlog Grooming | Agent: backlog-groomer

State label reconciliation: - Previous state: State/Verified - Corrected to: State/Completed - Reason: Issue is closed but had incorrect/missing terminal state label. Work was completed via merged PR #4219. --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: backlog-groomer
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#4222
No description provided.