import type { PipelineState, StepStateEntry, VerificationLevel } from '../types/index.js'; import type { DetectSpec } from '../types/frontmatter.js'; export interface CompletionResult { complete: boolean; artifactsPresent: string[]; artifactsMissing: string[]; /** Set when an artifact_map mapping (not the step's own outputs) satisfied completion. */ mappedArtifactUsed?: string; } export interface CrashRecoveryAction { action: 'auto_complete' | 'recommend_rerun' | 'ask_user'; presentArtifacts: string[]; missingArtifacts: string[]; } /** Check whether a step's expected outputs are present on disk. */ export declare function detectCompletion(step: string, state: PipelineState, expectedOutputs: string[], projectRoot: string, service?: string, artifactMap?: Record, globalSteps?: ReadonlySet): CompletionResult; /** Check state vs artifact existence — returns status enum. */ export declare function checkCompletion(step: string, state: PipelineState, projectRoot: string, artifactMap?: Record): { status: 'confirmed_complete' | 'likely_complete' | 'conflict' | 'incomplete'; presentArtifacts: string[]; missingArtifacts: string[]; }; /** Analyze a crashed session (non-null in_progress) and recommend recovery action. */ export declare function analyzeCrash(state: PipelineState, projectRoot: string): CrashRecoveryAction; export interface DetectCheckResult { kind: 'path' | 'cmd'; target: string; passed: boolean; } export interface DetectResult { /** False when the step declares no detect block (vacuously passed). */ evaluated: boolean; passed: boolean; checks: DetectCheckResult[]; } /** Execute a step's detect: contract (D4). Failures are never fatal. */ export declare function runDetect(detect: DetectSpec | null | undefined, projectRoot: string): DetectResult; export type ConflictClass = 'state-claim' | 'artifact-only'; export interface StepVerification { step: string; verification: VerificationLevel; status: 'confirmed_complete' | 'likely_complete' | 'conflict' | 'incomplete'; conflictClass: ConflictClass | null; /** True when the step has no outputs AND no detect block (D3) — never 'verified'. */ undetectable: boolean; outputsPresent: string[]; outputsMissing: string[]; detect: DetectResult; } /** * The single D3 verification path: a step is 'verified' only when ALL declared * outputs exist on disk AND its detect: contract passes. Conflict classes: * 'state-claim' (state says completed, checks fail) and 'artifact-only' * (no claim, but partial artifacts disagree with live checks — the beads case). */ export declare function verifyStep(step: string, entry: StepStateEntry | undefined, expectedOutputs: string[], detect: DetectSpec | null | undefined, projectRoot: string, artifactMap?: Record): StepVerification; /** * D3: conflict overrides completed for eligibility. FS-only by design — this * runs on every `status`/`next`, so detect: cmds are never executed here. * Returns a shallow copy with conflicted steps demoted to pending; returns the * input object unchanged when nothing conflicts. * * `resolvedOutputs`, when supplied, provides each step's CURRENT output * contract from the resolved pipeline (preset + project-type overlays). Passing * it is important: a package upgrade can add or change a step's outputs after it * was completed, and checking only the stored `entry.produces` would let a * now-incomplete step stay `completed`. The stored `entry.produces` is used * only as a fallback for steps the resolver no longer knows (extra/removed). * * `service`/`globalSteps`, when supplied, mirror `detectCompletion`'s * service-scoping: a service-local step's outputs (any slug not in * `globalSteps`) are checked under `services//` rather than * at the project root. Without this, `scaffold status --service api` would * check a service-local step's output at the ROOT (always absent), causing a * false conflict — or worse, a same-named root file could mask a genuinely * missing service file and report a broken step as complete. Global steps * (present in `globalSteps`) and callers that omit `service` stay unprefixed, * identical to today's behavior. * * `artifactMap`, when supplied (D10a, R3), mirrors `verifyStep`'s fallback: a * step whose declared outputs are missing but whose `artifact_map[slug]` * incumbent exists on disk is NOT demoted here. This stays fs-only (no * detect: cmds) like the rest of this function — mapping only ever * substitutes for the outputs-presence check. */ export declare function applyConflictOverrides(steps: Record, projectRoot: string, resolvedOutputs?: (slug: string) => string[] | undefined, service?: string, globalSteps?: ReadonlySet, artifactMap?: Record): { steps: Record; conflicts: string[]; }; //# sourceMappingURL=completion.d.ts.map