Files
HAL9000 9c49bbc4db fix(plan): use structured alternatives objects in plan explain output per spec
Convert alternatives_considered list of strings to structured objects with
index (1-based), description, and chosen fields in _build_explain_dict().
Rename output field from alternatives_considered to alternatives.
Update BDD tests in plan_explain.feature, plan_explain_cli_coverage.feature,
and plan_explain_steps.py to validate the new structured format.

Closes #9166
2026-06-13 14:44:45 -04:00

174 lines
7.7 KiB
Gherkin

Feature: Plan explain and decision tree CLI commands
Validates the plan explain and plan tree commands including
formatting, filtering, and flag-controlled detail views.
# ------------------------------------------------------------------
# plan explain - default format
# ------------------------------------------------------------------
Scenario: Explain a decision with default format
Given a test decision for explain
When I build the explain dict with default options
Then the explain dict should contain key "decision_id"
And the explain dict should contain key "question"
And the explain dict should contain key "chosen"
And the explain dict should contain key "type"
And the explain dict should contain key "alternatives"
And the explain dict should not contain key "rationale"
And the explain dict should not contain key "context_snapshot"
# ------------------------------------------------------------------
# plan explain - show-context
# ------------------------------------------------------------------
Scenario: Explain with show-context flag
Given a test decision with context snapshot for explain
When I build the explain dict with show-context enabled
Then the explain dict should contain key "context_snapshot"
And the context snapshot should contain key "hot_context_hash"
And the context snapshot should contain key "relevant_resources"
# ------------------------------------------------------------------
# plan explain - show-reasoning
# ------------------------------------------------------------------
Scenario: Explain with show-reasoning flag
Given a test decision with reasoning for explain
When I build the explain dict with show-reasoning enabled
Then the explain dict should contain key "rationale"
And the explain dict should contain key "actor_reasoning"
# ------------------------------------------------------------------
# plan explain - alternatives always included
# ------------------------------------------------------------------
Scenario: Explain includes alternatives by default
Given a test decision with alternatives for explain
When I build the explain dict with default options
Then the explain dict should contain key "alternatives"
And the alternatives list should have 2 items
And each alternative should have keys "index", "description", and "chosen"
And exactly one alternative should have chosen set to true
# ------------------------------------------------------------------
# plan explain - json format
# ------------------------------------------------------------------
Scenario: Explain with json format
Given a test decision for explain
When I format the explain dict as json
Then the json output should contain "decision_id"
And the plan explain json output should be valid
# ------------------------------------------------------------------
# plan explain - yaml format
# ------------------------------------------------------------------
Scenario: Explain with yaml format
Given a test decision for explain
When I format the explain dict as yaml
Then the yaml output should contain "decision_id"
# ------------------------------------------------------------------
# plan explain - non-existent decision
# ------------------------------------------------------------------
Scenario: Explain for non-existent decision returns error marker
Given a non-existent decision id
Then the explain lookup should indicate not found
# ------------------------------------------------------------------
# plan tree - default format
# ------------------------------------------------------------------
Scenario: Tree with default format builds tree structure
Given a set of test decisions forming a tree
When I build the decision tree with default options
Then the tree should have at least 1 root node
And the first root node should have children
# ------------------------------------------------------------------
# plan tree - show-superseded
# ------------------------------------------------------------------
Scenario: Tree with show-superseded includes superseded decisions
Given a set of test decisions with superseded entries
When I build the decision tree with show-superseded enabled
Then the tree should include superseded decision nodes
# ------------------------------------------------------------------
# plan tree - depth limit
# ------------------------------------------------------------------
Scenario: Tree with depth limit restricts tree depth
Given a set of test decisions forming a deep tree
When I build the decision tree with depth 1
Then the root nodes should have no children
# ------------------------------------------------------------------
# plan tree - json format
# ------------------------------------------------------------------
@tdd_issue @tdd_issue_4254
Scenario: Tree with json format
Given a set of test decisions forming a tree
When I format the tree as json
Then the json tree output should be a valid json envelope
And the json tree output should contain "command"
# ------------------------------------------------------------------
# plan tree - yaml format
# ------------------------------------------------------------------
Scenario: Tree with yaml format
Given a set of test decisions forming a tree
When I format the tree as yaml
Then the yaml tree output should contain "decision_id"
# ------------------------------------------------------------------
# plan tree - no decisions
# ------------------------------------------------------------------
Scenario: Tree for plan with no decisions
Given an empty list of decisions
When I build the decision tree with default options from empty list
Then the tree should be empty
# ------------------------------------------------------------------
# plan tree - filters superseded by default
# ------------------------------------------------------------------
Scenario: Tree filters out superseded decisions by default
Given a set of test decisions with superseded entries
When I build the decision tree with default options
Then the tree should not include superseded decision nodes
# ------------------------------------------------------------------
# plan tree - per-type ordinals in decision labels
# ------------------------------------------------------------------
Scenario: Decision labels use per-type ordinals
Given a set of test decisions with multiple types for ordinal testing
When I generate decision labels with per-type ordinals
Then the first invariant should be labeled "Invariant 1"
And the second invariant should be labeled "Invariant 2"
And the first strategy should be labeled "Strategy"
And the first parallel should be labeled "Parallel 1"
Scenario: Decision labels restart counting per decision type
Given a set of test decisions with mixed types
When I generate decision labels with per-type ordinals
Then each decision type should start counting from 1
And invariants should have sequential numbers
And parallel spawns should have sequential numbers
And spawn decisions should have sequential numbers
Scenario: Full tree output includes per-type ordinal labels
Given a set of test decisions forming a tree with multiple types
When I build the plain format tree output with decision labels
Then the decision tree output should contain "Invariant 1"
And the decision tree output should contain "Invariant 2"
And the decision tree output should contain "Strategy"
And the decision tree output should not contain "Invariant 6"
And the decision tree output should not contain "Strategy 7"