fix(service): address review findings for decision service
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 14s
CI / build (pull_request) Successful in 14s
CI / quality (pull_request) Successful in 16s
CI / security (pull_request) Successful in 31s
CI / typecheck (pull_request) Successful in 43s
CI / unit_tests (pull_request) Successful in 2m18s
CI / integration_tests (pull_request) Successful in 2m53s
CI / docker (pull_request) Successful in 39s
CI / coverage (pull_request) Successful in 3m58s
CI / benchmark-regression (pull_request) Successful in 24m44s
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 14s
CI / build (pull_request) Successful in 14s
CI / quality (pull_request) Successful in 16s
CI / security (pull_request) Successful in 31s
CI / typecheck (pull_request) Successful in 43s
CI / unit_tests (pull_request) Successful in 2m18s
CI / integration_tests (pull_request) Successful in 2m53s
CI / docker (pull_request) Successful in 39s
CI / coverage (pull_request) Successful in 3m58s
CI / benchmark-regression (pull_request) Successful in 24m44s
- Rehydrate sequence counter from DB on restart (BUG-1) - Add uniqueness guard raising SequenceConflictError (BUG-2) - Fix delete_decision consistency between persisted/in-memory (BUG-3) - Validate new_decision_id exists in mark_superseded (BUG-4) - Include orphaned subtrees in get_tree output (BUG-5) - Remove dead _decision_seq/_next_seq from plan_lifecycle (BUG-7) - Export SequenceConflictError from services __init__ (SPEC-2) - Replace list[Any] with list[ArtifactRef] typing (SPEC-4) - Add actor_reasoning max_length validation (SEC-1) - Use SELECT COUNT(*) in count_decisions (PERF-1) - Replace MagicMock with create_autospec(Settings) (TEST-3) - Eliminate UnitOfWork.__new__() anti-pattern (TEST-4) - Use exact assertion counts in DI tests (TEST-5) - Add restart rehydration, BFS order, invalid type, and confidence boundary test scenarios (TEST-1/2/6/7) - Fix decision_service_coverage.feature to match actual API ISSUES CLOSED: #172
This commit is contained in:
@@ -22,18 +22,15 @@ Feature: DecisionService application-layer coverage
|
||||
|
||||
Scenario: dsvc- record_decision persists and returns the decision
|
||||
Given dsvc- a DecisionService with a mocked UnitOfWork
|
||||
And dsvc- a sample root Decision object
|
||||
When dsvc- I call record_decision with the sample decision
|
||||
When dsvc- I call record_decision with plan_id and required args
|
||||
Then dsvc- the UoW transaction should have been entered
|
||||
And dsvc- ctx.decisions.create should have been called with the decision
|
||||
And dsvc- the returned decision should be the same object
|
||||
And dsvc- ctx.decisions.create should have been called once
|
||||
And dsvc- the returned decision should have the correct plan_id
|
||||
|
||||
Scenario: dsvc- record_decision logs info and debug messages
|
||||
Scenario: dsvc- record_decision logs info on success
|
||||
Given dsvc- a DecisionService with a mocked UnitOfWork and captured logger
|
||||
And dsvc- a sample root Decision object
|
||||
When dsvc- I call record_decision with the sample decision
|
||||
Then dsvc- the logger should have recorded an info call with "recording_decision"
|
||||
And dsvc- the logger should have recorded a debug call with "decision_recorded"
|
||||
When dsvc- I call record_decision with plan_id and required args
|
||||
Then dsvc- the logger should have recorded an info call with "decision.recorded"
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# get_decision
|
||||
@@ -46,57 +43,38 @@ Feature: DecisionService application-layer coverage
|
||||
Then dsvc- ctx.decisions.get should have been called with the ID
|
||||
And dsvc- the returned value should be the expected Decision
|
||||
|
||||
Scenario: dsvc- get_decision returns None when not found
|
||||
Scenario: dsvc- get_decision raises DecisionNotFoundError when not found
|
||||
Given dsvc- a DecisionService with a mocked UnitOfWork
|
||||
And dsvc- the mock repo get method returns None
|
||||
When dsvc- I call get_decision with an unknown ID
|
||||
Then dsvc- the returned value should be None
|
||||
|
||||
Scenario: dsvc- get_decision logs a debug message
|
||||
Given dsvc- a DecisionService with a mocked UnitOfWork and captured logger
|
||||
And dsvc- the mock repo get method returns a Decision
|
||||
When dsvc- I call get_decision with a known ID
|
||||
Then dsvc- the logger should have recorded a debug call with "getting_decision"
|
||||
When dsvc- I call get_decision with an unknown ID expecting not-found
|
||||
Then dsvc- a DecisionNotFoundError should have been raised
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# get_decisions_for_plan
|
||||
# list_decisions
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
Scenario: dsvc- get_decisions_for_plan returns list of decisions
|
||||
Scenario: dsvc- list_decisions returns list of decisions
|
||||
Given dsvc- a DecisionService with a mocked UnitOfWork
|
||||
And dsvc- the mock repo get_by_plan method returns 3 decisions
|
||||
When dsvc- I call get_decisions_for_plan with a plan ID
|
||||
When dsvc- I call list_decisions with a plan ID
|
||||
Then dsvc- ctx.decisions.get_by_plan should have been called with the plan ID
|
||||
And dsvc- the returned list should have 3 decisions
|
||||
|
||||
Scenario: dsvc- get_decisions_for_plan returns empty list when none exist
|
||||
Scenario: dsvc- list_decisions returns empty list when none exist
|
||||
Given dsvc- a DecisionService with a mocked UnitOfWork
|
||||
And dsvc- the mock repo get_by_plan method returns 0 decisions
|
||||
When dsvc- I call get_decisions_for_plan with a plan ID
|
||||
When dsvc- I call list_decisions with a plan ID
|
||||
Then dsvc- the returned list should have 0 decisions
|
||||
|
||||
Scenario: dsvc- get_decisions_for_plan logs a debug message
|
||||
Given dsvc- a DecisionService with a mocked UnitOfWork and captured logger
|
||||
And dsvc- the mock repo get_by_plan method returns 3 decisions
|
||||
When dsvc- I call get_decisions_for_plan with a plan ID
|
||||
Then dsvc- the logger should have recorded a debug call with "getting_decisions_for_plan"
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# get_decision_tree
|
||||
# get_tree
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
Scenario: dsvc- get_decision_tree returns BFS-ordered list
|
||||
Scenario: dsvc- get_tree returns BFS-ordered list
|
||||
Given dsvc- a DecisionService with a mocked UnitOfWork
|
||||
And dsvc- the mock repo get_tree method returns 4 decisions
|
||||
When dsvc- I call get_decision_tree with a root ID
|
||||
Then dsvc- ctx.decisions.get_tree should have been called with the root ID
|
||||
And dsvc- the returned tree list should have 4 decisions
|
||||
|
||||
Scenario: dsvc- get_decision_tree logs a debug message
|
||||
Given dsvc- a DecisionService with a mocked UnitOfWork and captured logger
|
||||
And dsvc- the mock repo get_tree method returns 4 decisions
|
||||
When dsvc- I call get_decision_tree with a root ID
|
||||
Then dsvc- the logger should have recorded a debug call with "getting_decision_tree"
|
||||
And dsvc- the mock repo get_by_plan method returns 4 decisions as a tree
|
||||
When dsvc- I call get_tree with a plan ID
|
||||
Then dsvc- the returned tree list should have 4 decisions
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# get_path_to_root
|
||||
@@ -109,18 +87,13 @@ Feature: DecisionService application-layer coverage
|
||||
Then dsvc- ctx.decisions.get_path_to_root should have been called with the leaf ID
|
||||
And dsvc- the returned path list should have 3 decisions
|
||||
|
||||
Scenario: dsvc- get_path_to_root logs a debug message
|
||||
Given dsvc- a DecisionService with a mocked UnitOfWork and captured logger
|
||||
And dsvc- the mock repo get_path_to_root method returns 3 decisions
|
||||
When dsvc- I call get_path_to_root with a leaf ID
|
||||
Then dsvc- the logger should have recorded a debug call with "getting_path_to_root"
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# mark_superseded
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
Scenario: dsvc- mark_superseded updates and returns the decision
|
||||
Given dsvc- a DecisionService with a mocked UnitOfWork
|
||||
And dsvc- the mock repo has the replacement decision in cache
|
||||
And dsvc- the mock repo update_superseded_by method returns a superseded Decision
|
||||
When dsvc- I call mark_superseded with old and new IDs
|
||||
Then dsvc- ctx.decisions.update_superseded_by should have been called with both IDs
|
||||
@@ -128,9 +101,10 @@ Feature: DecisionService application-layer coverage
|
||||
|
||||
Scenario: dsvc- mark_superseded logs info with both IDs
|
||||
Given dsvc- a DecisionService with a mocked UnitOfWork and captured logger
|
||||
And dsvc- the mock repo has the replacement decision in cache
|
||||
And dsvc- the mock repo update_superseded_by method returns a superseded Decision
|
||||
When dsvc- I call mark_superseded with old and new IDs
|
||||
Then dsvc- the logger should have recorded an info call with "marking_superseded"
|
||||
Then dsvc- the logger should have recorded an info call with "decision.superseded"
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# list_by_type
|
||||
@@ -148,9 +122,3 @@ Feature: DecisionService application-layer coverage
|
||||
And dsvc- the mock repo list_by_type method returns 0 decisions
|
||||
When dsvc- I call list_by_type with plan ID and type "error_recovery"
|
||||
Then dsvc- the returned type list should have 0 decisions
|
||||
|
||||
Scenario: dsvc- list_by_type logs a debug message
|
||||
Given dsvc- a DecisionService with a mocked UnitOfWork and captured logger
|
||||
And dsvc- the mock repo list_by_type method returns 2 decisions
|
||||
When dsvc- I call list_by_type with plan ID and type "strategy_choice"
|
||||
Then dsvc- the logger should have recorded a debug call with "listing_by_type"
|
||||
|
||||
Reference in New Issue
Block a user