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

Merged
HAL9000 merged 2 commits from fix/11041-plan-tree-envelope into master 2026-06-17 09:48:54 +00:00
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
CHANGELOG.md Outdated
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... ```
CONTRIBUTORS.md Outdated
@ -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
CHANGELOG.md Outdated
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
Author
Owner

🌱 Grooming: proceed — PR cleared for processing.

(check no_duplicates, category no_duplicates)

PR #11071 is not a duplicate. While PR #11044 exists with an identical title ("fix(plan): wrap plan tree JSON/YAML output in spec-required command envelope") and targets the same issue (#11041), #11071 is substantially more complete: 109 additions across 5 files vs #11044's 1 addition across 1 file. #11071 includes full BDD test updates, CHANGELOG, and CONTRIBUTORS entries, making it the canonical/superior implementation. Other plan-envelope PRs (#9817, #9827, #11107, #11224) wrap different commands (apply, status), not plan tree.

**🌱 Grooming: proceed** — PR cleared for processing. (check `no_duplicates`, category `no_duplicates`) PR #11071 is not a duplicate. While PR #11044 exists with an identical title ("fix(plan): wrap plan tree JSON/YAML output in spec-required command envelope") and targets the same issue (#11041), #11071 is substantially more complete: 109 additions across 5 files vs #11044's 1 addition across 1 file. #11071 includes full BDD test updates, CHANGELOG, and CONTRIBUTORS entries, making it the canonical/superior implementation. Other plan-envelope PRs (#9817, #9827, #11107, #11224) wrap different commands (apply, status), not plan tree. <!-- controller:fingerprint:3e1341dd08a8ebeb -->
Author
Owner

📋 Estimate: tier 1.

Core fix is a single-line change in plan.py (adding command parameter to format_output call), but CI has two distinct failures requiring fixes: (1) trivial lint — two F541 f-string-without-placeholder errors in plan_explain_steps.py; (2) AmbiguousStep collision — a new specific Behave step '@then the yaml tree output should contain "command:"' conflicts with the existing generic '@then the yaml tree output should contain "{text}"' step at line 456. Resolving the step conflict requires understanding the BDD step registry and restructuring the new assertions to avoid the ambiguity. Multi-file scope (plan.py, plan_explain_steps.py, plan_explain.feature), touches test fixtures with real logic issues — standard Tier 1 engineering work.

**📋 Estimate: tier 1.** Core fix is a single-line change in plan.py (adding command parameter to format_output call), but CI has two distinct failures requiring fixes: (1) trivial lint — two F541 f-string-without-placeholder errors in plan_explain_steps.py; (2) AmbiguousStep collision — a new specific Behave step '@then the yaml tree output should contain "command:"' conflicts with the existing generic '@then the yaml tree output should contain "{text}"' step at line 456. Resolving the step conflict requires understanding the BDD step registry and restructuring the new assertions to avoid the ambiguity. Multi-file scope (plan.py, plan_explain_steps.py, plan_explain.feature), touches test fixtures with real logic issues — standard Tier 1 engineering work. <!-- controller:fingerprint:b63c8d59610f15aa -->
- Change command from "agents plan tree" to "plan tree" per spec
- Fix AmbiguousStep: remove three literal step functions that shadowed
  the generic '{text}' step, causing all 32 feature files to error
- Fix step_tree_envelope_data_contains to check for key presence in
  nodes rather than checking for the literal key name as a value
- Fix plan_explain.feature step text mismatch (has key -> should have key)
- Move deque import to module level; remove two mid-function imports
- Remove f-prefix from two f-strings without placeholders (F541)
chore: worker ruff auto-fix (pre-push lint gate)
Some checks failed
CI / push-validation (pull_request) Successful in 32s
CI / helm (pull_request) Successful in 45s
CI / build (pull_request) Successful in 48s
CI / lint (pull_request) Successful in 1m12s
CI / quality (pull_request) Successful in 1m12s
CI / typecheck (pull_request) Successful in 1m22s
CI / security (pull_request) Successful in 1m52s
CI / e2e_tests (pull_request) Failing after 3m52s
CI / integration_tests (pull_request) Failing after 6m1s
CI / unit_tests (pull_request) Failing after 8m31s
CI / coverage (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 3s
CI / benchmark-publish (pull_request) Has been cancelled
CI / benchmark-regression (pull_request) Has been cancelled
e3e5aedcd5
Author
Owner

(attempt #5, tier 1)

🔧 Implementer attempt — resolved.

Pushed 2 commits: daa3e63, e3e5aed.

Files touched: features/plan_explain.feature, features/steps/plan_explain_steps.py, src/cleveragents/cli/commands/plan.py.

_(attempt #5, tier 1)_ **🔧 Implementer attempt — `resolved`.** Pushed 2 commits: `daa3e63`, `e3e5aed`. Files touched: `features/plan_explain.feature`, `features/steps/plan_explain_steps.py`, `src/cleveragents/cli/commands/plan.py`. <!-- controller:fingerprint:a292671ef88cdba0 -->
drew referenced this pull request from a commit 2026-06-11 00:19:09 +00:00
ci: stop master workflow on PR updates
Some checks failed
CI / lint (pull_request) Has been cancelled
CI / typecheck (pull_request) Has been cancelled
CI / security (pull_request) Has been cancelled
CI / quality (pull_request) Has been cancelled
CI / unit_tests (pull_request) Has been cancelled
CI / integration_tests (pull_request) Has been cancelled
CI / e2e_tests (pull_request) Has been cancelled
CI / coverage (pull_request) Has been cancelled
CI / build (pull_request) Has been cancelled
CI / docker (pull_request) Has been cancelled
CI / helm (pull_request) Has been cancelled
CI / push-validation (pull_request) Has been cancelled
CI / status-check (pull_request) Has been cancelled
6d8f0ebe1c
Remove the stale pull_request trigger from master.yml so PR branch commits do not launch the master workflow.

Maintenance patch for PR #11071.
Author
Owner

🌱 Grooming: proceed — PR cleared for processing.

(check no_duplicates, category no_duplicates)

PR #11071 shares an identical title with #11044 ("fix(plan): wrap plan tree JSON/YAML output in spec-required command envelope"), but is substantially more complete: 88 additions across 6 files (including comprehensive test updates in features/steps/ and features/plan_explain.feature) versus #11044's minimal 1-addition stub. The anchor PR is the better, more-complete implementation and should proceed rather than be marked as a duplicate.

**🌱 Grooming: proceed** — PR cleared for processing. (check `no_duplicates`, category `no_duplicates`) PR #11071 shares an identical title with #11044 ("fix(plan): wrap plan tree JSON/YAML output in spec-required command envelope"), but is substantially more complete: 88 additions across 6 files (including comprehensive test updates in features/steps/ and features/plan_explain.feature) versus #11044's minimal 1-addition stub. The anchor PR is the better, more-complete implementation and should proceed rather than be marked as a duplicate. <!-- controller:fingerprint:06c014ebcbc73d0d -->
Author
Owner

📋 Estimate: tier 1.

Multi-file change (6 files) touching CLI command code, BDD feature file, and BDD step definitions. Core fix is straightforward (adding a command parameter to format_output()), but test burden is moderate: 7 new envelope-aware BDD validators added and @tdd_expected_fail tag removed. All 13 CI gates are failing, indicating the branch is likely stale or has implementation gaps requiring diagnosis and repair. Cross-file scope with non-trivial test logic changes puts this firmly at tier 1.

**📋 Estimate: tier 1.** Multi-file change (6 files) touching CLI command code, BDD feature file, and BDD step definitions. Core fix is straightforward (adding a command parameter to format_output()), but test burden is moderate: 7 new envelope-aware BDD validators added and @tdd_expected_fail tag removed. All 13 CI gates are failing, indicating the branch is likely stale or has implementation gaps requiring diagnosis and repair. Cross-file scope with non-trivial test logic changes puts this firmly at tier 1. <!-- controller:fingerprint:94d59013a457ba8e -->
chore: re-trigger CI [controller]
Some checks failed
CI / lint (pull_request) Successful in 46s
CI / helm (pull_request) Successful in 36s
CI / build (pull_request) Successful in 37s
CI / quality (pull_request) Successful in 1m13s
CI / typecheck (pull_request) Successful in 1m24s
CI / security (pull_request) Successful in 1m25s
CI / push-validation (pull_request) Successful in 22s
CI / e2e_tests (pull_request) Failing after 3m24s
CI / integration_tests (pull_request) Failing after 4m34s
CI / unit_tests (pull_request) Failing after 5m49s
CI / coverage (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 2s
d5b35ecbad
Author
Owner

(attempt #8, tier 1)

🔧 Implementer attempt — blocked.

Blockers:

  • agent-side push detected: remote fix/11041-plan-tree-envelope is at d5b35ecbad but dispatch base was 6d8f0ebe1c. The implementer pushed from inside the worktree (forbidden by the git contract) OR a third party pushed during the attempt. Re-dispatch will re-prefetch and pick up the new head.
_(attempt #8, tier 1)_ **🔧 Implementer attempt — `blocked`.** Blockers: - agent-side push detected: remote fix/11041-plan-tree-envelope is at d5b35ecbadc0 but dispatch base was 6d8f0ebe1ce8. The implementer pushed from inside the worktree (forbidden by the git contract) OR a third party pushed during the attempt. Re-dispatch will re-prefetch and pick up the new head. <!-- controller:fingerprint:b69eb1feaa9382e5 -->
Author
Owner

(attempt #9, tier 2)

🔧 Implementer attempt — rebase-failed.

Blockers:

  • CHANGELOG.md
  • CONTRIBUTORS.md
  • features/plan_explain.feature
  • features/steps/plan_explain_steps.py
  • src/cleveragents/cli/commands/plan.py
_(attempt #9, tier 2)_ **🔧 Implementer attempt — `rebase-failed`.** Blockers: - CHANGELOG.md - CONTRIBUTORS.md - features/plan_explain.feature - features/steps/plan_explain_steps.py - src/cleveragents/cli/commands/plan.py <!-- controller:fingerprint:8fba1c8aa033fa78 -->
HAL9000 force-pushed fix/11041-plan-tree-envelope from d5b35ecbad
Some checks failed
CI / lint (pull_request) Successful in 46s
CI / helm (pull_request) Successful in 36s
CI / build (pull_request) Successful in 37s
CI / quality (pull_request) Successful in 1m13s
CI / typecheck (pull_request) Successful in 1m24s
CI / security (pull_request) Successful in 1m25s
CI / push-validation (pull_request) Successful in 22s
CI / e2e_tests (pull_request) Failing after 3m24s
CI / integration_tests (pull_request) Failing after 4m34s
CI / unit_tests (pull_request) Failing after 5m49s
CI / coverage (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 2s
to 14d6a9ed0d
All checks were successful
CI / load-versions (pull_request) Successful in 15s
CI / push-validation (pull_request) Successful in 25s
CI / lint (pull_request) Successful in 54s
CI / typecheck (pull_request) Successful in 1m4s
CI / security (pull_request) Successful in 1m8s
CI / build (pull_request) Successful in 37s
CI / quality (pull_request) Successful in 1m21s
CI / helm (pull_request) Successful in 35s
CI / unit_tests (pull_request) Successful in 7m17s
CI / docker (pull_request) Successful in 1m55s
CI / integration_tests (pull_request) Successful in 10m59s
CI / coverage (pull_request) Successful in 13m31s
CI / status-check (pull_request) Successful in 3s
2026-06-17 08:53:38 +00:00
Compare
Author
Owner

(attempt #11, tier 2)

🔧 Implementer attempt — ci-not-ready.

_(attempt #11, tier 2)_ **🔧 Implementer attempt — `ci-not-ready`.** <!-- controller:fingerprint:b2fba94b08cf6a4d -->
HAL9001 approved these changes 2026-06-17 09:48:42 +00:00
HAL9001 left a comment

Approved

Reviewed at commit 14d6a9e.

Confidence: high.

**✅ Approved** Reviewed at commit `14d6a9e`. Confidence: high. <!-- controller:fingerprint:330c3cc5e0647bb8 -->
Author
Owner

Claimed by merge_drive.py (pid 2202036) until 2026-06-17T11:18:50.144554+00:00.

This claim is advisory and will be released when the cycle ends, or after the TTL by a sibling driver's expired-claim sweep.

<!-- merge_drive.py: claim --> Claimed by `merge_drive.py` (pid 2202036) until `2026-06-17T11:18:50.144554+00:00`. This claim is advisory and will be released when the cycle ends, or after the TTL by a sibling driver's expired-claim sweep.
HAL9001 approved these changes 2026-06-17 09:48:53 +00:00
HAL9001 left a comment

Approved by the controller reviewer stage (workflow 454).

Approved by the controller reviewer stage (workflow 454).
HAL9000 merged commit 2d7ed9ce4f into master 2026-06-17 09:48:54 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 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.