| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- from content_agent.business_modules import learning_review
- from content_agent.integrations.runtime_files import LocalRuntimeFileStore
- from tests.test_p8_performance_feedback import FeedbackRuntime
- from tests.test_p8_strategy_review import _write_minimal_runtime
- def test_strategy_review_does_not_rewrite_runtime_inputs(tmp_path):
- runtime = LocalRuntimeFileStore(tmp_path / "runtime")
- run_id = "run_no_auto"
- policy_run_id = "policy_no_auto"
- runtime.prepare_run(run_id)
- _write_minimal_runtime(runtime, run_id, policy_run_id)
- final_before = runtime.read_json(run_id, "final_output.json")
- decisions_before = runtime.read_jsonl(run_id, "rule_decisions.jsonl")
- clues_before = runtime.read_jsonl(run_id, "search_clues.jsonl")
- review = learning_review.run(run_id, policy_run_id, runtime)
- assert runtime.read_json(run_id, "final_output.json") == final_before
- assert runtime.read_jsonl(run_id, "rule_decisions.jsonl") == decisions_before
- assert runtime.read_jsonl(run_id, "search_clues.jsonl") == clues_before
- assert all(item["requires_human_approval"] is True for item in review["recommendations"])
- forbidden_patch_fields = {
- "auto_" + "apply",
- "rule_pack_" + "patch",
- "walk_strategy_" + "patch",
- "budget_" + "patch",
- "publish_job_" + "patch",
- }
- for item in review["recommendations"]:
- assert forbidden_patch_fields.isdisjoint(item)
- def test_strategy_review_with_feedback_still_does_not_emit_auto_patches(tmp_path):
- run_id = "run_feedback_no_auto"
- policy_run_id = "policy_feedback_no_auto"
- runtime = FeedbackRuntime(
- tmp_path / "runtime",
- feedback_rows=[
- {
- "run_id": run_id,
- "policy_run_id": policy_run_id,
- "feedback_id": "feedback_no_auto",
- "feedback_status": "available",
- "completion_rate": 0.8,
- }
- ],
- )
- runtime.prepare_run(run_id)
- _write_minimal_runtime(runtime, run_id, policy_run_id)
- review = learning_review.run(run_id, policy_run_id, runtime)
- forbidden_patch_fields = {
- "auto_" + "apply",
- "rule_pack_" + "patch",
- "walk_strategy_" + "patch",
- "budget_" + "patch",
- "threshold_" + "patch",
- "publish_job_" + "patch",
- }
- assert all(item["requires_human_approval"] is True for item in review["recommendations"])
- for item in review["recommendations"]:
- assert forbidden_patch_fields.isdisjoint(item)
|