from content_agent.business_modules import learning_review from content_agent.integrations.runtime_files import LocalRuntimeFileStore from tests.test_p8_strategy_review import _write_minimal_runtime class FeedbackRuntime(LocalRuntimeFileStore): def __init__(self, *args, feedback_rows=None, **kwargs): super().__init__(*args, **kwargs) self.feedback_rows = feedback_rows or [] def read_performance_feedback(self, run_id: str, policy_run_id: str): return [ row for row in self.feedback_rows if row["run_id"] == run_id and row["policy_run_id"] == policy_run_id ] def test_strategy_review_summarizes_fake_performance_feedback(tmp_path): run_id = "run_feedback" policy_run_id = "policy_feedback" runtime = FeedbackRuntime( tmp_path / "runtime", feedback_rows=[ { "run_id": run_id, "policy_run_id": policy_run_id, "feedback_id": "feedback_001", "feedback_status": "available", "completion_rate": 0.72, "share_rate": 0.08, "average_watch_seconds": 18.5, } ], ) runtime.prepare_run(run_id) _write_minimal_runtime(runtime, run_id, policy_run_id) review = learning_review.run(run_id, policy_run_id, runtime) assert review["performance_feedback"]["performance_feedback_status"] == "available" assert review["performance_feedback"]["feedback_count"] == 1 assert review["performance_feedback"]["average_completion_rate"] == 0.72 assert any( item["recommendation_type"] == "performance_feedback" and item["suggested_action"] == "review_feedback_before_strategy_change" for item in review["recommendations"] ) assert review["rule_review"]["decision_distribution"]["ADD_TO_CONTENT_POOL"] == 1