UAT: agents plan apply and agents plan status JSON output missing spec-required fields — use generic plan model dict instead of command-specific structure #3815

Open
opened 2026-04-06 06:38:30 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: bugfix/plan-apply-status-json-output-spec
  • Commit Message: fix(cli): build spec-required output dicts for plan apply and plan status commands
  • Milestone: (none — backlog)
  • Parent Epic: #933

Background and Context

Both agents plan apply and agents plan status commands use _plan_spec_dict(plan) for non-rich output formats (JSON, YAML), but the specification requires command-specific output structures with rich contextual data. This means any tooling, scripts, or integrations that parse --format json output from these commands will receive incorrect, incomplete data that does not match the spec.

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

Note: A related issue #3442 covers agents plan apply --format json at Priority/Critical (milestone v3.2.0). This issue additionally covers agents plan status JSON output and tracks both together at Priority/Medium for backlog resolution.

Current Behavior

Bug 1: agents plan apply

Code Location: src/cleveragents/cli/commands/plan.py lines ~2270–2272:

if fmt != OutputFormat.RICH.value:
    data = _plan_spec_dict(plan)  # BUG: should use apply-specific structure
    console.print(format_output(data, fmt))

Actual output uses _plan_spec_dict(plan) which returns flat plan model fields (plan_id, namespaced_name, phase, processing_state, etc.) — missing artifacts, changes, validation, sandbox_cleanup, lifecycle fields. The command field is also absent (no command parameter passed to format_output).

Bug 2: agents plan status

Code Location: src/cleveragents/cli/commands/plan.py lines ~2342–2344 and ~2388:

if fmt != OutputFormat.RICH.value:
    data = [_plan_spec_dict(p) for p in plans]  # BUG: wrong structure
    console.print(format_output(data, fmt))

The agents plan status command also uses _plan_spec_dict for non-rich output. The spec requires a detailed status output with phase timeline, decisions summary, sandbox info, and cost tracking.

Expected Behavior

agents plan apply --format json (from spec §agents plan apply):

{
  "command": "plan apply",
  "status": "ok",
  "exit_code": 0,
  "data": {
    "plan_id": "...",
    "artifacts": 6,
    "changes": {"insertions": 42, "deletions": 9},
    "project": "local/api-service",
    "applied_at": "...",
    "validation": {
      "tests": {"status": "passed", "passed": 24, "total": 24},
      "lint": {"status": "passed", "warnings": 0},
      "type_check": {"status": "passed", "errors": 0},
      "duration_s": 12.4
    },
    "sandbox_cleanup": {
      "worktree": "removed",
      "branch": "merged to main",
      "checkpoint": "archived"
    },
    "lifecycle": {
      "phase": "apply",
      "state": "applied",
      "total_duration": "00:06:14",
      "total_cost": "$0.0847",
      "decisions_made": 8,
      "child_plans": 2
    }
  },
  "timing": {"duration_ms": 374000},
  "messages": ["Changes applied"]
}

agents plan status --format json (from spec §agents plan status):

The spec requires a detailed status output with phase timeline, decisions summary, sandbox info, and cost tracking — not a flat plan model dict.

Root Cause

Both commands use the generic _plan_spec_dict(plan) helper which returns the plan domain model fields. The spec requires command-specific output structures that include operational data (artifacts, validation results, sandbox cleanup, cost tracking) that is not part of the plan model itself.

Acceptance Criteria

  • agents plan apply --format json output matches spec §agents plan apply JSON example exactly
  • agents plan status --format json output matches spec §agents plan status JSON example exactly
  • agents plan apply --format yaml and agents plan status --format yaml also match spec
  • BDD test coverage >= 97% maintained
  • All nox stages pass

