feat: add governed cross-module reporting

This commit is contained in:
2026-08-02 05:29:38 +02:00
parent eba35edd3c
commit 0abcc2455e
21 changed files with 2497 additions and 38 deletions
+121
View File
@@ -218,6 +218,125 @@ class ReportingExecution(Base, TimestampMixin):
actor_id: Mapped[str | None] = mapped_column(String(255), nullable=True, index=True)
class ReportingProviderExecution(Base, TimestampMixin):
__tablename__ = "reporting_provider_executions"
__table_args__ = (
UniqueConstraint(
"tenant_id",
"execution_id",
name="uq_reporting_provider_execution",
),
UniqueConstraint(
"tenant_id",
"idempotency_key",
name="uq_reporting_provider_execution_idempotency",
),
Index(
"ix_reporting_provider_execution_history",
"tenant_id",
"provider_id",
"report_id",
"generated_at",
),
Index(
"ix_reporting_provider_execution_retention",
"tenant_id",
"expires_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)
execution_id: Mapped[str] = mapped_column(String(36), nullable=False, index=True)
provider_id: Mapped[str] = mapped_column(String(120), nullable=False, index=True)
report_id: Mapped[str] = mapped_column(String(255), nullable=False, index=True)
report_revision: Mapped[str] = mapped_column(String(255), nullable=False)
contract_version: Mapped[str] = mapped_column(String(30), nullable=False)
idempotency_key: Mapped[str] = mapped_column(String(255), nullable=False)
request_sha256: Mapped[str] = mapped_column(String(64), nullable=False)
purpose: Mapped[str] = mapped_column(Text, nullable=False)
audience_scope: Mapped[dict[str, Any]] = mapped_column(
JSON, default=dict, nullable=False
)
parameters: Mapped[dict[str, Any]] = mapped_column(
JSON, default=dict, nullable=False
)
result_schema: Mapped[list[dict[str, Any]]] = mapped_column(
JSON, default=list, nullable=False
)
result_payload: Mapped[dict[str, Any]] = mapped_column(
JSON, default=dict, nullable=False
)
source_revisions: Mapped[list[dict[str, Any]]] = mapped_column(
JSON, default=list, nullable=False
)
effective_scope: Mapped[dict[str, Any]] = mapped_column(
JSON, default=dict, nullable=False
)
privacy_transforms: Mapped[list[str]] = mapped_column(
JSON, default=list, nullable=False
)
provenance: Mapped[dict[str, Any]] = mapped_column(
JSON, default=dict, nullable=False
)
governance_provenance: Mapped[dict[str, Any]] = mapped_column(
JSON, default=dict, nullable=False
)
retention_class: Mapped[str] = mapped_column(String(120), nullable=False)
retention_days: Mapped[int | None] = mapped_column(Integer, nullable=True)
expires_at: Mapped[datetime | None] = mapped_column(
DateTime(timezone=True), nullable=True, index=True
)
retention_redacted_at: Mapped[datetime | None] = mapped_column(
DateTime(timezone=True), nullable=True, index=True
)
output_hash: Mapped[str] = mapped_column(String(64), nullable=False, index=True)
generated_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), nullable=False, index=True
)
actor_id: Mapped[str | None] = mapped_column(String(255), nullable=True, index=True)
class ReportingProviderExport(Base, TimestampMixin):
__tablename__ = "reporting_provider_exports"
__table_args__ = (
UniqueConstraint(
"tenant_id",
"export_id",
name="uq_reporting_provider_export",
),
Index(
"ix_reporting_provider_export_history",
"tenant_id",
"provider_execution_id",
"exported_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)
export_id: Mapped[str] = mapped_column(String(36), nullable=False, index=True)
provider_execution_id: Mapped[str] = mapped_column(
ForeignKey(
"reporting_provider_executions.id",
ondelete="RESTRICT",
),
nullable=False,
index=True,
)
execution_id: Mapped[str] = mapped_column(String(36), nullable=False, index=True)
format: Mapped[str] = mapped_column(String(30), nullable=False)
purpose: Mapped[str] = mapped_column(Text, nullable=False)
audience_scope: Mapped[dict[str, Any]] = mapped_column(
JSON, default=dict, nullable=False
)
output_hash: Mapped[str] = mapped_column(String(64), nullable=False, index=True)
exported_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), nullable=False, index=True
)
actor_id: Mapped[str | None] = mapped_column(String(255), nullable=True, index=True)
class ReportingDefinitionGrant(Base, TimestampMixin):
__tablename__ = "reporting_definition_grants"
__table_args__ = (
@@ -435,6 +554,8 @@ __all__ = [
"ReportingExecution",
"ReportingImportAssessment",
"ReportingPublication",
"ReportingProviderExecution",
"ReportingProviderExport",
"ReportingQualityResult",
"ReportingSavedView",
"ReportingSchedule",