BUG-HUNT: [spec-alignment] Hardcoded 'git_worktree' Strategy in _execute_output_dict #3739

Open
opened 2026-04-05 22:23:03 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/plan-execute-sandbox-strategy-hardcode
  • Commit Message: fix(cli): derive sandbox strategy from plan config in _execute_output_dict
  • Milestone: None
  • Parent Epic: TBD (see orphan note below)

Backlog note: This issue was discovered during autonomous operation
on milestone v3.6.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.

Background and Context

The _execute_output_dict function in src/cleveragents/cli/commands/plan.py (lines 303–471) builds the output dictionary for the plan execute command. Within this function, the sandbox dictionary is constructed with a hardcoded "strategy": "git_worktree" value in both the if plan.sandbox_refs: and else: branches.

The inline TODO comment acknowledges this is a known shortcut:

# TODO: derive strategy from plan's actual sandbox configuration
# once the plan model exposes it; "git_worktree" is the current
# default strategy used in all local execution environments.
"strategy": "git_worktree",

This is a spec-alignment issue: the specification requires that output dictionaries faithfully reflect the plan's actual runtime configuration. Hardcoding the strategy means any plan using a non-default sandbox strategy (e.g., a container-based or remote sandbox) will produce incorrect output.

Current Behavior

_execute_output_dict always emits "strategy": "git_worktree" in the sandbox section of its output, regardless of the plan's actual sandbox configuration.

Affected code (src/cleveragents/cli/commands/plan.py, lines ~303–471):

if plan.sandbox_refs:
    primary_ref = plan.sandbox_refs[0]
    sandbox = {
        # TODO: derive strategy from plan's actual sandbox configuration
        "strategy": "git_worktree",   # ← hardcoded
        "path": primary_ref,
        "branch": f"cleveragents/plan-{plan_id[:8]}",
        "status": "active",
    }
else:
    sandbox = {
        # TODO: derive strategy from plan's actual sandbox configuration
        "strategy": "git_worktree",   # ← hardcoded
        "path": None,
        "branch": f"cleveragents/plan-{plan_id[:8]}",
        "status": "pending",
    }

Expected Behavior

The sandbox["strategy"] value should be derived from the plan's actual sandbox configuration (e.g., plan.sandbox_strategy, plan.config.sandbox.strategy, or equivalent once the plan model exposes it). If the plan model does not yet expose this field, the model must be extended to do so before this function can be corrected.

Subtasks

  • Audit the plan model (Plan / PlanModel) to determine whether a sandbox strategy field already exists or needs to be added
  • Expose sandbox strategy on the plan model if not already present (add field + schema update)
  • Update _execute_output_dict to read "strategy" from the plan's sandbox configuration instead of hardcoding "git_worktree"
  • Remove both hardcoded "git_worktree" occurrences from the if/else branches
  • Tests (Behave): Add scenarios for _execute_output_dict with a non-default sandbox strategy to prevent regression
  • Verify coverage >=97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

  • All subtasks above are completed and checked off
  • _execute_output_dict no longer hardcodes "git_worktree" as the sandbox strategy
  • The sandbox strategy in the output dictionary correctly reflects the plan's actual configuration
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation
  • 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
  • All nox stages pass
  • Coverage >= 97%

