import {OrderedHashMap} from 'zena:collections'; import {ResolvedInput} from './canonical.zena'; import {CacheKey, Fingerprint} from './fingerprint.zena'; import {OutputManifest} from './manifest.zena'; import {StepKey} from './step.zena'; /** * What the engine remembers about one step between runs: enough to * detect freshness (the cache key), to serve dependents (the * manifest), and to compute an input delta for incremental reruns * (the config fingerprint and resolved inputs of the recording run). */ export class StepRecord( config: Fingerprint, cacheKey: CacheKey, manifest: OutputManifest, inputs: Array, ) /** * Prior-run state: each step's cache key and output manifest. Plain * data — hosts persist it between runs and hand it back; an empty * state is a valid first run. Iteration order is insertion order, so * serialization is deterministic. */ export class EngineState { #records: OrderedHashMap; new() : #records = new OrderedHashMap(); static empty(): EngineState { return new EngineState(); } size: i32 { get { return this.#records.size; } } recordOf(key: StepKey): StepRecord? { if (let (true, record) = this.#records.get(key.value)) { return record; } return null; } setRecord(key: StepKey, record: StepRecord): void { this.#records[key.value] = record; } forEach(callback: (key: String, record: StepRecord) => void): void { this.#records.forEach(callback); } }