Documentation
¶
Overview ¶
Package oracle verifies invariants over the observation channels a flowtest run leaves behind. The invariant registry is the single source of truth for the verifiable properties: the verifier evaluates it and the documentation catalog is rendered from it.
Index ¶
Constants ¶
const DefaultRetentionWindow = 89 * 24 * time.Hour
DefaultRetentionWindow is the reconciliation lookback floor: the engine retires workflow partitions after its 90-day retention window (see doc/autocore.md, "Partition Management & Retention"), and one safety day less keeps a bucket retired mid-verify out of the reconciled population.
Variables ¶
This section is empty.
Functions ¶
func RenderCatalog ¶
func RenderCatalog() []byte
RenderCatalog renders the invariant catalog as a Markdown document from the registry, deterministically: one table per class, invariants in evaluation order. The output is written to doc/flowtest-invariants.md by `make regenerate-flowtest-docs`; the registry stays the single source of truth and CI fails when the generated file drifts from it.
Types ¶
type CheckContext ¶
type CheckContext struct {
Ledger *ledger.Store
// History carries the system-under-test's own databases. Nil skips
// history-kind checks.
History *HistoryChannel
// Metrics carries the run's Prometheus. Nil skips metrics-kind checks.
Metrics *MetricsChannel
PostDrain bool // the run has quiesced: liveness checks may assert emptiness
Now time.Time // evaluation instant (deadline comparisons)
// Window bounds verification to the sessions and workflows created in
// [Since, Until). A zero bound leaves that side unbounded.
// Metrics checks diverge one-sidedly: their ranges cover [Since, Now]
// rather than [Since, Until), because terminals recorded during the
// drain tail must stay in range.
Window Window
// RetentionWindow floors the directory reconciliation's lookback so
// engine retention is not mistaken for corruption; zero means
// DefaultRetentionWindow.
RetentionWindow time.Duration
// contains filtered or unexported fields
}
CheckContext carries the observation channels a check may use. Fields are nil when the corresponding channel is not configured; checks requiring a nil channel are skipped and reported as such.
type CheckKind ¶
type CheckKind int
CheckKind names the observation channel an invariant's check consumes.
func (CheckKind) MarshalJSON ¶
func (*CheckKind) UnmarshalJSON ¶
type Class ¶
type Class int
Class groups invariants by the kind of guarantee they verify.
func (Class) MarshalJSON ¶
func (*Class) UnmarshalJSON ¶
type HistoryChannel ¶
type HistoryChannel struct {
Central *pgxpool.Pool
Workflow []WorkflowDB // every workflow DB in the deployment
}
HistoryChannel is the observation channel for history-kind checks: direct read access to the system-under-test's own databases.
type Invariant ¶
type Invariant struct {
Name string // kebab-case, unique
Class Class
Kind CheckKind
Severity Severity
Description string // one or two sentences, rendered into the catalog
DocAnchor string // optional doc/autocore.md anchor for background
Check CheckFunc
}
Invariant is one verifiable property of the system under test. The registry is the single source of truth: the verifier evaluates it and the documentation catalog is rendered from it.
type InvariantResult ¶
type InvariantResult struct {
Name string `json:"name"`
Class Class `json:"class"`
Kind CheckKind `json:"kind"`
Severity Severity `json:"severity"`
Checked int64 `json:"checked"`
Violations []Violation `json:"violations,omitempty"`
Skipped bool `json:"skipped,omitempty"`
SkipReason string `json:"skip_reason,omitempty"`
}
InvariantResult pairs an invariant's identity with its evaluation result.
type MetricsChannel ¶
type MetricsChannel struct {
// Query evaluates one instant PromQL query at the given instant and sums
// the resulting vector to a single value. An empty vector sums to 0.
Query func(ctx context.Context, promql string, at time.Time) (float64, error)
}
MetricsChannel is the observation channel for metrics-kind checks.
func NewPrometheusMetricsChannel ¶
func NewPrometheusMetricsChannel(baseURL string) *MetricsChannel
NewPrometheusMetricsChannel returns a MetricsChannel backed by the Prometheus HTTP API at baseURL (e.g. http://prometheus:9090): each Query runs one instant query against /api/v1/query and sums the resulting vector to a single value.
type Report ¶
type Report struct {
Results []InvariantResult `json:"results"`
}
Report is the outcome of evaluating a set of invariants.
func Evaluate ¶
Evaluate runs the given invariants against the configured observation channels. A check error aborts the evaluation: it means the check could not run, not that the invariant is violated.
func (*Report) Pass ¶
Pass reports whether no evaluated invariant of SeverityViolation recorded a violation. Warnings and skipped invariants never fail a run.
func (*Report) RenderMarkdown ¶
RenderMarkdown renders the report as a compact human-readable summary: one status line per invariant with sample violations underneath.
type Severity ¶
type Severity int
Severity decides what a violation means for the run's verdict.
func (Severity) MarshalJSON ¶
func (*Severity) UnmarshalJSON ¶
type Window ¶
Window is a half-open creation-time interval [Since, Until). A zero bound leaves that side unbounded.
type WorkflowDB ¶
type WorkflowDB struct {
Name string // identifies the DB in violation details
DBID persistence.DBID // identity in the central registry, for shard routing checks
Pool *pgxpool.Pool
}
WorkflowDB is one workflow database of the deployment under test.