Expand description
Datalog-style fixed-point computation of dirty objects, clusters, and schemas.
Implements the propagation rules documented in the parent module’s header. The evaluator is organized as:
- immutable input facts (
BaseFacts) - precomputed join indexes and helper relations (
FactIndexes) - mutable derived relations (
DirtyState) - rule-group evaluators that collect pending derivations before merging
Each derive_* helper corresponds to one or more Datalog rules and is
annotated with the exact rule it encodes.
§Algorithm
- Seed: Initialize
dirty_stmtsfromchanged_stmts(objects whose hashes differ between the old and new snapshots) anddirty_schemasfromforced_dirty_schemas(schemas the caller redeploys unconditionally). - Build indexes: Pre-compute reverse lookup maps and the current
ClusterBoundaryrelation from base facts for O(1) rule evaluation. - Fixed-point loop: In each iteration, apply all five rule groups in
a fixed order:
- Cluster dirtiness (from changed statements only, within
ClusterBoundary) - Statement dirtiness from dirty clusters
- Dependency propagation (downstream of dirty statements, excluding replacement MVs, whose dirtiness does not fan out to dependents)
- Schema dirtiness (from dirty statements, excluding sinks)
- Statement dirtiness from dirty schemas
- Cluster dirtiness (from changed statements only, within
- Termination: The loop converges when no set (
dirty_stmts,dirty_clusters,dirty_schemas) grows in an iteration. Convergence is guaranteed because all sets are monotonically non-decreasing and bounded by the finite project universe.
§Rule Application Order
The ordering within a single iteration matters for convergence speed but not correctness — the fixed-point semantics guarantee the same result regardless of order. The chosen order (clusters → stmts-from-clusters → dependencies → schemas → stmts-from-schemas) maximizes information propagated per iteration, typically converging in 2–3 rounds.
ClusterBoundary is materialized as all clusters referenced by statements
or indexes in the project.
Structs§
- Dirty
State 🔒 - Mutable working sets carried across fixed-point iterations.
- Evaluator 🔒
- Fixed-point evaluator for the dirty propagation rules.
- Fact
Indexes 🔒 - Pre-computed indexes for efficient Datalog rule evaluation.
- Pending
Facts 🔒 - Newly derived facts from one rule group before they are merged into
DirtyState.
Functions§
- compute_
dirty_ 🔒datalog - Compute dirty objects, clusters, and schemas using fixed-point iteration.