feat: implement assurance graph and screening evidence

This commit is contained in:
2026-08-01 17:48:39 +02:00
parent bbf7288e14
commit a23b53dc9e
18 changed files with 4005 additions and 42 deletions
@@ -841,7 +841,274 @@ class RiskScreeningException(Base, TimestampMixin):
)
class RiskAssuranceNode(Base, TimestampMixin):
__tablename__ = "risk_assurance_nodes"
__table_args__ = (
UniqueConstraint(
"tenant_id",
"stable_id",
"revision",
name="uq_risk_assurance_node_revision",
),
Index(
"ix_risk_assurance_node_current",
"tenant_id",
"kind",
"state",
"superseded_at",
),
Index(
"ix_risk_assurance_node_governed_object",
"tenant_id",
"governed_object_ref",
"superseded_at",
),
)
id: Mapped[str] = mapped_column(
String(36),
primary_key=True,
default=new_uuid,
)
tenant_id: Mapped[str] = mapped_column(
String(36),
nullable=False,
index=True,
)
stable_id: Mapped[str] = mapped_column(
String(255),
nullable=False,
index=True,
)
kind: Mapped[str] = mapped_column(
String(40),
nullable=False,
index=True,
)
revision: Mapped[int] = mapped_column(
Integer,
nullable=False,
)
previous_revision_id: Mapped[str | None] = mapped_column(
ForeignKey(
"risk_assurance_nodes.id",
ondelete="RESTRICT",
),
nullable=True,
)
label: Mapped[str] = mapped_column(
String(500),
nullable=False,
)
description: Mapped[str | None] = mapped_column(
Text,
nullable=True,
)
state: Mapped[str] = mapped_column(
String(40),
nullable=False,
index=True,
)
owner_ref: Mapped[str] = mapped_column(
String(500),
nullable=False,
index=True,
)
scope_ref: Mapped[str | None] = mapped_column(
String(500),
nullable=True,
index=True,
)
governed_object_ref: Mapped[str | None] = mapped_column(
String(1000),
nullable=True,
index=True,
)
valid_from: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
nullable=False,
index=True,
)
valid_to: Mapped[datetime | None] = mapped_column(
DateTime(timezone=True),
nullable=True,
index=True,
)
recorded_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
nullable=False,
index=True,
)
superseded_at: Mapped[datetime | None] = mapped_column(
DateTime(timezone=True),
nullable=True,
index=True,
)
provenance: Mapped[dict[str, Any]] = mapped_column(
JSON,
default=dict,
nullable=False,
)
legal_basis_refs: Mapped[list[str]] = mapped_column(
JSON,
default=list,
nullable=False,
)
policy_refs: Mapped[list[str]] = mapped_column(
JSON,
default=list,
nullable=False,
)
evidence_refs: Mapped[list[str]] = mapped_column(
JSON,
default=list,
nullable=False,
)
classification: Mapped[str] = mapped_column(
String(50),
default="internal",
nullable=False,
index=True,
)
created_by: Mapped[str | None] = mapped_column(
String(255),
nullable=True,
index=True,
)
class RiskAssuranceEdge(Base, TimestampMixin):
__tablename__ = "risk_assurance_edges"
__table_args__ = (
UniqueConstraint(
"tenant_id",
"stable_id",
"revision",
name="uq_risk_assurance_edge_revision",
),
Index(
"ix_risk_assurance_edge_source",
"tenant_id",
"source_node_ref",
"state",
"superseded_at",
),
Index(
"ix_risk_assurance_edge_target",
"tenant_id",
"target_node_ref",
"state",
"superseded_at",
),
)
id: Mapped[str] = mapped_column(
String(36),
primary_key=True,
default=new_uuid,
)
tenant_id: Mapped[str] = mapped_column(
String(36),
nullable=False,
index=True,
)
stable_id: Mapped[str] = mapped_column(
String(255),
nullable=False,
index=True,
)
revision: Mapped[int] = mapped_column(
Integer,
nullable=False,
)
previous_revision_id: Mapped[str | None] = mapped_column(
ForeignKey(
"risk_assurance_edges.id",
ondelete="RESTRICT",
),
nullable=True,
)
source_node_ref: Mapped[str] = mapped_column(
String(255),
nullable=False,
index=True,
)
target_node_ref: Mapped[str] = mapped_column(
String(255),
nullable=False,
index=True,
)
relation: Mapped[str] = mapped_column(
String(50),
nullable=False,
index=True,
)
state: Mapped[str] = mapped_column(
String(30),
default="active",
nullable=False,
index=True,
)
owner_ref: Mapped[str] = mapped_column(
String(500),
nullable=False,
index=True,
)
scope_ref: Mapped[str | None] = mapped_column(
String(500),
nullable=True,
index=True,
)
valid_from: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
nullable=False,
index=True,
)
valid_to: Mapped[datetime | None] = mapped_column(
DateTime(timezone=True),
nullable=True,
index=True,
)
recorded_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
nullable=False,
index=True,
)
superseded_at: Mapped[datetime | None] = mapped_column(
DateTime(timezone=True),
nullable=True,
index=True,
)
provenance: Mapped[dict[str, Any]] = mapped_column(
JSON,
default=dict,
nullable=False,
)
legal_basis_refs: Mapped[list[str]] = mapped_column(
JSON,
default=list,
nullable=False,
)
policy_refs: Mapped[list[str]] = mapped_column(
JSON,
default=list,
nullable=False,
)
evidence_refs: Mapped[list[str]] = mapped_column(
JSON,
default=list,
nullable=False,
)
created_by: Mapped[str | None] = mapped_column(
String(255),
nullable=True,
index=True,
)
__all__ = [
"RiskAssuranceEdge",
"RiskAssuranceNode",
"RiskSanctionsAddress",
"RiskSanctionsAlias",
"RiskSanctionsDate",