test_p7_policy_walk_versions.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from content_agent.integrations.policy_json import JsonPolicyBundleStore
  2. from content_agent.run_service import RunService, _policy_run_record_from_state
  3. from content_agent.schemas import RunStartRequest
  4. from tests.p1_helpers import FakeQueryVariantClient, REAL_SOURCE_FIXTURE
  5. def test_final_output_separates_policy_and_walk_strategy_versions(tmp_path):
  6. service = RunService(
  7. runtime_root=tmp_path / "runtime" / "v1",
  8. query_variant_client=FakeQueryVariantClient(),
  9. )
  10. state = service.start_run(
  11. RunStartRequest(platform_mode="mock", source=str(REAL_SOURCE_FIXTURE))
  12. )
  13. final_output = service.read_json(state["run_id"], "final_output.json")
  14. assert final_output["policy"]["policy_bundle_id"] == "douyin_policy_bundle_v1"
  15. assert final_output["policy"]["strategy_version"] == "V1"
  16. assert final_output["policy"]["rule_pack_id"] == "douyin_content_discovery_rule_pack_v1"
  17. assert final_output["walk_strategy"]["walk_strategy_id"] == "douyin_walk_strategy_v1"
  18. assert final_output["walk_strategy"]["walk_strategy_version"] == "V1.0"
  19. assert final_output["walk_strategy"]["walk_strategy_source_ref"]["file"].endswith(
  20. "douyin_walk_strategy.v1.json"
  21. )
  22. def test_policy_run_record_uses_walk_strategy_version_from_walk_config():
  23. policy_bundle = JsonPolicyBundleStore().load_policy_bundle("V1")
  24. record = _policy_run_record_from_state(
  25. {
  26. "run_id": "run_001",
  27. "policy_run_id": "policy_run_001",
  28. "strategy_version": "V1",
  29. "policy_bundle_id": policy_bundle["policy_bundle_id"],
  30. "policy_bundle": policy_bundle,
  31. "rule_decisions": [],
  32. "final_output": {"summary": {}},
  33. "status": "success",
  34. }
  35. )
  36. assert record["strategy_version"] == "V1"
  37. assert record["walk_strategy_version"] == "V1.0"