feat: 2026-04-15~05-02 累积变更基线 — AI 重构 + Runtime Context + DWS 修复
涵盖(每条对应已存的审计记录): - AI 模块拆分:apps/backend/app/ai/apps -> prompts/(8 个 APP + app2a 派生) audit: 2026-04-20__ai-module-complete.md - admin-web AI 管理套件:AIDashboard / AIOperations / AIRunLogs / AITriggers / TriggerManager audit: 2026-04-21__admin-web-ai-management-suite.md - App2 财务洞察 prompt v3 -> v5.1 + 小程序 AI 接入(chat / board-finance) audit: 2026-04-22__app2_prompt_v5_1_and_miniprogram_ai_insight.md - App2 prewarm 全过滤器 + AI 触发器 cron reschedule audit: 2026-04-21__app2-finance-prewarm-all-filters.md migration: 20260420_ai_trigger_jobs_and_app2_prewarm.sql / 20260421_app2_prewarm_cron_reschedule.sql - AppType 联合类型对齐 + adminAiAppTypes.test.ts audit: 2026-04-30__admin_web_ai_app_type_alignment.md - DashScope tokens_used 提取修复 audit: 2026-04-30__backend_dashscope_tokens_used_extraction.md - App3 线索完整详情 prompt audit: 2026-05-01__backend_app3_full_detail_prompt.md - Runtime Context 沙箱(5-1~5-2 主线): - 后端 schema/service + admin_runtime_context / xcx_runtime_clock 两个 router - admin-web RuntimeContext.tsx + miniprogram runtime-clock.ts - migration: 20260501__runtime_context_sandbox.sql - tools/db/verify_admin_web_sandbox.py + verify_sandbox_end_to_end.py - database/changes: 7 份 sandbox_* 验证报告 - 飞球 DWS 修复:finance_area_daily 区域汇总 + task_engine 调整 + RLS 视图业务日上界(migration 20260502 + scripts/ops/gen_rls_business_date_migration.py) 合规: - .gitignore 启用 tmp/ 排除 - 不入仓:apps/etl/connectors/feiqiu/.env(API_TOKEN secret,本地修改保留) 待验证清单: - docs/audit/changes/2026-05-04__cumulative_baseline_pending_verification.md 每个主题的功能完整性 / 上线验证几乎都未收口,按优先级 P0~P3 逐一处理
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
# 2026-05-01 App3 完整消费明细 Prompt 策略
|
||||
|
||||
## 背景
|
||||
|
||||
- 历史问题:2026-04-20 真实 E2E 中 `app3_clue` 曾因 prompt 过大在 121s 超时。
|
||||
- 原缓解策略:App3 prompt 超过 4000 字后,仅保留最近 3 条 `consumption_records`,必要时清空 `reference`。
|
||||
- 本轮用户明确倾向:保留完整消费明细,先验证完整明细是否能正常返回。
|
||||
|
||||
## 变更内容
|
||||
|
||||
| 文件 | 变更 |
|
||||
| --- | --- |
|
||||
| `apps/backend/app/ai/prompts/app3_clue_prompt.py` | 取消 App3 4000 字/3 条消费记录硬截断,保留完整 `consumption_records` 与 `reference` |
|
||||
| `apps/backend/tests/tests/unit/test_app3_clue_prompt_full_detail.py` | 新增单元测试,锁定 100 条消费记录完整保留 |
|
||||
| `docs/ai/ai_apps_feature_acceptance_spec.md` | 更新 App3 验收点与消费记录风险说明 |
|
||||
| `docs/claude-history/issue_resolution_tracker_2026-04-30.md` | 将 A1-03 状态更新为已验证,并记录真实调用结果 |
|
||||
|
||||
## 验证记录
|
||||
|
||||
### RED
|
||||
|
||||
```powershell
|
||||
C:\Project\NeoZQYY\.venv\Scripts\python.exe -m pytest tests/tests/unit/test_app3_clue_prompt_full_detail.py -q
|
||||
```
|
||||
|
||||
结果:失败。当前实现把 100 条消费记录裁剪到 3 条,符合预期 RED。
|
||||
|
||||
### GREEN
|
||||
|
||||
```powershell
|
||||
C:\Project\NeoZQYY\.venv\Scripts\python.exe -m pytest tests/tests/unit/test_app3_clue_prompt_full_detail.py -q
|
||||
```
|
||||
|
||||
结果:`1 passed`。
|
||||
|
||||
```powershell
|
||||
C:\Project\NeoZQYY\.venv\Scripts\python.exe -m pytest tests/tests/unit/test_app3_clue_prompt_full_detail.py tests/tests/test_ai_prompts_smoke.py -q
|
||||
```
|
||||
|
||||
结果:`7 passed`。
|
||||
|
||||
```powershell
|
||||
C:\Project\NeoZQYY\.venv\Scripts\python.exe -m compileall app/ai/prompts/app3_clue_prompt.py
|
||||
```
|
||||
|
||||
结果:通过。
|
||||
|
||||
### 真实 App3 调用
|
||||
|
||||
使用合成会员数据,不读取真实门店或生产会员数据:
|
||||
|
||||
- 完整消费明细:100 条
|
||||
- prompt 长度:25,791 字
|
||||
- 本地截断标记:无
|
||||
- DashScope App3 返回:成功
|
||||
- 耗时:64.30s
|
||||
- tokens_used:15,708
|
||||
- 返回结构:`{"clues": [...]}`,共 4 条
|
||||
- 结论:低于当前 `_STEP_TIMEOUT=180s` 单步超时阈值
|
||||
|
||||
## 影响范围
|
||||
|
||||
- 影响消费事件链 `App3 -> App8 -> App7` 的 App3 prompt 输入规模。
|
||||
- App3 成功时,App8 可获得更完整的消费线索输入,降低高频客户模式被裁剪的风险。
|
||||
- 不涉及数据库 schema、RLS、权限、API 入参或前端字段变更。
|
||||
|
||||
## 风险与回滚
|
||||
|
||||
剩余风险:
|
||||
|
||||
- 真实门店极端会员、较大的历史 `reference`、百炼侧临时性能波动,仍可能导致 App3 耗时升高。
|
||||
- prompt 长度增加会提高单次 token 消耗,本次合成样例为 15,708 tokens。
|
||||
|
||||
观察建议:
|
||||
|
||||
- 后续上线后重点观察 `ai_run_logs.elapsed_ms`、`tokens_used` 和 `app3_clue` timeout 告警。
|
||||
|
||||
回滚方式:
|
||||
|
||||
- 如真实数据出现持续超时,可恢复 App3 的消费记录截断逻辑,或改为“完整明细优先 + 超大样本动态降级”的折中策略。
|
||||
Reference in New Issue
Block a user