Hermes CI Fix
2c2dbc2b2d
ci/woodpecker/push/main Pipeline failed
fix(cma): 行动计划自动生成补账套 — 第 4 处写入点 + 写前同源校验
任务:0-P1-project-20260922-actionplan-entity-write-fullstack
父单:project-20260921-cma-entity-isolation-batch5(§B 治本 0c2e57a)
同族已修(勿重做):alerts.py / deviation_push.py / ai_suggestions.py(d03e322)
缺陷(唯一活写入点):
scripts/alert_generator.py::run_alert_check 为 red/yellow 预警自动建 ActionPlan 时
不传 entity_id(模型 default=1 + 生产 DDL `DEFAULT 1` 双默认静默兜底)⇒ 非 e1 账套的
KPI 触发阈值时「同一次事务里预警归属正确、计划归属落 1」;读侧 dashboard.py 工作台按
ActionPlan.entity_id 取出计划、KPI 名不做账套过滤渲染 ⇒ 酣客(e1) 工作台显示博海(e2)/
演示(e6) 的 KPI 名(实测 19/83 行归属不符,09-17/18/22 07:00 各新增 6/7/6 行,每日复发)。
改动:
1. 写入点补账套:ActionPlan(entity_id=kpi.entity_id, …) —— 归属唯一事实源 = 来源 KPI 账套;
2. 写前同源校验 action_plan_entity_guard():来源账套(kpi.entity_id) 与目标账套
(alert.entity_id,即本次遍历账套) 不一致或任一为空 → 不建计划 + OperationLog
(action="skip_plan", reason=plan_entity_attribution_mismatch) 留痕 + 计入统计输出,
不 raise、不中断流水线(口径照抄 bot_bridge_v2 R1 账套守卫 / B3(b) skip_alert 留痕姿势);
3. 统计/汇总:stats 增 skipped_plan_entity_mismatch / skipped_plan_kpis,并在
generate_and_push 返回值与 coverage_note 中显式输出(不得静默丢弃);
4. 新增回归 tests/test_alert_generator_entity_attribution_20260922.py(T1/T2/T3 改前 RED、
改后 GREEN;T4 正对照改前即绿,不构成本单判据)。
边界(零越界):零 DDL(未动列默认、无 alembic/migration/SQL 脚本)、未改 models、
未动同族三处已修文件、未写生产库、未调写端点、未改 cron/前端、未 push、未部署、未重启。
回归:backend `pytest -q` 1374 passed / 0 failed(基线 1370 + 新增 4)
2026-09-22 11:35:01 +08:00
..
2026-09-14 17:39:53 +08:00
2026-09-11 17:25:24 +08:00
2026-09-15 18:12:05 +08:00
2026-08-28 09:59:07 +08:00
2026-09-16 06:53:28 +08:00
2026-08-31 15:33:07 +08:00
2026-08-31 15:33:07 +08:00
2026-08-31 15:33:07 +08:00
2026-07-12 17:46:08 +08:00
2026-07-12 17:46:08 +08:00
2026-08-31 15:33:07 +08:00
2026-07-12 17:46:08 +08:00
2026-08-31 15:33:07 +08:00
2026-08-31 07:44:00 +08:00
2026-05-28 17:32:22 +08:00
2026-09-22 11:35:01 +08:00
2026-07-12 17:46:08 +08:00
2026-09-14 16:41:15 +08:00
2026-09-16 23:46:48 +08:00
2026-09-11 19:33:52 +08:00
2026-08-10 23:56:14 +08:00
2026-08-31 17:05:21 +08:00
2026-09-12 23:34:35 +08:00
2026-09-12 23:34:35 +08:00
2026-08-30 12:05:36 +08:00
2026-07-12 17:46:08 +08:00
2026-08-31 15:33:07 +08:00
2026-08-31 15:33:07 +08:00
2026-08-27 15:51:19 +08:00
2026-09-03 18:15:05 +08:00
2026-05-28 17:32:22 +08:00
2026-09-16 14:39:54 +08:00
2026-07-14 16:02:33 +08:00
2026-07-14 16:02:33 +08:00
2026-06-05 07:51:20 +08:00
2026-07-14 16:02:33 +08:00
2026-08-31 15:33:07 +08:00
2026-06-05 07:51:20 +08:00
2026-07-12 17:46:08 +08:00
2026-08-31 15:33:07 +08:00
2026-09-12 23:34:35 +08:00
2026-09-11 17:25:24 +08:00
2026-08-28 09:59:07 +08:00
2026-07-12 17:46:08 +08:00
2026-07-29 18:16:37 +08:00
2026-09-18 00:34:04 +08:00
2026-09-12 23:34:35 +08:00
2026-09-12 23:34:35 +08:00
2026-09-16 01:17:09 +08:00
2026-09-14 17:25:49 +08:00
2026-09-19 10:05:11 +08:00
2026-07-14 16:02:33 +08:00
2026-07-14 16:02:33 +08:00
2026-09-14 18:21:33 +08:00
2026-09-18 00:34:04 +08:00
2026-09-14 19:05:16 +08:00
2026-09-14 17:19:49 +08:00
2026-07-22 17:43:59 +08:00
2026-09-22 11:06:02 +08:00
2026-08-27 15:51:19 +08:00
2026-09-12 23:34:35 +08:00
2026-09-15 18:12:05 +08:00
2026-07-14 16:02:33 +08:00
2026-09-18 00:34:04 +08:00
2026-08-27 10:59:56 +08:00
2026-07-14 17:32:22 +08:00
2026-07-21 23:41:40 +08:00
2026-09-11 19:33:52 +08:00
2026-08-04 15:35:15 +08:00
2026-08-30 19:16:19 +08:00
2026-09-12 01:03:31 +08:00
2026-08-30 12:05:36 +08:00
2026-07-12 17:46:08 +08:00
2026-06-05 07:51:20 +08:00
2026-07-12 17:46:08 +08:00
2026-07-16 16:39:24 +08:00
2026-08-28 07:18:54 +08:00
2026-07-12 17:46:08 +08:00
2026-09-12 23:34:35 +08:00
2026-07-12 17:46:08 +08:00
2026-07-21 17:30:50 +08:00
2026-07-12 17:46:08 +08:00
2026-08-11 00:11:25 +08:00
2026-07-13 09:52:06 +08:00
2026-07-21 17:22:43 +08:00
2026-08-19 22:58:10 +08:00
2026-07-14 16:02:33 +08:00
2026-07-14 16:02:33 +08:00
2026-09-16 14:59:02 +08:00
2026-09-18 06:04:48 +08:00
2026-09-15 20:02:56 +08:00
2026-09-03 18:41:44 +08:00
2026-07-14 16:02:33 +08:00
2026-09-08 13:43:20 +08:00
2026-09-12 20:35:20 +08:00
2026-09-14 17:39:53 +08:00
2026-09-14 17:39:53 +08:00
2026-09-14 17:39:53 +08:00
2026-09-14 18:44:39 +08:00
2026-09-14 17:39:53 +08:00
2026-09-13 07:38:58 +08:00
2026-09-14 17:39:53 +08:00
2026-09-14 17:39:53 +08:00
2026-09-14 17:39:53 +08:00
2026-09-14 17:39:53 +08:00
2026-09-14 17:39:53 +08:00
2026-09-15 18:12:05 +08:00
2026-09-14 17:39:53 +08:00
2026-09-14 17:39:53 +08:00
2026-09-14 17:39:53 +08:00
2026-09-16 01:17:09 +08:00
2026-09-14 17:39:53 +08:00
2026-09-16 00:38:01 +08:00
2026-09-14 17:39:53 +08:00
2026-09-11 17:25:24 +08:00
2026-09-06 16:47:25 +08:00