feat(plan): implement agents plan tree decision tree rendering #9280

Open
opened 2026-04-14 13:57:32 +00:00 by HAL9000 · 1 comment
Owner

Metadata

  • Commit Message: feat(plan): implement agents plan tree decision tree rendering
  • Branch: feat/plan-tree-decision-rendering
  • Milestone: v3.2.0

Background and Context

The v3.2.0 milestone (M3: Decisions + Validations + Invariants) requires that agents plan tree renders the decision tree correctly. This command is a core observability tool that allows users and automated agents to inspect the full decision history of a plan execution — including which decisions were made, when, their types, and their current status (pending, completed, or reverted).

Currently, the agents plan tree command either lacks full implementation or does not expose the complete decision tree with all required metadata fields, status indicators, depth-limiting, and machine-readable JSON output. Without this command working correctly, users cannot:

  • Audit the decision history of a running or completed plan
  • Identify which decisions are candidates for correction via agents plan correct
  • Programmatically consume decision tree data in CI/CD pipelines or downstream tooling
  • Limit output to a specific depth when plans have deeply nested decision trees

This feature is a prerequisite for agents plan explain (which shows decision details) and agents plan correct (which re-executes from a targeted decision point), making it a critical path item for the milestone.

Expected Behavior

Running agents plan tree <PLAN_ID> should display a hierarchical tree view of all decisions recorded during plan execution. Each node in the tree should show:

  • Decision ID — unique identifier for the decision
  • Decision Type — e.g., strategy, tool_selection, parameter, branch
  • Timestamp — when the decision was recorded (ISO 8601)
  • Brief Summary — a short human-readable description of the decision
  • Status — one of pending, completed, or reverted

The command should support:

  • --format json — emit a machine-readable JSON representation of the full decision tree
  • --depth N — limit the rendered tree to N levels deep (default: unlimited)
  • Rich terminal output (default) with colour-coded status indicators
  • Plain text output (when --format plain or when stdout is not a TTY)

Example rich output:

Plan Decision Tree: plan-abc123
├── [completed] d-001 | strategy       | 2026-04-14T10:00:00Z | Selected iterative approach
│   ├── [completed] d-002 | tool_selection | 2026-04-14T10:01:00Z | Chose ruff for linting
│   └── [reverted]  d-003 | parameter      | 2026-04-14T10:02:00Z | Set max_retries=3
└── [pending]   d-004 | branch         | 2026-04-14T10:03:00Z | Awaiting user confirmation

