Files
cleveragents-core/features/decision_service_coverage_boost.feature

118 lines
6.2 KiB
Gherkin

Feature: DecisionService coverage boost for uncovered lines
As a developer
I want tests that cover remaining uncovered code paths in decision_service.py
So that line coverage increases toward 100%
# All steps use the "dscb-" prefix to avoid collisions with other step files.
# ------------------------------------------------------------------
# Lines 318-319: actor_reasoning exceeds _MAX_ACTOR_REASONING
# ------------------------------------------------------------------
Scenario: dscb- record_decision rejects actor_reasoning exceeding max length
Given dscb- a DecisionService in memory mode
When dscb- I record a decision with actor_reasoning exceeding the max length
Then dscb- a ValidationError should have been raised mentioning "actor_reasoning"
# ------------------------------------------------------------------
# Line 488: BFS continue on already-visited node in get_tree
# ------------------------------------------------------------------
Scenario: dscb- get_tree handles duplicate nodes in BFS queue gracefully
Given dscb- a DecisionService in memory mode
And dscb- a decision tree where the same child is reachable from two parents
When dscb- I call get_tree for the plan
Then dscb- the tree result should contain each decision exactly once
# ------------------------------------------------------------------
# Lines 500-501: Orphaned subtrees appended after BFS nodes
# ------------------------------------------------------------------
Scenario: dscb- get_tree appends orphaned subtrees after BFS-reachable nodes
Given dscb- a DecisionService in memory mode
And dscb- a plan with a root decision and an orphaned decision with a dangling parent
When dscb- I call get_tree for the plan
Then dscb- the tree result should include both the root and the orphaned decision
And dscb- the root decision should appear before the orphan
# ------------------------------------------------------------------
# Line 534: get_path_to_root breaks on cycle (parent already visited)
# ------------------------------------------------------------------
Scenario: dscb- get_path_to_root breaks on a cycle in parent chain
Given dscb- a DecisionService in memory mode
And dscb- two decisions that form a parent cycle
When dscb- I call get_path_to_root from the first cycled decision
Then dscb- the path should terminate without infinite loop
And dscb- the path should contain exactly 2 decisions
# ------------------------------------------------------------------
# Lines 578-579: mark_superseded finds replacement via persisted lookup
# ------------------------------------------------------------------
Scenario: dscb- mark_superseded falls back to DB to find replacement decision
Given dscb- a DecisionService with a mock UoW for superseded fallback
And dscb- the replacement decision exists only in the database not in cache
And dscb- the original decision exists in the cache
When dscb- I call mark_superseded with the original and replacement IDs
Then dscb- the original decision should be marked as superseded
# ------------------------------------------------------------------
# Line 600: mark_superseded raises DecisionNotFoundError in memory mode
# ------------------------------------------------------------------
Scenario: dscb- mark_superseded raises error when original not found in memory mode
Given dscb- a DecisionService in memory mode
And dscb- a replacement decision is recorded for the plan
When dscb- I call mark_superseded with a nonexistent original ID
Then dscb- a DecisionNotFoundError should have been raised
# ------------------------------------------------------------------
# Lines 627-628: delete_decision falls back to DB lookup
# ------------------------------------------------------------------
Scenario: dscb- delete_decision falls back to DB when decision not in cache
Given dscb- a DecisionService with a mock UoW for delete fallback
And dscb- the decision exists in DB but not in cache for delete
When dscb- I call delete_decision with the decision ID
Then dscb- the decision should be deleted via the UoW
# ------------------------------------------------------------------
# Line 741: _next_sequence raises SequenceConflictError
# ------------------------------------------------------------------
Scenario: dscb- next_sequence raises SequenceConflictError on duplicate sequence
Given dscb- a DecisionService in memory mode
And dscb- a plan with a decision manually inserted at sequence 0
When dscb- I try to generate the next sequence for that plan
Then dscb- a SequenceConflictError should have been raised
# ------------------------------------------------------------------
# Line 757: _rehydrate_sequence early return when counter exists
# ------------------------------------------------------------------
Scenario: dscb- rehydrate_sequence returns early when counter already set
Given dscb- a DecisionService in memory mode
And dscb- the plan sequence counter is already set to 5
When dscb- I call rehydrate_sequence for the plan
Then dscb- the plan sequence counter should still be 5
# ------------------------------------------------------------------
# Line 806: _record_dependencies skips blank upstream IDs
# ------------------------------------------------------------------
Scenario: dscb- record_dependencies skips empty and whitespace-only upstream IDs
Given dscb- a DecisionService in memory mode
When dscb- I record a decision with dependency IDs including blanks
Then dscb- only non-blank upstream IDs should be recorded in the dependency DAG
# ------------------------------------------------------------------
# Line 832: get_influence_edges skips sources not in plan
# ------------------------------------------------------------------
Scenario: dscb- get_influence_edges excludes dependency sources outside the plan
Given dscb- a DecisionService in memory mode
And dscb- a plan with decisions and cross-plan dependency edges
When dscb- I call get_influence_edges for the plan
Then dscb- only edges within the plan should be returned