/** * Mainline Contract (Runtime Mainline Convergence — load-bearing wall) * * Single executable source of truth for the Story A' product mainline: * * pain -> diagnosis -> diagnostician artifact -> candidate * -> dreamer task (lineage) -> dreamer context -> successor * -> owner-reviewable principle * * Plus the two runtime-readiness gates that sit *above* the chain and silently * break it when they drift: config-source alignment and diagnostician readiness. * * Design rules (do NOT relax without ADR review): * - PURE: no fs, no DB, no network, no Date.now side effects beyond `generatedAt`. * The caller assembles a read-only `MainlineSnapshot` from canonical sources; * this module only judges it. (Keeps it in principles-core per ADR-0001.) * - TOTAL: never throws. Malformed/absent input becomes a `violation` or * `skipped` verdict, never an exception. * - FAIL LOUD (EP-03): every `violation` carries a concrete `reason` and a * `nextAction` an operator can run. No silent degradation. * - SAME-SOURCE LINEAGE (EP-07): lineage checks compare fields that must come * from one source (candidate.sourceTaskId/sourceArtifactId/sourceRunId vs the * diagnosis task / diagnostician artifact that produced them). * - ONE TRUTH (EP-02): the integrity read-model, `pd mvp smoke`, the CI * product-path test, and the Console chain view must all call THIS function. * Do not fork a second copy of these rules. */ /** Stages of the mainline, in evaluation order. Readiness gates first. */ export type MainlineStage = 'config_source_alignment' | 'diagnostician_readiness' | 'pain_record' | 'diagnosis_task' | 'diagnostician_artifact' | 'candidate_lineage' | 'dreamer_task_lineage' | 'dreamer_context' | 'successor' | 'owner_reviewable_principle' | 'auto_consumption'; export type StageStatus = 'ok' | 'violation' | 'skipped'; export interface StageVerdict { stage: MainlineStage; status: StageStatus; /** Always present. For `ok` it states what was satisfied; for `violation`/`skipped` why. */ reason: string; /** Required for `violation`: a concrete operator action. Optional otherwise. */ nextAction?: string; } export interface MainlineVerdict { overall: 'ok' | 'violation'; painId: string | null; stages: StageVerdict[]; generatedAt: string; } export interface ArtifactRefSnapshot { artifactType: string; ref: string; } /** Workspace-global readiness, independent of any single chain. */ export interface RuntimeReadinessSnapshot { /** Runtime profile reported by `pd config doctor` (reads .pd/config.yaml). */ configDoctorProfile: string | null; /** Runtime profile actually resolved by run-once/probe at execution time. */ runtimeProbeProfile: string | null; /** Canonical config source path, e.g. ".pd/config.yaml". */ configSource: string; /** Config source the probe/run-once resolver actually read, e.g. ".state/workflows.yaml". */ probeConfigSource: string; /** Whether the diagnostician agent passed its readiness/connectivity probe. */ diagnosticianReady: boolean; diagnosticianReadinessReason?: string; } export interface DiagnosisTaskSnapshot { taskId: string; /** Task status string from the task store (e.g. 'succeeded'). */ status: string; /** Whether at least one run for this task has execution_status === 'succeeded'. */ hasSucceededRun: boolean; } export interface DiagnosticianArtifactSnapshot { artifactId: string; /** painId the artifact traces back to; must equal the chain painId. */ sourcePainId: string | null; } export interface CandidateSnapshot { candidateId: string; status: 'pending' | 'consumed' | 'expired'; /** candidate.taskId — must equal the diagnosis task that produced it. */ sourceTaskId: string; /** candidate.artifactId — must equal the diagnostician artifact. */ sourceArtifactId: string; /** candidate.sourceRunId. */ sourceRunId: string; } export interface DreamerTaskSnapshot { taskId: string; dependencyTaskIds: string[]; inputArtifactRefs: ArtifactRefSnapshot[]; /** True only when this dreamer task is an intentional manual empty-input task. */ isManualEmptyInput?: boolean; } export interface DreamerContextSnapshot { contextHash: string; contextRefs: string[]; } export interface SuccessorSnapshot { taskId: string; taskKind: string; exists: boolean; } export interface OwnerReviewablePrincipleSnapshot { exists: boolean; principleId?: string; reviewable: boolean; } /** One pain's chain. Any stage not yet reached is `null`. */ export interface MainlineChainSnapshot { painId: string | null; diagnosisTask: DiagnosisTaskSnapshot | null; diagnosticianArtifact: DiagnosticianArtifactSnapshot | null; candidate: CandidateSnapshot | null; dreamerTask: DreamerTaskSnapshot | null; dreamerContext: DreamerContextSnapshot | null; successor: SuccessorSnapshot | null; principle: OwnerReviewablePrincipleSnapshot | null; } export interface MainlineSnapshot { readiness: RuntimeReadinessSnapshot; chain: MainlineChainSnapshot; /** * Workspace-level: candidateIds that are `consumed` but have no dreamer task. * Surfaces the `missing_dreamer_task` auto-consumption hole. Optional. */ consumedCandidatesMissingDreamer?: string[]; } /** Sentinel contextHash produced by hashing an empty contextRefs list. */ export declare const EMPTY_CONTEXT_SENTINEL = "empty"; /** * Judge a single mainline snapshot. Pure and total. * * Readiness gates (config alignment, diagnostician readiness) and the * workspace-level auto-consumption check always evaluate. Chain stages cascade: * once a chain prerequisite is a `violation`, downstream chain stages become * `skipped` so the output names one actionable root cause instead of a misleading * cascade of violations. */ export declare function assertMainlineContract(snapshot: MainlineSnapshot, now?: () => Date): MainlineVerdict; //# sourceMappingURL=mainline-contract.d.ts.map