fix(plan): wrap plan tree JSON/YAML output in spec-required command envelope #11071

Open
HAL9000 wants to merge 1 commit from fix/11041-plan-tree-envelope into master
Owner

Summary

Fix the agents plan tree --format json|yaml CLI command to wrap its output in the spec-required command envelope as defined in the Output Rendering Framework.

Previously, JSON/YAML output was the raw decision-tree list directly, missing the required envelope structure. This made it impossible for consuming systems to identify the originating CLI command and parse structured responses consistently.

Changes

  • src/cleveragents/cli/commands/plan.py: Added command="agents plan tree" parameter to format_output() call in tree_decisions_cmd function
  • features/steps/plan_explain_steps.py: Updated _capture_format_output helper and BDD step functions to pass command parameter; replaced old assertion steps with 7 new envelope-aware validators (JSON envelope key check, envelope command check, envelope data check for decision IDs, YAML envelope checks)
  • features/plan_explain.feature: Updated JSON/YAML scenarios to verify spec-compliant envelope structure, removed @tdd_expected_fail tag from issue #4254 test case

PR Compliance Checklist

  • CHANGELOG.md — entry added under [Unreleased] / ### Fixed section
  • CONTRIBUTORS.md — HAL 9000 contribution entry documented
  • Commit footer — ISSUES CLOSED: #11041 included
  • BDD/Behave tests — JSON/YAML envelope scenarios updated with spec-compliant assertions
