PMFlow/backend/tests/test_business_semantic_fram...

82 lines
2.6 KiB
Python

from app.services.ai_pmo.semantic_context.business_frame_schema import (
AnswerShapeContract,
BusinessSemanticFrame,
ClarificationDelta,
CorrectionDelta,
OperationIntentContract,
)
def test_business_semantic_frame_supports_signal_source_recommendation() -> None:
frame = BusinessSemanticFrame(
goal_kind="recommendation",
target_scope="current_project",
resource_role="signal_source",
source_kind="external",
expected_answer_shape="ranked_candidates",
conversation_posture="business_operating",
)
assert frame.goal_kind == "recommendation"
assert frame.resource_role == "signal_source"
assert frame.expected_answer_shape == "ranked_candidates"
def test_business_semantic_frame_supports_feature_and_doc_resource_roles() -> None:
feature_frame = BusinessSemanticFrame(
goal_kind="status_lookup",
target_scope="global",
resource_role="feature",
source_kind="internal",
expected_answer_shape="bounded_explanation",
conversation_posture="business_operating",
)
doc_frame = BusinessSemanticFrame(
goal_kind="status_lookup",
target_scope="global",
resource_role="doc",
source_kind="internal",
expected_answer_shape="inventory",
conversation_posture="business_operating",
)
assert feature_frame.resource_role == "feature"
assert doc_frame.resource_role == "doc"
def test_answer_shape_contract_supports_social_reply() -> None:
contract = AnswerShapeContract(shape="social_reply", confidence=0.92)
assert contract.shape == "social_reply"
assert contract.confidence == 0.92
def test_operation_intent_contract_supports_non_plan_write_phases() -> None:
contract = OperationIntentContract(
intent_phase="prepare_write",
requires_confirmation=True,
candidate_set_binding="cand_123",
)
assert contract.intent_phase == "prepare_write"
assert contract.requires_confirmation is True
assert contract.candidate_set_binding == "cand_123"
def test_clarification_and_correction_deltas_capture_structural_updates() -> None:
clarify = ClarificationDelta(
field="goal_kind",
previous_value="status_lookup",
next_value="recommendation",
reason="user_clarified_scope",
)
correction = CorrectionDelta(
field="project_binding",
previous_value=81,
next_value=101,
reason="user_corrected_project",
)
assert clarify.next_value == "recommendation"
assert correction.next_value == 101