feat(#72): 预警规则与阈值设定(声明式AlertRule三级severity+SOP联动,PRD 5.3 ③ 场景A)
把行业知识——预警分级(P0/P1/P2)+阈值+处置SOP——外置为模板配置(PRD line 152/171 阈值外置,行业工程师配置台维护),规则引擎零改动。 - alert_rules.py:AlertSeverity(P0/P1/P2) + AlertCondition(6 运算) + AlertRule(AND 语义) + AlertRuleEngine(按 severity 降序 + primary_alert) + 零依赖 YAML 解析(flow map)。 - config/alert_rules.template.yaml:6 条规则,特征名对齐 #70 FeatureSpec.name,sop 引用 异常处置 SOP(供 #11 LLM 报警解释 + 驾驶舱红色告警 + 值班长确认,PRD 场景A)。 - tests/test_alert_rules.py:16 项单测(运算/规则/引擎排序/配置/端到端P0)全通过。 - _sanity_check_rules.py:冒烟(正常无告警 + 急升温P0)。 PRD line 333:关键告警不直接联动执行机构,高利害输出人工确认 → severity 分级支撑。
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""测试引导:把连字符目录挂载为可导入包(与 core 模块同款模式)。
|
||||
|
||||
- ``templates/ti-cl4/impurity-forecast`` → 包名 ``impurity_forecast``。
|
||||
本规则引擎零内核依赖(纯标准库),仅挂载自身包即可。
|
||||
"""
|
||||
import importlib.util
|
||||
import os
|
||||
import sys
|
||||
|
||||
PKG_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
||||
def _load_package(name: str, path: str) -> None:
|
||||
"""按文件路径完整加载一个包(执行其 __init__.py)。"""
|
||||
if name in sys.modules:
|
||||
return
|
||||
init_py = os.path.join(path, "__init__.py")
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
name, init_py, submodule_search_locations=[path])
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
sys.modules[name] = module
|
||||
spec.loader.exec_module(module)
|
||||
|
||||
|
||||
_load_package("impurity_forecast", PKG_DIR)
|
||||
Reference in New Issue
Block a user