Skip to content

Commit 6e19011

Browse files
Add shared AST helper usage architecture guard
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 37a202e commit 6e19011

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ This runs lint, format checks, compile checks, tests, and package build.
8787
- `tests/test_agent_task_read_helper_usage.py` (shared agent task read-helper usage enforcement),
8888
- `tests/test_agent_terminal_status_helper_usage.py` (shared agent terminal-status helper usage enforcement),
8989
- `tests/test_architecture_marker_usage.py` (architecture marker coverage across guard modules),
90+
- `tests/test_ast_function_source_helper_usage.py` (shared AST function-source helper usage enforcement across architecture guard suites),
9091
- `tests/test_binary_file_open_helper_usage.py` (shared binary file open helper usage enforcement),
9192
- `tests/test_browser_use_payload_helper_usage.py` (browser-use payload helper usage enforcement),
9293
- `tests/test_ci_workflow_quality_gates.py` (CI guard-stage + make-target enforcement),

tests/test_architecture_marker_usage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"tests/test_agent_task_read_helper_usage.py",
1717
"tests/test_agent_stop_helper_usage.py",
1818
"tests/test_agent_terminal_status_helper_usage.py",
19+
"tests/test_ast_function_source_helper_usage.py",
1920
"tests/test_guardrail_ast_utils.py",
2021
"tests/test_helper_transport_usage_boundary.py",
2122
"tests/test_manager_model_dump_usage.py",
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from pathlib import Path
2+
3+
import pytest
4+
5+
pytestmark = pytest.mark.architecture
6+
7+
8+
AST_FUNCTION_SOURCE_GUARD_MODULES = (
9+
"tests/test_job_request_route_builder_internal_reuse.py",
10+
"tests/test_job_request_wrapper_internal_reuse.py",
11+
"tests/test_model_request_function_transport_boundary.py",
12+
"tests/test_model_request_wrapper_internal_reuse.py",
13+
"tests/test_request_wrapper_internal_reuse.py",
14+
"tests/test_session_recordings_follow_redirects_boundary.py",
15+
"tests/test_session_request_wrapper_internal_reuse.py",
16+
"tests/test_session_resource_wrapper_internal_reuse.py",
17+
)
18+
19+
20+
def test_ast_guard_modules_reuse_shared_collect_function_sources_helper():
21+
violating_modules: list[str] = []
22+
for module_path in AST_FUNCTION_SOURCE_GUARD_MODULES:
23+
module_text = Path(module_path).read_text(encoding="utf-8")
24+
if "ast_function_source_utils import collect_function_sources" not in module_text:
25+
violating_modules.append(module_path)
26+
continue
27+
if "def _collect_function_sources" in module_text:
28+
violating_modules.append(module_path)
29+
30+
assert violating_modules == []

0 commit comments

Comments
 (0)