| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- from content_agent.integrations.policy_json import JsonPolicyBundleStore
- from content_agent.run_service import RunService, _policy_run_record_from_state
- from content_agent.schemas import RunStartRequest
- from tests.p1_helpers import FakeQueryVariantClient, REAL_SOURCE_FIXTURE
- def test_final_output_separates_policy_and_walk_strategy_versions(tmp_path):
- service = RunService(
- runtime_root=tmp_path / "runtime" / "v1",
- query_variant_client=FakeQueryVariantClient(),
- )
- state = service.start_run(
- RunStartRequest(platform_mode="mock", source=str(REAL_SOURCE_FIXTURE))
- )
- final_output = service.read_json(state["run_id"], "final_output.json")
- assert final_output["policy"]["policy_bundle_id"] == "douyin_policy_bundle_v1"
- assert final_output["policy"]["strategy_version"] == "V1"
- assert final_output["policy"]["rule_pack_id"] == "douyin_content_discovery_rule_pack_v1"
- assert final_output["walk_strategy"]["walk_strategy_id"] == "douyin_walk_strategy_v1"
- assert final_output["walk_strategy"]["walk_strategy_version"] == "V1.0"
- assert final_output["walk_strategy"]["walk_strategy_source_ref"]["file"].endswith(
- "douyin_walk_strategy.v1.json"
- )
- def test_policy_run_record_uses_walk_strategy_version_from_walk_config():
- policy_bundle = JsonPolicyBundleStore().load_policy_bundle("V1")
- record = _policy_run_record_from_state(
- {
- "run_id": "run_001",
- "policy_run_id": "policy_run_001",
- "strategy_version": "V1",
- "policy_bundle_id": policy_bundle["policy_bundle_id"],
- "policy_bundle": policy_bundle,
- "rule_decisions": [],
- "final_output": {"summary": {}},
- "status": "success",
- }
- )
- assert record["strategy_version"] == "V1"
- assert record["walk_strategy_version"] == "V1.0"
|