UAT: agents plan apply --format json does not produce spec-required JSON envelope #4970

Open
opened 2026-04-08 23:41:23 +00:00 by freemo · 1 comment
Owner

Bug Report

Feature Area: Plan Lifecycle — agents plan apply
Severity: High
Discovered by: UAT tester (uat-worker-plan-lifecycle)

What Was Tested

The JSON output format of agents plan apply <PLAN_ID> --format json.

Expected Behavior (from spec §agents plan apply)

The spec requires a structured JSON envelope with apply result details:

{
  "command": "plan apply",
  "status": "ok",
  "exit_code": 0,
  "data": {
    "plan_id": "01HXM8C2ZK4Q7C2B3F2R4VYV6J",
    "artifacts": 6,
    "changes": {
      "insertions": 42,
      "deletions": 9
    },
    "project": "local/api-service",
    "applied_at": "2026-02-08T13:04:00Z",
    "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": { "started": "2026-02-09T14:30:00Z", "duration_ms": 1250 },
  "messages": ["Changes applied"]
}

Actual Behavior (from code analysis)

The lifecycle_apply_plan command at src/cleveragents/cli/commands/plan.py line 2270-2272 outputs _plan_spec_dict(plan) when fmt != "rich":

data = _plan_spec_dict(plan)
console.print(format_output(data, fmt))

_plan_spec_dict() returns the internal plan representation and is missing all spec-required apply-specific fields:

  • data.artifacts (count of artifacts produced)
  • data.changes (insertions/deletions)
  • data.applied_at (timestamp)
  • data.validation (test/lint/typecheck results)
  • data.sandbox_cleanup (worktree/branch/checkpoint status)
  • data.lifecycle (total_duration, total_cost, decisions_made, child_plans)
  • command, status, exit_code, timing, messages envelope (missing)

Code Location

  • src/cleveragents/cli/commands/plan.py, lines 2270-2272 (lifecycle_apply_plan function)

Steps to Reproduce

agents plan apply <PLAN_ID> --yes --format json

Impact

Any tooling or scripts that parse agents plan apply --format json output will fail. The validation and lifecycle fields are particularly important for CI/CD pipelines that need to verify apply success.


Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: uat-tester

## Bug Report **Feature Area**: Plan Lifecycle — `agents plan apply` **Severity**: High **Discovered by**: UAT tester (uat-worker-plan-lifecycle) ### What Was Tested The JSON output format of `agents plan apply <PLAN_ID> --format json`. ### Expected Behavior (from spec §agents plan apply) The spec requires a structured JSON envelope with apply result details: ```json { "command": "plan apply", "status": "ok", "exit_code": 0, "data": { "plan_id": "01HXM8C2ZK4Q7C2B3F2R4VYV6J", "artifacts": 6, "changes": { "insertions": 42, "deletions": 9 }, "project": "local/api-service", "applied_at": "2026-02-08T13:04:00Z", "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": { "started": "2026-02-09T14:30:00Z", "duration_ms": 1250 }, "messages": ["Changes applied"] } ``` ### Actual Behavior (from code analysis) The `lifecycle_apply_plan` command at `src/cleveragents/cli/commands/plan.py` line 2270-2272 outputs `_plan_spec_dict(plan)` when `fmt != "rich"`: ```python data = _plan_spec_dict(plan) console.print(format_output(data, fmt)) ``` `_plan_spec_dict()` returns the internal plan representation and is missing all spec-required apply-specific fields: - `data.artifacts` (count of artifacts produced) - `data.changes` (insertions/deletions) - `data.applied_at` (timestamp) - `data.validation` (test/lint/typecheck results) - `data.sandbox_cleanup` (worktree/branch/checkpoint status) - `data.lifecycle` (total_duration, total_cost, decisions_made, child_plans) - `command`, `status`, `exit_code`, `timing`, `messages` envelope (missing) ### Code Location - `src/cleveragents/cli/commands/plan.py`, lines 2270-2272 (`lifecycle_apply_plan` function) ### Steps to Reproduce ```bash agents plan apply <PLAN_ID> --yes --format json ``` ### Impact Any tooling or scripts that parse `agents plan apply --format json` output will fail. The `validation` and `lifecycle` fields are particularly important for CI/CD pipelines that need to verify apply success. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.2.0 milestone 2026-04-09 00:53:19 +00:00
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: High — JSON output envelope is required by the spec for all CLI commands; missing envelope breaks any tooling or scripts parsing CLI output
  • Milestone: v3.2.0 (plan commands are core plan lifecycle)
  • Story Points: 3 — M — Fix requires wrapping existing output in the standard JSON envelope
  • MoSCoW: Must Have — The spec explicitly requires the JSON envelope format for all --format json output; this is a spec compliance bug
  • Parent Epic: #4958 (Decision Recording Epic covers plan output formats)

This is a valid spec compliance bug. Part of a batch of JSON envelope bugs across plan commands (see also #4964, #4969, #4970, #4974, #4975, #4976).


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner

Issue triaged by project owner: - **State**: Verified - **Priority**: High — JSON output envelope is required by the spec for all CLI commands; missing envelope breaks any tooling or scripts parsing CLI output - **Milestone**: v3.2.0 (plan commands are core plan lifecycle) - **Story Points**: 3 — M — Fix requires wrapping existing output in the standard JSON envelope - **MoSCoW**: Must Have — The spec explicitly requires the JSON envelope format for all `--format json` output; this is a spec compliance bug - **Parent Epic**: #4958 (Decision Recording Epic covers plan output formats) This is a valid spec compliance bug. Part of a batch of JSON envelope bugs across plan commands (see also #4964, #4969, #4970, #4974, #4975, #4976). --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner
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.

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