"""M8E:query_next_page 边全链路无残留——硬编码集合 2 边、图 9 边、profile/源码/前端无残留。""" import json from pathlib import Path from content_agent.business_modules import walk_engine from content_agent.integrations.walk_graph_json import WalkGraphStore from scripts.validate_v4_config_contract import M4_WALK_GATE_EDGES ROOT = Path(__file__).resolve().parents[1] _TWO_EDGES = {"hashtag_to_query", "author_to_works"} def test_hardcoded_gate_edge_sets_are_two_edges(): # 删边的"必崩点":四处硬编码集合必须全是 2 边(不含 query_next_page)。 assert walk_engine.V4_WALK_GATE_EDGES == _TWO_EDGES assert M4_WALK_GATE_EDGES == _TWO_EDGES def test_walk_graph_has_no_query_next_page_edge(): graph = WalkGraphStore().load_graph() edge_ids = {edge["edge_id"] for edge in graph["edges"]} assert "query_next_page" not in edge_ids def test_walk_policy_gate_applies_to_two_edges(): policy = WalkGraphStore().load_policy() gate = policy.get("v4_walk_gate") or {} assert set(gate.get("applies_to_edges") or []) == _TWO_EDGES def test_platform_profiles_have_no_query_next_page(): profile_dir = ROOT / "tech_documents" / "数据接口与来源" / "platform_profiles" for path in profile_dir.glob("*.json"): data = json.loads(path.read_text(encoding="utf-8")) assert "query_next_page" not in json.dumps(data), f"{path.name} still references query_next_page" def test_engine_and_frontend_source_have_no_query_next_page(): for rel in [ "content_agent/business_modules/walk_engine.py", "content_agent/flow_ledger_service.py", "content_agent/dashboard_service.py", ]: text = (ROOT / rel).read_text(encoding="utf-8") assert "query_next_page" not in text, f"{rel} still references query_next_page"