test_p8_single_run_policy_context.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. from content_agent.business_modules import learning_review
  2. from content_agent.integrations.runtime_files import LocalRuntimeFileStore
  3. from tests.test_p8_strategy_review import _clue, _write_minimal_runtime
  4. def test_strategy_review_uses_single_run_policy_context(tmp_path):
  5. runtime = LocalRuntimeFileStore(tmp_path / "runtime")
  6. run_id = "run_single"
  7. policy_run_id = "policy_single"
  8. other_run_id = "run_other"
  9. other_policy_run_id = "policy_other"
  10. runtime.prepare_run(run_id)
  11. runtime.prepare_run(other_run_id)
  12. _write_minimal_runtime(runtime, run_id, policy_run_id)
  13. _write_minimal_runtime(runtime, other_run_id, other_policy_run_id)
  14. runtime.append_jsonl(
  15. other_run_id,
  16. "search_clues.jsonl",
  17. [_clue(other_run_id, other_policy_run_id, "clue_other", "q_other", "跨 run", "success", 99)],
  18. )
  19. review = learning_review.run(run_id, policy_run_id, runtime)
  20. assert review["data_window"]["scope"] == "single_run"
  21. assert review["data_window"]["run_id"] == run_id
  22. assert review["data_window"]["policy_run_id"] == policy_run_id
  23. assert review["data_window"]["policy_context"]["strategy_version"] == "V1"
  24. assert review["data_window"]["policy_context"]["walk_strategy_version"] == "V1.0"
  25. assert review["metric_summary"]["success_query_count"] == 1
  26. assert all(
  27. item["clue_id"] != "clue_other"
  28. for bucket in review["query_review"].values()
  29. if isinstance(bucket, list)
  30. for item in bucket
  31. )