/** * Stale-marking (M4) — conservative transitive invalidation over the observed * readSet captured in M3. * * This is the "mark stale, don't rerun" half of overstory's cost-asymmetric * reactivity (VISION §2.3): the cheap effects (figuring out what WOULD be * invalidated) run for free; the expensive effects (actually re-running an LLM * phase) are gated for M5. Given a run's observed readSets and a set of phases * assumed to have changed, `computeStaleFrontier` returns the transitive * closure of phases whose recorded dependencies are no longer trustworthy. * * Pure module: no IO, no Date, no randomness. Deterministic. * * Scope (honest): this is TOPOLOGICAL propagation only — a changed seed * invalidates everything that (transitively) read it. The overstory * "early cutoff" refinement (a re-run whose output HASH is unchanged does NOT * invalidate, even if the version advanced) needs before/after content hashes, * which only exist when a phase is actually re-run — that is the M5 * recomputation concern, deliberately out of scope here. Marking is the safe, * conservative prerequisite that lets M5 rerun with confidence. * * @see docs/internal/overstory-convergence-roadmap.md §3 (M4) */ import type { PhaseState } from "./store.ts"; import { type Taskflow } from "./schema.ts"; /** phaseId → the upstream stepIds it observed-reading (M3 PhaseState.reads). */ export type ReadMap = Map; /** Fold a run's PhaseStates into a read map (drops phases with no reads). */ export declare function readMapOf(phases: Record): ReadMap; /** Phases that directly read `phaseId` (its immediate dependents). * * When `declared` is provided, the dependent set is the **union** of * observed dependents (from `reads`) and declared dependents (from * `declared`) — a declared-but-unobserved edge (e.g. a `when` ref that never * fired) still counts as a dependency for staleness propagation (M2 union). * `declared` undefined → observed-only (backward-compatible). */ export declare function dependentsOf(reads: ReadMap, phaseId: string, declared?: ReadMap): string[]; /** * The set of phases that are stale if `seeds` change, transitively. A reader * is stale if ANY phase it (observed- OR declared-)reading is stale * (union/I5: when in doubt, assume dependency). Includes the seeds themselves. * * When `declared` is provided, the read graph used for propagation is the * **union** of `reads` (observed, M3) and `declared` (M2 compile-time refs): * a declared-but-unobserved edge still propagates staleness. `declared` * undefined → observed-only (backward-compatible, identical to pre-M2). * * Deterministic. O(phases + read-edges). Cycles in the read graph (which a * correct DAG can't produce, but a pathological one could) terminate because a * phase is enqueued at most once. */ export declare function computeStaleFrontier(reads: ReadMap, seeds: Iterable, declared?: ReadMap): Set; /** Build a declared ReadMap from a flow definition: each phase's `collectRefs` * `{steps.X}` refs become its declared reads (self-refs excluded so a loop * `until` checking `{steps.thisId.output}` doesn't create a self-edge). * * Pure. Used by `recomputeTaskflow` and `/tf why-stale` so union (observed ∪ * declared) semantics apply to old runs too (pre-H1 runs have no persisted * `RunState.declaredDeps` — deriving from `def` keeps recompute sound). */ export declare function declaredReadMapOfDef(def: Taskflow): ReadMap; /** * Render either the full observed dependency graph (no seeds) or the stale * frontier given assumed-changed seeds. Each stale phase lists the stale * upstreams that caused it (its "why"). * * When `declared` is provided, the frontier is the **union** (observed ∪ * declared) and a stale phase's "why" annotates edges present only in the * declared plane (not observed at runtime) with `(declared)`. `declared` * undefined → observed-only rendering (backward-compatible). */ export declare function formatWhyStale(runId: string, flowName: string, reads: ReadMap, seeds: readonly string[], declared?: ReadMap): string; //# sourceMappingURL=stale.d.ts.map