merge: 集成投顾组 3 个提交(解除与「投顾模块清除」的冲突)+ 客服 Agent 重构收口
## 为什么要合并
远端 `origin/qyqy_develop` 领先 3 个提交(`5607751` / `2fe7d0c` / `74b7d00`:投顾需求与架构文档、
客户主动申报投顾方案 + 受理自动出草稿、方案交付落点与推荐依据 LLM 增强),而本地 `5d0becb`
按 `D4.4` / `D4.5`(CS-PURGE-2026-012/013)把投顾模块整体清除了。**两个目标不可兼得**:
远端新代码反向 import 已被清除的模块(`app.model.investment_goal`、
`app.service.product_recommendation_service`、`app.service.advisor_rollout_service`),
强行推进只会让两边都跑不起来。
**裁定:投顾组的新功能 > 本地的投顾清除。** 依据是 `D4.4` §0-②③ 自己写下的风险
——按名字清投顾会同时拆掉产品数据底座与 MVP 硬阻断,并失去"改 6 个底座文件时的对照组"。
本次合并因此**恢复投顾模块**;就代码面而言,`D4.4` / `D4.5` 的清除结果被本次合并取代
(留痕见 `开发文档\D1.6` §4.37)。
## 冲突怎么解的(12 处)
- **8 处 modify/delete 取远端**:`recommendations.py` / `product_recommendation_service.py` /
`employee-advisor/dashboard/{actions-module.js,dashboard.css,dashboard.js,index.html}` /
`tools/{check_portal_modules.py,grant_advisor_role.py}` —— 即"我删、远端改",保留投顾文件。
- **3 处内容冲突取远端**:`app/main.py`(投顾 import 与 `include_router`)、
`common/api-client.js`(投顾端点表)、`tests/unit/api/test_portal_frontend.py`(4 条投顾前端契约)。
- **1 处取远端 + 保留我方**:`app/main.py` 解除冲突的同时,保留本轮的
`/customer-service-test` 挂载移除(该联调页与用例已随重构作废)。
## 因"取消清除"而必须回滚的语义改动(否则恢复出来的投顾代码跑不动)
- `app/service/agent/bootstrap.py`:恢复 `AdvisorAgent` 与 5 个投顾工具注册
(`query_investment_goal` / `analyze_portfolio` / `generate_asset_allocation` /
`recommend_products` / `compare_products`);客服 Agent 注释按本轮口径保留。
- `app/core/config.py`:恢复 `advisor_rollout_enabled` / `advisor_rollout_customer_ids`。
- `app/static/portal/common/layout/app-shell.js`:恢复投顾工作台导航与 `advisor` 角色名。
- `tools/seed_test_rbac.py`:恢复"admin 取全量元组"的授权模型(保留远端新增的
9070-9074 权限码与客户侧 9071/9072 绑定)。
- `tools/portal_api_check.py`:恢复投顾实测用例(AD003/AD005/AD011/A047 与 `advisor_t` 登录),
并**新增判定**:被渲染的集合为空(0 条)时判 `SKIP` 而不是 `FAIL`
—— "没有行"与"字段没带"是两回事,混报会把排查方向带偏。
- `app/static/portal/common/api-client.js`:以远端为基准,重新叠加本轮的
**访客令牌 `Authorization` 优先**修复(浮窗访客身份稳定性)。
## 数据库夹具同步(代码恢复 ⇒ 夹具也要恢复)
- `tools/grant_advisor_role.py`:新建 `advisor` 角色并授权(实测 34 项权限)。
- `tools/create_test_user.py --id 9020 --username advisor_t --role advisor`:重建演示账号。
## 集成期发现并修掉的过期断言
- `tests/unit/test_advisor_migration_contract.py`:alembic 末端钉死值仍是
`20260914_baseline_auto_increment`,而远端新增了 `20260916_advisor_service_request`
⇒ 这条断言**在远端分支上本身就是红的**。本次把它更新到新末端并补了注释。
## 验证(本机实测)
| 门禁 | 结果 |
|---|---|
| `pytest -q`(全量,含集成) | **1909 passed / 3 skipped / 0 failed** |
| `ruff check app tools tests` | 20(远端分支 22,本地仅客服线基线 19) |
| `mypy app` | 2(= 既有基线) |
| `tools/portal_api_check.py` | 40 项:通过 35 / 失败 0 / 跳过 5 |
| `tools/e2e_smoke_test.py --read-only` | 31/31 |
| `_eval_harness/http_probe.py` | 11/11 succeeded |
| `_consistency.py` | GATE PASS |
| `_fe_boundary_http.py`(前端入参边界真机) | 全部符合预期 |
## 未做(如实登记)
- **投顾演示数据未灌**:`AD011` / `A047` 需要 `advisor_product_suitability_reference`
这类带 `source_url` + `document_sha256` 的证据行,而披露文件不在仓库里;
`tools/seed_advisor_demo.py` 明确"不编证据"(fail closed),故这两条按空集 SKIP。
- **客服线文档目录仍未入库**:`客服agent/`、`开发文档/`(权威副本在本机)与
`_chunks_report.txt`(本地构建产物)依旧排除在提交之外。
This commit is contained in:
@@ -4,6 +4,7 @@ from typing import Any, cast
|
||||
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.core.advisor_allocation_contracts import AssetAllocationQuery
|
||||
from app.core.config import get_settings
|
||||
from app.core.errors import RecoverableAgentError
|
||||
from app.core.fund_contracts import FundQuoteQuery
|
||||
@@ -23,6 +24,7 @@ from app.infrastructure.milvus_profile_vector_client import MilvusProfileVectorC
|
||||
from app.infrastructure.vector_memory import VectorMemoryAdapter
|
||||
from app.service.agent.factory import AgentFactory
|
||||
from app.service.agent.governance import PlatformGovernance
|
||||
from app.service.agent.implementations.advisor import AdvisorAgent
|
||||
from app.service.agent.implementations.customer_service import CustomerServiceAgent
|
||||
from app.service.agent.implementations.financial_nl2sql import FinancialNL2SQLAgent
|
||||
from app.service.agent.implementations.fund_query_demo import FundQueryDemoAgent
|
||||
@@ -38,6 +40,7 @@ from app.service.agent.implementations.platform_probe import (
|
||||
from app.service.agent.implementations.risk_agent import RiskAgent
|
||||
from app.service.agent.offsite_fund_agent import OffsiteFundAgent
|
||||
from app.service.agent.promotion_material_agent import PromotionMaterialAgent
|
||||
from app.service.asset_allocation_service import asset_allocation_tool
|
||||
from app.service.customer_profile_service import (
|
||||
CustomerProfileQuery,
|
||||
query_customer_profile_tool,
|
||||
@@ -45,6 +48,7 @@ from app.service.customer_profile_service import (
|
||||
from app.service.financial_nl2sql_service import query_financial_data_tool
|
||||
from app.service.fund_quote_service import query_fund_quote_tool
|
||||
from app.service.intent_classifier import IntentClassifier
|
||||
from app.service.investment_goal_service import investment_goal_query_tool
|
||||
from app.service.knowledge_search_service import KnowledgeSearchService
|
||||
from app.service.knowledge_tool import knowledge_search_tool
|
||||
from app.service.memory_recall_service import MemoryRecallService
|
||||
@@ -55,6 +59,9 @@ from app.service.model_gateway import (
|
||||
ModelEmbeddingService,
|
||||
ModelGenerationService,
|
||||
)
|
||||
from app.service.portfolio_analysis_service import portfolio_analysis_tool
|
||||
from app.service.product_comparison_service import product_comparison_tool
|
||||
from app.service.product_recommendation_service import product_recommendation_tool
|
||||
from app.service.relationship_service import RelationshipService
|
||||
from app.service.risk_tools import (
|
||||
get_alert_evidence_tool,
|
||||
@@ -349,6 +356,45 @@ def get_agent_factory() -> AgentFactory:
|
||||
required_permission="risk:alert:read",
|
||||
allowed_roles=("risk_operator", "admin"),
|
||||
))
|
||||
registry.register(ToolDefinition(
|
||||
name="query_investment_goal",
|
||||
input_model=InvestmentGoalQuery,
|
||||
handler=cast(Any, investment_goal_query_tool),
|
||||
required_permission="investment-goal:read:self",
|
||||
allowed_roles=("customer", "advisor", "operator", "admin"),
|
||||
))
|
||||
registry.register(ToolDefinition(
|
||||
name="analyze_portfolio",
|
||||
input_model=PortfolioAnalysisQuery,
|
||||
handler=cast(Any, portfolio_analysis_tool),
|
||||
required_permission="portfolio-analysis:read:self",
|
||||
allowed_roles=("customer", "advisor", "operator", "admin"),
|
||||
timeout_seconds=10,
|
||||
))
|
||||
registry.register(ToolDefinition(
|
||||
name="generate_asset_allocation",
|
||||
input_model=AssetAllocationQuery,
|
||||
handler=cast(Any, asset_allocation_tool),
|
||||
required_permission="asset-allocation:generate:self",
|
||||
allowed_roles=("customer", "advisor", "operator", "admin"),
|
||||
timeout_seconds=15,
|
||||
))
|
||||
registry.register(ToolDefinition(
|
||||
name="recommend_products",
|
||||
input_model=ProductRecommendationQuery,
|
||||
handler=cast(Any, product_recommendation_tool),
|
||||
required_permission="product-recommendation:generate:self",
|
||||
allowed_roles=("customer", "advisor", "operator", "admin"),
|
||||
timeout_seconds=15,
|
||||
))
|
||||
registry.register(ToolDefinition(
|
||||
name="compare_products",
|
||||
input_model=ProductComparisonQuery,
|
||||
handler=cast(Any, product_comparison_tool),
|
||||
required_permission="product-comparison:read:self",
|
||||
allowed_roles=("customer", "advisor", "operator", "admin"),
|
||||
timeout_seconds=10,
|
||||
))
|
||||
|
||||
model_service = get_model_service()
|
||||
endpoint_resolver = DatabaseModelEndpointResolver()
|
||||
@@ -379,6 +425,13 @@ def register_business_agents(factory: AgentFactory) -> None:
|
||||
FundQueryDemoAgent.definition,
|
||||
lambda _context: FundQueryDemoAgent(FundQueryDemoAgent.definition),
|
||||
)
|
||||
# 客服 Agent:访客(免登录)与登录客户共用一个 agent_type,档位由身份推导
|
||||
# (见 `knowledge_tool.tiers_for_roles`)。实际可调用的工具还要与发布配置里
|
||||
# `agent_tools/customer_service:<intent>` 的白名单取交集——代码声明只是上限。
|
||||
factory.register(
|
||||
CustomerServiceAgent.definition,
|
||||
lambda _context: CustomerServiceAgent(CustomerServiceAgent.definition),
|
||||
)
|
||||
factory.register(
|
||||
RiskAgent.definition,
|
||||
lambda _context: RiskAgent(RiskAgent.definition),
|
||||
@@ -397,14 +450,11 @@ def register_business_agents(factory: AgentFactory) -> None:
|
||||
PlatformProbeAgent.definition,
|
||||
lambda _context: PlatformProbeAgent(PlatformProbeAgent.definition),
|
||||
)
|
||||
factory.register(
|
||||
AdvisorAgent.definition,
|
||||
lambda _context: AdvisorAgent(AdvisorAgent.definition),
|
||||
)
|
||||
factory.register(
|
||||
FinancialNL2SQLAgent.definition,
|
||||
lambda _context: FinancialNL2SQLAgent(FinancialNL2SQLAgent.definition),
|
||||
)
|
||||
# 客服 Agent:访客(免登录)与登录客户共用一个 agent_type,档位由身份推导
|
||||
# (见 `knowledge_tool.tiers_for_roles`)。实际可调用的工具还要与发布配置里
|
||||
# `agent_tools/customer_service:<intent>` 的白名单取交集——代码声明只是上限。
|
||||
factory.register(
|
||||
CustomerServiceAgent.definition,
|
||||
lambda _context: CustomerServiceAgent(CustomerServiceAgent.definition),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user