import type { PipelineState, StepStateEntry, InProgressRecord, DepthLevel, StepStatus } from '../types/index.js'; import type { ScaffoldError } from '../types/index.js'; import { StatePathResolver } from './state-path-resolver.js'; import { runPhaseAudit, type PhaseAuditResult } from '../observability/engine/phase-audit.js'; export declare class StateManager { private projectRoot; private computeEligible; private configProvider?; private globalSteps?; /** * Pipeline-graph hash for the manager's scope. If omitted, saveState writes * `next_eligible_hash: undefined`, which consumers treat as invalid cache * (live recompute). Legacy-safe default. */ private pipelineHash?; private statePath; private pathResolver; /** * Captured during service-mode loadState. Used by saveState to stamp * next_eligible_root_counter TOCTOU-safely (spec §3). `undefined` = never * loaded; `null` = loaded but root file had no save_counter (legacy). */ private loadedRootCounter; private phaseAuditFn; setPhaseAuditFn(fn: typeof runPhaseAudit): void; constructor(projectRoot: string, computeEligible: (steps: Record, options?: { scope?: 'global' | 'service'; globalSteps?: Set; }) => string[], configProvider?: (() => { project?: { services?: unknown[]; }; } | undefined) | undefined, pathResolver?: StatePathResolver, globalSteps?: Set | undefined, /** * Pipeline-graph hash for the manager's scope. If omitted, saveState writes * `next_eligible_hash: undefined`, which consumers treat as invalid cache * (live recompute). Legacy-safe default. */ pipelineHash?: string | undefined); /** Load and validate state.json from disk. Throws ScaffoldError on schema mismatch. */ loadState(): PipelineState; /** Atomically persist state to disk (write tmp + rename). */ saveState(state: PipelineState): void; /** Transition step to in_progress; sets in_progress record with actor. */ setInProgress(step: string, actor: string): void; /** Transition step to completed; records outputs, actor, and depth. Invokes phase-audit hook post-save. */ markCompleted(step: string, outputs: string[], completedBy: string, depth: DepthLevel): Promise; /** Transition step to in_progress and record in_progress_started_at (idempotent). */ markInProgress(step: string): void; /** Transition step to skipped; records reason and actor. */ markSkipped(step: string, reason: string, skippedBy: string): void; /** Clear the in_progress record (null out). Used by crash recovery. */ clearInProgress(): void; /** Return the status of a single step, or undefined if step not in state. */ getStepStatus(step: string): StepStatus | undefined; /** * Reconcile state with the current pipeline definition. * * Steps that exist in the pipeline but are missing from state.steps * (e.g., a new step added after the project was initialized) are * inserted as pending. Returns true if any steps were added (and * the state was persisted). */ reconcileWithPipeline(pipelineSteps: Array<{ slug: string; produces: string[]; enabled: boolean; }>): boolean; /** * Initialize a new state.json with all steps in pending status. * Not in the formal interface but needed by T-033 init wizard. */ initializeState(options: { enabledSteps: Array<{ slug: string; produces: string[]; }>; scaffoldVersion: string; methodology: string; initMode: 'greenfield' | 'brownfield' | 'v1-migration'; config?: { project?: { services?: unknown[]; }; }; }): void; /** * Load state WITHOUT side effects — no saveState, no next_eligible recompute, no lock. * Applies dispatchStateMigration + migrateState in memory only. Use ONLY for * read-only inspection of foreign state (cross-reads, readiness display). * The returned PipelineState is a detached snapshot — mutating it does not persist. */ static loadStateReadOnly(projectRoot: string, pathResolver: StatePathResolver, configProvider?: () => { project?: { services?: unknown[]; }; } | undefined): PipelineState; } export type { ScaffoldError, InProgressRecord }; //# sourceMappingURL=state-manager.d.ts.map