refactor: isolate runtime contracts and enforce import boundaries (#6166)
* test: enforce Python import ownership boundaries * test: protect client import boundaries and rehome shared UI contracts * refactor: remove gateway and client dependency inversions * fix: detect dynamic imports in conditional expressions * refactor(tools): keep configuration contracts with their owners * docs: keep design guidance focused on ownership and checks * fix: preserve default threaded turn delivery
This commit is contained in:
1 parent
cd2a863710
commit
328e933d36
162 files changed
+3449
-1888
No files matched your search
@@ -2637,7 +2637,7 @@ def test_optional_dependency_metadata_for_enable():
|
||||
required = data["project"]["dependencies"]
|
||||
|
||||
assert "boto3>=1.43.0" not in data["project"]["dependencies"]
|
||||
assert deps["bedrock"] == ["boto3>=1.43.0"]
|
||||
assert deps["bedrock"] == ["boto3>=1.43.0", "botocore>=1.43.0,<2.0.0"]
|
||||
# The built-in remote WebUI proxy now needs aiohttp even without channels.
|
||||
# Keep the historical API extra installable for existing deployment commands.
|
||||
assert "aiohttp>=3.14.3,<4.0.0" in required
|
||||
@@ -2729,6 +2729,8 @@ def test_optional_dependency_metadata_for_enable():
|
||||
"weixin": ("qrcode[pil]>=8.0", "pycryptodome>=3.20.0"),
|
||||
"whatsapp": (
|
||||
"neonize>=0.4.3.post0,<0.5.0",
|
||||
"python-magic>=0.4.27; sys_platform != 'win32'",
|
||||
"python-magic-bin>=0.4.14; sys_platform == 'win32'",
|
||||
"segno>=1.6.1,<2.0.0",
|
||||
),
|
||||
}
|
||||
|
||||
@@ -10,18 +10,6 @@ from nanobot.channels.websocket import runtime
|
||||
_REPOSITORY_ROOT = Path(__file__).resolve().parents[2]
|
||||
_RUNTIME_PATH = _REPOSITORY_ROOT / "nanobot" / "channels" / "websocket" / "runtime.py"
|
||||
_SESSION_IDENTITY_PATH = _REPOSITORY_ROOT / "nanobot" / "webui" / "session_identity.py"
|
||||
_FORBIDDEN_RUNTIME_IMPORTS = (
|
||||
"nanobot.bus.outbound_events",
|
||||
"nanobot.command",
|
||||
"nanobot.runtime_context",
|
||||
"nanobot.security.workspace_access",
|
||||
"nanobot.session.goal_state",
|
||||
"nanobot.webui.cli_apps_api",
|
||||
"nanobot.webui.forking",
|
||||
"nanobot.webui.mcp_presets_api",
|
||||
"nanobot.webui.sidebar_state",
|
||||
"nanobot.webui.transcription_ws",
|
||||
)
|
||||
|
||||
|
||||
def _channel_method(name: str) -> ast.AsyncFunctionDef:
|
||||
@@ -50,21 +38,6 @@ def _statements_without_docstring(node: ast.AsyncFunctionDef) -> list[ast.stmt]:
|
||||
return body
|
||||
|
||||
|
||||
def test_websocket_runtime_does_not_import_application_command_trees() -> None:
|
||||
tree = ast.parse(_RUNTIME_PATH.read_text(encoding="utf-8"))
|
||||
imported = {
|
||||
node.module
|
||||
for node in tree.body
|
||||
if isinstance(node, ast.ImportFrom) and node.module is not None
|
||||
}
|
||||
violations = sorted(
|
||||
module
|
||||
for module in imported
|
||||
if module.startswith(_FORBIDDEN_RUNTIME_IMPORTS)
|
||||
)
|
||||
assert violations == []
|
||||
|
||||
|
||||
def test_business_entrypoints_are_thin_transport_delegations() -> None:
|
||||
for method_name in ("_dispatch_envelope", "_hydrate_after_subscribe", "send"):
|
||||
statements = _statements_without_docstring(_channel_method(method_name))
|
||||
|
||||
Reference in new issue
Block a user