import { type StringEnum, type ParticipantBindingEpoch, type StoreValidationResult, type WorkerGeneration } from "./canonical.ts"; /** Revision 17, section 22.5 canonical vocabulary. Order is contract-significant. */ export declare const PARTICIPANT_STATES: readonly ["provisioning", "registering", "ready", "working", "waiting", "paused", "stalled", "blocked", "failed", "lost", "unreachable", "stopped"]; export type ParticipantState = StringEnum; export declare const TERMINAL_PARTICIPANT_STATES: readonly ["failed", "lost", "stopped"]; export type TerminalParticipantState = StringEnum; export declare const LEGACY_WORKER_STATES: readonly ["provisioning", "running", "idle", "needs_attention", "completed", "failed", "stopped", "lost", "stopping"]; export type LegacyWorkerState = StringEnum; export declare const PARTICIPANT_HEALTH_EVENT_VERSION: 1; export declare const WORKER_STATE_MIGRATION_CONTRACT_VERSION: 1; export declare const LEGACY_WORKER_STORE_SCHEMA_VERSION: 1; export declare const CANONICAL_WORKER_STORE_SCHEMA_VERSION: 2; export declare const PARTICIPANT_HEALTH_SEVERITIES: readonly ["info", "warning", "error", "critical"]; export type ParticipantHealthSeverity = StringEnum; export interface ParticipantHealthEventV1 { version: typeof PARTICIPANT_HEALTH_EVENT_VERSION; eventId: string; bossRunId: string; participantId: string; bindingEpoch: ParticipantBindingEpoch; previousState: ParticipantState; state: ParticipantState; severity: ParticipantHealthSeverity; failureCode: string | null; reason: string | null; suggestedRecovery: string | null; occurredAt: string; acknowledgedAt?: string; } export interface LegacyWorkerMigrationInputV1 { version: typeof WORKER_STATE_MIGRATION_CONTRACT_VERSION; sourceStoreVersion: typeof LEGACY_WORKER_STORE_SCHEMA_VERSION; targetStoreVersion: typeof CANONICAL_WORKER_STORE_SCHEMA_VERSION; workerId: string; /** The legacy WorkerStore `runId`; it is an incarnation ID, never Boss authority. */ legacyRunId: string; /** Preserved for audit only; this deprecated environment value never becomes `bossRunId`. */ deprecatedAgentIntercomRunId: string | null; legacyState: LegacyWorkerState; legacyOutcome: string | null; /** Highest already-persisted generation for this stable worker ID, or zero for its first generation. */ workerGenerationFloor: number; assignedWorkerGeneration: WorkerGeneration; migratedAt: string; } export type WorkerMigrationStatus = "complete" | "pending_stopping_reconciliation"; export interface WorkerStateMigrationAuditV1 { version: typeof WORKER_STATE_MIGRATION_CONTRACT_VERSION; sourceStoreVersion: typeof LEGACY_WORKER_STORE_SCHEMA_VERSION; targetStoreVersion: typeof CANONICAL_WORKER_STORE_SCHEMA_VERSION; sourceIncarnationField: "runId"; originalRunId: string; originalDeprecatedAgentIntercomRunId: string | null; originalState: LegacyWorkerState; originalOutcome: string | null; workerGenerationFloor: number; migratedAt: string; } export declare const STOPPING_RECONCILIATION_OUTCOMES: readonly ["stopped", "failed", "lost", "unresolved_after_settle"]; export type StoppingReconciliationOutcome = StringEnum; export declare const STOPPING_EVIDENCE_SOURCES: readonly ["systemd", "cgroup", "systemd_and_cgroup"]; export type StoppingEvidenceSource = StringEnum; export interface LegacyStoppingReconciliationV1 { version: typeof WORKER_STATE_MIGRATION_CONTRACT_VERSION; workerId: string; workerIncarnationId: string; workerGeneration: WorkerGeneration; observationId: string; evidenceSource: StoppingEvidenceSource; outcome: StoppingReconciliationOutcome; boundedSettleWindowExpired: boolean; observedAt: string; } export interface MigratedWorkerRecordV2 { schemaVersion: typeof CANONICAL_WORKER_STORE_SCHEMA_VERSION; workerId: string; workerIncarnationId: string; workerGeneration: WorkerGeneration; /** Null only while legacy `stopping` is fenced pending direct process reconciliation. */ state: ParticipantState | null; /** Persisted recovery target; non-null exactly while the canonical state is `blocked`. */ resumeState: BlockedResumeState | null; reason: string | null; terminalOutcome: string | null; requiresReadinessReconciliation: boolean; legacyIdleHint: boolean; migrationStatus: WorkerMigrationStatus; readOnly: boolean; dispatchAllowed: false; migrationAudit: WorkerStateMigrationAuditV1; stoppingReconciliation: LegacyStoppingReconciliationV1 | null; } export declare function parseParticipantState(value: unknown, path?: string): ParticipantState; export declare function isTerminalParticipantState(state: ParticipantState): state is TerminalParticipantState; export declare function parseParticipantHealthEventV1(value: unknown, path?: string): ParticipantHealthEventV1; export declare function parseLegacyWorkerMigrationInputV1(value: unknown, path?: string): LegacyWorkerMigrationInputV1; /** * Applies only the frozen v1 projection contract. Store readers must validate their own complete * source record before projecting it here; unknown/corrupt store versions are never normalized. */ export declare function migrateLegacyWorkerRecordV1(value: unknown): MigratedWorkerRecordV2; export declare function parseLegacyStoppingReconciliationV1(value: unknown, path?: string): LegacyStoppingReconciliationV1; export declare function reconcileLegacyStoppingWorker(pendingValue: unknown, evidenceValue: unknown): MigratedWorkerRecordV2; export declare function parseMigratedWorkerRecordV2(value: unknown, path?: string): MigratedWorkerRecordV2; export declare const PARTICIPANT_STATE_TRANSITION_CONTRACT_VERSION: 1; export declare const BLOCKED_RESUME_STATES: readonly ["registering", "ready", "working", "waiting", "paused"]; export type BlockedResumeState = StringEnum; export declare const STALLED_RESUME_STATES: readonly ["registering", "ready", "working", "waiting"]; export type StalledResumeState = StringEnum; export declare const PARTICIPANT_STATE_TRANSITION_EVIDENCE_KINDS: readonly ["state_confirmation", "registration_started", "readiness_reconciled", "legacy_idle_reconciled", "turn_started", "turn_settled", "intentional_pause", "parked_resume", "blocker_detected", "blocked_reaffirmed", "blocker_cleared", "controller_liveness_stalled", "controller_liveness_recovered", "connectivity_recovered", "failure_observed", "stop_observed", "new_generation_provisioned"]; export type ParticipantStateTransitionEvidenceKind = StringEnum; interface TransitionEvidenceBase { kind: K; evidenceId: string; } interface ReadinessAssertions { adapterStartupReady: true; brokerRegistrationReady: true; bindingAttested: true; capabilityProfileAttested: true; assignmentControlSupported: true; } export type ParticipantStateTransitionEvidence = TransitionEvidenceBase<"state_confirmation"> | TransitionEvidenceBase<"registration_started"> | (TransitionEvidenceBase<"readiness_reconciled"> & ReadinessAssertions) | (TransitionEvidenceBase<"legacy_idle_reconciled"> & ReadinessAssertions & { legacyIdleHint: true; noActiveTurn: true; }) | (TransitionEvidenceBase<"turn_started"> & { turnId: string; }) | (TransitionEvidenceBase<"turn_settled"> & { turnId: string; noActiveTurn: true; }) | (TransitionEvidenceBase<"intentional_pause"> & { checkpointId: string; }) | (TransitionEvidenceBase<"parked_resume"> & ReadinessAssertions & { resumableState: "ready" | "waiting"; parkedProcessConfirmed: true; noActiveTurn: true; }) | (TransitionEvidenceBase<"blocker_detected"> & { resumeState: BlockedResumeState; reason: string; }) | (TransitionEvidenceBase<"blocked_reaffirmed"> & { storedResumeState: BlockedResumeState; reason: string; }) | (TransitionEvidenceBase<"blocker_cleared"> & { storedResumeState: BlockedResumeState; blockerClearConfirmed: true; }) | (TransitionEvidenceBase<"controller_liveness_stalled"> & { controllerParticipantId: string; livenessDeadlineExceeded: true; }) | (TransitionEvidenceBase<"controller_liveness_recovered"> & { controllerParticipantId: string; resumableState: StalledResumeState; positiveStateEvidenceId: string; }) | (TransitionEvidenceBase<"connectivity_recovered"> & { freshReadinessReconciliationRequired: true; }) | (TransitionEvidenceBase<"failure_observed"> & { outcome: "failed" | "lost" | "unreachable"; }) | TransitionEvidenceBase<"stop_observed"> | TransitionEvidenceBase<"new_generation_provisioned">; export interface ParticipantStateTransitionContextV1 { version: typeof PARTICIPANT_STATE_TRANSITION_CONTRACT_VERSION; previousState: ParticipantState; previousResumeState?: BlockedResumeState; state: ParticipantState; previousWorkerGeneration: WorkerGeneration; workerGeneration: WorkerGeneration; evidence: ParticipantStateTransitionEvidence; } /** Backwards-compatible type name for the v1 transition contract. */ export type ParticipantStateTransitionContext = ParticipantStateTransitionContextV1; /** * Every same-generation pair is explicit. `null` is a denial; no exceptional-target fallback exists. * In particular, terminal states have no exits, paused cannot stall, and unreachable can only * re-enter readiness through registering. */ export declare const PARTICIPANT_STATE_TRANSITION_TABLE: { readonly provisioning: { readonly provisioning: "state_confirmation"; readonly registering: "registration_started"; readonly ready: null; readonly working: null; readonly waiting: null; readonly paused: null; readonly stalled: null; readonly blocked: null; readonly failed: "failure_observed"; readonly lost: "failure_observed"; readonly unreachable: "failure_observed"; readonly stopped: "stop_observed"; }; readonly registering: { readonly provisioning: null; readonly registering: "state_confirmation"; readonly ready: "readiness_reconciled"; readonly working: null; readonly waiting: "legacy_idle_reconciled"; readonly paused: null; readonly stalled: "controller_liveness_stalled"; readonly blocked: "blocker_detected"; readonly failed: "failure_observed"; readonly lost: "failure_observed"; readonly unreachable: "failure_observed"; readonly stopped: "stop_observed"; }; readonly ready: { readonly provisioning: null; readonly registering: null; readonly ready: "state_confirmation"; readonly working: "turn_started"; readonly waiting: null; readonly paused: null; readonly stalled: "controller_liveness_stalled"; readonly blocked: "blocker_detected"; readonly failed: "failure_observed"; readonly lost: "failure_observed"; readonly unreachable: "failure_observed"; readonly stopped: "stop_observed"; }; readonly working: { readonly provisioning: null; readonly registering: null; readonly ready: null; readonly working: "state_confirmation"; readonly waiting: "turn_settled"; readonly paused: "intentional_pause"; readonly stalled: "controller_liveness_stalled"; readonly blocked: "blocker_detected"; readonly failed: "failure_observed"; readonly lost: "failure_observed"; readonly unreachable: "failure_observed"; readonly stopped: "stop_observed"; }; readonly waiting: { readonly provisioning: null; readonly registering: null; readonly ready: null; readonly working: "turn_started"; readonly waiting: "state_confirmation"; readonly paused: "intentional_pause"; readonly stalled: "controller_liveness_stalled"; readonly blocked: "blocker_detected"; readonly failed: "failure_observed"; readonly lost: "failure_observed"; readonly unreachable: "failure_observed"; readonly stopped: "stop_observed"; }; readonly paused: { readonly provisioning: null; readonly registering: null; readonly ready: "parked_resume"; readonly working: null; readonly waiting: "parked_resume"; readonly paused: "state_confirmation"; readonly stalled: null; readonly blocked: null; readonly failed: "failure_observed"; readonly lost: "failure_observed"; readonly unreachable: "failure_observed"; readonly stopped: "stop_observed"; }; readonly stalled: { readonly provisioning: null; readonly registering: "controller_liveness_recovered"; readonly ready: "controller_liveness_recovered"; readonly working: "controller_liveness_recovered"; readonly waiting: "controller_liveness_recovered"; readonly paused: null; readonly stalled: "controller_liveness_stalled"; readonly blocked: null; readonly failed: "failure_observed"; readonly lost: "failure_observed"; readonly unreachable: "failure_observed"; readonly stopped: "stop_observed"; }; readonly blocked: { readonly provisioning: null; readonly registering: "blocker_cleared"; readonly ready: "blocker_cleared"; readonly working: "blocker_cleared"; readonly waiting: "blocker_cleared"; readonly paused: "blocker_cleared"; readonly stalled: null; readonly blocked: "blocked_reaffirmed"; readonly failed: "failure_observed"; readonly lost: "failure_observed"; readonly unreachable: "failure_observed"; readonly stopped: "stop_observed"; }; readonly failed: { readonly provisioning: null; readonly registering: null; readonly ready: null; readonly working: null; readonly waiting: null; readonly paused: null; readonly stalled: null; readonly blocked: null; readonly failed: "state_confirmation"; readonly lost: null; readonly unreachable: null; readonly stopped: null; }; readonly lost: { readonly provisioning: null; readonly registering: null; readonly ready: null; readonly working: null; readonly waiting: null; readonly paused: null; readonly stalled: null; readonly blocked: null; readonly failed: null; readonly lost: "state_confirmation"; readonly unreachable: null; readonly stopped: null; }; readonly unreachable: { readonly provisioning: null; readonly registering: "connectivity_recovered"; readonly ready: null; readonly working: null; readonly waiting: null; readonly paused: null; readonly stalled: null; readonly blocked: null; readonly failed: "failure_observed"; readonly lost: "failure_observed"; readonly unreachable: "failure_observed"; readonly stopped: "stop_observed"; }; readonly stopped: { readonly provisioning: null; readonly registering: null; readonly ready: null; readonly working: null; readonly waiting: null; readonly paused: null; readonly stalled: null; readonly blocked: null; readonly failed: null; readonly lost: null; readonly unreachable: null; readonly stopped: "state_confirmation"; }; }; /** The only transitions that may cross exactly one worker-generation boundary. */ export declare const PARTICIPANT_NEW_GENERATION_TRANSITIONS: { readonly provisioning: readonly []; readonly registering: readonly []; readonly ready: readonly []; readonly working: readonly []; readonly waiting: readonly []; readonly paused: readonly ["ready", "waiting"]; readonly stalled: readonly []; readonly blocked: readonly []; readonly failed: readonly ["provisioning"]; readonly lost: readonly ["provisioning"]; readonly unreachable: readonly []; readonly stopped: readonly ["provisioning"]; }; export declare function parseParticipantStateTransitionEvidence(value: unknown, path?: string): ParticipantStateTransitionEvidence; export declare function parseParticipantStateTransitionContextV1(value: unknown, path?: string): ParticipantStateTransitionContextV1; /** Enforces the complete evidence-guarded ยง22.5 transition and generation tables. */ export declare function validateParticipantStateTransition(value: unknown): void; export declare const PARTICIPANT_DISPATCHABLE_STATES: readonly ["ready", "waiting"]; export declare const PARTICIPANT_READ_ONLY_STATES: readonly ["unreachable"]; /** Dispatch is positive-state gated; transition, failure, park, block, stall, and connectivity states fail closed. */ export declare function canDispatchParticipantState(value: unknown): boolean; /** Unreachable remains a nonterminal observation state, but is read-only until registration recovery. */ export declare function isParticipantStateReadOnly(value: unknown): boolean; /** Compatibility helpers must consult direct systemd/cgroup evidence before process cleanup. */ export declare function requiresDirectProcessEvidenceForCleanup(_state: ParticipantState): true; /** Dispatch requires positive v2 readiness proof; no legacy-migrated record is immediately dispatchable. */ export declare function canDispatchMigratedWorker(record: MigratedWorkerRecordV2): false; export declare const validateParticipantHealthEventStore: (value: unknown) => StoreValidationResult; export declare const validateLegacyWorkerMigrationInputStore: (value: unknown) => StoreValidationResult; export declare const validateLegacyStoppingReconciliationStore: (value: unknown) => StoreValidationResult; export {}; //# sourceMappingURL=boss-participant-state.d.ts.map