Acceptance Criteria

  • agents plan tree <PLAN_ID> renders a hierarchical tree of all decisions for the given plan
  • Each tree node displays: decision ID, type, timestamp (ISO 8601), brief summary, and status
  • Status values pending, completed, and reverted are visually distinct in rich output (colour-coded or prefixed)
  • --format json emits a valid JSON document representing the full decision tree with all node fields
  • --depth N limits the rendered tree to N levels; nodes beyond depth N are omitted (not truncated mid-node)
  • When --depth 0 or --depth 1 is specified, only the root-level decisions are shown
  • Plain text output (non-TTY or --format plain) renders the tree using ASCII characters (|, +--, `--)
  • An unknown or non-existent PLAN_ID exits with a non-zero status code and a clear error message
  • A plan with zero decisions renders an empty tree with a summary line (e.g., No decisions recorded.)
  • Output validation checks structural components (presence of decision IDs, status labels, timestamps) — not exact character matching
  • Unit tests cover: normal tree, empty tree, --depth limiting, --format json, non-existent plan ID
  • BDD/integration tests cover the full CLI invocation for at least the happy path and the --format json path
  • Test coverage for the plan tree command and its supporting service/model code is ≥ 97%

Subtasks

  • ST-1: Define or extend the Decision model to include status field (pending | completed | reverted) and ensure it is persisted and retrievable
  • ST-2: Implement PlanTreeService.get_decision_tree(plan_id, depth=None) that returns a nested tree structure of Decision nodes
  • ST-3: Implement the tree_decisions_cmd() CLI handler in src/cleveragents/cli/commands/plan.py with --format and --depth options
  • ST-4: Implement the Rich renderer for the decision tree (colour-coded status, tree connectors, summary panel)
  • ST-5: Implement the plain-text renderer (ASCII tree connectors, no colour codes)
  • ST-6: Implement the JSON renderer (--format json) producing a structured document with all node fields
  • ST-7: Add --depth N filtering logic to the tree renderer (prune nodes beyond depth N)
  • ST-8: Add error handling for unknown plan IDs (non-zero exit, clear message)
  • ST-9: Add empty-tree handling (zero decisions — render summary line, exit 0)
  • ST-10: Write unit tests for PlanTreeService.get_decision_tree() covering: normal tree, empty tree, depth limiting
  • ST-11: Write unit tests for each renderer (Rich, plain, JSON) covering all status values and edge cases
  • ST-12: Write BDD/integration tests for agents plan tree CLI (happy path, --format json, --depth, unknown plan ID)
  • ST-13: Verify test coverage ≥ 97% for all new/modified modules; add missing tests as needed
  • ST-14: Update docs/specification.md and CLI help text to reflect the final command signature and output format

Definition of Done

The issue should be closed when all of the following are true:

  1. agents plan tree <PLAN_ID> is fully implemented and renders a correct hierarchical decision tree in rich, plain, and JSON formats
  2. All Acceptance Criteria checkboxes above are checked
  3. All Subtasks are completed
  4. CI passes (lint, type-check, unit tests, BDD tests)
  5. Test coverage for affected modules is ≥ 97%
  6. docs/specification.md and CLI --help output accurately describe the command signature and output format
  7. A peer review has approved the PR and it has been merged to the target branch

Automated by CleverAgents Bot
Agent: new-issue-creator

## Metadata - **Commit Message**: `feat(plan): implement agents plan tree decision tree rendering` - **Branch**: `feat/plan-tree-decision-rendering` - **Milestone**: v3.2.0 ## Background and Context The v3.2.0 milestone (M3: Decisions + Validations + Invariants) requires that `agents plan tree` renders the decision tree correctly. This command is a core observability tool that allows users and automated agents to inspect the full decision history of a plan execution — including which decisions were made, when, their types, and their current status (pending, completed, or reverted). Currently, the `agents plan tree` command either lacks full implementation or does not expose the complete decision tree with all required metadata fields, status indicators, depth-limiting, and machine-readable JSON output. Without this command working correctly, users cannot: - Audit the decision history of a running or completed plan - Identify which decisions are candidates for correction via `agents plan correct` - Programmatically consume decision tree data in CI/CD pipelines or downstream tooling - Limit output to a specific depth when plans have deeply nested decision trees This feature is a prerequisite for `agents plan explain` (which shows decision details) and `agents plan correct` (which re-executes from a targeted decision point), making it a critical path item for the milestone. ## Expected Behavior Running `agents plan tree <PLAN_ID>` should display a hierarchical tree view of all decisions recorded during plan execution. Each node in the tree should show: - **Decision ID** — unique identifier for the decision - **Decision Type** — e.g., `strategy`, `tool_selection`, `parameter`, `branch` - **Timestamp** — when the decision was recorded (ISO 8601) - **Brief Summary** — a short human-readable description of the decision - **Status** — one of `pending`, `completed`, or `reverted` The command should support: - `--format json` — emit a machine-readable JSON representation of the full decision tree - `--depth N` — limit the rendered tree to N levels deep (default: unlimited) - Rich terminal output (default) with colour-coded status indicators - Plain text output (when `--format plain` or when stdout is not a TTY) Example rich output: ``` Plan Decision Tree: plan-abc123 ├── [completed] d-001 | strategy | 2026-04-14T10:00:00Z | Selected iterative approach │ ├── [completed] d-002 | tool_selection | 2026-04-14T10:01:00Z | Chose ruff for linting │ └── [reverted] d-003 | parameter | 2026-04-14T10:02:00Z | Set max_retries=3 └── [pending] d-004 | branch | 2026-04-14T10:03:00Z | Awaiting user confirmation ``` ## Acceptance Criteria - [ ] `agents plan tree <PLAN_ID>` renders a hierarchical tree of all decisions for the given plan - [ ] Each tree node displays: decision ID, type, timestamp (ISO 8601), brief summary, and status - [ ] Status values `pending`, `completed`, and `reverted` are visually distinct in rich output (colour-coded or prefixed) - [ ] `--format json` emits a valid JSON document representing the full decision tree with all node fields - [ ] `--depth N` limits the rendered tree to N levels; nodes beyond depth N are omitted (not truncated mid-node) - [ ] When `--depth 0` or `--depth 1` is specified, only the root-level decisions are shown - [ ] Plain text output (non-TTY or `--format plain`) renders the tree using ASCII characters (`|`, `+--`, `` `-- ``) - [ ] An unknown or non-existent `PLAN_ID` exits with a non-zero status code and a clear error message - [ ] A plan with zero decisions renders an empty tree with a summary line (e.g., `No decisions recorded.`) - [ ] Output validation checks structural components (presence of decision IDs, status labels, timestamps) — not exact character matching - [ ] Unit tests cover: normal tree, empty tree, `--depth` limiting, `--format json`, non-existent plan ID - [ ] BDD/integration tests cover the full CLI invocation for at least the happy path and the `--format json` path - [ ] Test coverage for the `plan tree` command and its supporting service/model code is ≥ 97% ## Subtasks - [ ] **ST-1**: Define or extend the `Decision` model to include `status` field (`pending` | `completed` | `reverted`) and ensure it is persisted and retrievable - [ ] **ST-2**: Implement `PlanTreeService.get_decision_tree(plan_id, depth=None)` that returns a nested tree structure of `Decision` nodes - [ ] **ST-3**: Implement the `tree_decisions_cmd()` CLI handler in `src/cleveragents/cli/commands/plan.py` with `--format` and `--depth` options - [ ] **ST-4**: Implement the Rich renderer for the decision tree (colour-coded status, tree connectors, summary panel) - [ ] **ST-5**: Implement the plain-text renderer (ASCII tree connectors, no colour codes) - [ ] **ST-6**: Implement the JSON renderer (`--format json`) producing a structured document with all node fields - [ ] **ST-7**: Add `--depth N` filtering logic to the tree renderer (prune nodes beyond depth N) - [ ] **ST-8**: Add error handling for unknown plan IDs (non-zero exit, clear message) - [ ] **ST-9**: Add empty-tree handling (zero decisions — render summary line, exit 0) - [ ] **ST-10**: Write unit tests for `PlanTreeService.get_decision_tree()` covering: normal tree, empty tree, depth limiting - [ ] **ST-11**: Write unit tests for each renderer (Rich, plain, JSON) covering all status values and edge cases - [ ] **ST-12**: Write BDD/integration tests for `agents plan tree` CLI (happy path, `--format json`, `--depth`, unknown plan ID) - [ ] **ST-13**: Verify test coverage ≥ 97% for all new/modified modules; add missing tests as needed - [ ] **ST-14**: Update `docs/specification.md` and CLI help text to reflect the final command signature and output format ## Definition of Done The issue should be closed when **all** of the following are true: 1. `agents plan tree <PLAN_ID>` is fully implemented and renders a correct hierarchical decision tree in rich, plain, and JSON formats 2. All Acceptance Criteria checkboxes above are checked 3. All Subtasks are completed 4. CI passes (lint, type-check, unit tests, BDD tests) 5. Test coverage for affected modules is ≥ 97% 6. `docs/specification.md` and CLI `--help` output accurately describe the command signature and output format 7. A peer review has approved the PR and it has been merged to the target branch --- **Automated by CleverAgents Bot** Agent: new-issue-creator
HAL9000 added this to the v3.2.0 milestone 2026-04-14 13:58:51 +00:00
Author
Owner