Subtasks

  • Create _apply_output_dict(plan) helper with spec-required apply output structure
  • Create _status_output_dict(plan) helper with spec-required status output structure
  • Replace _plan_spec_dict calls in lifecycle_apply_plan with _apply_output_dict
  • Replace _plan_spec_dict calls in plan_status with _status_output_dict
  • Pass command="plan apply" and command="plan status" to format_output
  • Add BDD tests (Behave) verifying JSON output structures match spec for plan apply
  • Add BDD tests (Behave) verifying JSON output structures match spec for plan status
  • Verify YAML formats also match spec
  • Verify nox -e typecheck passes
  • Verify coverage >= 97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • agents plan apply --format json output matches spec §agents plan apply JSON example
  • agents plan status --format json output matches spec §agents plan status JSON example
  • 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: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `bugfix/plan-apply-status-json-output-spec` - **Commit Message**: `fix(cli): build spec-required output dicts for plan apply and plan status commands` - **Milestone**: *(none — backlog)* - **Parent Epic**: #933 ## Background and Context Both `agents plan apply` and `agents plan status` commands use `_plan_spec_dict(plan)` for non-rich output formats (JSON, YAML), but the specification requires command-specific output structures with rich contextual data. This means any tooling, scripts, or integrations that parse `--format json` output from these commands will receive incorrect, incomplete data that does not match the spec. > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.2.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. **Note:** A related issue #3442 covers `agents plan apply --format json` at Priority/Critical (milestone v3.2.0). This issue additionally covers `agents plan status` JSON output and tracks both together at Priority/Medium for backlog resolution. ## Current Behavior ### Bug 1: `agents plan apply` **Code Location:** `src/cleveragents/cli/commands/plan.py` lines ~2270–2272: ```python if fmt != OutputFormat.RICH.value: data = _plan_spec_dict(plan) # BUG: should use apply-specific structure console.print(format_output(data, fmt)) ``` **Actual output** uses `_plan_spec_dict(plan)` which returns flat plan model fields (`plan_id`, `namespaced_name`, `phase`, `processing_state`, etc.) — missing `artifacts`, `changes`, `validation`, `sandbox_cleanup`, `lifecycle` fields. The `command` field is also absent (no command parameter passed to `format_output`). ### Bug 2: `agents plan status` **Code Location:** `src/cleveragents/cli/commands/plan.py` lines ~2342–2344 and ~2388: ```python if fmt != OutputFormat.RICH.value: data = [_plan_spec_dict(p) for p in plans] # BUG: wrong structure console.print(format_output(data, fmt)) ``` The `agents plan status` command also uses `_plan_spec_dict` for non-rich output. The spec requires a detailed status output with phase timeline, decisions summary, sandbox info, and cost tracking. ## Expected Behavior ### `agents plan apply --format json` (from spec §agents plan apply): ```json { "command": "plan apply", "status": "ok", "exit_code": 0, "data": { "plan_id": "...", "artifacts": 6, "changes": {"insertions": 42, "deletions": 9}, "project": "local/api-service", "applied_at": "...", "validation": { "tests": {"status": "passed", "passed": 24, "total": 24}, "lint": {"status": "passed", "warnings": 0}, "type_check": {"status": "passed", "errors": 0}, "duration_s": 12.4 }, "sandbox_cleanup": { "worktree": "removed", "branch": "merged to main", "checkpoint": "archived" }, "lifecycle": { "phase": "apply", "state": "applied", "total_duration": "00:06:14", "total_cost": "$0.0847", "decisions_made": 8, "child_plans": 2 } }, "timing": {"duration_ms": 374000}, "messages": ["Changes applied"] } ``` ### `agents plan status --format json` (from spec §agents plan status): The spec requires a detailed status output with phase timeline, decisions summary, sandbox info, and cost tracking — not a flat plan model dict. ## Root Cause Both commands use the generic `_plan_spec_dict(plan)` helper which returns the plan domain model fields. The spec requires command-specific output structures that include operational data (artifacts, validation results, sandbox cleanup, cost tracking) that is not part of the plan model itself. ## Acceptance Criteria - `agents plan apply --format json` output matches spec §agents plan apply JSON example exactly - `agents plan status --format json` output matches spec §agents plan status JSON example exactly - `agents plan apply --format yaml` and `agents plan status --format yaml` also match spec - BDD test coverage >= 97% maintained - All nox stages pass ## Subtasks - [ ] Create `_apply_output_dict(plan)` helper with spec-required apply output structure - [ ] Create `_status_output_dict(plan)` helper with spec-required status output structure - [ ] Replace `_plan_spec_dict` calls in `lifecycle_apply_plan` with `_apply_output_dict` - [ ] Replace `_plan_spec_dict` calls in `plan_status` with `_status_output_dict` - [ ] Pass `command="plan apply"` and `command="plan status"` to `format_output` - [ ] Add BDD tests (Behave) verifying JSON output structures match spec for `plan apply` - [ ] Add BDD tests (Behave) verifying JSON output structures match spec for `plan status` - [ ] Verify YAML formats also match spec - [ ] Verify `nox -e typecheck` passes - [ ] Verify coverage >= 97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - `agents plan apply --format json` output matches spec §agents plan apply JSON example - `agents plan status --format json` output matches spec §agents plan status JSON example - 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: UAT Testing | 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.

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