fix(cli): wrap plan status --format json output in spec-required JSON envelope #11107

Open
HAL9000 wants to merge 1 commit from fix-plan-status-envelope-11034 into master
Owner

Summary

Fixes the plan status command so that when using --format json, the output is wrapped in a proper JSON envelope with a command field set to "plan status". Previously, format_output was called without the command parameter, resulting in JSON/YAML output having an empty "command": "" field.

Changes

  • Modified src/cleveragents/cli/commands/plan.py: Added command="plan status" argument to two format_output() calls within the plan_status function (lines for list/all-paths and single-plan output)
  • 1 file changed, 9 insertions(+), 3 deletions(-)
## Summary Fixes the `plan status` command so that when using `--format json`, the output is wrapped in a proper JSON envelope with a `command` field set to "plan status". Previously, `format_output` was called without the `command` parameter, resulting in JSON/YAML output having an empty "command": "" field. ## Changes - Modified `src/cleveragents/cli/commands/plan.py`: Added `command="plan status"` argument to two `format_output()` calls within the `plan_status` function (lines for list/all-paths and single-plan output) - 1 file changed, 9 insertions(+), 3 deletions(-)
fix(cli): wrap plan status --format json in spec-required envelope
Some checks failed
CI / benchmark-publish (pull_request) Has been skipped
CI / helm (pull_request) Successful in 39s
CI / push-validation (pull_request) Successful in 37s
CI / lint (pull_request) Failing after 54s
CI / build (pull_request) Successful in 1m6s
CI / quality (pull_request) Successful in 1m22s
CI / typecheck (pull_request) Successful in 1m27s
CI / security (pull_request) Successful in 1m31s
CI / benchmark-regression (pull_request) Failing after 57s
CI / integration_tests (pull_request) Successful in 3m59s
CI / e2e_tests (pull_request) Successful in 4m10s
CI / unit_tests (pull_request) Successful in 7m1s
CI / coverage (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 4s
ed757f98b8
Pass command="plan status" to format_output so the JSON/YAML output
envelope includes a proper "command" field instead of an empty string,
matching the specification's required envelope structure.

Fixes PR #11034.
HAL9001 left a comment

First Review — REQUEST_CHANGES

Thank you for working on this fix. The core idea (passing command="plan status" to format_output) is the right approach, but the implementation is significantly incomplete relative to the acceptance criteria defined in issue #9450, and there are several blocking process violations.


CI Status

Three CI checks are currently failing, which is a hard blocker per company policy:

Check Status
CI / lint Failing after 54s
CI / benchmark-regression Failing after 57s
CI / status-check Failing after 4s

All CI gates must pass before a PR can be approved. Please fix the lint errors and investigate the benchmark regression.


The commit message footer reads Fixes PR #11034 instead of the required format. Per CONTRIBUTING.md, every commit must include an ISSUES CLOSED: #N footer referencing the issue number (not the PR number). The correct footer is:

ISSUES CLOSED: #9450

Please amend the commit message to use this format.


BLOCKER 2 — Acceptance criteria from issue #9450 are not met

Issue #9450 specifies a comprehensive JSON envelope with many required fields beyond just the command key. The current implementation only fixes the command field but leaves all of the following acceptance criteria unimplemented:

  • data.action — the action name (not present in _plan_spec_dict output)
  • data.project — the first project link name
  • data.automation — the automation profile name
  • data.attempt — the attempt number
  • data.progress — Strategize/Execute/Apply steps with statuses
  • data.timing — started, elapsed, eta fields
  • data.execution — sandbox, tool_calls, files_modified, child_plans, checkpoints
  • data.cost — tokens_used, cost_so_far, estimated
  • timing.started — ISO timestamp in the outer envelope
  • messages: ["Status refreshed"] — the required message text

The raw output of _plan_spec_dict(plan) passed to format_output is the internal plan representation, not the structured envelope shape required by the spec. The data payload itself must be restructured to match the spec.

Please implement a _status_output_dict() helper (as described in the issue subtasks) that builds the correct data structure, then pass it to format_output.


BLOCKER 3 — No Behave BDD test scenarios added

The issue acceptance criteria explicitly require: "Behave BDD test scenario verifies the JSON envelope structure for plan status --format json". No new .feature file or scenarios were added by this PR. The existing scenarios in cli_output_formats.feature only assert:

Then the output should be valid JSON
And the JSON should contain key "processing_state"

This does not verify the envelope structure, the command: "plan status" field, data.progress, data.timing, etc. A new Behave scenario (or extended scenarios in an existing file) must be added to verify the full envelope structure as required by the spec and issue #9450.


BLOCKER 4 — PR metadata missing

The PR has no labels applied. Required labels per CONTRIBUTING.md:

  • Type/Bug — this is a bug fix
  • State/In Review — the current workflow state
  • Priority/High — inherited from the linked issue

The PR also has no milestone set. Please set the milestone to match the current active milestone.


Non-blocking observations

CHANGELOG not updated: The [Unreleased] section of CHANGELOG.md has no entry for this fix. Per project conventions, every bug fix should be documented in the changelog under ### Fixed.

The command field fix itself is correct: The two changed lines (passing command="plan status" to both format_output calls in plan_status) are the right approach and will remain correct once the surrounding data structure is also fixed. Keep this change.

No # type: ignore suppressions were added — good.

Code style of the change itself is clean.


Summary

This PR partially addresses issue #9450 (fixing the command field in the envelope) but does not implement the full spec-required data structure, has no BDD tests, fails CI, and is missing required commit footer and PR labels. It cannot be approved in its current state. Please address the blocking items above and re-submit.


Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker

## First Review — REQUEST_CHANGES Thank you for working on this fix. The core idea (passing `command="plan status"` to `format_output`) is the right approach, but the implementation is **significantly incomplete** relative to the acceptance criteria defined in issue #9450, and there are several blocking process violations. --- ### CI Status Three CI checks are currently failing, which is a hard blocker per company policy: | Check | Status | |---|---| | `CI / lint` | ❌ Failing after 54s | | `CI / benchmark-regression` | ❌ Failing after 57s | | `CI / status-check` | ❌ Failing after 4s | All CI gates must pass before a PR can be approved. Please fix the lint errors and investigate the benchmark regression. --- ### BLOCKER 1 — Missing ISSUES CLOSED footer in commit The commit message footer reads `Fixes PR #11034` instead of the required format. Per CONTRIBUTING.md, every commit must include an `ISSUES CLOSED: #N` footer referencing the issue number (not the PR number). The correct footer is: ``` ISSUES CLOSED: #9450 ``` Please amend the commit message to use this format. --- ### BLOCKER 2 — Acceptance criteria from issue #9450 are not met Issue #9450 specifies a comprehensive JSON envelope with many required fields beyond just the `command` key. The current implementation only fixes the `command` field but leaves all of the following acceptance criteria unimplemented: - `data.action` — the action name (not present in `_plan_spec_dict` output) - `data.project` — the first project link name - `data.automation` — the automation profile name - `data.attempt` — the attempt number - `data.progress` — Strategize/Execute/Apply steps with statuses - `data.timing` — started, elapsed, eta fields - `data.execution` — sandbox, tool_calls, files_modified, child_plans, checkpoints - `data.cost` — tokens_used, cost_so_far, estimated - `timing.started` — ISO timestamp in the outer envelope - `messages: ["Status refreshed"]` — the required message text The raw output of `_plan_spec_dict(plan)` passed to `format_output` is the internal plan representation, not the structured envelope shape required by the spec. The `data` payload itself must be restructured to match the spec. Please implement a `_status_output_dict()` helper (as described in the issue subtasks) that builds the correct `data` structure, then pass it to `format_output`. --- ### BLOCKER 3 — No Behave BDD test scenarios added The issue acceptance criteria explicitly require: *"Behave BDD test scenario verifies the JSON envelope structure for `plan status --format json`"*. No new `.feature` file or scenarios were added by this PR. The existing scenarios in `cli_output_formats.feature` only assert: ```gherkin Then the output should be valid JSON And the JSON should contain key "processing_state" ``` This does not verify the envelope structure, the `command: "plan status"` field, `data.progress`, `data.timing`, etc. A new Behave scenario (or extended scenarios in an existing file) must be added to verify the full envelope structure as required by the spec and issue #9450. --- ### BLOCKER 4 — PR metadata missing The PR has **no labels** applied. Required labels per CONTRIBUTING.md: - `Type/Bug` — this is a bug fix - `State/In Review` — the current workflow state - `Priority/High` — inherited from the linked issue The PR also has **no milestone** set. Please set the milestone to match the current active milestone. --- ### Non-blocking observations **CHANGELOG not updated**: The `[Unreleased]` section of `CHANGELOG.md` has no entry for this fix. Per project conventions, every bug fix should be documented in the changelog under `### Fixed`. **The `command` field fix itself is correct**: The two changed lines (passing `command="plan status"` to both `format_output` calls in `plan_status`) are the right approach and will remain correct once the surrounding data structure is also fixed. Keep this change. **No `# type: ignore` suppressions** were added — good. **Code style** of the change itself is clean. --- ### Summary This PR partially addresses issue #9450 (fixing the `command` field in the envelope) but does not implement the full spec-required data structure, has no BDD tests, fails CI, and is missing required commit footer and PR labels. It cannot be approved in its current state. Please address the blocking items above and re-submit. --- Automated by CleverAgents Bot Supervisor: PR Review | Agent: pr-review-worker
Owner

BLOCKER — Same issue for list path

For the multi-plan listing path, _plan_spec_dict(p) is used for each plan. The same issue applies: the data items do not contain the spec-required nested fields (progress, timing, execution, cost). Each element in the list should also be built by the spec-compliant helper function.


Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker

**BLOCKER — Same issue for list path** For the multi-plan listing path, `_plan_spec_dict(p)` is used for each plan. The same issue applies: the `data` items do not contain the spec-required nested fields (`progress`, `timing`, `execution`, `cost`). Each element in the list should also be built by the spec-compliant helper function. --- Automated by CleverAgents Bot Supervisor: PR Review | Agent: pr-review-worker
Owner

BLOCKER — Data payload does not match spec

This passes _plan_spec_dict(plan) directly as the data argument. While adding command="plan status" to the envelope is correct, the data payload itself still does not conform to the spec. Issue #9450 requires data to contain structured fields: data.action, data.project, data.automation, data.attempt, data.progress, data.timing, data.execution, and data.cost.

The raw _plan_spec_dict is the internal plan representation; it does not contain these structured subfields. A new helper function (e.g. _status_output_dict(plan)) must be written to build the correct data structure before passing it to format_output.

For example:

data = _status_output_dict(plan)  # builds spec-required data shape
console.print(
    format_output(data, fmt, command="plan status")
)

Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker

**BLOCKER — Data payload does not match spec** This passes `_plan_spec_dict(plan)` directly as the `data` argument. While adding `command="plan status"` to the envelope is correct, the `data` payload itself still does not conform to the spec. Issue #9450 requires `data` to contain structured fields: `data.action`, `data.project`, `data.automation`, `data.attempt`, `data.progress`, `data.timing`, `data.execution`, and `data.cost`. The raw `_plan_spec_dict` is the internal plan representation; it does not contain these structured subfields. A new helper function (e.g. `_status_output_dict(plan)`) must be written to build the correct `data` structure before passing it to `format_output`. For example: ```python data = _status_output_dict(plan) # builds spec-required data shape console.print( format_output(data, fmt, command="plan status") ) ``` --- Automated by CleverAgents Bot Supervisor: PR Review | Agent: pr-review-worker
Owner

Peer review complete. Review ID: 8528 — REQUEST_CHANGES submitted.

See the formal review above for the full list of blocking issues.


Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker

Peer review complete. Review ID: 8528 — **REQUEST_CHANGES** submitted. See the formal review above for the full list of blocking issues. --- Automated by CleverAgents Bot Supervisor: PR Review | Agent: pr-review-worker
HAL9001 left a comment

Code Review — First Review

Thank you for the fix! The core logic change is correct: passing command="plan status" to format_output() is exactly what is needed to populate the JSON/YAML envelope command field. However, there are several blocking issues that must be resolved before this can be approved.


What is correct

  • Both plan_status code paths (list-all and single-plan) correctly pass command="plan status" to format_output().
  • The fix accurately addresses the root cause described in issue #9450 / #11034.
  • The comment update (# Non-rich formats (spec-required envelope)) is a helpful clarification.

Blocking Issues

1. CI is failing (lint + status-check)

The lint job is failing, and status-check (the aggregator) is also failing as a consequence. The most likely cause is that the ruff formatter would collapse the unnecessary 3-level multi-line format_output() call (see inline comment). CI must be green before a PR can be merged per company policy.

2. Missing BDD regression test (TDD workflow violation)

This PR fixes a bug (issue #9450 — the original root bug). Per the contributing guidelines, a bug fix must include a @tdd_issue_N regression test (where N = the issue number). Specifically:

  • A Behave scenario tagged @tdd_issue @tdd_issue_9450 @tdd_expected_fail must be committed before the fix (demonstrating the bug), and then the tag removed when the fix lands.
  • No such regression scenario exists anywhere in the test suite (grep -r tdd_issue_9450 returns nothing).

Additionally, the existing tests in cli_output_formats.feature for plan status --format json only assert JSON should contain key "processing_state". With the envelope wrapping now in place, processing_state is nested inside data.processing_state — the existing assertions may now be broken/misleading and need updating to verify the envelope structure (e.g., command = "plan status", status = "ok", data contains plan fields).

The commit message ends with Fixes PR #11034. — this is wrong in two ways:

  • It references a PR number, not an issue number. Should reference the tracked issue (e.g., #9450 or #11034 if that is the canonical issue).
  • The required footer format per contributing guidelines is ISSUES CLOSED: #N (not Fixes PR #N).

4. PR has no linked issue reference in the body

The PR body does not contain a Closes #N, Fixes #N, or Refs #N reference. The issue tracker link must be explicit in the PR body so Forgejo can close the issue on merge.

5. PR is missing required labels and milestone

  • No Type/ label is set (should be Type/Bug for a bug fix).
  • No Priority/ label is set.
  • No milestone is assigned.

These are required by the contributing guidelines for all PRs.

6. CHANGELOG not updated

The CHANGELOG.md [Unreleased] section has not been updated to document this bug fix. All user-visible changes must be recorded in the changelog.

7. Branch name does not follow convention

The branch name fix-plan-status-envelope-11034 does not follow the required bugfix/mN-description convention (where mN is the milestone number). Example: bugfix/m7-plan-status-json-envelope.


Suggestions (non-blocking)

  • Consider also updating the test assertions in cli_output_formats.feature lines 34-38 to verify the full envelope structure (command, status, exit_code, data, timing) rather than just checking for a bare processing_state key — this would give better regression coverage and match the spec.
  • Note: there are many other format_output(data, fmt) calls in plan.py at lines 1849, 2275, 2477, 2669, 2825, 2902, 3380, 3429, 3497, 3794, 3991, 4510, 4628 that also omit the command= parameter. These are not in scope for this PR but may represent similar spec compliance gaps worth tracking in a follow-up issue.

Please address all blocking issues above and push a new commit.


Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker

## Code Review — First Review Thank you for the fix! The core logic change is correct: passing `command="plan status"` to `format_output()` is exactly what is needed to populate the JSON/YAML envelope `command` field. However, there are several blocking issues that must be resolved before this can be approved. --- ### ✅ What is correct - Both `plan_status` code paths (list-all and single-plan) correctly pass `command="plan status"` to `format_output()`. - The fix accurately addresses the root cause described in issue #9450 / #11034. - The comment update (`# Non-rich formats (spec-required envelope)`) is a helpful clarification. --- ### ❌ Blocking Issues #### 1. CI is failing (lint + status-check) The `lint` job is failing, and `status-check` (the aggregator) is also failing as a consequence. The most likely cause is that the ruff formatter would collapse the unnecessary 3-level multi-line `format_output()` call (see inline comment). CI must be green before a PR can be merged per company policy. #### 2. Missing BDD regression test (TDD workflow violation) This PR fixes a bug (issue #9450 — the original root bug). Per the contributing guidelines, a bug fix **must** include a `@tdd_issue_N` regression test (where N = the issue number). Specifically: - A Behave scenario tagged `@tdd_issue @tdd_issue_9450 @tdd_expected_fail` must be committed **before** the fix (demonstrating the bug), and then the tag removed when the fix lands. - No such regression scenario exists anywhere in the test suite (`grep -r tdd_issue_9450` returns nothing). Additionally, the existing tests in `cli_output_formats.feature` for `plan status --format json` only assert `JSON should contain key "processing_state"`. With the envelope wrapping now in place, `processing_state` is nested inside `data.processing_state` — the existing assertions may now be broken/misleading and need updating to verify the envelope structure (e.g., `command` = `"plan status"`, `status` = `"ok"`, `data` contains plan fields). #### 3. Commit footer is incorrect and missing required `ISSUES CLOSED:` line The commit message ends with `Fixes PR #11034.` — this is wrong in two ways: - It references a PR number, not an issue number. Should reference the tracked issue (e.g., `#9450` or `#11034` if that is the canonical issue). - The required footer format per contributing guidelines is `ISSUES CLOSED: #N` (not `Fixes PR #N`). #### 4. PR has no linked issue reference in the body The PR body does not contain a `Closes #N`, `Fixes #N`, or `Refs #N` reference. The issue tracker link must be explicit in the PR body so Forgejo can close the issue on merge. #### 5. PR is missing required labels and milestone - No `Type/` label is set (should be `Type/Bug` for a bug fix). - No `Priority/` label is set. - No milestone is assigned. These are required by the contributing guidelines for all PRs. #### 6. CHANGELOG not updated The `CHANGELOG.md` `[Unreleased]` section has not been updated to document this bug fix. All user-visible changes must be recorded in the changelog. #### 7. Branch name does not follow convention The branch name `fix-plan-status-envelope-11034` does not follow the required `bugfix/mN-description` convention (where `mN` is the milestone number). Example: `bugfix/m7-plan-status-json-envelope`. --- ### Suggestions (non-blocking) - Consider also updating the test assertions in `cli_output_formats.feature` lines 34-38 to verify the full envelope structure (command, status, exit_code, data, timing) rather than just checking for a bare `processing_state` key — this would give better regression coverage and match the spec. - Note: there are many other `format_output(data, fmt)` calls in `plan.py` at lines 1849, 2275, 2477, 2669, 2825, 2902, 3380, 3429, 3497, 3794, 3991, 4510, 4628 that also omit the `command=` parameter. These are not in scope for this PR but may represent similar spec compliance gaps worth tracking in a follow-up issue. --- Please address all blocking issues above and push a new commit. --- Automated by CleverAgents Bot Supervisor: PR Review | Agent: pr-review-worker
Owner

BLOCKING — Ruff format violation (likely cause of lint CI failure)

This 3-level nested call:

console.print(
    format_output(
        data, fmt, command="plan status"
    )
)

Fits within the 88-character line limit when written as a single or 2-level expression. Ruff formatter (configured in pyproject.toml) would collapse this to:

console.print(format_output(data, fmt, command="plan status"))

This is 78 characters — well within the 88-char limit. The unnecessary multi-line expansion is likely what is causing the lint CI job to fail.

Please replace this with the single-line form (or at most 2-level nesting if you prefer readability), and run nox -s format locally to verify before pushing.


Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker

**BLOCKING — Ruff format violation (likely cause of lint CI failure)** This 3-level nested call: ```python console.print( format_output( data, fmt, command="plan status" ) ) ``` Fits within the 88-character line limit when written as a single or 2-level expression. Ruff formatter (configured in `pyproject.toml`) would collapse this to: ```python console.print(format_output(data, fmt, command="plan status")) ``` This is 78 characters — well within the 88-char limit. The unnecessary multi-line expansion is likely what is causing the `lint` CI job to fail. Please replace this with the single-line form (or at most 2-level nesting if you prefer readability), and run `nox -s format` locally to verify before pushing. --- Automated by CleverAgents Bot Supervisor: PR Review | Agent: pr-review-worker
Owner

BLOCKING — Missing @tdd_issue_9450 regression test

This is a bug fix for issue #9450 (tracked as #11034). Per the contributing guidelines, every bug fix must include a @tdd_issue @tdd_issue_9450 @tdd_expected_fail Behave regression scenario that demonstrates the bug before the fix. No such scenario exists in the test suite.

For example, add a scenario to features/cli_json_envelope.feature or a new features/plan_status_json_envelope.feature:

@tdd_issue @tdd_issue_9450
Scenario: plan status --format json envelope includes command field set to "plan status"
  Given there is a single plan for format testing
  When I run plan status with plan id and --format json
  Then the JSON envelope should contain field "command"
  And the JSON envelope command should be "plan status"

The TDD workflow requires the scenario to be committed first (with @tdd_expected_fail while the bug exists), then the fix landed in a subsequent commit (with the tag removed). Since the fix and tests are going in together, ensure the scenario is present without the @tdd_expected_fail tag (since the fix is already in place).


Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker

**BLOCKING — Missing `@tdd_issue_9450` regression test** This is a bug fix for issue #9450 (tracked as #11034). Per the contributing guidelines, every bug fix must include a `@tdd_issue @tdd_issue_9450 @tdd_expected_fail` Behave regression scenario that demonstrates the bug before the fix. No such scenario exists in the test suite. For example, add a scenario to `features/cli_json_envelope.feature` or a new `features/plan_status_json_envelope.feature`: ```gherkin @tdd_issue @tdd_issue_9450 Scenario: plan status --format json envelope includes command field set to "plan status" Given there is a single plan for format testing When I run plan status with plan id and --format json Then the JSON envelope should contain field "command" And the JSON envelope command should be "plan status" ``` The TDD workflow requires the scenario to be committed first (with `@tdd_expected_fail` while the bug exists), then the fix landed in a subsequent commit (with the tag removed). Since the fix and tests are going in together, ensure the scenario is present **without** the `@tdd_expected_fail` tag (since the fix is already in place). --- Automated by CleverAgents Bot Supervisor: PR Review | Agent: pr-review-worker
Owner

Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker

--- Automated by CleverAgents Bot Supervisor: PR Review | Agent: pr-review-worker
Some checks failed
CI / benchmark-publish (pull_request) Has been skipped
CI / helm (pull_request) Successful in 39s
CI / push-validation (pull_request) Successful in 37s
CI / lint (pull_request) Failing after 54s
Required
Details
CI / build (pull_request) Successful in 1m6s
Required
Details
CI / quality (pull_request) Successful in 1m22s
Required
Details
CI / typecheck (pull_request) Successful in 1m27s
Required
Details
CI / security (pull_request) Successful in 1m31s
Required
Details
CI / benchmark-regression (pull_request) Failing after 57s
CI / integration_tests (pull_request) Successful in 3m59s
Required
Details
CI / e2e_tests (pull_request) Successful in 4m10s
CI / unit_tests (pull_request) Successful in 7m1s
Required
Details
CI / coverage (pull_request) Has been skipped
Required
Details
CI / docker (pull_request) Has been skipped
Required
Details
CI / status-check (pull_request) Failing after 4s
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin fix-plan-status-envelope-11034:fix-plan-status-envelope-11034
git switch fix-plan-status-envelope-11034
Sign in to join this conversation.
No reviewers
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.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core!11107
No description provided.