bug(cli): plan correct JSON/YAML output missing spec-required envelope and structured fields #9434

Open
opened 2026-04-14 17:40:35 +00:00 by HAL9000 · 1 comment
Owner

Metadata

  • Commit Message: fix(cli): emit spec-required JSON envelope in plan correct output for revert and append modes
  • Branch: fix/plan-correct-json-yaml-output-envelope

Background and Context

The agents plan correct command (both --mode revert and --mode append) produces a flat, minimal JSON output that does not match the spec-required structured envelope. This breaks programmatic consumers (CI/CD pipelines, scripts) that rely on the documented JSON schema.

Current Behavior

In src/cleveragents/cli/commands/plan.py (lines 3672–3680), the non-dry-run JSON output is:

data = {
    "correction_id": result.correction_id,
    "status": result.status.value,
    "mode": correction_mode.value,
    "new_decisions": result.new_decisions,
    "reverted_decisions": result.reverted_decisions,
}
console.print(format_output(data, fmt))

This produces a flat dict with 5 fields, missing the outer command/status/exit_code envelope and all the structured sub-objects.

Expected Behavior

Per docs/specification.md §agents plan correct (lines 15006–15044), the JSON output MUST be:

{
  "command": "plan correct",
  "status": "ok",
  "exit_code": 0,
  "data": {
    "correction": {
      "mode": "revert",
      "impact": "3 decisions, 2 child plans, 5 artifacts",
      "new_decision": "<new_decision_id>",
      "corrects": "<target_decision_id>",
      "attempt": 2
    },
    "affected_subtree": {
      "decisions_invalidated": 3,
      "child_plans_rolled_back": 2,
      "artifacts_archived": 5,
      "unaffected_decisions": 2
    },
    "sandbox_rollback": {
      "checkpoint": "<checkpoint_id>",
      "files_reverted": 5,
      "status": "restored"
    },
    "recompute": {
      "queued": "2 child plans",
      "eta": "4m"
    },
    "history": [
      "Original decision superseded",
      "Prior artifacts archived for comparison",
      "agents plan diff --correction <correction_id>.."
    ]
  },
  "timing": { "started": "...", "duration_ms": 2350 },
  "messages": ["Correction applied"]
}

For --mode append, the spec requires a different data structure with append_detail and queued sub-objects (spec lines 15145–15175).

Evidence

  • src/cleveragents/cli/commands/plan.py lines 3672–3680: flat dict output missing envelope
  • docs/specification.md lines 15006–15044: revert mode JSON spec
  • docs/specification.md lines 15145–15175: append mode JSON spec
  • v3.3.0 deliverable #9: "Correction flow functional (plan correct --mode revert and --mode append)" — both modes must be functional end-to-end including correct output

Acceptance Criteria

  • agents plan correct <id> --mode revert --guidance "..." --yes --format json outputs the spec-required envelope with command, status, exit_code, data.correction, data.affected_subtree, data.sandbox_rollback, data.recompute, data.history, timing, messages
  • agents plan correct <id> --mode append --guidance "..." --format json outputs the spec-required envelope with data.correction (mode=append), data.append_detail, data.queued
  • BDD tests pass for both modes
  • nox passes

Subtasks

  • Refactor correct_decision() in plan.py to emit the full spec-required JSON envelope for --mode revert
  • Refactor correct_decision() in plan.py to emit the full spec-required JSON envelope for --mode append
  • Ensure command, status, exit_code, data, timing, and messages top-level keys are present
  • Add BDD tests asserting the structured JSON output shape for both modes

Definition of Done

  • agents plan correct <id> --mode revert --guidance "..." --yes --format json outputs the spec-required envelope with command, status, exit_code, data.correction, data.affected_subtree, data.sandbox_rollback, data.recompute, data.history, timing, messages
  • agents plan correct <id> --mode append --guidance "..." --format json outputs the spec-required envelope with data.correction (mode=append), data.append_detail, data.queued
  • BDD tests pass for both modes
  • nox passes

Automated by CleverAgents Bot
Supervisor: UAT Test Pool | Agent: uat-test-pool-supervisor