Automated by CleverAgents Bot
Supervisor: Bug Hunting | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/plan-execute-sandbox-strategy-hardcode` - **Commit Message**: `fix(cli): derive sandbox strategy from plan config in _execute_output_dict` - **Milestone**: None - **Parent Epic**: TBD (see orphan note below) > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.6.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. ## Background and Context The `_execute_output_dict` function in `src/cleveragents/cli/commands/plan.py` (lines 303–471) builds the output dictionary for the `plan execute` command. Within this function, the `sandbox` dictionary is constructed with a hardcoded `"strategy": "git_worktree"` value in both the `if plan.sandbox_refs:` and `else:` branches. The inline TODO comment acknowledges this is a known shortcut: ```python # TODO: derive strategy from plan's actual sandbox configuration # once the plan model exposes it; "git_worktree" is the current # default strategy used in all local execution environments. "strategy": "git_worktree", ``` This is a spec-alignment issue: the specification requires that output dictionaries faithfully reflect the plan's actual runtime configuration. Hardcoding the strategy means any plan using a non-default sandbox strategy (e.g., a container-based or remote sandbox) will produce incorrect output. ## Current Behavior `_execute_output_dict` always emits `"strategy": "git_worktree"` in the sandbox section of its output, regardless of the plan's actual sandbox configuration. **Affected code** (`src/cleveragents/cli/commands/plan.py`, lines ~303–471): ```python if plan.sandbox_refs: primary_ref = plan.sandbox_refs[0] sandbox = { # TODO: derive strategy from plan's actual sandbox configuration "strategy": "git_worktree", # ← hardcoded "path": primary_ref, "branch": f"cleveragents/plan-{plan_id[:8]}", "status": "active", } else: sandbox = { # TODO: derive strategy from plan's actual sandbox configuration "strategy": "git_worktree", # ← hardcoded "path": None, "branch": f"cleveragents/plan-{plan_id[:8]}", "status": "pending", } ``` ## Expected Behavior The `sandbox["strategy"]` value should be derived from the plan's actual sandbox configuration (e.g., `plan.sandbox_strategy`, `plan.config.sandbox.strategy`, or equivalent once the plan model exposes it). If the plan model does not yet expose this field, the model must be extended to do so before this function can be corrected. ## Subtasks - [ ] Audit the plan model (`Plan` / `PlanModel`) to determine whether a sandbox strategy field already exists or needs to be added - [ ] Expose sandbox strategy on the plan model if not already present (add field + schema update) - [ ] Update `_execute_output_dict` to read `"strategy"` from the plan's sandbox configuration instead of hardcoding `"git_worktree"` - [ ] Remove both hardcoded `"git_worktree"` occurrences from the if/else branches - [ ] Tests (Behave): Add scenarios for `_execute_output_dict` with a non-default sandbox strategy to prevent regression - [ ] Verify coverage >=97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done - [ ] All subtasks above are completed and checked off - [ ] `_execute_output_dict` no longer hardcodes `"git_worktree"` as the sandbox strategy - [ ] The sandbox strategy in the output dictionary correctly reflects the plan's actual configuration - [ ] A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation - [ ] 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 - All nox stages pass - Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: Bug Hunting | Agent: ca-new-issue-creator
Author
Owner

⚠️ Orphan Issue — Manual Linking Required

This issue was created without a known parent Epic. Per project conventions, all issues (except Epics and Legendaries) must be linked to a parent Epic via Forgejo's dependency system (child blocks parent).

A human reviewer should:

  1. Identify the appropriate parent Epic for this CLI plan-execute sandbox fix (candidates: #368 Subplans & Parallelism, #397 Server & Autonomy Infrastructure, or a future CLI-focused Epic)
  2. Create the dependency link so that this issue blocks the parent Epic:
    curl -s -X POST "https://git.cleverthis.com/api/v1/repos/cleveragents/cleveragents-core/issues/3739/blocks" \
      -H "Authorization: token <PAT>" \
      -H "Content-Type: application/json" \
      -d '{"owner": "cleveragents", "repo": "cleveragents-core", "index": <PARENT_EPIC_NUMBER>}'
    

Automated by CleverAgents Bot
Supervisor: Bug Hunting | Agent: ca-new-issue-creator

⚠️ **Orphan Issue — Manual Linking Required** This issue was created without a known parent Epic. Per project conventions, all issues (except Epics and Legendaries) must be linked to a parent Epic via Forgejo's dependency system (child **blocks** parent). A human reviewer should: 1. Identify the appropriate parent Epic for this CLI plan-execute sandbox fix (candidates: #368 Subplans & Parallelism, #397 Server & Autonomy Infrastructure, or a future CLI-focused Epic) 2. Create the dependency link so that this issue **blocks** the parent Epic: ```bash curl -s -X POST "https://git.cleverthis.com/api/v1/repos/cleveragents/cleveragents-core/issues/3739/blocks" \ -H "Authorization: token <PAT>" \ -H "Content-Type: application/json" \ -d '{"owner": "cleveragents", "repo": "cleveragents-core", "index": <PARENT_EPIC_NUMBER>}' ``` --- **Automated by CleverAgents Bot** Supervisor: Bug Hunting | Agent: ca-new-issue-creator
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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#3739
No description provided.