收口MCP提交为V4契约

This commit is contained in:
andy
2026-07-22 23:43:54 +07:00
parent 68ff9e2b38
commit 5df2910465
21 changed files with 897 additions and 1609 deletions

View File

@@ -84,37 +84,30 @@
| 用例 ID | 场景 | 输入要点 | 期望结果 |
| --- | --- | --- | --- |
| MCP-T05-001 | 提交单个 normal task | `ai_task_results` 1 条 | 返回 `accepted_count=1` |
| MCP-T05-002 | 提交 manual review | `result_type=manual_review` | 写入人工复核任务 |
| MCP-T05-003 | 提交 informational message | `result_type=informational_message` | 写入提示类信息 |
| MCP-T05-004 | source message 不存在 | 不存在的外部 `source_message_id` | 返回 `SOURCE_MESSAGE_NOT_FOUND` |
| MCP-T05-005 | 缺省 hotel id | 不传 `hotel_id`source message 属于系统酒店 | 后端按系统唯一 ACTIVE 酒店写入成功 |
| MCP-T05-006 | 重复提交同一幂等任务 | 使用相同幂等信息 | 不重复创建业务任务 |
| MCP-T05-007 | hotel id 不一致 | 显式传非系统酒店 `hotel_id` | 返回 `HOTEL_ID_MISMATCH` |
| MCP-T05-008 | source message 入库渠道为 OUTLOOK | 不传 `source_channel`,只传外部 `source_message_id` | 后端按真实 Inbox 渠道写入成功 |
| MCP-T05-009 | source message 多渠道重复 | 同一酒店存在相同外部 `source_message_id` 的多条 Inbox | 返回 `SOURCE_MESSAGE_AMBIGUOUS` |
| MCP-T05-010 | V3 Parent split 使用 Agent 内部事件 ID | `message_events[].source_event_index=E_CHILD_1/E_CHILD_2/E_PARENT` | MCP adapter 按数组顺序映射为 `1/2/3`,返回 `accepted_count=3` |
| MCP-T05-011 | V3 缺失 source message id | `source_message.source_message_id` 缺失 | 返回既有 `MISSING_SOURCE_MESSAGE_ID` typed infrastructure error |
| MCP-T05-012 | V3 多事件关系悬空 | `related_source_event_indices` 引用不存在的事件 ID | 返回 `MCP_SUBMIT_PAYLOAD_INVALID`,不写 AI batch、订单或任务 |
| MCP-T05-013 | V3 多事件关系重复 | `related_source_event_indices=["E_CHILD_1","E_CHILD_1"]` | 返回 `MCP_SUBMIT_PAYLOAD_INVALID`,不写 AI batch、订单或任务 |
| MCP-T05-014 | V3 根节点未知字段 | 根节点存在 `unexpected_root` | 返回 `MCP_SUBMIT_PAYLOAD_INVALID`,不调用业务写入 Service |
| MCP-T05-015 | V3 跨 Child Trace | Trace event 关联全部 Child event | `related_source_event_indices[]` 保留全量关系并映射为真实索引,不压缩到第一个 Child |
| MCP-T05-016 | V3 缺失整个 source_message | 业务根或 S10/S99 没有 `source_message` | 返回既有 `MISSING_SOURCE_MESSAGE_ID` typed infrastructure error |
| MCP-T05-017 | V2 item 缺必填字段 | `ai_task_results[]` item 缺 `task_type` 等必填字段 | 返回 `MCP_SUBMIT_PAYLOAD_INVALID`,不调用业务写入 Service |
| MCP-T05-018 | V3 event 业务契约错误 | event_type unsupported 但 transport 字段完整 | MCP adapter 不整批拒绝,业务入站层保存 `adapter_contract_error` transition |
| MCP-T05-019 | V3 S10 入口通知 | `route_code=S10` | 通过 MCP 写入只读 `SOURCE_MESSAGE_ONLY` 任务 |
| MCP-T05-020 | V3 S99 入口通知 | `route_code=S99``manual_review` 完整 | 通过 MCP 写入只读 `SOURCE_MESSAGE_ONLY` 任务 |
| MCP-T05-001 | V4 普通业务包 | `route_code=null + source_message + order_contexts[] + message_events[]` | 返回 `accepted_count`;只创建 V4 order task / cards不创建旧 `workflow_reservation_task` |
| MCP-T05-001A | V4 普通业务包缺省 conversation_id | `source_message` 不传 `conversation_id` | 返回 `accepted_count`;仍只创建 V4 order task / cards |
| MCP-T05-002 | V4 type-known manual review | V4 `message_events[].manual_review=true`,业务字段可由 V4 入站识别 | 创建 V4 `REVIEW_REQUIRED` 卡,后续通过 V4 复核接口解阻 |
| MCP-T05-003 | V4 S10 来源通知 | `route_code=S10``order_contexts=[]``message_events=[]` | 创建 V4 source notification不创建订单和旧任务 |
| MCP-T05-004 | V4 S99 来源通知 | `route_code=S99``order_contexts=[]``message_events=[]` | 创建 V4 source notification不创建订单和旧任务 |
| MCP-T05-005 | source message 不存在 | V4 `source_message.source_message_id` 无法匹配 Inbox | 返回 `SOURCE_MESSAGE_NOT_FOUND` |
| MCP-T05-006 | 缺省 hotel id | 不传 `hotel_id`source message 属于系统酒店 | 后端按系统唯一 ACTIVE 酒店写入成功 |
| MCP-T05-007 | source message 入库渠道为 OUTLOOK | 不传 `source_channel`,只传 V4 `source_message.source_message_id` | 后端按真实 Inbox 渠道写入成功 |
| MCP-T05-008 | source message 多渠道重复 | 同一酒店存在相同外部 `source_message_id` 的多条 Inbox | 返回 `SOURCE_MESSAGE_AMBIGUOUS` |
| MCP-T05-009 | V4 根结构缺字段 | 缺少 `order_contexts``message_events` | 返回 `MCP_SUBMIT_V4_REQUIRED`,不调用业务写入 Service |
| MCP-T05-010 | V4 source_message 字段错误 | 使用旧 `from/received_at/source_channel` 或缺少 `sender/body_content_type` | 返回 `MCP_SUBMIT_PAYLOAD_INVALID`,不调用业务写入 Service |
| MCP-T05-011 | V4 附件字段错误 | 附件缺少 `id/name/content_type/url``size` 不是数字 | 返回 `MCP_SUBMIT_PAYLOAD_INVALID`,不调用业务写入 Service |
| MCP-T05-012 | V4 event 业务契约错误 | event_type unsupported 或 Payment `attachment_ids[]` 不匹配同包附件 | 由业务入站层保存 `adapter_contract_error`,不创建用户可处理卡 |
| MCP-T05-013 | V3 业务根 | 含 `case_candidates` / `unhandled_current_intents` | 返回 `MCP_SUBMIT_V4_REQUIRED`,不调用业务写入 Service |
| MCP-T05-014 | V3 S10/S99 | 含 `handler_type` / `result_type=source_message_review_notification` | 返回 `MCP_SUBMIT_V4_REQUIRED`,不调用业务写入 Service |
| MCP-T05-015 | 旧 V2 task results | 顶层 `source_message_id + ai_task_results[]` | 返回 `MCP_SUBMIT_V4_REQUIRED`,不调用业务写入 Service |
写入验证:
- `ai_task_results[]` 顺序不能被 MCP endpoint 改变。
- V3 `message_events[]` 顺序是 `source_event_index` 的唯一基准MCP endpoint 不能重排。
- `E1/E2/E_PARENT` 等 Agent 内部事件 ID 只能由 MCP adapter 转换,不能作为本系统最终 `source_event_index`
- V4 `message_events[]` 顺序不能被 MCP endpoint 改变;业务层按数组顺序派生 event index
- MCP endpoint 不能在日志输出完整 `extracted_fields` 中的敏感内容。
- 失败响应应保留后端错误码和 message。
- MCP adapter 校验失败时不进入业务写入 Service且不自动重试。
- V3 成功响应返回 `mapping_diagnostics.source_event_index_mapping[]`,但 AI transition 业务 payload 不包含该诊断字段
- V3 `relationship_type` 可在 event 根节点透传,也可在 `extracted_fields` 中作为业务关系字段MCP adapter 不据此派生业务含义。
- V4-only 模式下 `mapping_diagnostics_json` 为空对象;旧 V3 事件 ID 映射已经废弃
## 9. MCP 鉴权和开关测试
@@ -143,9 +136,9 @@
- 5 个工具正常成功调用。
- 查询接口错误 envelope 不丢失。
- 任务结果写入成功和幂等重放正常。
- V3 submit payload adapter 的事件索引映射、mapping 诊断、悬空关系拒绝、重复关系拒绝和未知字段拒绝正常。
- V2 `ai_task_results[]` item schema 和 adapter 校验正常
- S10/S99 结构化入口通知可通过 MCP 写入工具。
- V4 submit payload adapter 的根结构、source_message、attachments 校验正常。
- 旧 V2/V3 submit payload 统一返回 `MCP_SUBMIT_V4_REQUIRED`,不会进入业务写入 Service
- V4 S10/S99 来源通知可通过 MCP 写入工具。
- provider/channel 隔离正常。
- 受控正文不返回附件 URL。
- MCP auth 失败不进入业务 Service。