From 887e8aebc723bbceebbf1d84302fe9cdd7dede74 Mon Sep 17 00:00:00 2001 From: HAL9000 Date: Thu, 7 May 2026 19:05:31 +0000 Subject: [PATCH] fix(plan): include decision_id field in plan tree JSON output The step_tree_json_valid BDD step was asserting a raw list from format_output, but the function wraps all machine-readable output in a spec-required envelope dict ({"data": [...]}). This PR fixes the step to correctly validate the envelope structure (dict with data key) and removes @tdd_expected_fail from the @tdd_issue_4254 scenario so it runs as a permanent regression guard. The code producing decision_id in tree nodes was already correct; only the test assertion needed fixing. ISSUES CLOSED: #9096 --- CHANGELOG.md | 7 +++++++ CONTRIBUTORS.md | 1 + features/steps/plan_explain_steps.py | 8 +++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d8568c18..0b8c3a2e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -362,6 +362,13 @@ ensuring data is stored with proper parameter values. `hot_context_hash`, `hot_context_ref`, `actor_state_ref`, and `relevant_resources` are all populated for Strategize-phase decisions. +- **Plan tree JSON output missing `decision_id` field** (#9096): The `step_tree_json_valid` + BDD step was asserting a raw list from `format_output`, but the function wraps all + machine-readable output in a spec-required envelope dict (`{"data": [...]}`). Updated + the assertion to validate envelope structure and removed `@tdd_expected_fail` from the + `@tdd_issue_4254` scenario so it runs as a permanent regression guard. The code producing + `decision_id` in tree nodes was already correct; only the test assertion needed fixing. + ### Changed - Fixed stale `AUTO-BUG-POOL` tracking prefix references in automation-tracking.md documentation and agent-system-specification.md spec document, replaced with correct `AUTO-BUG-SUP` prefix used by the bug-hunt-pool-supervisor agent (#7875). diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 54802c6bc..3c52726b1 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -66,3 +66,4 @@ Below are some of the specific details of various contributions. * HAL 9000 has contributed the engine cache TOCTOU race condition fix (PR #8265 / issue #7566): added `MEMORY_ENGINES_LOCK` to `engine_cache.py` and wrapped the check-and-set operation in `UnitOfWork.engine` with `with MEMORY_ENGINES_LOCK:` to prevent concurrent threads from creating duplicate in-memory SQLite engine instances; also fixed a cache-hit bug where `self._engine` was never assigned on a cache hit. * HAL 9000 has contributed the plan correct JSON output envelope fix (PR #8662 / issue #8584): restructured `agents plan correct --format json` output to nest correction fields under `data.correction` and pass `command="plan correct"` to `format_output`, producing the spec-required CLI envelope. Added three BDD scenarios validating `data.correction.mode` (revert and append modes) and the `command` field. * HAL 9000 has contributed BDD feature file tag coverage improvements (#9124 / pr #9183): added required `@a2a`, `@session`, and `@cli` Gherkin tags to 30 feature files (8 A2A, 7 session, 15 CLI) to enable selective tag-based test filtering via `behave --tags=a2a,session,cli`. +* HAL 9000 has contributed the plan tree JSON `decision_id` fix (#9096): updated `step_tree_json_valid` in features/steps/plan_explain_steps.py to correctly handle the {"data": [...]} envelope structure produced by format_output, and removed @tdd_expected_fail from the @tdd_issue_4254 scenario so it runs as a permanent regression guard. diff --git a/features/steps/plan_explain_steps.py b/features/steps/plan_explain_steps.py index f664eb038..02a5eee3f 100644 --- a/features/steps/plan_explain_steps.py +++ b/features/steps/plan_explain_steps.py @@ -402,7 +402,13 @@ def step_roots_no_children(context: Context) -> None: @then("the json tree output should be valid json") def step_tree_json_valid(context: Context) -> None: parsed = json.loads(context.pe_tree_json) - assert isinstance(parsed, list), "Expected a JSON array" + assert isinstance(parsed, dict), "Expected a JSON envelope object" + assert "data" in parsed, "Expected data key in JSON envelope" + # format_output wraps data in a spec-required envelope dict; + # the actual tree array is in the "data" key. + assert isinstance(parsed["data"], list), ( + "Expected data to be a JSON array of tree nodes" + ) @then("the json tree output should be a valid json envelope")