Eos Build Scheduling
Formal model: Eos Build Scheduling
Terminology note: This model's nodes are atom actions — the substrate build unit (ADR-0005, htc-sad §1.5/§6.5), identified by
action_id = H(atom_czd_closure_root, toolchain_composition_root, action_params). Earlier revisions of this model used "derivation" for the Nix-native build unit; that mapping is retired except where a passage below is explicitly scoped to the legacy passthrough-snix executor, which still bindsBuildEngine::Plan = Derivation. See ADR-0004 for the full scheduling design.
Domain Classification¶
Problem Statement: The Eos build scheduler constructs entry point DAGs from atom-action DAGs read off locks, dispatches them topologically across federated workers, relies on CAS-idempotent store semantics to deduplicate concurrent transitive builds, and uses historical predictions keyed by atom label to improve placement. These mechanisms interact concurrently under nondeterministic request arrival and worker failure. Before implementation, the scheduling algorithm needs formal validation to confirm: (1) the dispatch protocol is correct — ordering and liveness invariants hold under all interleavings; (2) the optimization heuristics achieve bounded performance relative to an optimal offline algorithm.
Domain Characteristics:
- Concurrent state machine — the scheduler maintains mutable state (entry point status, worker loads, artifact store) accessed by concurrent request handlers and completion callbacks. Correctness depends on interleaving behavior.
- DAG-structured workflow — atom-action dependencies form a DAG. Entry point selection partitions this DAG into covering subgraphs. Dispatch order must respect the induced entry point dependency DAG.
- Content-addressed deduplication — action ids provide globally unique identity. CAS-idempotent store semantics guarantee at-most-one materialization per output-tree digest across all concurrent builds.
- Prediction-augmented optimization — historical build profiles (keyed by atom label) augment a baseline scheduling algorithm. Quality guarantees must hold when predictions are accurate (consistency) and when they are arbitrarily wrong (robustness).
- Federated scale — workers may span multiple clusters with varying latency and trust boundaries. Liveness must hold under network partitions and artifact store propagation delays.
Model Scope:
| In Scope | Out of Scope |
| Entry point DAG construction correctness | executor internals / within-atom parallelism (upstream make -j) |
| Dispatch protocol ordering and liveness | Builder-internal dependency resolution |
| CAS-idempotent store deduplication | Artifact store implementation details |
| Coverage property (partition completeness) | Wire protocol (Cap'n Proto serialization) |
| Consistency/robustness competitive bounds | Authentication/authorization middleware |
| Federated liveness under partition | Specific hash algorithm (BLAKE3, etc.) |
| Historical profile EMA convergence | Operator tuning parameter selection |
Formalism Selection¶
| Aspect | Detail |
| Primary Formalism | Two-track: State machine + temporal logic (Track A); |
| Online scheduling on DAGs + competitive analysis (Track B) | |
| Supporting Tools | Graph theory (coverage), probability (EMA convergence) |
| Decision Matrix Row | Row 4 (protocol-heavy concurrency) → Track A; |
| Outside SDMA matrix (combinatorial optimization) → Track B | |
| Rationale | The protocol and optimization concerns are formally |
| independent. A correct-but-naive scheduler satisfies A. | |
| A near-optimal-but-buggy scheduler satisfies B. They | |
| compose but don't interact at the formal level. |
Verification Tooling Plan:
| Track | Concern | Tool | Justification |
| A | Protocol correctness | TLA+ | Designed for concurrent state machines |
| with temporal invariants. Model | |||
| checking finds interleaving bugs that | |||
| inspection misses. Fast iteration. | |||
| B | Optimization quality | Lean 4 | Machine-checked proofs for competitive |
| analysis bounds. Paper proofs first to | |||
| stabilize definitions, then mechanize. | |||
| Valuable if CAS+scheduling is a novel | |||
| contribution. |
Alternatives Considered:
- Single-tool (Lean 4 for everything): Possible but encoding nondeterministic protocol interleavings in a theorem prover is 5-10× slower than TLA+ for equivalent confidence. Lean excels at mathematical proofs, not state space exploration.
- Petri nets: Natural for concurrency but lack TLA+'s temporal logic operators and mature tooling for liveness.
- Alloy: Good for structural/relational properties but weak on temporal and quantitative bounds.
- Coalgebraic bisimulation (SDMA §3): More relevant for implementation interchangeability (covered by the existing publishing-stack-layers model). The scheduling protocol is better modeled as an explicit state machine than as observations over hidden state.
Model¶
Shared Definitions¶
The following definitions are shared between Track A and Track B. They constitute the mathematical universe in which both the protocol and the optimization operate.
Atom Action DAG¶
Let be a directed acyclic graph where:
- is the set of atom actions (nodes)
- is the dependency relation: means action depends on the output of action (i.e., must be built before can start)
Each action has (symbols unchanged from earlier revisions — only the gloss below is updated; see Theorems below, which depend on these same symbols):
- : the action identity (
action_id, ADR-0005 htc-sad §6.5: ) (globally unique, deterministic) - : the atom label, from the owning atom's
(set, label)pair (human-readable, structurally stable across versions) - : whether 's output exists in the artifact store at the time of DAG construction
Uncached Sub-DAG¶
where and .
This is the sub-DAG of actions that must be built. Cached nodes and their edges to other cached nodes are removed. Edges from uncached nodes to cached nodes are removed (the dependency is already satisfied).
Multi-Request Union Graph and Clients¶
When concurrent requests arrive, the scheduler merges their uncached sub-DAGs JIT into a single unified global atom-action graph where:
To track ownership, each node is associated with a set of requesting clients:
When request is cancelled, the client ID is removed from for all . If and the node is mutable (not yet dispatched), it is pruned from the global DAG.
Entry Points and Coverage¶
An entry point selection is a subset and a coverage relation satisfying:
Total coverage: (every uncached action is assigned to at least one entry point).
Self-coverage: , and if then (every entry point covers itself uniquely).
Transitive containment: If and , then is in the transitive dependency closure of in (an action is only covered by an entry point that transitively depends on it).
Downward closure within coverage: If , , and , then (if is covered by and depends on non-entry-point , then is also covered by — entry point scopes propagate downward through non-entry-point dependency chains).
Relation Overlap: Unlike a single-valued function, the relation permits overlapping entry point scopes. If a non-entry-point has multiple dependents covered by different entry points , it is simply covered by both: and . This removes the strict Convergence Obligation from the formal model, preventing the macroscopic scheduling DAG from shattering into tiny, high-overhead synchronization steps for shared leaves. Overlapping transitive builds are resolved safely by the content-addressed, idempotent storage model (CAS) where concurrent writes of the same outputs both succeed independently. Redundant computation is minimized at the scheduler level via convergence-point promotion to standalone entry points.
The entry point DAG is where iff transitively depends on in and there is no intermediate entry point on the path.
Workers and Assignment¶
is the set of available workers. Each worker has:
- : set of capability tags
- : resource capacity vector
- : current load vector at time
- : federation cluster identifier
An assignment maps each entry point to a worker, subject to:
- Feasibility:
- Capacity: The aggregate predicted resource demand of all entry points assigned to does not exceed
Historical Profiles and Predictions¶
maps atom labels to historical profiles:
where is predicted build duration,
is predicted peak memory, is
predicted CPU cores, and is predicted output
size. These four fields populate the resource vector used
by the scoring function's resource_fit term.
For actions with no history, falls back to developer-declared atom metadata (every node is now atom-scoped by construction, so this always applies) or system defaults.
The prediction error for a specific execution is:
where is the actual duration revealed on completion and is the predicted duration. Normalizing by the prediction (rather than the actual) reflects the information available at scheduling time.
Track A: Protocol Correctness (→ TLA+)¶
This track formalizes the dispatch protocol as a state machine and specifies the temporal properties it must satisfy.
Scope note: This track models entry-point-level scheduling and dependency constraints. To simplify the correctness state space, scheduler-level structural deduplication is treated as a software-level performance optimization (Track B) and is omitted from the Track A correctness model. In the absence of locks, correct build execution under overlapping entry point scopes relies entirely on the content-addressed, idempotent storage model (CAS). Simultaneous identical builds both write to the store safely — builds are NOT assumed bit-deterministic (execution-model.md §2.2): records (witnesses) accumulate per request, each downstream branch coheres by binding the concrete output digests it consumed, and witness selection at request formation is a recorded choice. Safety rests on commutative witness accumulation plus per-branch content-addressed coherence, not on output determinism (ADR-0006 §4) — consistency without blocking either way.
State Space¶
The system state is a tuple:
where:
- — entry point status
- — the artifact store contents (set of completed action ids)
- — per-worker load state
Initial State¶
= set of cached action ids, for all .
Transitions¶
Dispatch — assign ready entry point to worker :
- Guard: and and worker has capacity
- Effect:
Complete — entry point finishes building:
- Guard:
- Effect:
- (outputs enter store)
- For each : if , then
Fail — entry point fails:
- Guard:
- Effect:
- (Retry policy is orthogonal — may transition back to )
CascadeFail — propagate failure to dependent entry point:
- Guard: and such that
- Effect:
Safety Properties (□ — must always hold)¶
P1. Ordering soundness: No entry point is dispatched before all its dependency entry points have completed.
P2. Coverage completeness: Every uncached action is covered by at least one in-progress, completed, or failed entry point (no action is lost).
P3. Artifact completeness: If an entry point completes, its outputs are present in the artifact store.
P4. Capacity safety: No worker is assigned load exceeding its capacity.
Enforcement note: is a virtual capacity vector reported by the worker at registration. The scheduler is enforcement-agnostic — the dispatch guard is identical regardless of the worker's enforcement capability. Under OCI-based workers, capacity equals physical resources and P4 is kernel-enforced via cgroup limits (
cpu.max,memory.max). Under non-OCI workers (e.g., macOS), capacity is a conservative virtual budget accounting for the lack of kernel enforcement. See ADR-0004 §3.1.
P8. Frozen stability: Once an entry point is dispatched to a worker, its assignment is fixed for that execution. It can only transition to complete (on the same worker), failed (released from worker), or back to ready (released from worker via transient failure). It can never be migrated directly to a different worker while dispatched.
Liveness Properties (◇ — must eventually hold)¶
P5. Progress: If a ready entry point exists and a feasible worker has capacity, the entry point is eventually dispatched.
P5'. Head-of-line (HoL) immunity: The progress of a ready entry point belonging to request is independent of the status of any unrelated entry point or blocking states of unrelated requests. P5 holds locally for each request sub-DAG.
P6. Completion propagation: If all entry points in a request either complete or fail, the request terminates.
P6'. Per-request completion: Each request independently terminates. If all entry points associated with request complete or fail, then request terminates, regardless of whether other requests are still active.
P7. Federation liveness: In a federated deployment, after an entry point completes, its outputs are reachable by any worker within bounded time (artifact store propagation).
where is the artifact store view at worker .
P9. Work Conservation: If a ready entry point exists and a worker has capacity, that entry point is eventually dispatched (or skipped, failed, or canceled).
P10. Transient Failure Recovery: If an infrastructure or worker crash occurs while running entry point , the entry point is unfrozen back to ready for re-dispatch, and worker capacity is reclaimed.
P11. Failure Isolation: An entry point can only transition to failed if it fails deterministically (build failure) or if a dependency fails (cascade failure), preventing spurious failure propagation.
Track B: Optimization Quality (→ Paper Proofs → Lean 4)¶
This track formalizes the optimization properties of the entry point selection and worker assignment algorithms.
Coverage Optimality¶
Definition (Makespan): Given entry point DAG , assignment , and actual durations , the makespan is:
where is the completion time of entry point :
- is the artifact transfer time from to (zero if same worker)
- is the build duration of on worker , which includes all transitive builds within 's coverage scope
Theorem 1: Coverage Existence¶
For any uncached sub-DAG , a valid entry point selection satisfying properties 1-4 exists.
Proof intuition: The trivial selection (every uncached node is an entry point), with (each node covers itself), satisfies all four properties. This is the degenerate case (maximum parallelism but zero locality benefit).
Status: Machine-checked in Lean 4 (Theorem1.lean).
Zero sorry, zero custom axiom.
The optimization problem is finding that minimizes makespan — the identity witness proves such a selection always exists.
Theorem 2: Consistency Bound¶
Given a fixed entry point DAG constructed from uncached sub-DAG , if predictions are accurate ( for all ) and the overlap between entry point transitive scopes in the coverage relation is negligible (ensuring task duration independence), then the heuristic assignment achieves:
where is the optimal offline assignment for and is the heuristic's base approximation ratio on perfectly-predicted inputs.
Concession on Coarsening: We explicitly narrow this bound to the assignment phase on a fixed entry point DAG . The entry point selection (graph coarsening) phase, which groups into , currently lacks a formal competitive bound. The gap is captured by — heuristic quality on perfect predictions.
Atom-scale re-scoping: Under the atom-DAG doctrine (ADR-0005),
arrives pre-coarsened — every node is already an atom action, not a
fine-grained, evaluation-expanded Nix derivation. The coarsening gap
above still stands as an open formal question, but its practical
weight shrinks: the degenerate identity witness of Theorem 1 (,
every node its own entry point) was a worst-case corner when ranged
over thousands of derivations; at atom granularity it is closer to the
typical case, since within-atom build parallelism is now the concern of
the upstream build system (make -j), not this scheduler.
Proof approach: Well-founded induction on DAG completion times. The inductive step uses -accuracy to bound predicted vs. actual completion, and non-negative transfer times between dependent entry points.
Status: Machine-checked in Lean 4 (Theorem2.lean).
Zero sorry, zero custom axiom. Key hypothesis:
(predictions are better than 100% error).
Theorem 2': Adaptive Consistency Bound¶
Let be the entry point DAG under average prediction error . If , then the heuristic assignment achieves:
where is the adaptive coarsening quality function, which is monotonically non-increasing and tightens as prediction quality improves:
Proof approach: Corollary of Theorem 2 where the constant approximation factor is parameterized by prediction-error-based coarsening boundaries. Under perfect predictions (), cost thresholds are lowered, yielding more precise entry points (closer to the optimal HEFT schedule, ). As error increases, thresholds rise, coarsening the DAG and forcing conservative scheduling, bounded by the prediction-free baseline approximation .
Status: Machine-checked in Lean 4 (Theorem2Prime.lean).
Zero sorry, zero custom axiom.
Theorem 3: Robustness Bound¶
For any prediction quality (including ), the heuristic assignment achieves:
_where is the prediction-free baseline (tag matching with LRH affinity and availability only) and is a small constant._
Proof approach: We normalize the resource_fit term using capacity-relative fractions:
bounding it to match the range of the cache affinity and availability terms while preserving task magnitude and resolving dimensional mismatch.
Furthermore, the scheduler dynamically decays the weight of the resource_fit
term based on the exponential moving average (EMA) of absolute relative prediction error:
where is the running average of relative prediction error magnitude.
If predictions are systematically incorrect (even with zero variance), ,
causing . The scoring function thus dynamically filters out the noisy prediction
term, mathematically collapsing the assignment algorithm back to the prediction-free baseline.
Because the degradation scales with the decayed weight and the normalized terms, the makespan
under incorrect predictions is bounded within a small constant factor of the baseline
placement.
Status: Machine-checked in Lean 4 (Theorem3.lean). Two sub-results verified:
- Lemma 3.1 (Assignment stability): If perturbation , then
- EMA lower bound: Under sustained error ,
The quantitative -makespan bound during the EMA transient window is not mechanized (low risk — the transient is geometrically short and capacity safety P4 holds throughout via Track A).
Corollary 3.2: Concrete α via Graham's Bound¶
Since the modified HEFT is a list scheduling algorithm (tasks processed in upward-rank order, each assigned to a worker), Graham's List Scheduling Bound (1966) applies. For identical machines:
Substituting into Theorem 2:
This bound is tight — there exist adversarial DAGs that achieve it (Graham 1966). However, it is rarely tight in practice for build dependency graphs. Empirical studies of HEFT on DAGs of comparable size () typically show 1.1–1.3× optimal — and this regime is more representative at atom-DAG scale, where a request's entry-point DAG spans dozens of atom actions rather than the thousands of fine-grained derivations a full Nix evaluation could produce.
For heterogeneous machines (varying worker capacities), the bound generalizes to:
where is the heterogeneity ratio and is a correction factor that vanishes when (identical machines). For "related machines" (speeds differ by a bounded constant), the bound remains .
Status: Not mechanized. This is a direct application of a classical result (Graham 1966) to our existing Theorem 2. Mechanization would be a straightforward substitution lemma in the existing Lean proof structure.
Prior art: R. L. Graham, "Bounds for Certain Multiprocessing Anomalies," Bell System Technical Journal 45(9), pp. 1563–1581, 1966.
Theorem 4: Structural Deduplication Savings (Track B Optimization)¶
Let concurrent requests produce derivation DAGs with shared uncached sub-DAGs. Total build work is instead of builds, preventing duplicate worker slot allocation.
Proof intuition:
holds by construction of the action id — is
action_id, a hash over signed inputs (the atom's czd closure root,
the toolchain composition root, and the action params; ADR-0005
htc-sad §6.5), not a byproduct of evaluating a Nix expression.
Content-addressing guarantees uniqueness by construction over those
signed inputs. Identical actions across requests coalesce in the
global DAG.
The savings ratio is:
In practice, is small when requests share common
dependencies (e.g., many projects depend on openssl),
yielding large savings.
Status: Machine-checked in Lean 4 (Theorem4.lean).
Theorem 4': Weighted Structural Deduplication¶
_Let concurrent requests produce uncached sub-DAGs . Let be the duration-weighted cost of each node. Then:_
with equality holding iff the uncached sub-DAGs are pairwise disjoint.
Proof intuition: This generalizes Theorem 4 from cardinality to duration-weighted sums, directly capturing the total computation reduction from content-addressed storage deduplication. Formally proved in Lean 4 using set-theoretic properties.
Status: Machine-checked in Lean 4 (Theorem4Prime.lean).
Theorem 5: Unified Coarsening Dominance¶
_Let be the per-request coarsened set of entry points, and be the unified coarsened set of entry points under deduplication. For any valid schedule on , the restricted schedule on satisfies:_
where is the makespan of schedule .
Proof intuition: Proves makespan dominance of the unified schedule over the per-request schedule. Because the unified coarsened set has fewer nodes to schedule due to deduplication (i.e. ), a restricted schedule can be constructed that pointwise preserves or reduces task start times, durations, and load, thereby ensuring makespan dominance under the Schedule model.
Status: Machine-checked in Lean 4 (Theorem5.lean).
Zero sorry, zero custom axiom.
Theorem 6: CAS-Scheduling Bound¶
_Let concurrent requests produce uncached sub-DAGs . Let be the unified HEFT schedule on and be the independent schedules. Let be the deduplication factor. Then there exists a unified schedule such that:_
Proof intuition: This connects CAS deduplication to scheduling quality, bounding makespan under worker contention. It is derived using Schedule.lean (valid worker schedules, non-overlapping constraints, and critical path makespan lower bounds) and HEFT.lean (the work-conserving makespan bound proved from first principles). By replacing the bare scheduling makespan hypothesis with the verified work-conserving bound, the theorem establishes the final competitive ratio using only structural DAG parameters and the deduplication factor , with no unproven scheduling assumptions.
Status: Machine-checked in Lean 4 (Theorem6.lean).
Theorem 7: Re-coarsening Convergence¶
Let be the cache state of the system. Let be the confidence-gated coarsening function selecting entry points from the uncached sub-DAG. Then:
- Monotonicity: If , then .
- Convergence: Under strict incremental cache growth, the active entry point set converges to in at most steps.
Proof intuition: Monotonicity is verified because a larger cache reduces the size of the uncached sub-DAG, yielding fewer or equal candidate entry points. Convergence follows because the uncached set strictly shrinks with each cache update, terminating in at most steps on any finite DAG.
Status: Machine-checked in Lean 4 (Theorem7.lean).
Validation¶
| Check | Result | Detail |
| Coverage properties (1-4) coherent | PASS | Identity witness mechanized in Lean 4 (Thm 1); |
| properties 1-4 are satisfiable and non-contradictory | ||
| Coverage existence (Thm 1) | PASS | Machine-checked in Lean 4. Constructs EosModel with |
S = V', κ = id. Zero sorry, zero axiom. |
||
| Ordering soundness (P1) | PASS | Model-checked in TLA+ across 4 topology models |
| (linear, diamond, convergence, independent) | ||
| Coverage completeness (P2) | PASS | Track B (Lean) — guaranteed by EosModel total coverage |
| property, verified satisfiable by Thm 1 | ||
| Artifact completeness (P3) | PASS | Model-checked in TLA+ (ArtifactSafety invariant) |
| Capacity safety (P4) | PASS | Model-checked in TLA+ under all interleavings |
| Liveness (P5, P6) | PASS | Model-checked in TLA+ with WF_vars(Next) weak |
| fairness. All 4 topology models verify both properties | ||
| Federation liveness (P7) | OPEN | Requires real-time bounds () |
| not expressible in standard TLA+ temporal logic. | ||
| Intentionally deferred — see note below | ||
| HoL immunity (P5') | PASS | Model-checked in TLA+ under concurrent requests |
| Per-request completion (P6') | PASS | Model-checked in TLA+ under concurrent requests |
| Frozen stability (P8) | PASS | Model-checked in TLA+ under dynamic re-coarsening |
| Work conservation (P9) | PASS | Model-checked in TLA+ under concurrent requests |
| Transient failure recovery (P10) | PASS | Model-checked in TLA+ under transient failures |
| Failure isolation (P11) | PASS | Model-checked in TLA+ under deterministic and cascade failures |
| Consistency bound (Thm 2) | PASS | Machine-checked in Lean 4. Proves |
| via well-founded induction on DAG completion times | ||
| Adaptive consistency (Thm 2') | PASS | Machine-checked in Lean 4 (Theorem2Prime.lean) |
| Robustness — assignment stability | PASS | Lean 4 Lemma 3.1: perturbation implies |
| (assignment identity) | ||
| Robustness — EMA convergence | PASS | Lean 4: under sustained error , |
| EMA | ||
| Robustness — μ-makespan bound | OPEN | Quantitative bound during transient not mechanized. |
| Low risk — transient is short (geometric convergence) | ||
| and capacity safety holds throughout (Track A) | ||
| Structural deduplication (Thm 4) | PASS | Machine-checked in Lean 4. Proves |
| with equality iff pairwise disjoint | ||
| Weighted deduplication (Thm 4') | PASS | Machine-checked in Lean 4. Generalizes Thm 4 to |
| duration-weighted computation cost sums. | ||
| Unified Coarsening Dominance (Thm 5) | PASS | Machine-checked in Lean 4. Proves |
| via schedule restriction. | ||
| CAS-scheduling bound (Thm 6) | PASS | Machine-checked in Lean 4. Bounds unified makespan |
| as . | ||
| Re-coarsening convergence (Thm 7) | PASS | Machine-checked in Lean 4. Proves monotonicity and |
| convergence of coarsened EPs under cache growth. | ||
| End-to-end composition (Main Thm) | PASS | Machine-checked in Lean 4. Composes Thm 4'→5→HEFT→6 |
| into a single bound with all hypotheses justified. | ||
| Graph coarsening optimality | COND PASS | Bounded by ; competitive gap |
| closes dynamically as prediction quality improves | ||
| Minimality | PASS | Two-track decomposition is minimal — protocol and |
| optimization are formally independent concerns | ||
| External adequacy | PASS | Model captures all mechanisms described in ADR-0004 |
Remaining open items:
- Federation liveness (P7): Requires bounded artifact store propagation time as an environmental assumption. Under partition, and P7 fails. This is inherently unverifiable by the system — it depends on network infrastructure. Implementation should use timeouts with worker reassignment as a pragmatic mitigation.
- Robustness - -makespan transient: The transient makespan bound during prediction weight decay is not formally mechanized. Its correctness and boundedness are verified empirically and protected by local capacity constraints (Track A).
- Starvation prevention (P12): While the work-conserving liveness property (P9) guarantees that ready EPs are eventually dispatched, it does not prevent low-priority tasks from being starved indefinitely under continuous high-priority arrival. Formalizing starvation-freedom requires modeling arrival processes and priority queuing disciplines (e.g. aging or FIFO bounds), which is deferred to future work.
- DAG Boundedness and Memory Limits (P13): The TLA+ and Lean models assume a finite vertex set . At runtime, the unified global DAG must be bounded to prevent memory exhaustion under continuous request streams. Proving memory safety and progress under sliding window request pruning is a future modeling objective.
Implications¶
Verification Status¶
Both tracks of formal verification are complete:
- Track A (TLA+): Protocol correctness model-checked.
MultiRequestModelverifies safety invariants (P1 Ordering, P3 Artifact, P4 Capacity, P11 Failure Isolation) and liveness properties (P5 Progress, P5' HoL Immunity, P6 Completion, P6' Per-request Completion, P8 Frozen Stability, P9 Work Conservation, P10 Transient Failure Recovery) underWF_vars(Next)weak fairness with multi-request DAG merging, cache-skip, cancellation, transient failure, and failure cascading. Seemodels/tla/. - Track B (Lean 4): Optimization quality machine-checked.
Zero
sorry, zero customaxiom. Nine theorems verified with Mathlib: Theorem 1 (Coverage Existence), Theorem 2 (Consistency Bound), Theorem 2' (Adaptive Consistency), Theorem 3 (Robustness), Theorem 4 (Structural Deduplication), Theorem 4' (Weighted Structural Deduplication), Theorem 5 (Unified Coarsening Dominance), Theorem 6 (CAS-Scheduling Bound), Theorem 7 (Re-coarsening Convergence). Seemodels/lean/.
For Implementation (Derived from Proofs)¶
Entry point status enum: The TLA+ state machine maps directly to a Rust
enum { Pending, Ready, Dispatched, Complete, Failed }withtokio::sync::watchfor completion broadcast.Coverage relation as lookup table: The
EosModelcoverage relation is computed once during entry point selection and stored as aHashMap<ActionId, Vec<EntryPointHash>>. TheEosModelproperties (1-4) should be enforced asdebug_assert!checks on the output of the selection algorithm.Ordering soundness as runtime assertion: Before dispatching entry point , verify all have . This is the P1 invariant from the TLA+ proof, translated to a pre-dispatch guard.
Consistency bound is monitorable: The proven bound has measurable inputs. After each build, compute observed from
|d - d_hat| / d_hatand track the EMA. If exceeds a threshold, the bound degrades and the system should surface this in metrics/telemetry.Transfer time non-negativity: Theorem 2's proof depends on . This is trivially satisfied by network transfer times but would break if the model encoded "time savings from caching" as negative . The implementation must not conflate transfer cost with cache benefit in the same variable.
Structural deduplication keyed by action id: Theorem 4 operates on abstract set families. In implementation, the content-addressed global DAG merging is the concrete instantiation. The theorem guarantees deduplication savings exactly equal the overlap between concurrent requests' uncached sub-DAGs.
EMA decay as self-healing mechanism: The EMA lower bound proof guarantees that under sustained prediction error, the prediction weight decays geometrically. The implementation's EMA smoothing factor controls convergence speed — smaller means faster decay but more sensitivity to noise.
Design Insights Revealed by Verification¶
Coverage property 4 (downward closure) constrains entry point selection: You cannot split a dependency chain across two entry points unless the split point is itself an entry point. This means the entry point set must form an antichain cover of the DAG — a set of nodes such that every maximal chain passes through at least one entry point, and non-entry-point subchains are fully contained within one entry point's scope.
Cascade failure propagation prevents deadlocks: The TLA+ model checking confirmed that without
CascadeFail, dependent tasks hang inpendingorreadyforever after a dependency failure. The implementation must actively propagate failure — this is not optional.Federation liveness (P7) is the weakest property: It depends on an environmental assumption (bounded propagation ) that the system cannot enforce. Implementation should use configurable timeouts with worker reassignment rather than relying on unbounded store propagation.
The identity witness (Thm 1) is the degenerate case: Making every node an entry point satisfies all coverage properties trivially but provides zero locality benefit. The optimization problem is finding entry points that maximize parallelism while preserving locality — the consistency bound (Thm 2) guarantees that any valid selection with good predictions achieves near-optimal makespan on the resulting DAG.
α separates DAG quality from prediction quality: The consistency bound cleanly factors into (how good is your heuristic on perfect predictions?) and (how much does prediction error cost?). This separation means the implementation can independently tune the entry point selection heuristic (affects ) and the prediction infrastructure (affects ) without cross-concern interference.