|
|
@@ -95,7 +95,20 @@ def _expansion_successes(walk_actions):
|
|
|
]
|
|
|
|
|
|
|
|
|
-def test_deep_frontier_alternates_edges_within_caps(tmp_path):
|
|
|
+def test_deep_frontier_alternates_edges_within_caps(tmp_path, monkeypatch):
|
|
|
+ # 本测试钉死小预算(10/5/5)验"撞顶留痕"机制,与生产 walk_policy 数值解耦(生产改大不影响本测试)。
|
|
|
+ from content_agent.integrations import walk_graph_json as _wgj
|
|
|
+ _orig_load = _wgj.WalkGraphStore.load_policy
|
|
|
+
|
|
|
+ def _capped(self):
|
|
|
+ import copy
|
|
|
+ policy = copy.deepcopy(_orig_load(self)) # 深拷贝,别污染共享缓存的 policy
|
|
|
+ policy["global"]["max_total_actions_per_run"] = 10
|
|
|
+ policy["edge_budgets_by_id"]["hashtag_to_query"]["max_total_actions"] = 5
|
|
|
+ policy["edge_budgets_by_id"]["author_to_works"]["max_total_actions"] = 5
|
|
|
+ return policy
|
|
|
+
|
|
|
+ monkeypatch.setattr(_wgj.WalkGraphStore, "load_policy", _capped)
|
|
|
context = _seed(tmp_path)
|
|
|
client = _BranchingClient()
|
|
|
|
|
|
@@ -109,7 +122,7 @@ def test_deep_frontier_alternates_edges_within_caps(tmp_path):
|
|
|
depths = {a["depth"] for a in successes}
|
|
|
assert {1, 2, 3} <= depths
|
|
|
|
|
|
- # 三道闸 + 总闸:depth≤5、标签≤5、作者≤5、总向外跳≤10。
|
|
|
+ # 三道闸 + 总闸(本测试钉死的小预算):depth≤5、标签≤5、作者≤5、总向外跳≤10。
|
|
|
assert max(depths) <= 5
|
|
|
tag_jumps = [a for a in successes if a["edge_id"] == "hashtag_to_query"]
|
|
|
author_jumps = [a for a in successes if a["edge_id"] == "author_to_works"]
|
|
|
@@ -155,7 +168,7 @@ def test_deep_frontier_dedups_repeated_content_author_tag(tmp_path):
|
|
|
content_ids = [i["platform_content_id"] for i in result["discovered_content_items"]]
|
|
|
assert len(content_ids) == len(set(content_ids)) # 无重复内容
|
|
|
successes = _expansion_successes(result["walk_actions"])
|
|
|
- assert len(successes) <= 10
|
|
|
+ assert len(successes) <= 30
|
|
|
|
|
|
|
|
|
def test_global_action_cap_emits_skip(tmp_path):
|