refactor(schemas): 统一 message/notification 命名边界,旧名收敛至兼容映射表

- notification 域:渠道能力(MessageChannel→NotificationChannel、ChannelCapability* 迁入 notification.py)
- message 域:消息收发(Notification→Message、NotificationType→MessageType、CommingMessage→IncomingMessage、NotificationHistoryItem→MessageHistoryItem、NotificationClear*→MessageClear*)
- Agent 工具契约:send_notification_message→send_message、notification_callback→message_callback
- 源码不保留旧名物理别名,旧导入经 app/runtime/compat/manifest.py SYMBOL_ALIASES 惰性解析
- API 路径与持久化键冻结不变,前端零改动
- 新增兼容守护测试与 docs/rules/07 命名边界规范
This commit is contained in:
jxxghp
2026-08-16 19:32:20 +08:00
parent 98276a68a8
commit 240a4dffe6
96 changed files with 1975 additions and 1751 deletions
+13 -13
View File
@@ -15,7 +15,7 @@ from app.db.models.message import Message
from app.application.messaging.agent import AgentInteractionOption, agent_interaction_manager
from app.application.messaging.interaction import InteractionContext
from app.application.messaging.media import media_interaction_manager
from app.schemas.types import MessageChannel, NotificationType
from app.schemas.types import NotificationChannel, MessageType
def _clear_messages() -> None:
@@ -31,7 +31,7 @@ def test_explicit_ai_message_bypasses_pending_media_interaction():
media_interaction_manager.clear()
media_interaction_manager.create_or_replace(
user_id="10001",
channel=MessageChannel.Wechat,
channel=NotificationChannel.Wechat,
source="wechat-test",
username="tester",
action="Search",
@@ -47,7 +47,7 @@ def test_explicit_ai_message_bypasses_pending_media_interaction():
chain, "_handle_ai_message", return_value=True
) as handle_ai_message:
chain.handle_message(
channel=MessageChannel.Wechat,
channel=NotificationChannel.Wechat,
source="wechat-test",
userid="10001",
username="tester",
@@ -74,7 +74,7 @@ def test_explicit_ai_message_is_not_recorded_to_message_history():
side_effect=lambda coro, _loop: (coro.close(), Mock())[1],
):
chain.handle_message(
channel=MessageChannel.Telegram,
channel=NotificationChannel.Telegram,
source="telegram-test",
userid="10001",
username="tester",
@@ -97,7 +97,7 @@ def test_message_chain_passes_stable_channel_admin_principal_to_agent():
side_effect=lambda coro, _loop: (coro.close(), Mock())[1],
):
chain.handle_message(
channel=MessageChannel.Telegram,
channel=NotificationChannel.Telegram,
source="telegram-test",
userid="10001",
username="renamed-user",
@@ -120,7 +120,7 @@ def test_message_chain_does_not_trust_channel_display_username():
side_effect=lambda coro, _loop: (coro.close(), Mock())[1],
):
chain.handle_message(
channel=MessageChannel.Telegram,
channel=NotificationChannel.Telegram,
source="telegram-test",
userid="10002",
username="admin",
@@ -143,7 +143,7 @@ def test_message_chain_uses_same_admin_contract_for_slack():
side_effect=lambda coro, _loop: (coro.close(), Mock())[1],
):
chain.handle_message(
channel=MessageChannel.Slack,
channel=NotificationChannel.Slack,
source="slack-test",
userid="UADMIN",
username="renamed-user",
@@ -159,7 +159,7 @@ def test_ask_user_choice_message_is_not_recorded_to_message_history():
_clear_messages()
tool = AskUserChoiceTool(session_id="session-choice", user_id="10001")
tool.set_message_attr(
channel=MessageChannel.Telegram.value,
channel=NotificationChannel.Telegram.value,
source="telegram-test",
username="tester",
)
@@ -198,7 +198,7 @@ def test_agent_final_reply_disables_notification_history():
agent = MoviePilotAgent(
session_id="session-agent-reply",
user_id="10001",
channel=MessageChannel.Telegram.value,
channel=NotificationChannel.Telegram.value,
source="telegram-test",
username="tester",
)
@@ -210,7 +210,7 @@ def test_agent_final_reply_disables_notification_history():
asyncio.run(agent.send_agent_message("已完成处理"))
notification = async_post_message.await_args.args[0]
assert notification.mtype == NotificationType.Agent
assert notification.mtype == MessageType.Agent
assert notification.save_history is False
@@ -218,7 +218,7 @@ def test_send_message_tool_disables_notification_history():
"""Agent 主动发消息工具发送的通知不保存通知历史。"""
tool = SendMessageTool(session_id="session-send-message", user_id="10001")
tool.set_message_attr(
channel=MessageChannel.Telegram.value,
channel=NotificationChannel.Telegram.value,
source="telegram-test",
username="tester",
)
@@ -242,7 +242,7 @@ def test_agent_choice_callback_is_not_recorded_to_message_history():
request = agent_interaction_manager.create_request(
session_id="session-choice",
user_id="10001",
channel=MessageChannel.Telegram.value,
channel=NotificationChannel.Telegram.value,
source="telegram-test",
username="tester",
title="需要你的选择",
@@ -268,7 +268,7 @@ def test_agent_choice_callback_is_not_recorded_to_message_history():
chain._handle_callback(
callback_data=f"agent_interaction:choice:{request.request_id}:1",
context=InteractionContext(
channel=MessageChannel.Telegram,
channel=NotificationChannel.Telegram,
source="telegram-test",
user_id="10001",
username="tester",