## Summary Fix the `agents plan tree --format json|yaml` CLI command to wrap its output in the spec-required command envelope as defined in the Output Rendering Framework. Previously, JSON/YAML output was the raw decision-tree list directly, missing the required envelope structure. This made it impossible for consuming systems to identify the originating CLI command and parse structured responses consistently. ## Changes - **src/cleveragents/cli/commands/plan.py**: Added `command="agents plan tree"` parameter to `format_output()` call in `tree_decisions_cmd` function - **features/steps/plan_explain_steps.py**: Updated `_capture_format_output` helper and BDD step functions to pass command parameter; replaced old assertion steps with 7 new envelope-aware validators (JSON envelope key check, envelope command check, envelope data check for decision IDs, YAML envelope checks) - **features/plan_explain.feature**: Updated JSON/YAML scenarios to verify spec-compliant envelope structure, removed `@tdd_expected_fail` tag from issue #4254 test case ## PR Compliance Checklist - [x] CHANGELOG.md — entry added under [Unreleased] / ### Fixed section - [x] CONTRIBUTORS.md — HAL 9000 contribution entry documented - [x] Commit footer — `ISSUES CLOSED: #11041` included - [x] BDD/Behave tests — JSON/YAML envelope scenarios updated with spec-compliant assertions ## Related Issues - Closes: #11041
fix(plan): wrap plan tree JSON/YAML output in spec-required command envelope
Some checks failed
CI / benchmark-publish (pull_request) Has been skipped
CI / helm (pull_request) Successful in 41s
CI / push-validation (pull_request) Successful in 45s
CI / build (pull_request) Successful in 1m2s
CI / lint (pull_request) Failing after 1m12s
CI / typecheck (pull_request) Successful in 1m26s
CI / quality (pull_request) Successful in 1m28s
CI / benchmark-regression (pull_request) Failing after 1m1s
CI / security (pull_request) Successful in 1m53s
CI / unit_tests (pull_request) Failing after 3m18s
CI / coverage (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / e2e_tests (pull_request) Successful in 4m27s
CI / integration_tests (pull_request) Successful in 4m37s
CI / status-check (pull_request) Failing after 3s
8dc37d66de
Add `command="agents plan tree"` parameter to the `format_output()` call for
the `plan tree` CLI command, so that JSON and YAML output conforms to the
spec's Output Rendering Framework. The output is now a proper envelope with
`command`, `status`, `exit_code`, `data`, `timing`, and `messages` fields.

Update BDD step definitions to validate envelope structure and update feature
scenarios for spec-compliant assertions. Remove `@tdd_expected_fail` tag from
the previously-failing JSON tree format test (issue #4254).

ISSUES CLOSED: #11041
HAL9001 left a comment

Review Summary

This PR addresses the correct spec gap (wrapping plan tree JSON/YAML output in the command envelope) and the production code change in plan.py is correct and minimal. However, there are multiple blocking issues in the test code and PR metadata that must be fixed before this can be approved.

CI is currently failing on lint, unit_tests, benchmark-regression, and the aggregate status-check. The coverage gate was skipped (it only runs when unit_tests passes) — so we cannot verify the >= 97% coverage requirement. The PR cannot be merged until all required gates are green.

CI Status

Job Status
lint FAILING
typecheck passing
security passing
quality passing
unit_tests FAILING
coverage SKIPPED (blocked by unit_tests failure)
integration_tests passing
e2e_tests passing
benchmark-regression FAILING
status-check FAILING

Blocking Issues Found

  1. Step phrase mismatch — Feature file scenario "Tree with json format contains tree decision IDs" uses the json tree envelope has key "data" but the only registered step definition is decorated with @then('the json tree envelope should have key "{key}"'). The missing step causes Behave to error, explaining the unit_tests CI failure.

  2. Wrong function signature on YAML stepstep_tree_yaml_command_value is decorated with @then('the yaml tree output should contain "plan tree"') (no capture group), yet the function accepts (context: Context, text: str) — Behave will error because it won't provide a text argument. Fix: remove the text: str parameter.

  3. Mid-function imports violate project rulesfrom collections import deque appears inside two function bodies in plan_explain_steps.py. Project rules mandate all imports at the top of the file. This also likely contributes to the lint CI failure.

  4. Coverage is skipped — The coverage CI job was skipped because unit_tests failed. Coverage >= 97% is a hard merge gate. Once unit tests are fixed, the author must confirm coverage still passes.

  5. PR has no milestone — The PR is missing its milestone assignment. Per CONTRIBUTING.md, the PR must be assigned to the same milestone as the linked issue. Issue #11041 is in milestone v3.2.0 — the PR must match.

  6. Linked entity #11041 is a PR, not an issueCloses: #11041 closes another PR, not a tracking issue. PRs should close Issues. Ensure the PR body uses Closes #N referencing the correct issue (not another PR), and verify the correct issue number.

  7. Forgejo dependency direction not set — Per CONTRIBUTING.md, the PR must block the linked issue (PR blocks issue). Currently PR #11071 has no blocking relationships set in Forgejo. Fix: on PR #11071, add the issue under "blocks".

  8. Benchmark regression CI failing — The benchmark-regression job is failing. Investigate whether this regression was introduced by this PR or is pre-existing. If introduced by this PR, it must be fixed.

  9. Missing trailing newline in CONTRIBUTORS.md — The diff shows no newline at end of file for the last line of CONTRIBUTORS.md. This will fail lint EOF checks. Fix: ensure the file ends with a newline.

Non-Blocking Observations

  • The step_tree_yaml_contains implementation is overly complex: the condition checking "decision_id" in context.pe_tree_yaml in the if-branch is always true if the YAML contains any decision_id. Suggestion: simplify to a straight string-in-string check.

  • Changelog entry has a redundant parenthetical: "Output Rendering Framework (Output Rendering Framework)" — the inline parenthetical repeats the section title. Suggestion: remove the redundant parenthetical.

  • The deque[dict] annotation uses an unsubscripted dict. For Pyright strict compliance, prefer deque[dict[str, Any]].

What is correct

  • The production change in src/cleveragents/cli/commands/plan.py is correct: adding command="agents plan tree" to the format_output() call properly populates the envelope per spec.
  • The _capture_format_output helper update in steps (adding the command parameter) is correct.
  • The step_format_tree_json and step_format_tree_yaml when-steps correctly pass command="plan tree" to the helper.
  • Most of the new step definitions are well-structured and the envelope assertions are logically sound.
  • CHANGELOG.md entry is in the right ### Fixed section under [Unreleased].

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

## Review Summary This PR addresses the correct spec gap (wrapping `plan tree` JSON/YAML output in the command envelope) and the production code change in `plan.py` is correct and minimal. However, there are **multiple blocking issues** in the test code and PR metadata that must be fixed before this can be approved. CI is currently failing on `lint`, `unit_tests`, `benchmark-regression`, and the aggregate `status-check`. The `coverage` gate was **skipped** (it only runs when `unit_tests` passes) — so we cannot verify the >= 97% coverage requirement. The PR cannot be merged until all required gates are green. ### CI Status | Job | Status | |-----|--------| | lint | FAILING | | typecheck | passing | | security | passing | | quality | passing | | unit_tests | FAILING | | coverage | SKIPPED (blocked by unit_tests failure) | | integration_tests | passing | | e2e_tests | passing | | benchmark-regression | FAILING | | status-check | FAILING | ### Blocking Issues Found 1. **Step phrase mismatch** — Feature file scenario "Tree with json format contains tree decision IDs" uses `the json tree envelope has key "data"` but the only registered step definition is decorated with `@then('the json tree envelope should have key "{key}"')`. The missing step causes Behave to error, explaining the unit_tests CI failure. 2. **Wrong function signature on YAML step** — `step_tree_yaml_command_value` is decorated with `@then('the yaml tree output should contain "plan tree"')` (no capture group), yet the function accepts `(context: Context, text: str)` — Behave will error because it won't provide a `text` argument. Fix: remove the `text: str` parameter. 3. **Mid-function imports violate project rules** — `from collections import deque` appears inside two function bodies in `plan_explain_steps.py`. Project rules mandate all imports at the top of the file. This also likely contributes to the `lint` CI failure. 4. **Coverage is skipped** — The `coverage` CI job was skipped because `unit_tests` failed. Coverage >= 97% is a hard merge gate. Once unit tests are fixed, the author must confirm coverage still passes. 5. **PR has no milestone** — The PR is missing its milestone assignment. Per CONTRIBUTING.md, the PR must be assigned to the same milestone as the linked issue. Issue #11041 is in milestone `v3.2.0` — the PR must match. 6. **Linked entity #11041 is a PR, not an issue** — `Closes: #11041` closes another PR, not a tracking issue. PRs should close Issues. Ensure the PR body uses `Closes #N` referencing the correct issue (not another PR), and verify the correct issue number. 7. **Forgejo dependency direction not set** — Per CONTRIBUTING.md, the PR must block the linked issue (PR blocks issue). Currently PR #11071 has no blocking relationships set in Forgejo. Fix: on PR #11071, add the issue under "blocks". 8. **Benchmark regression CI failing** — The `benchmark-regression` job is failing. Investigate whether this regression was introduced by this PR or is pre-existing. If introduced by this PR, it must be fixed. 9. **Missing trailing newline in CONTRIBUTORS.md** — The diff shows no newline at end of file for the last line of `CONTRIBUTORS.md`. This will fail lint EOF checks. Fix: ensure the file ends with a newline. ### Non-Blocking Observations - The `step_tree_yaml_contains` implementation is overly complex: the condition checking `"decision_id" in context.pe_tree_yaml` in the if-branch is always true if the YAML contains any decision_id. Suggestion: simplify to a straight string-in-string check. - Changelog entry has a redundant parenthetical: "Output Rendering Framework (Output Rendering Framework)" — the inline parenthetical repeats the section title. Suggestion: remove the redundant parenthetical. - The `deque[dict]` annotation uses an unsubscripted `dict`. For Pyright strict compliance, prefer `deque[dict[str, Any]]`. ### What is correct - The production change in `src/cleveragents/cli/commands/plan.py` is correct: adding `command="agents plan tree"` to the `format_output()` call properly populates the envelope per spec. - The `_capture_format_output` helper update in steps (adding the `command` parameter) is correct. - The `step_format_tree_json` and `step_format_tree_yaml` when-steps correctly pass `command="plan tree"` to the helper. - Most of the new step definitions are well-structured and the envelope assertions are logically sound. - CHANGELOG.md entry is in the right `### Fixed` section under `[Unreleased]`. --- Automated by CleverAgents Bot Supervisor: PR Review | Agent: pr-review-worker
Owner

Suggestion (non-blocking): The changelog entry contains a redundant parenthetical — "Output Rendering Framework (Output Rendering Framework)" repeats the section name. Consider removing the parenthetical:

spec's Output Rendering Framework, with a top-level envelope...
Suggestion (non-blocking): The changelog entry contains a redundant parenthetical — "Output Rendering Framework (Output Rendering Framework)" repeats the section name. Consider removing the parenthetical: ``` spec's Output Rendering Framework, with a top-level envelope... ```
@ -39,3 +39,4 @@
* HAL 9000 has contributed the Strategize phase full context snapshot fix (issue #9056): added `_build_strategize_context_snapshot()` helper to `PlanLifecycleService`, updated `_try_record_decision()` to accept and forward a `ContextSnapshot` parameter, and added BDD test coverage verifying all four `ContextSnapshot` fields (`hot_context_hash`, `hot_context_ref`, `actor_state_ref`, `relevant_resources`) are populated during the Strategize phase.
* HAL 9000 has contributed the ACMS context path matching fix (PR #10975 / issue #10972): corrects `_path_matches()` and `_matches_pattern()` to properly match absolute fragment paths against relative glob patterns by auto-prefixing with `**/` before calling `PurePath.full_match()`, preventing silent inefficacy of include/exclude filters for absolute paths in fragment metadata.
* HAL 9000 has contributed the plan tree JSON/YAML spec-compliant envelope fix (issue #11041): wrapped `agents plan tree` JSON and YAML output in the spec-required command envelope (`command`, `status`, `exit_code`, `data`, `timing`, `messages`), updated BDD step definitions to validate envelope structure, and removed the `@tdd_expected_fail` tag from the previously-failing JSON tree format test (issue #4254).
Owner

BLOCKER: Missing trailing newline at end of file

The diff shows no newline at end of file for this last line. This will fail ruff's EOF lint check.

Fix: Ensure the file ends with a newline character after the last bullet line.

**BLOCKER: Missing trailing newline at end of file** The diff shows no newline at end of file for this last line. This will fail ruff's EOF lint check. Fix: Ensure the file ends with a newline character after the last bullet line.
Owner

BLOCKER: Step phrase mismatch causing unit_tests CI failure

This line uses:

And the json tree envelope has key "data"

But the only registered step definition in plan_explain_steps.py is:

@then('the json tree envelope should have key "{key}"')

Note the difference: has key vs should have key. Behave will raise NotImplementedError: Step not found for this line, causing the scenario to fail.

Fix: Change the feature file to match the existing step:

And the json tree envelope should have key "data"
**BLOCKER: Step phrase mismatch causing unit_tests CI failure** This line uses: ```gherkin And the json tree envelope has key "data" ``` But the only registered step definition in `plan_explain_steps.py` is: ```python @then('the json tree envelope should have key "{key}"') ``` Note the difference: **`has key`** vs **`should have key`**. Behave will raise `NotImplementedError: Step not found` for this line, causing the scenario to fail. Fix: Change the feature file to match the existing step: ```gherkin And the json tree envelope should have key "data" ```
Owner

BLOCKER: Mid-function import violates project rules and likely causes lint failure

from collections import deque

This import appears inside the function body. Project rules are explicit: all imports must be at the top of the file (if TYPE_CHECKING: is the only exception). Ruff will flag this as a lint violation.

Fix: Move from collections import deque to the top of the file, alongside the other standard-library imports. The same issue exists in a second function further down in this file.

**BLOCKER: Mid-function import violates project rules and likely causes lint failure** ```python from collections import deque ``` This import appears inside the function body. Project rules are explicit: all imports must be at the top of the file (`if TYPE_CHECKING:` is the only exception). Ruff will flag this as a lint violation. Fix: Move `from collections import deque` to the top of the file, alongside the other standard-library imports. The same issue exists in a second function further down in this file.
Owner

BLOCKER: Wrong function signature — extra text: str parameter Behave will not provide

This step:

@then('the yaml tree output should contain "plan tree"')
def step_tree_yaml_command_value(context: Context, text: str) -> None:

The decorator has no capture group (no {text} in the pattern), so Behave will call this function with only context. The extra text: str parameter has no corresponding capture group — Behave will raise a TypeError at runtime.

Fix: Remove the unused text: str parameter:

@then('the yaml tree output should contain "plan tree"')
def step_tree_yaml_command_value(context: Context) -> None:
    assert "plan tree" in context.pe_tree_yaml, (
        f"Expected 'plan tree' command value in tree YAML:\n{context.pe_tree_yaml}"
    )
**BLOCKER: Wrong function signature — extra `text: str` parameter Behave will not provide** This step: ```python @then('the yaml tree output should contain "plan tree"') def step_tree_yaml_command_value(context: Context, text: str) -> None: ``` The decorator has **no capture group** (no `{text}` in the pattern), so Behave will call this function with only `context`. The extra `text: str` parameter has no corresponding capture group — Behave will raise a `TypeError` at runtime. Fix: Remove the unused `text: str` parameter: ```python @then('the yaml tree output should contain "plan tree"') def step_tree_yaml_command_value(context: Context) -> None: assert "plan tree" in context.pe_tree_yaml, ( f"Expected 'plan tree' command value in tree YAML:\n{context.pe_tree_yaml}" ) ```
Owner

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

--- Automated by CleverAgents Bot Supervisor: PR Review | Agent: pr-review-worker
HAL9001 left a comment

First Review — fix(plan): wrap plan tree JSON/YAML output in spec-required command envelope

Summary

The intent of this PR is correct and the core production-code change is minimal and well-targeted. However, there are four blocking issues that must be fixed before this PR can be approved:

  1. Spec violation — the command envelope value does not match what the specification requires.
  2. Undefined Behave step — the feature file uses a step text that has no matching step definition, causing a guaranteed test failure.
  3. Broken step function signature — a YAML step function declares a parameter that Behave will never pass, causing a TypeError at runtime.
  4. Missing trailing newline in CONTRIBUTORS.md — causes a lint failure (ruff W292), directly confirmed by the failing CI / lint check.

CI is failing on lint, unit_tests, and benchmark-regression, all consistent with defects 1–4 above.


CI Status

Check Result
lint FAILING
typecheck passing
security passing
quality passing
unit_tests FAILING
coverage skipped (unit_tests failed)
integration_tests passing
e2e_tests passing
build passing
benchmark-regression FAILING
status-check FAILING (aggregate)

Review Checklist Results

Category Result Notes
1. Correctness BLOCKING Command string mismatches spec; broken step definitions cause test failures
2. Specification Alignment BLOCKING command value "agents plan tree" contradicts spec which requires "plan tree"
3. Test Quality BLOCKING Undefined step text + broken function signature cause runtime failures
4. Type Safety pass No new # type: ignore; signatures are fine
5. Readability minor suggestion deque import inside function body should move to module top-level
6. Performance pass BFS traversal is appropriate
7. Security pass No new attack surface
8. Code Style BLOCKING Missing trailing newline in CONTRIBUTORS.md (lint W292)
9. Documentation minor suggestion Duplicate phrase in CHANGELOG prose
10. Commit & PR Quality minor Milestone not set on PR; referenced issue #11041 is itself an open PR

Please address all four blocking issues. Inline comments below provide exact fix instructions for each.


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

## First Review — `fix(plan): wrap plan tree JSON/YAML output in spec-required command envelope` ### Summary The intent of this PR is correct and the core production-code change is minimal and well-targeted. However, there are **four blocking issues** that must be fixed before this PR can be approved: 1. **Spec violation** — the `command` envelope value does not match what the specification requires. 2. **Undefined Behave step** — the feature file uses a step text that has no matching step definition, causing a guaranteed test failure. 3. **Broken step function signature** — a YAML step function declares a parameter that Behave will never pass, causing a `TypeError` at runtime. 4. **Missing trailing newline in `CONTRIBUTORS.md`** — causes a lint failure (ruff W292), directly confirmed by the failing `CI / lint` check. CI is failing on `lint`, `unit_tests`, and `benchmark-regression`, all consistent with defects 1–4 above. --- ### CI Status | Check | Result | |---|---| | lint | FAILING | | typecheck | passing | | security | passing | | quality | passing | | unit_tests | FAILING | | coverage | skipped (unit_tests failed) | | integration_tests | passing | | e2e_tests | passing | | build | passing | | benchmark-regression | FAILING | | status-check | FAILING (aggregate) | --- ### Review Checklist Results | Category | Result | Notes | |---|---|---| | 1. Correctness | BLOCKING | Command string mismatches spec; broken step definitions cause test failures | | 2. Specification Alignment | BLOCKING | `command` value `"agents plan tree"` contradicts spec which requires `"plan tree"` | | 3. Test Quality | BLOCKING | Undefined step text + broken function signature cause runtime failures | | 4. Type Safety | pass | No new `# type: ignore`; signatures are fine | | 5. Readability | minor suggestion | `deque` import inside function body should move to module top-level | | 6. Performance | pass | BFS traversal is appropriate | | 7. Security | pass | No new attack surface | | 8. Code Style | BLOCKING | Missing trailing newline in CONTRIBUTORS.md (lint W292) | | 9. Documentation | minor suggestion | Duplicate phrase in CHANGELOG prose | | 10. Commit & PR Quality | minor | Milestone not set on PR; referenced issue #11041 is itself an open PR | --- Please address all four blocking issues. Inline comments below provide exact fix instructions for each. --- Automated by CleverAgents Bot Supervisor: PR Review | Agent: pr-review-worker
Owner

Suggestion (non-blocking) — Duplicate phrase in prose

Line 100 reads:

...the spec's Output Rendering Framework (Output Rendering Framework), with...

The phrase Output Rendering Framework appears twice — likely a copy-paste artifact from a Markdown link that lost its anchor text. Consider simplifying to:

...the spec's Output Rendering Framework, with...


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

**Suggestion (non-blocking) — Duplicate phrase in prose** Line 100 reads: > ...the spec's Output Rendering Framework (Output Rendering Framework), with... The phrase `Output Rendering Framework` appears twice — likely a copy-paste artifact from a Markdown link that lost its anchor text. Consider simplifying to: > ...the spec's Output Rendering Framework, with... --- Automated by CleverAgents Bot Supervisor: PR Review | Agent: pr-review-worker
Owner

BLOCKING — Missing trailing newline (ruff W292 / lint failure)

The new line appended to this file does not end with a newline character (\ No newline at end of file in the diff). This violates the ruff W292 rule (no-newline-at-end-of-file) and is a direct cause of the failing CI / lint check.

How to fix: Ensure the file ends with a newline character after the final line. Most editors insert this automatically; verify with:

tail -c1 CONTRIBUTORS.md | od -c   # should show \n

If missing, append one:

echo '' >> CONTRIBUTORS.md

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

**BLOCKING — Missing trailing newline (ruff W292 / lint failure)** The new line appended to this file does not end with a newline character (`\ No newline at end of file` in the diff). This violates the ruff W292 rule (`no-newline-at-end-of-file`) and is a direct cause of the failing `CI / lint` check. **How to fix:** Ensure the file ends with a newline character after the final line. Most editors insert this automatically; verify with: ```bash tail -c1 CONTRIBUTORS.md | od -c # should show \n ``` If missing, append one: ```bash echo '' >> CONTRIBUTORS.md ``` --- Automated by CleverAgents Bot Supervisor: PR Review | Agent: pr-review-worker
Owner

BLOCKING — Undefined Behave step: text mismatch

Line 123 of the feature file reads:

And the json tree envelope has key "data"

But the only relevant step definition is decorated with:

@then('the json tree envelope should have key "{key}"')

has key does not match should have key. Behave will report this as an Undefined step, failing the Tree with json format contains tree decision IDs scenario at runtime.

How to fix: Update line 123 of the feature file to use the already-defined step text:

And the json tree envelope should have key "data"

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

**BLOCKING — Undefined Behave step: text mismatch** Line 123 of the feature file reads: ```gherkin And the json tree envelope has key "data" ``` But the only relevant step definition is decorated with: ```python @then('the json tree envelope should have key "{key}"') ``` `has key` does not match `should have key`. Behave will report this as an **Undefined step**, failing the `Tree with json format contains tree decision IDs` scenario at runtime. **How to fix:** Update line 123 of the feature file to use the already-defined step text: ```gherkin And the json tree envelope should have key "data" ``` --- Automated by CleverAgents Bot Supervisor: PR Review | Agent: pr-review-worker
Owner

Suggestion (non-blocking) — Move from collections import deque to module top-level

The from collections import deque import appears inline inside step_tree_envelope_data_contains (new code, around line 444) and also inside _collect_ids (line 514). Moving it to the module-level import block (alongside the existing imports at lines 7–20) is consistent with project style, avoids repeated lazy imports, and makes the dependency immediately visible to readers and static analysers.


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

**Suggestion (non-blocking) — Move `from collections import deque` to module top-level** The `from collections import deque` import appears inline inside `step_tree_envelope_data_contains` (new code, around line 444) and also inside `_collect_ids` (line 514). Moving it to the module-level import block (alongside the existing imports at lines 7–20) is consistent with project style, avoids repeated lazy imports, and makes the dependency immediately visible to readers and static analysers. --- Automated by CleverAgents Bot Supervisor: PR Review | Agent: pr-review-worker
Owner

BLOCKING — Broken step function signature: spurious text parameter

The step decorator is:

@then('the yaml tree output should contain "plan tree"')
def step_tree_yaml_command_value(context: Context, text: str) -> None:

The pattern 'the yaml tree output should contain "plan tree"' contains no capture groups, so Behave calls this function with only context. The declared second parameter text: str causes Python to raise TypeError: step_tree_yaml_command_value() missing 1 required positional argument: 'text'. The function body also never uses text.

How to fix: Remove the text: str parameter:

@then('the yaml tree output should contain "plan tree"')
def step_tree_yaml_command_value(context: Context) -> None:
    assert "plan tree" in context.pe_tree_yaml, (
        f"Expected 'plan tree' command value in tree YAML:\n{context.pe_tree_yaml}"
    )

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

**BLOCKING — Broken step function signature: spurious `text` parameter** The step decorator is: ```python @then('the yaml tree output should contain "plan tree"') def step_tree_yaml_command_value(context: Context, text: str) -> None: ``` The pattern `'the yaml tree output should contain "plan tree"'` contains **no capture groups**, so Behave calls this function with only `context`. The declared second parameter `text: str` causes Python to raise `TypeError: step_tree_yaml_command_value() missing 1 required positional argument: 'text'`. The function body also never uses `text`. **How to fix:** Remove the `text: str` parameter: ```python @then('the yaml tree output should contain "plan tree"') def step_tree_yaml_command_value(context: Context) -> None: assert "plan tree" in context.pe_tree_yaml, ( f"Expected 'plan tree' command value in tree YAML:\n{context.pe_tree_yaml}" ) ``` --- Automated by CleverAgents Bot Supervisor: PR Review | Agent: pr-review-worker
Owner

BLOCKING — Spec Violation: wrong command string in envelope

The spec (docs/specification.md line 14538) explicitly defines the envelope command field for this command as:

"command": "plan tree"

and for YAML (line 14598):

command: plan tree

But this code passes command="agents plan tree" (with the agents prefix), making production output non-conformant with the specification.

How to fix:

# Before (wrong — does not match spec)
console.print(format_output(tree_data, fmt, command="agents plan tree"))

# After (correct — matches spec §14538)
console.print(format_output(tree_data, fmt, command="plan tree"))

Note: the BDD step helpers at features/steps/plan_explain_steps.py already pass command="plan tree" (without the prefix), so fixing the production code also makes it consistent with the test helpers.


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

**BLOCKING — Spec Violation: wrong `command` string in envelope** The spec (`docs/specification.md` line 14538) explicitly defines the envelope `command` field for this command as: ```json "command": "plan tree" ``` and for YAML (line 14598): ```yaml command: plan tree ``` But this code passes `command="agents plan tree"` (with the `agents ` prefix), making production output non-conformant with the specification. **How to fix:** ```python # Before (wrong — does not match spec) console.print(format_output(tree_data, fmt, command="agents plan tree")) # After (correct — matches spec §14538) console.print(format_output(tree_data, fmt, command="plan tree")) ``` Note: the BDD step helpers at `features/steps/plan_explain_steps.py` already pass `command="plan tree"` (without the prefix), so fixing the production code also makes it consistent with the test helpers. --- 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 41s
CI / push-validation (pull_request) Successful in 45s
CI / build (pull_request) Successful in 1m2s
Required
Details
CI / lint (pull_request) Failing after 1m12s
Required
Details
CI / typecheck (pull_request) Successful in 1m26s
Required
Details
CI / quality (pull_request) Successful in 1m28s
Required
Details
CI / benchmark-regression (pull_request) Failing after 1m1s
CI / security (pull_request) Successful in 1m53s
Required
Details
CI / unit_tests (pull_request) Failing after 3m18s
Required
Details
CI / coverage (pull_request) Has been skipped
Required
Details
CI / docker (pull_request) Has been skipped
Required
Details
CI / e2e_tests (pull_request) Successful in 4m27s
CI / integration_tests (pull_request) Successful in 4m37s
Required
Details
CI / status-check (pull_request) Failing after 3s
This pull request has changes conflicting with the target branch.
  • CONTRIBUTORS.md
  • features/plan_explain.feature
  • src/cleveragents/cli/commands/plan.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin fix/11041-plan-tree-envelope:fix/11041-plan-tree-envelope
git switch fix/11041-plan-tree-envelope
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!11071
No description provided.