refactor(events): unify scoped runtime notifications across clients (#5670)

* refactor(events): unify scoped runtime notifications across clients

* style(tests): sort auto-compaction event imports

* refactor(events): scope connections and remove retry callback plumbing

* docs: remove runtime notification design write-up

* refactor(bus): route operation events through the message bus

* fix(channels): isolate outbound sends by destination

* style(events): group shared notification imports

* refactor(events): converge runtime and hook delivery on MessageBus

* test(events): migrate fixtures to unified message bus
This commit is contained in:
chengyongru authored and GitHub committed 2026-09-06 02:11:19 +08:00
1 parent 3495281282
commit 192e2e90dc
78 files changed
+1620 -1194

No files matched your search

+9 -8
View File
@@ -17,6 +17,7 @@ from nanobot.agent.memory import MemoryStore
from nanobot.agent.tools.registry import ToolRegistry
from nanobot.agent.turn_delivery import TurnDeliveryFactory
from nanobot.bus.events import InboundMessage, OutboundMessage
from nanobot.bus.queue import MessageBus
from nanobot.cli import commands as cli_commands
from nanobot.cli import gateway_runtime as cli_gateway_runtime
from nanobot.cli import provider as provider_commands
@@ -2871,7 +2872,7 @@ def _patch_serve_runtime(monkeypatch, config: Config, seen: dict[str, object]) -
_patch_cli_command_runtime(
monkeypatch,
config,
message_bus=lambda: object(),
message_bus=MessageBus,
session_manager=lambda _workspace: _EmptyGatewaySessionManager(),
)
monkeypatch.setattr("nanobot.cli.commands.AgentLoop", _FakeAgentLoop)
@@ -2938,7 +2939,7 @@ def test_gateway_uses_workspace_directory_for_cron_store(monkeypatch, tmp_path:
_patch_cli_command_runtime(
monkeypatch,
config,
message_bus=lambda: object(),
message_bus=MessageBus,
session_manager=lambda _workspace: _EmptyGatewaySessionManager(),
cron_service=_StopCron,
)
@@ -3290,7 +3291,7 @@ def test_gateway_local_trigger_queue_submits_agent_turns(
config.agents.defaults.workspace = str(tmp_path / "config-workspace")
config.agents.defaults.dream.enabled = False
config.gateway.heartbeat.enabled = False
bus = MagicMock()
bus = MessageBus()
seen: dict[str, object] = {}
_patch_cli_command_runtime(
@@ -3444,7 +3445,7 @@ def test_gateway_workspace_override_does_not_migrate_legacy_cron(
_patch_cli_command_runtime(
monkeypatch,
config,
message_bus=lambda: object(),
message_bus=MessageBus,
session_manager=lambda _workspace: _EmptyGatewaySessionManager(),
cron_service=_StopCron,
get_cron_dir=lambda: legacy_dir,
@@ -3483,7 +3484,7 @@ def test_gateway_custom_config_workspace_does_not_migrate_legacy_cron(
_patch_cli_command_runtime(
monkeypatch,
config,
message_bus=lambda: object(),
message_bus=MessageBus,
session_manager=lambda _workspace: _EmptyGatewaySessionManager(),
cron_service=_StopCron,
get_cron_dir=lambda: legacy_dir,
@@ -3684,7 +3685,7 @@ def test_gateway_health_endpoint_binds_and_serves_expected_responses(
_patch_cli_command_runtime(
monkeypatch,
config,
message_bus=lambda: object(),
message_bus=MessageBus,
session_manager=lambda _workspace: _EmptyGatewaySessionManager(),
)
monkeypatch.setattr("nanobot.cli.gateway_runtime.AgentLoop", _FakeAgentLoop)
@@ -3895,7 +3896,7 @@ def test_gateway_agent_task_owns_initial_mcp_provider_close(
_patch_cli_command_runtime(
monkeypatch,
config,
message_bus=lambda: object(),
message_bus=MessageBus,
session_manager=lambda _workspace: _EmptyGatewaySessionManager(),
)
monkeypatch.setattr("nanobot.cli.gateway_runtime.AgentLoop", _FakeAgentLoop)
@@ -4024,7 +4025,7 @@ def test_gateway_shutdown_event_exits_forever_runtime_tasks(
_patch_cli_command_runtime(
monkeypatch,
config,
message_bus=lambda: object(),
message_bus=MessageBus,
session_manager=lambda _workspace: _EmptyGatewaySessionManager(),
)
monkeypatch.setattr("nanobot.cli.gateway_runtime.AgentLoop", _FakeAgentLoop)