UAT: agents plan rollback JSON output uses wrong field names — plan_id instead of plan, restored_files_count instead of files_reverted #4730

Open
opened 2026-04-08 18:12:29 +00:00 by HAL9000 · 1 comment
Owner

Bug Report

Feature Area: Plan execution and apply phase
Command: agents plan rollback --format json <PLAN_ID> <CHECKPOINT_ID>

What Was Tested

The JSON output format of agents plan rollback.

Expected Behavior (from spec §agents plan rollback)

The spec defines the JSON output envelope for agents plan rollback --format json:

{
  "command": "plan rollback",
  "status": "ok",
  "exit_code": 0,
  "data": {
    "rollback_summary": {
      "plan": "01HXM8C2ZK4Q7C2B3F2R4VYV6J",
      "checkpoint": "cp_01HXM8C2",
      "label": "before auth refactor",
      "files_reverted": 6
    },
    "changes_reverted": [
      { "file": "src/auth/session.py", "action": "restored" },
      ...
    ],
    "impact": {
      "child_plans_invalidated": 2,
      "sandbox": "restored to cp_01HXM8C2",
      "decisions_after_cp": "2 discarded",
      "tool_calls_after_cp": "5 undone"
    },
    "post_rollback_state": {
      "phase": "execute",
      "state": "queued (awaiting input)",
      "checkpoints_remaining": 2
    }
  },
  "timing": { "started": "...", "duration_ms": 1850 },
  "messages": ["Rollback complete"]
}

Key spec field names in rollback_summary:

  • plan (not plan_id)
  • checkpoint (not from_checkpoint_id)
  • files_reverted (not restored_files_count)

Actual Behavior (from code analysis)

File: src/cleveragents/cli/commands/plan.py, lines 3677–3695

data = {
    "rollback_summary": {
        "plan_id": plan_id,                              # BUG: spec uses "plan"
        "from_checkpoint_id": result.from_checkpoint_id, # BUG: spec uses "checkpoint"
        "restored_files_count": result.restored_files_count, # BUG: spec uses "files_reverted"
    },
    "changes_reverted": result.changed_paths,
    "impact": {
        "files_affected": result.restored_files_count,   # BUG: spec uses "child_plans_invalidated", "sandbox", "decisions_after_cp", "tool_calls_after_cp"
    },
    "post_rollback_state": {
        "active_checkpoint": result.from_checkpoint_id,  # BUG: spec uses "phase", "state", "checkpoints_remaining"
        "plan_id": plan_id,
    },
    "timing": {
        "elapsed_seconds": round(elapsed, 3),            # BUG: spec uses "started" + "duration_ms" at top level
    },
    "messages": ["Rollback completed successfully."],    # BUG: spec uses "Rollback complete"
}

Specific deviations:

  1. rollback_summary.plan_id → spec requires rollback_summary.plan
  2. rollback_summary.from_checkpoint_id → spec requires rollback_summary.checkpoint
  3. rollback_summary.restored_files_count → spec requires rollback_summary.files_reverted
  4. impact only has files_affected → spec requires child_plans_invalidated, sandbox, decisions_after_cp, tool_calls_after_cp
  5. post_rollback_state has active_checkpoint and plan_id → spec requires phase, state, checkpoints_remaining
  6. timing is nested inside data with elapsed_seconds → spec has timing at top level with started and duration_ms
  7. Message is "Rollback completed successfully." → spec uses "Rollback complete"
  8. Missing top-level command: "plan rollback", status: "ok", exit_code: 0 envelope

Note: The rich output (lines 3700–3782) does correctly render the spec-required panels (Rollback Summary, Changes Reverted, Impact, Post-Rollback State), but the JSON output structure is wrong.

Code Location

  • src/cleveragents/cli/commands/plan.py:
    • rollback_plan() function, lines 3677–3695 (JSON data dict construction)

Steps to Reproduce

agents plan use local/some-action my-project
agents plan execute <PLAN_ID>
# Create a checkpoint during execution
agents plan rollback --yes --format json <PLAN_ID> <CHECKPOINT_ID>
# Observe: JSON output has wrong field names

Impact

Any tooling or scripting that parses agents plan rollback --format json output will fail because the field names do not match the spec. The rollback_summary.plan, rollback_summary.files_reverted, impact.child_plans_invalidated, and post_rollback_state.phase/state/checkpoints_remaining fields are absent.

Fix Suggestion

Update the data dict in rollback_plan() to use spec-aligned field names:

data = {
    "command": "plan rollback",
    "status": "ok",
    "exit_code": 0,
    "data": {
        "rollback_summary": {
            "plan": plan_id,
            "checkpoint": result.from_checkpoint_id,
            "label": getattr(result, "label", None) or "",
            "files_reverted": result.restored_files_count,
        },
        "changes_reverted": result.changed_paths,
        "impact": {
            "child_plans_invalidated": getattr(result, "child_plans_invalidated", 0),
            "sandbox": f"restored to {result.from_checkpoint_id}",
            "decisions_after_cp": f"{getattr(result, 'decisions_after_cp', 0)} discarded",
            "tool_calls_after_cp": f"{getattr(result, 'tool_calls_after_cp', 0)} undone",
        },
        "post_rollback_state": {
            "phase": getattr(result, "phase", "execute"),
            "state": getattr(result, "state", "queued"),
            "checkpoints_remaining": getattr(result, "checkpoints_remaining", None),
        },
    },
    "timing": {"started": t0_iso, "duration_ms": int(elapsed * 1000)},
    "messages": ["Rollback complete"],
}

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

