feat: 增强规则资产管理与审计页面运行时调试
后端新增规则资产版本管理和规则文件 CRUD 接口,优化风险 规则生成模板执行和员工数据模型字段,知识库 RAG 增强本 地回退和文档提取能力,清理旧风险规则文件统一由生成引擎 管理,前端审计页面增加运行时调试面板和规则资产编辑交互, 补充单元测试覆盖。
This commit is contained in:
@@ -4,7 +4,7 @@ import uuid
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
from sqlalchemy import DateTime, ForeignKey, String, Text, UniqueConstraint, func
|
||||
from sqlalchemy import Boolean, DateTime, ForeignKey, String, Text, UniqueConstraint, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.types import JSON
|
||||
|
||||
@@ -46,6 +46,12 @@ class AgentAsset(Base):
|
||||
order_by="desc(AgentAssetReview.created_at)",
|
||||
)
|
||||
scheduled_runs = relationship("AgentRun", back_populates="task_asset")
|
||||
test_runs = relationship(
|
||||
"AgentAssetTestRun",
|
||||
back_populates="asset",
|
||||
cascade="all, delete-orphan",
|
||||
order_by="desc(AgentAssetTestRun.created_at)",
|
||||
)
|
||||
|
||||
|
||||
class AgentAssetVersion(Base):
|
||||
@@ -79,3 +85,21 @@ class AgentAssetReview(Base):
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
asset = relationship("AgentAsset", back_populates="reviews")
|
||||
|
||||
|
||||
class AgentAssetTestRun(Base):
|
||||
__tablename__ = "agent_asset_test_runs"
|
||||
|
||||
id: Mapped[str] = mapped_column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
||||
asset_id: Mapped[str] = mapped_column(ForeignKey("agent_assets.id"), index=True)
|
||||
version: Mapped[str] = mapped_column(String(30), index=True)
|
||||
test_type: Mapped[str] = mapped_column(String(30), index=True)
|
||||
status: Mapped[str] = mapped_column(String(20), index=True)
|
||||
passed: Mapped[bool] = mapped_column(Boolean, default=False, index=True)
|
||||
summary: Mapped[str] = mapped_column(Text(), default="")
|
||||
input_json: Mapped[dict[str, Any]] = mapped_column(JSON, default=dict)
|
||||
result_json: Mapped[dict[str, Any]] = mapped_column(JSON, default=dict)
|
||||
created_by: Mapped[str] = mapped_column(String(100))
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
asset = relationship("AgentAsset", back_populates="test_runs")
|
||||
|
||||
Reference in New Issue
Block a user