## Metadata - **Commit Message**: `fix(cli): emit spec-required JSON envelope in plan correct output for revert and append modes` - **Branch**: `fix/plan-correct-json-yaml-output-envelope` ## Background and Context The `agents plan correct` command (both `--mode revert` and `--mode append`) produces a flat, minimal JSON output that does not match the spec-required structured envelope. This breaks programmatic consumers (CI/CD pipelines, scripts) that rely on the documented JSON schema. ## Current Behavior In `src/cleveragents/cli/commands/plan.py` (lines 3672–3680), the non-dry-run JSON output is: ```python data = { "correction_id": result.correction_id, "status": result.status.value, "mode": correction_mode.value, "new_decisions": result.new_decisions, "reverted_decisions": result.reverted_decisions, } console.print(format_output(data, fmt)) ``` This produces a flat dict with 5 fields, missing the outer `command`/`status`/`exit_code` envelope and all the structured sub-objects. ## Expected Behavior Per `docs/specification.md` §agents plan correct (lines 15006–15044), the JSON output MUST be: ```json { "command": "plan correct", "status": "ok", "exit_code": 0, "data": { "correction": { "mode": "revert", "impact": "3 decisions, 2 child plans, 5 artifacts", "new_decision": "<new_decision_id>", "corrects": "<target_decision_id>", "attempt": 2 }, "affected_subtree": { "decisions_invalidated": 3, "child_plans_rolled_back": 2, "artifacts_archived": 5, "unaffected_decisions": 2 }, "sandbox_rollback": { "checkpoint": "<checkpoint_id>", "files_reverted": 5, "status": "restored" }, "recompute": { "queued": "2 child plans", "eta": "4m" }, "history": [ "Original decision superseded", "Prior artifacts archived for comparison", "agents plan diff --correction <correction_id>.." ] }, "timing": { "started": "...", "duration_ms": 2350 }, "messages": ["Correction applied"] } ``` For `--mode append`, the spec requires a different `data` structure with `append_detail` and `queued` sub-objects (spec lines 15145–15175). ## Evidence - `src/cleveragents/cli/commands/plan.py` lines 3672–3680: flat dict output missing envelope - `docs/specification.md` lines 15006–15044: revert mode JSON spec - `docs/specification.md` lines 15145–15175: append mode JSON spec - v3.3.0 deliverable #9: "Correction flow functional (`plan correct --mode revert` and `--mode append`)" — both modes must be functional end-to-end including correct output ## Acceptance Criteria - [ ] `agents plan correct <id> --mode revert --guidance "..." --yes --format json` outputs the spec-required envelope with `command`, `status`, `exit_code`, `data.correction`, `data.affected_subtree`, `data.sandbox_rollback`, `data.recompute`, `data.history`, `timing`, `messages` - [ ] `agents plan correct <id> --mode append --guidance "..." --format json` outputs the spec-required envelope with `data.correction` (mode=append), `data.append_detail`, `data.queued` - [ ] BDD tests pass for both modes - [ ] `nox` passes ## Subtasks - [ ] Refactor `correct_decision()` in `plan.py` to emit the full spec-required JSON envelope for `--mode revert` - [ ] Refactor `correct_decision()` in `plan.py` to emit the full spec-required JSON envelope for `--mode append` - [ ] Ensure `command`, `status`, `exit_code`, `data`, `timing`, and `messages` top-level keys are present - [ ] Add BDD tests asserting the structured JSON output shape for both modes ## Definition of Done - [ ] `agents plan correct <id> --mode revert --guidance "..." --yes --format json` outputs the spec-required envelope with `command`, `status`, `exit_code`, `data.correction`, `data.affected_subtree`, `data.sandbox_rollback`, `data.recompute`, `data.history`, `timing`, `messages` - [ ] `agents plan correct <id> --mode append --guidance "..." --format json` outputs the spec-required envelope with `data.correction` (mode=append), `data.append_detail`, `data.queued` - [ ] BDD tests pass for both modes - [ ] `nox` passes --- **Automated by CleverAgents Bot** Supervisor: UAT Test Pool | Agent: uat-test-pool-supervisor
Author
Owner

Triage Decision [AUTO-OWNR-2]: Verified as a spec compliance bug. The plan correct JSON/YAML output is missing the spec-required command envelope and structured fields. Must Have for v3.3.0 acceptance criteria.


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

✅ **Triage Decision [AUTO-OWNR-2]**: Verified as a spec compliance bug. The `plan correct` JSON/YAML output is missing the spec-required command envelope and structured fields. `Must Have` for v3.3.0 acceptance criteria. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
HAL9000 added this to the v3.3.0 milestone 2026-04-14 18:04:46 +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#9434
No description provided.