import { type CampaignStatus, type Clock, type KernelPaths, type RunRecord, type WorkSource } from "./types.js"; export { NEEDS_HUMAN_REASON_MAX, parseExactRunRecord, validateNeedsHumanPair, } from "./run-invariants.js"; export interface InitializeRuntimeOptions { readonly workspaceRoot: string; readonly clock: Clock; readonly cwd?: string; } export interface AcceptGoalOptions { readonly paths: KernelPaths; readonly clock: Clock; readonly goalText: string; readonly workSource: WorkSource; readonly readyLabel?: string; readonly repository?: string | null; readonly campaignHours?: number; readonly conductorSessionId?: string | null; } export declare function initializeRuntimeV2(options: InitializeRuntimeOptions): KernelPaths; /** * Public read of the projected run summary. For mutations, kernel paths always * reload from the journal under the lock (loadAuthoritativeRunUnlocked). */ export declare function readRun(paths: KernelPaths): RunRecord | null; export declare function requireActiveRun(paths: KernelPaths): RunRecord; /** * One authoritative start transition: full goal text + complete run view in one journal * record, then project goal.md and run.json. Prior terminal runs are archived as * projection from the previous run journal before the new start. */ export declare function acceptGoal(options: AcceptGoalOptions): RunRecord; /** Read archived goal text for a terminal run (immutable). */ export declare function readArchivedGoalText(paths: KernelPaths, runId: string): string | null; export interface TransitionRunOptions { readonly paths: KernelPaths; readonly clock: Clock; readonly expectedVersion: number; readonly toStatus: CampaignStatus; readonly reason: string; /** * Optional durable binding checked under the kernel lock against the * journal-authoritative run before terminal idempotency or mutation. */ readonly expectedRunId?: string; readonly expectedConductorSessionId?: string | null; readonly patch?: Partial>; /** Package-internal audit evidence for a dedicated transition authority. */ readonly extraPayload?: Readonly>; } /** * Package-internal status primitive. Production callers must use a dedicated * authority such as stopCampaign, expireDeadline, or the certified campaign * terminalizer below. It is intentionally omitted from the kernel barrel. */ export declare function transitionRunInternal(options: TransitionRunOptions): RunRecord; export type WorkerStopTerminalStatus = "stopped" | "deadline_expired"; export type WorkerStopTerminalAuthority = "operator_stop" | "deadline"; export interface TerminalizeCampaignAfterWorkerStopsOptions { readonly paths: KernelPaths; readonly clock: Clock; readonly expectedRunId: string; readonly expectedVersion: number; readonly status: WorkerStopTerminalStatus; readonly authority: WorkerStopTerminalAuthority; readonly reason: string; readonly expectedConductorSessionId?: string | null; } /** * Sole worker-stop terminal authority. * * Under one kernel lock it replays run and task state from the journal, proves * the matching stopping authority, verifies every historical launch binding has * an exact successful stop completion, and only then commits stopped/deadline. * It is package-internal and intentionally omitted from the kernel barrel. */ export declare function terminalizeCampaignAfterWorkerStopsInternal(options: TerminalizeCampaignAfterWorkerStopsOptions): RunRecord; export type CampaignCompletionStatus = "completed" | "blocked"; export type CampaignTerminalTaskStatus = "done" | "blocked"; export type CampaignTerminalTaskAuthority = "result_terminal" | "github_cancellation_terminal"; /** * Exact output of one independent journal-only task terminal inspector. * The campaign owner obtains these from ResultService or GitHub cancellation * certification before requesting the final run transition. */ export interface CampaignTerminalTaskCertification { readonly task_id: string; readonly task_version: number; readonly status: CampaignTerminalTaskStatus; readonly authority: CampaignTerminalTaskAuthority; } export interface TerminalizeCampaignFromCertifiedTasksOptions { readonly paths: KernelPaths; readonly clock: Clock; readonly expectedRunId: string; readonly expectedVersion: number; readonly status: CampaignCompletionStatus; readonly reason: string; readonly taskCertifications: readonly CampaignTerminalTaskCertification[]; } /** * Sole normal-completion run authority. * * Certifications are minted by independent journal-only task inspectors. Under * one kernel lock this function replays the complete task set from the journal, * binds every certification to the exact task version/status, rejects residual * worker identities, validates the campaign aggregate, and only then appends the * campaign terminal transition. * * Intentionally not re-exported from the production kernel barrel. */ export declare function terminalizeCampaignFromCertifiedTasks(options: TerminalizeCampaignFromCertifiedTasksOptions): RunRecord; /** Typed GitHub poll outcome transition. */ export declare function applyGithubPollOutcome(paths: KernelPaths, clock: Clock, expectedVersion: number, patch: Pick): RunRecord; /** Caller already holds the kernel lock. */ export declare function applyGithubPollOutcomeUnlocked(paths: KernelPaths, clock: Clock, expectedVersion: number, patch: Pick, operationId?: string): RunRecord; export declare function applyNeedsHuman(paths: KernelPaths, clock: Clock, expectedVersion: number, reason: string): RunRecord; /** Caller must hold the kernel lock. Not a production export. */ export declare function applyNeedsHumanUnlocked(paths: KernelPaths, clock: Clock, expectedVersion: number, reason: string): RunRecord; export declare function applyMonitorGenerationOnRun(paths: KernelPaths, clock: Clock, expectedVersion: number, monitorGeneration: number): RunRecord; export declare function isTerminalStatus(status: CampaignStatus): boolean; /** * Durable run/session binding against a journal-authoritative run view. * Omitted fields are not checked (shell/deadline callers may omit binding). */ export declare function assertExpectedRunBinding(run: RunRecord, binding: { readonly expectedRunId?: string; readonly expectedConductorSessionId?: string | null; }): void; /** Projection/public name — delegates to the shared exact parser (7A.3A.3). */ export declare function parseRunRecord(value: unknown, label: string): RunRecord; /** Repair run.json from journal after crash. */ export declare function repairRunProjection(paths: KernelPaths, runId: string): RunRecord | null;