## Bug Report **Feature Area:** Plan execution and apply phase **Command:** `agents plan rollback --format json <PLAN_ID> <CHECKPOINT_ID>` ### What Was Tested The JSON output format of `agents plan rollback`. ### Expected Behavior (from spec §agents plan rollback) The spec defines the JSON output envelope for `agents plan rollback --format json`: ```json { "command": "plan rollback", "status": "ok", "exit_code": 0, "data": { "rollback_summary": { "plan": "01HXM8C2ZK4Q7C2B3F2R4VYV6J", "checkpoint": "cp_01HXM8C2", "label": "before auth refactor", "files_reverted": 6 }, "changes_reverted": [ { "file": "src/auth/session.py", "action": "restored" }, ... ], "impact": { "child_plans_invalidated": 2, "sandbox": "restored to cp_01HXM8C2", "decisions_after_cp": "2 discarded", "tool_calls_after_cp": "5 undone" }, "post_rollback_state": { "phase": "execute", "state": "queued (awaiting input)", "checkpoints_remaining": 2 } }, "timing": { "started": "...", "duration_ms": 1850 }, "messages": ["Rollback complete"] } ``` Key spec field names in `rollback_summary`: - `plan` (not `plan_id`) - `checkpoint` (not `from_checkpoint_id`) - `files_reverted` (not `restored_files_count`) ### Actual Behavior (from code analysis) **File:** `src/cleveragents/cli/commands/plan.py`, lines 3677–3695 ```python data = { "rollback_summary": { "plan_id": plan_id, # BUG: spec uses "plan" "from_checkpoint_id": result.from_checkpoint_id, # BUG: spec uses "checkpoint" "restored_files_count": result.restored_files_count, # BUG: spec uses "files_reverted" }, "changes_reverted": result.changed_paths, "impact": { "files_affected": result.restored_files_count, # BUG: spec uses "child_plans_invalidated", "sandbox", "decisions_after_cp", "tool_calls_after_cp" }, "post_rollback_state": { "active_checkpoint": result.from_checkpoint_id, # BUG: spec uses "phase", "state", "checkpoints_remaining" "plan_id": plan_id, }, "timing": { "elapsed_seconds": round(elapsed, 3), # BUG: spec uses "started" + "duration_ms" at top level }, "messages": ["Rollback completed successfully."], # BUG: spec uses "Rollback complete" } ``` **Specific deviations:** 1. `rollback_summary.plan_id` → spec requires `rollback_summary.plan` 2. `rollback_summary.from_checkpoint_id` → spec requires `rollback_summary.checkpoint` 3. `rollback_summary.restored_files_count` → spec requires `rollback_summary.files_reverted` 4. `impact` only has `files_affected` → spec requires `child_plans_invalidated`, `sandbox`, `decisions_after_cp`, `tool_calls_after_cp` 5. `post_rollback_state` has `active_checkpoint` and `plan_id` → spec requires `phase`, `state`, `checkpoints_remaining` 6. `timing` is nested inside `data` with `elapsed_seconds` → spec has `timing` at top level with `started` and `duration_ms` 7. Message is `"Rollback completed successfully."` → spec uses `"Rollback complete"` 8. Missing top-level `command: "plan rollback"`, `status: "ok"`, `exit_code: 0` envelope Note: The rich output (lines 3700–3782) does correctly render the spec-required panels (Rollback Summary, Changes Reverted, Impact, Post-Rollback State), but the JSON output structure is wrong. ### Code Location - `src/cleveragents/cli/commands/plan.py`: - `rollback_plan()` function, lines 3677–3695 (JSON data dict construction) ### Steps to Reproduce ```bash agents plan use local/some-action my-project agents plan execute <PLAN_ID> # Create a checkpoint during execution agents plan rollback --yes --format json <PLAN_ID> <CHECKPOINT_ID> # Observe: JSON output has wrong field names ``` ### Impact Any tooling or scripting that parses `agents plan rollback --format json` output will fail because the field names do not match the spec. The `rollback_summary.plan`, `rollback_summary.files_reverted`, `impact.child_plans_invalidated`, and `post_rollback_state.phase/state/checkpoints_remaining` fields are absent. ### Fix Suggestion Update the `data` dict in `rollback_plan()` to use spec-aligned field names: ```python data = { "command": "plan rollback", "status": "ok", "exit_code": 0, "data": { "rollback_summary": { "plan": plan_id, "checkpoint": result.from_checkpoint_id, "label": getattr(result, "label", None) or "", "files_reverted": result.restored_files_count, }, "changes_reverted": result.changed_paths, "impact": { "child_plans_invalidated": getattr(result, "child_plans_invalidated", 0), "sandbox": f"restored to {result.from_checkpoint_id}", "decisions_after_cp": f"{getattr(result, 'decisions_after_cp', 0)} discarded", "tool_calls_after_cp": f"{getattr(result, 'tool_calls_after_cp', 0)} undone", }, "post_rollback_state": { "phase": getattr(result, "phase", "execute"), "state": getattr(result, "state", "queued"), "checkpoints_remaining": getattr(result, "checkpoints_remaining", None), }, }, "timing": {"started": t0_iso, "duration_ms": int(elapsed * 1000)}, "messages": ["Rollback complete"], } ``` --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Medium — spec compliance bug identified by UAT testing
  • Story Points: 3 (M) — targeted fix to align implementation with spec
  • MoSCoW: Must Have — spec compliance is required for correct system behavior

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

Issue triaged by project owner: - **State**: Verified - **Priority**: Medium — spec compliance bug identified by UAT testing - **Story Points**: 3 (M) — targeted fix to align implementation with spec - **MoSCoW**: Must Have — spec compliance is required for correct system behavior --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner
HAL9000 added this to the v3.5.0 milestone 2026-04-09 03:05:50 +00:00
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#4730
No description provided.