fix(cma): 工作台跨实体污染治本 — 全局键拆账套 + 缺列收口 + 预警归属兜底
任务 dama-workbench-entity-isolation-fullstack-20260922(DAMA 诊断 / 项目Bot batch5 §B / 任总 2026-09-22「都批」) B1 现金基线拆账套(零 DDL) - cash_forecast_engine: 键 cash.current_balance → cash.current_balance.<entity_id>; 读只读本账套键、不做旧键回退;set_* 签名 entity_id 必传(漏传 TypeError) - cash.py: POST /balance 挂 get_entity_id;网银流水联动写回带账套 B3(a) alignment_config 拆账套(零 DDL) - alignment.py: GET/POST /config、GET /tree 只读 alignment_config.<entity_id>;未配置=configured:false B3(b) 预警 KPI 归属兜底 - bot_bridge_v2: 去掉 kpi_id or 1 兜底;本账套无 KPI 定义 → 跳过建预警 + OperationLog 留痕 (kpi_alerts.kpi_id NOT NULL ⇒ 方案A 置 NULL 不可行,走方案B 跳过+审计) B2 缺列五表分表处置 - notification_logs: 经 alert_id → kpi_alerts.entity_id join 归属(无父键行不返回) - notification_channels / okr_templates: 集团共享口径写入 docstring(有意不过滤) - system_configs: 由 B1/B3(a) 拆键覆盖;kpi_data_quality_logs 沿用 batch5 的 join 收口 P0 语义收敛 - tenant.py: current_tenant 收敛为项目Bot A2A 状态记录,GET 仅 it/ceo;POST 补 operation_logs 审计 证据:新增/改写用例 22 条;全量 1370 passed(基线 1348)
This commit is contained in:
@@ -41,13 +41,19 @@ def _ensure_entity(db: Session, eid: int, name: str) -> Entity:
|
||||
return ent
|
||||
|
||||
|
||||
def _set_mode(db: Session, mode: str) -> None:
|
||||
"""写入全局对齐模式配置(RolePermission.alignment_config,不分账套)"""
|
||||
perm = db.query(RolePermission).filter(RolePermission.key == "alignment_config").first()
|
||||
if perm:
|
||||
perm.value = {"mode": mode}
|
||||
else:
|
||||
db.add(RolePermission(key="alignment_config", value={"mode": mode}))
|
||||
def _set_mode(db: Session, mode: str, entity_ids=(1, 2)) -> None:
|
||||
"""写入对齐模式配置 —— 2026-09-22 B3(a) 拆账套后为 `alignment_config.<entity_id>`
|
||||
|
||||
本文件断言的语义 =「两账套处在同一对齐模式时,各自只返回本账套 KPI」,
|
||||
故对 e1/e2 各写一份(修复前为全局唯一键,一份两账套共用)。
|
||||
"""
|
||||
for eid in entity_ids:
|
||||
key = f"alignment_config.{eid}"
|
||||
perm = db.query(RolePermission).filter(RolePermission.key == key).first()
|
||||
if perm:
|
||||
perm.value = {"mode": mode}
|
||||
else:
|
||||
db.add(RolePermission(key=key, value={"mode": mode}))
|
||||
db.commit()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user