feat: 扩展风险规则体系、审批动态路由与预算中心列表化改造

- 新增 25+ 条风险规则(预算/报销/申请/通用类),完善风险规则模拟与反馈发布机制
- 引入费用审批动态路由、平台风险分级、预审与风险阶段管理
- 预算中心列表化改造,优化票据夹仪表盘与数字员工工作看板
- 新增 Hermes 风险线索收集器、Agent 链路追踪中心
- 扩展数字员工能力库(18 个领域 Skill)与交通费用自动预估
- 完善报销申请快速预览、权限控制与前端测试覆盖
This commit is contained in:
caoxiaozhu
2026-06-01 17:07:14 +08:00
parent 7989f3a159
commit 92444e7eae
285 changed files with 25075 additions and 2986 deletions

View File

@@ -211,11 +211,11 @@ def test_user_agent_application_context_uses_application_language() -> None:
assert "| 字段 | 内容 |" in response.answer
assert "| 发生时间 | 2026-05-25 至 2026-05-27 |" in response.answer
assert "支持上海国网服务器部署" in response.answer
assert "当前还需要补充:出行方式、用户预估费用" in response.answer
assert "当前还需要补充:出行方式" in response.answer
assert "请先在下面选择报销场景" not in response.answer
assert response.review_payload is None
assert [item.label for item in response.suggested_actions] == ["一次性补充申请信息"]
assert response.suggested_actions[0].payload["prompt_prefill"] == "出行方式:\n用户预估费用:"
assert response.suggested_actions[0].payload["prompt_prefill"] == "出行方式:"
def test_user_agent_application_infers_natural_reason_and_expands_single_date() -> None:
@@ -228,7 +228,7 @@ def test_user_agent_application_infers_natural_reason_and_expands_single_date()
assert "| 地点 | 上海市 |" in response.answer
assert "| 事由 | 支撑上海国网服务器部署 |" in response.answer
assert "当前还需要先补充:申请事由" not in response.answer
assert "当前还需要补充:出行方式、用户预估费用" in response.answer
assert "当前还需要补充:出行方式" in response.answer
assert [item.label for item in response.suggested_actions] == ["一次性补充申请信息"]
@@ -292,13 +292,13 @@ def test_user_agent_application_uses_selected_time_and_natural_language_fields()
assert "| 发生时间 | 2026-05-25 |" in response.answer
assert "| 地点 | 上海市 |" in response.answer
assert "| 事由 | 支撑国网服务器上线部署 |" in response.answer
assert "当前还需要补充:出行方式、用户预估费用" in response.answer
assert "当前还需要补充:出行方式" in response.answer
assert [item.label for item in response.suggested_actions] == ["一次性补充申请信息"]
assert response.suggested_actions[0].action_type == "prefill_composer"
assert response.suggested_actions[0].payload["prompt_prefill"] == "出行方式:\n用户预估费用:"
assert response.suggested_actions[0].payload["prompt_prefill"] == "出行方式:"
def test_user_agent_application_asks_amount_after_transport_choice() -> None:
def test_user_agent_application_builds_system_estimate_after_transport_choice() -> None:
session_factory = build_session_factory()
initial_message = (
"发生时间2026-05-25\n"
@@ -313,11 +313,16 @@ def test_user_agent_application_asks_amount_after_transport_choice() -> None:
history=[{"role": "user", "content": initial_message}],
)
assert "这是费用申请核对结果" in response.answer
assert "| 出行方式 | 飞机 |" in response.answer
assert "当前还需要补充:用户预估费用" in response.answer
assert [item.label for item in response.suggested_actions] == ["一次性补充申请信息"]
assert response.suggested_actions[0].action_type == "prefill_composer"
assert response.suggested_actions[0].payload["prompt_prefill"] == "用户预估费用:"
assert "| 系统预估费用 |" in response.answer
assert "交通" in response.answer
assert "参考票价" in response.answer
assert "按 2026-05-25 参考票价" in response.answer
assert "2,330元" in response.answer
assert "查询耗时" in response.answer
assert response.requires_confirmation is True
assert response.suggested_actions == []
def test_user_agent_application_missing_base_actions_prefill_composer() -> None:
@@ -328,10 +333,10 @@ def test_user_agent_application_missing_base_actions_prefill_composer() -> None:
"地点:上海\n事由:支撑国网服务器部署\n天数3天",
)
assert "当前还需要补充:出行方式、用户预估费用" in response.answer
assert "当前还需要补充:出行方式" in response.answer
assert [item.label for item in response.suggested_actions] == ["一次性补充申请信息"]
assert response.suggested_actions[0].action_type == "prefill_composer"
assert response.suggested_actions[0].payload["prompt_prefill"] == "出行方式:\n用户预估费用:"
assert response.suggested_actions[0].payload["prompt_prefill"] == "出行方式:"
def test_user_agent_application_precomputes_time_from_today_and_days() -> None:
@@ -346,7 +351,7 @@ def test_user_agent_application_precomputes_time_from_today_and_days() -> None:
},
)
assert "这是模拟的费用申请结果" in response.answer
assert "这是费用申请核对结果" in response.answer
assert "| 发生时间 | 2026-05-29 至 2026-05-31 |" in response.answer
assert response.requires_confirmation is True
@@ -363,17 +368,27 @@ def test_user_agent_application_builds_preview_when_amount_is_ready() -> None:
response = build_application_user_agent_response(
db,
"预计总费用12000元",
context_overrides={
"name": "张三",
"department_name": "交付部",
"position": "实施经理",
"manager_name": "李文静",
},
history=[
{"role": "user", "content": initial_message},
{"role": "user", "content": "飞机"},
],
)
assert "这是模拟的费用申请结果" in response.answer
assert "这是费用申请核对结果" in response.answer
assert "| 字段 | 内容 |" in response.answer
assert "| 姓名 | 张三 |" in response.answer
assert "| 部门 | 交付部 |" in response.answer
assert "| 岗位 | 实施经理 |" in response.answer
assert "| 直属领导 | 李文静 |" in response.answer
assert "| 事由 | 支持上海国网服务器部署 |" in response.answer
assert "| 出行方式 | 飞机 |" in response.answer
assert "| 用户预估费用 | 12000元 |" in response.answer
assert "| 系统预估费用 | 12000元 |" in response.answer
assert "请核对上述信息无误" in response.answer
assert "[确认](#application-submit)" in response.answer
assert response.requires_confirmation is True
@@ -389,7 +404,7 @@ def test_user_agent_application_submit_enters_leader_review() -> None:
"天数3天"
)
preview_answer = (
"这是模拟的费用申请结果,请核对:\n"
"这是费用申请核对结果,请核对:\n"
"| 字段 | 内容 |\n"
"| --- | --- |\n"
"| 申请类型 | 差旅费用申请 |\n"
@@ -398,7 +413,7 @@ def test_user_agent_application_submit_enters_leader_review() -> None:
"| 事由 | 支持上海国网服务器部署 |\n"
"| 天数 | 3天 |\n"
"| 出行方式 | 飞机 |\n"
"| 用户预估费用 | 12000元 |\n\n"
"| 系统预估费用 | 12000元 |\n\n"
"请核对上述信息无误,确认无误后 [确认](#application-submit) 提交至审批流程。"
)
with session_factory() as db: