feat: Phase2影响分析 — EXPLAIN预检+大表检测(简化版)+执行策略+风险评估table_sizes支持 (1141测试)

新增:
- explain_preview.py: EXPLAIN预检服务(MySQL/PG), 影响行数预估, 全表扫描检测
- ticket.executor: 三种执行策略(stop_on_error/continue/transaction)
- risk_evaluator: table_sizes参数, 大表ALTER/UPDATE/DELETE自动升级high
- test_phase2_features.py: 22个测试(EXPLAIN+执行策略+大表检测)

简化:
- 砍掉CTX-001上下文感知规则(复杂二次扫描), 合并大表检测到risk_evaluator
- 审核引擎保持纯静态分析, 不再导入_RULE_REGISTRY做二次扫描

模型:
- Ticket加exec_strategy字段
- TicketSqlItem模型
- schema加sql_type/exec_strategy/risk_level/workflow_id
This commit is contained in:
logan committed 2026-05-25 11:02:51 +08:00
1 parent 7be0bf1a7c
commit f6f9142ce8
7 files changed
+574 -22

No files matched your search

+1
View File
@@ -18,6 +18,7 @@ class Ticket(Base):
priority = Column(String(10), default="medium") # high / medium / low
risk_level = Column(String(20), default="low", comment="自动风险等级: low/medium/high/critical")
workflow_id = Column(Integer, ForeignKey("workflow_definitions.id"), nullable=True, comment="关联审批流")
exec_strategy = Column(String(20), default="stop_on_error", comment="执行策略: stop_on_error/continue/transaction")
applicant_id = Column(Integer, ForeignKey("users.id"), nullable=False)
approver_id = Column(Integer, ForeignKey("users.id"), nullable=True)
reason = Column(Text, nullable=True)