from app.schemas.project_operating_context import ExecutionRecipe, ProjectOperatingContext from app.services.ai_pmo.project_operating_context_builder import ProjectOperatingContextBuilder def test_project_operating_context_schema_contract() -> None: context = ProjectOperatingContext( current_project_id=17, current_repo_scope="pmflow-main", page_anchor={"project_id": 17, "origin": "pathname"}, thread_anchor={"reply_to_message_id": "om_xxx"}, ) assert context.context_version == "v1" assert context.current_project_id == 17 assert context.current_repo_scope == "pmflow-main" assert context.page_anchor["project_id"] == 17 assert context.thread_anchor["reply_to_message_id"] == "om_xxx" assert context.fit_scope == "current_project_and_repo" assert context.decision_strategy == "answer_then_offer_plan" def test_project_operating_context_builder_collects_project_repo_and_anchors() -> None: builder = ProjectOperatingContextBuilder(repo_scope="pmflow-main") context = builder.build( current_project_id=17, page_anchor={"project_id": 17, "origin": "rag_request_context"}, thread_anchor={"reply_to_message_id": "om_xxx", "root_message_id": "om_root"}, ) assert context.current_project_id == 17 assert context.current_repo_scope == "pmflow-main" assert context.page_anchor == {"project_id": 17, "origin": "rag_request_context"} assert context.thread_anchor == {"reply_to_message_id": "om_xxx", "root_message_id": "om_root"} assert context.fit_scope == "current_project_and_repo" assert context.decision_strategy == "answer_then_offer_plan" def test_execution_recipe_schema_contract() -> None: recipe = ExecutionRecipe( primary_lane="external", fit_brief_required=True, external_evidence_required=True, plan_handoff_mode="offer_after_answer", ) assert recipe.primary_lane == "external" assert recipe.fit_brief_required is True assert recipe.external_evidence_required is True assert recipe.plan_handoff_mode == "offer_after_answer"