fix: harden Flow v2 authoritative cutover semantics
This commit is contained in:
@@ -27,6 +27,19 @@ def test_business_baselines_and_terminal():
|
||||
assert decide_authoritative_operation(projection("COMPLETED"), now=NOW).queue == "not_current"
|
||||
|
||||
|
||||
def test_terminal_state_ignores_leftover_pending_obligation():
|
||||
got = decide_authoritative_operation(projection("COMPLETED"),
|
||||
obligations=[task("REVIEW_RECONSTRUCTED_PROCESS")], now=NOW)
|
||||
assert (got.effective_action, got.queue, got.reason_code) == (None, "not_current", "TERMINAL_BUSINESS_STATE")
|
||||
|
||||
|
||||
def test_specific_reconstructed_review_overrides_generic_business_review():
|
||||
got = decide_authoritative_operation(projection("REVIEW_REQUIRED", "REVIEW_REQUIRED"),
|
||||
obligations=[task("REVIEW_RECONSTRUCTED_PROCESS")], now=NOW)
|
||||
assert (got.business_next_action, got.effective_action, got.queue) == (
|
||||
"REVIEW_REQUIRED", "REVIEW_RECONSTRUCTED_PROCESS", "review")
|
||||
|
||||
|
||||
def test_missing_projection_fails_closed_without_v1():
|
||||
got = decide_authoritative_operation(None, now=NOW)
|
||||
assert (got.effective_action, got.queue, got.reason_code) == ("REVIEW_REQUIRED", "review", "MISSING_V2_PROJECTION")
|
||||
@@ -46,7 +59,8 @@ def test_only_active_non_superseded_tasks_override_and_precedence():
|
||||
obligations = [task("CALL_CUSTOMER"), task("SEND_INFO"), task("SUPPORT"), task("REVIEW_MANUALLY")]
|
||||
assert decide_authoritative_operation(projection(), obligations=obligations, now=NOW).effective_action == "REVIEW_MANUALLY"
|
||||
assert decide_authoritative_operation(projection(), obligations=[task("SUPPORT")], now=NOW).effective_action == "SUPPORT"
|
||||
assert decide_authoritative_operation(projection(), obligations=[task("SEND_INFO")], now=NOW).effective_action == "SEND_INFO"
|
||||
assert decide_authoritative_operation(projection("INQUIRY", "SEND_INFO"), obligations=[task("SEND_INFO")], now=NOW).effective_action == "SEND_INFO"
|
||||
assert decide_authoritative_operation(projection(), obligations=[task("SEND_INFO")], now=NOW).effective_action is None
|
||||
assert decide_authoritative_operation(projection(), obligations=[task("CALL_CUSTOMER")], now=NOW).effective_action == "CALL_CUSTOMER"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user