88
99APP_DIR = Path (__file__ ).resolve ().parents [1 ]
1010SERVICES_DIR = APP_DIR / "services"
11+ WORKFLOW_DIR = APP_DIR / "workflow"
12+ MOVED_WORKFLOW_SERVICE_MODULES = {
13+ "app.services.workflow_agent_drafts" ,
14+ "app.services.workflow_agent_response" ,
15+ "app.services.workflow_agent_runs" ,
16+ "app.services.workflow_repair_state" ,
17+ "app.services.workflow_workspace_state" ,
18+ }
1119
1220
1321def _imported_modules (path : Path ) -> set [str ]:
@@ -18,6 +26,7 @@ def _imported_modules(path: Path) -> set[str]:
1826 modules .update (alias .name for alias in node .names )
1927 elif isinstance (node , ast .ImportFrom ) and node .module :
2028 modules .add (node .module )
29+ modules .update (f"{ node .module } .{ alias .name } " for alias in node .names )
2130 return modules
2231
2332
@@ -31,3 +40,34 @@ def test_services_do_not_depend_on_tools_layer() -> None:
3140 violations .append (f"{ path .relative_to (APP_DIR )} imports { module } " )
3241
3342 assert violations == []
43+
44+
45+ def test_workflow_domain_does_not_depend_on_tools_layer () -> None :
46+ violations : list [str ] = []
47+ for path in sorted (WORKFLOW_DIR .rglob ("*.py" )):
48+ if path .name == "__init__.py" :
49+ continue
50+ for module in sorted (_imported_modules (path )):
51+ if module == "app.tools" or module .startswith ("app.tools." ):
52+ violations .append (f"{ path .relative_to (APP_DIR )} imports { module } " )
53+
54+ assert violations == []
55+
56+
57+ def test_moved_workflow_services_use_domain_import_paths () -> None :
58+ violations : list [str ] = []
59+ legacy_wrapper_paths = {
60+ SERVICES_DIR / "workflow_agent_drafts.py" ,
61+ SERVICES_DIR / "workflow_agent_response.py" ,
62+ SERVICES_DIR / "workflow_agent_runs.py" ,
63+ SERVICES_DIR / "workflow_repair_state.py" ,
64+ SERVICES_DIR / "workflow_workspace_state.py" ,
65+ }
66+ for path in sorted (APP_DIR .rglob ("*.py" )):
67+ if path in legacy_wrapper_paths :
68+ continue
69+ legacy_imports = sorted (_imported_modules (path ) & MOVED_WORKFLOW_SERVICE_MODULES )
70+ for module in legacy_imports :
71+ violations .append (f"{ path .relative_to (APP_DIR )} imports { module } " )
72+
73+ assert violations == []
0 commit comments