feat: executions, assertions y bucle reactivo en fn_operations
Añade Execution, Assertion, AssertionResult al paquete fn_operations. Motor de evaluación de assertions con reescritura SQL automática. Bucle reactivo: ExecuteAndReact evalúa assertions y cambia status de entities (corrupted/stale) + auto-crea proposals en registry. CLI fn ops: assertion (add/list/show/delete/eval) y execution (add/list/show). Migración 002_executions_assertions.sql con FTS para assertions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -78,6 +78,73 @@ type RelationInput struct {
|
||||
Order *int `json:"order"`
|
||||
}
|
||||
|
||||
// ExecutionStatus represents the result of a pipeline execution.
|
||||
type ExecutionStatus string
|
||||
|
||||
const (
|
||||
ExecSuccess ExecutionStatus = "success"
|
||||
ExecFailure ExecutionStatus = "failure"
|
||||
ExecPartial ExecutionStatus = "partial"
|
||||
)
|
||||
|
||||
// Severity classifies the impact of an assertion failure.
|
||||
type Severity string
|
||||
|
||||
const (
|
||||
SeverityCritical Severity = "critical"
|
||||
SeverityWarning Severity = "warning"
|
||||
SeverityInfo Severity = "info"
|
||||
)
|
||||
|
||||
// AssertionResultStatus represents the outcome of an assertion evaluation.
|
||||
type AssertionResultStatus string
|
||||
|
||||
const (
|
||||
ResultPass AssertionResultStatus = "pass"
|
||||
ResultFail AssertionResultStatus = "fail"
|
||||
ResultSkip AssertionResultStatus = "skip"
|
||||
)
|
||||
|
||||
// Execution records a pipeline run with its metrics and outcome.
|
||||
type Execution struct {
|
||||
ID string `json:"id"`
|
||||
PipelineID string `json:"pipeline_id"`
|
||||
RelationID string `json:"relation_id"`
|
||||
Status ExecutionStatus `json:"status"`
|
||||
StartedAt time.Time `json:"started_at"`
|
||||
EndedAt *time.Time `json:"ended_at"`
|
||||
DurationMs *int64 `json:"duration_ms"`
|
||||
RecordsIn *int64 `json:"records_in"`
|
||||
RecordsOut *int64 `json:"records_out"`
|
||||
Error string `json:"error"`
|
||||
Metrics map[string]any `json:"metrics"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// Assertion is a formal quality rule evaluated against an entity.
|
||||
type Assertion struct {
|
||||
ID string `json:"id"`
|
||||
EntityID string `json:"entity_id"`
|
||||
Name string `json:"name"`
|
||||
Kind string `json:"kind"` // free text: range, null, statistical, consistency, freshness, ...
|
||||
Rule string `json:"rule"`
|
||||
Severity Severity `json:"severity"`
|
||||
Description string `json:"description"`
|
||||
Active bool `json:"active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// AssertionResult records one evaluation of an assertion.
|
||||
type AssertionResult struct {
|
||||
ID string `json:"id"`
|
||||
AssertionID string `json:"assertion_id"`
|
||||
ExecutionID string `json:"execution_id"`
|
||||
Status AssertionResultStatus `json:"status"`
|
||||
Value map[string]any `json:"value"`
|
||||
Message string `json:"message"`
|
||||
EvaluatedAt time.Time `json:"evaluated_at"`
|
||||
}
|
||||
|
||||
// TypeSnapshot is an immutable copy of a registry type at point of use.
|
||||
type TypeSnapshot struct {
|
||||
ID string `json:"id"`
|
||||
|
||||
Reference in New Issue
Block a user