Triage: Verified [AUTO-OWNR-1]

Valid feature: agents plan tree is a core M3 deliverable (v3.2.0 milestone acceptance criteria: "agents plan tree renders the decision tree correctly"). This issue provides a comprehensive specification for implementing the command with 14 subtasks covering the Decision model, service layer, CLI handler, Rich/plain/JSON renderers, depth limiting, error handling, and tests.

This is a prerequisite for agents plan explain and agents plan correct, making it a critical path item for the milestone.

Assigning to v3.2.0 as plan tree is explicitly listed in the M3 acceptance criteria. Priority High — this is a core M3 deliverable that blocks other features.

MoSCoW: Must Haveagents plan tree is explicitly required by the v3.2.0 milestone acceptance criteria. The milestone cannot be considered complete without it.


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

✅ **Triage: Verified** [AUTO-OWNR-1] Valid feature: `agents plan tree` is a core M3 deliverable (v3.2.0 milestone acceptance criteria: "agents plan tree renders the decision tree correctly"). This issue provides a comprehensive specification for implementing the command with 14 subtasks covering the Decision model, service layer, CLI handler, Rich/plain/JSON renderers, depth limiting, error handling, and tests. This is a prerequisite for `agents plan explain` and `agents plan correct`, making it a critical path item for the milestone. Assigning to **v3.2.0** as `plan tree` is explicitly listed in the M3 acceptance criteria. Priority **High** — this is a core M3 deliverable that blocks other features. MoSCoW: **Must Have** — `agents plan tree` is explicitly required by the v3.2.0 milestone acceptance criteria. The milestone cannot be considered complete without it. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#9280
No description provided.