Files
cleveragents-core/features/decision_service_coverage_boost.feature
freemo a808c395f9
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 15s
CI / build (pull_request) Successful in 15s
CI / quality (pull_request) Successful in 17s
CI / typecheck (pull_request) Successful in 35s
CI / security (pull_request) Successful in 50s
CI / unit_tests (pull_request) Successful in 2m46s
CI / integration_tests (pull_request) Successful in 3m16s
CI / docker (pull_request) Successful in 40s
CI / coverage (pull_request) Successful in 5m6s
CI / lint (push) Successful in 13s
CI / quality (push) Successful in 16s
CI / build (push) Successful in 18s
CI / security (push) Successful in 32s
CI / typecheck (push) Successful in 35s
CI / benchmark-regression (push) Has been skipped
CI / unit_tests (push) Successful in 2m52s
CI / integration_tests (push) Successful in 3m8s
CI / docker (push) Successful in 39s
CI / coverage (push) Successful in 5m53s
CI / benchmark-publish (push) Successful in 16m55s
CI / benchmark-regression (pull_request) Successful in 33m0s
test(coverage): add Behave BDD tests to improve unit test coverage across 53 source modules
Add 53 new .feature files and corresponding step definition files targeting
uncovered lines identified in build/coverage.xml. Fix AmbiguousStep conflicts
in 7 pre-existing step files by disambiguating step text.

New tests cover: ACP clients/facade, actor CLI/config, application container,
ACMS service/strategies, async worker, automation profile CLI, autonomy
guardrail, bridge, change model, config CLI/service, context service,
cross-plan correction, database models, decision service, decomposition
clustering/service, discovery handler, langchain chat provider, langgraph
nodes, materializers, multi-project service, plan apply/CLI/lifecycle/model/
preflight/resume/service, PostgreSQL analyzer, project CLI/context CLI,
provider registry, reactive application/route, repositories, resolver handler,
resource registry service, resume model, retry patterns, sandbox protocol,
server CLI, skill CLI/service, skills registry, subplan execution/service,
system CLI, UKO loader, UoW, and YAML template engine.

Closes #645
2026-03-09 13:01:58 -04:00

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