import { type StoreValidationResult, type SubscriberBindingEpoch, type SubscriberBindingGeneration, type ParticipantBindingEpoch, type WorkerGeneration, type TriggerGeneration, type RecipientTransferGeneration, type DeliveryClaimGeneration } from "./canonical.ts"; import { type DeliveryClaimRecord, type DeliveryEquivalenceKey, type DeliveryGroupRecord, type DeliveryIntent } from "./boss-wire.ts"; import { type ParticipantState } from "./boss-participant-state.ts"; export declare const LIFECYCLE_SUBSCRIPTION_VERSION: "orc.lifecycle-subscription.v1"; export declare const ACTIVITY_RECORD_VERSION: "orc.activity-record.v1"; export declare const ACTIVE_OPERATION_LEASE_VERSION: "orc.active-operation-lease.v1"; export declare const EXTERNAL_WAIT_LEASE_VERSION: "orc.external-wait-lease.v1"; export declare const SUBSCRIBER_REBIND_MIGRATION_VERSION: "orc.subscriber-rebind-migration.v1"; export declare const LIFECYCLE_TRIGGER_SCHEMA_VERSION: 1; export declare const LIFECYCLE_TRIGGER_VERSION: "orc.lifecycle-trigger.v1"; export declare const MAX_EXTERNAL_WAIT_LEASE_MS_DEFAULT: number; export declare const SUBSCRIPTION_STATES: readonly ["armed", "triggered", "suspended", "cancelled", "expired"]; export type SubscriptionState = (typeof SUBSCRIPTION_STATES)[number]; export declare const INACTIVITY_MODES: readonly ["smart", "raw"]; export type InactivityMode = (typeof INACTIVITY_MODES)[number]; export declare const ACTIVITY_BASES: readonly ["meaningful", "liveness"]; export type ActivityBasis = (typeof ACTIVITY_BASES)[number]; export declare const SUPERVISED_ROLES: readonly ["boss", "manager", "adversary", "scout", "worker", "council"]; export type SupervisedRole = (typeof SUPERVISED_ROLES)[number]; export type LifecycleTarget = { kind: "worker"; workerId: string; workerGeneration: WorkerGeneration; } | { kind: "role"; bossRunId: string; role: SupervisedRole; }; export type LifecyclePredicate = { kind: "state_changed"; } | { kind: "state_in"; states: ParticipantState[]; } | { kind: "failed"; } | { kind: "stopped"; } | { kind: "turn_settled"; } | { kind: "inactive_for"; }; export interface LifecycleSubscriptionRecord { version: typeof LIFECYCLE_SUBSCRIPTION_VERSION; subscriptionId: string; subscriberPrincipalId: string; subscriberBindingEpoch: SubscriberBindingEpoch; subscriberBindingGeneration: SubscriberBindingGeneration; lastSubscriberAuthorityTransitionId?: string; bossRunId?: string; target: LifecycleTarget; followReplacement: boolean; predicates: LifecyclePredicate[]; inactivityMode?: InactivityMode; inactiveAfterMs?: number; activityBasis?: ActivityBasis; cooldownMs: number; maxFires?: number; expiresAt?: string; delivery: DeliveryIntent; state: SubscriptionState; triggerGeneration: TriggerGeneration; lastActivityAt?: string; dueAt?: string; lastSourceEventId?: string; createdAt: string; updatedAt: string; } export declare function parseLifecycleTarget(value: unknown, path?: string): LifecycleTarget; export declare function parseLifecycleSubscription(value: unknown): LifecycleSubscriptionRecord; export declare const ACTIVITY_KINDS: readonly ["meaningful", "liveness"]; export type ActivityKind = (typeof ACTIVITY_KINDS)[number]; export declare const ACTIVITY_TYPES: readonly ["turn", "tool", "progress", "checkpoint", "assignment", "state_transition", "heartbeat", "health_confirmation"]; export type ActivityType = (typeof ACTIVITY_TYPES)[number]; export interface AuthenticatedActivityRecord { version: typeof ACTIVITY_RECORD_VERSION; activityId: string; workerId: string; workerGeneration: WorkerGeneration; sourceEventId: string; participantId: string; bindingEpoch: ParticipantBindingEpoch; kind: ActivityKind; activityType: ActivityType; occurredAt: string; } export declare function parseAuthenticatedActivity(value: unknown): AuthenticatedActivityRecord; export declare const OPERATION_LEASE_STATES: readonly ["active", "settled", "cancelled", "expired"]; export type OperationLeaseState = (typeof OPERATION_LEASE_STATES)[number]; export interface ActiveOperationLease { version: typeof ACTIVE_OPERATION_LEASE_VERSION; leaseId: string; workerId: string; workerGeneration: WorkerGeneration; invocationId: string; processId: number; cgroupIdentity: string; startedAt: string; renewBy: string; maxUntil: string; hardWorkerLeaseExpiresAt: string; maxRuntimeAt: string; state: OperationLeaseState; } export declare function parseActiveOperationLease(value: unknown): ActiveOperationLease; export declare const WAIT_SOURCE_KINDS: readonly ["process", "timer", "file", "port", "url", "webhook", "async_tool", "other"]; export type WaitSourceKind = (typeof WAIT_SOURCE_KINDS)[number]; export declare const WAIT_LEASE_STATES: readonly ["active", "fired", "cancelled", "expired"]; export type WaitLeaseState = (typeof WAIT_LEASE_STATES)[number]; export interface ExternalWaitLease { version: typeof EXTERNAL_WAIT_LEASE_VERSION; leaseId: string; workerId: string; workerGeneration: WorkerGeneration; sourceKind: WaitSourceKind; sourceRefHash: string; processIdentity?: string; startedAt: string; renewBy: string; maxUntil: string; expectedWakeAt?: string; hardWorkerLeaseExpiresAt: string; maxRuntimeAt: string; state: WaitLeaseState; } export declare function parseExternalWaitLease(value: unknown, maxExternalWaitLeaseMs?: number): ExternalWaitLease; /** Validates an operation progress/settlement update without allowing identity, generation, or hard-bound drift. */ export declare function validateActiveOperationLeaseRenewal(previousValue: unknown, nextValue: unknown): ActiveOperationLease; /** Validates wait renewal/fire/cancellation while keeping the original bounded maximum immutable. */ export declare function validateExternalWaitLeaseRenewal(previousValue: unknown, nextValue: unknown, maxExternalWaitLeaseMs?: number): ExternalWaitLease; export interface SmartInactivityEvidence { workerId: string; workerGeneration: WorkerGeneration; now: string; currentOperation?: { invocationId: string; processId: number; cgroupIdentity: string; live: boolean; }; activeOperation?: ActiveOperationLease; externalWait?: ExternalWaitLease; externalWaitSourceTerminal?: boolean; } export declare function isSmartInactivitySuppressed(evidence: SmartInactivityEvidence): boolean; export interface LifecycleTriggerRecord { version: typeof LIFECYCLE_TRIGGER_VERSION; triggerId: string; subscriptionId: string; triggerGeneration: TriggerGeneration; targetWorkerId: string; targetWorkerGeneration: WorkerGeneration; predicateEdge: string; sourceEventId: string; transitionId: string; subscriberBindingEpoch: SubscriberBindingEpoch; subscriberBindingGeneration: SubscriberBindingGeneration; deliveryGroupId: string; deliveryGroupMembershipRevision: number; noticeId?: string; satisfiedByNoticeId?: string; successorDeliveryGroupId?: string; recipientTransferGeneration: RecipientTransferGeneration; createdAt: string; acknowledgedAt?: string; } export declare function parseLifecycleTrigger(value: unknown): LifecycleTriggerRecord; export interface InactivityEdgeKey { workerId: string; workerGeneration: WorkerGeneration; inactivityEpochId: string; inactivityMode: InactivityMode; activityBasis: ActivityBasis; inactiveAfterMs: number; dueAt: string; } export declare function parseInactivityEdgeKey(value: unknown): InactivityEdgeKey; export declare function inactivityTransitionId(key: InactivityEdgeKey): string; export declare const REBIND_MIGRATION_STATES: readonly ["prepared", "projected", "committed", "aborted", "blocked"]; export type RebindMigrationState = (typeof REBIND_MIGRATION_STATES)[number]; export interface RebindCurrentClaimEvidence { status: "unclaimed" | "claimed"; observedAt: string; claim?: DeliveryClaimRecord; } export interface RebindTargetLedgerEvidence { deliveryGroupId: string; membershipRevision: number; recipientPrincipalId: string; recipientBindingEpoch: SubscriberBindingEpoch; recipientTransferGeneration: RecipientTransferGeneration; state: "absent" | "inserting" | "inserted" | "ambiguous"; checkedAt: string; targetLedgerEntryId?: string; insertedAt?: string; } export interface RebindDeliveryReceiptEvidence { deliveryClaimId: string; claimGeneration: DeliveryClaimGeneration; deliveryGroupId: string; membershipRevision: number; recipientPrincipalId: string; recipientBindingEpoch: SubscriberBindingEpoch; recipientTransferGeneration: RecipientTransferGeneration; deliveryReceiptId: string; targetLedgerEntryId: string; insertedAt: string; deliveredAt: string; } export interface RebindDrainBarrierEvidence { deliveryGroupId: string; membershipRevision: number; recipientPrincipalId: string; recipientBindingEpoch: SubscriberBindingEpoch; recipientTransferGeneration: RecipientTransferGeneration; barrierId: string; noSessionEntry: true; noAdapterQueue: true; noInflightInvocation: true; operativePathsDrained: true; establishedAt: string; } export interface RebindAcknowledgmentEvidence { deliveryGroupId: string; noticeIds: string[]; recipientPrincipalId: string; recipientBindingEpoch: SubscriberBindingEpoch; acknowledgedAt: string; } /** One authenticated authority-socket projection binds every fact used to classify an old group. */ export interface RebindMigrationLinkEvidence { authorityPrincipalId: string; authoritySessionId: string; authenticatedAt: string; evidenceDigest: string; oldGroup: DeliveryGroupRecord; currentClaim: RebindCurrentClaimEvidence; targetLedger: RebindTargetLedgerEvidence; receipt?: RebindDeliveryReceiptEvidence; drainBarrier?: RebindDrainBarrierEvidence; acknowledgment?: RebindAcknowledgmentEvidence; } export declare function rebindMigrationEvidenceDigest(evidence: Omit): string; export interface DeliveryGroupMigrationLink { oldDeliveryGroupId: string; oldEquivalenceKey: DeliveryEquivalenceKey; successorDeliveryGroupId?: string; successorEquivalenceKey?: DeliveryEquivalenceKey; disposition: "migrated" | "delivered_old_epoch" | "blocked_ambiguous" | "not_replayed"; previousRecipientTransferGeneration: RecipientTransferGeneration; recipientTransferGeneration: RecipientTransferGeneration; evidence: RebindMigrationLinkEvidence; } export interface SubscriberRebindMigrationRecord { version: typeof SUBSCRIBER_REBIND_MIGRATION_VERSION; authorityTransitionId: string; subscriptionId: string; stableSubscriberPrincipalId: string; oldSubscriberBindingEpoch: SubscriberBindingEpoch; newSubscriberBindingEpoch: SubscriberBindingEpoch; oldSubscriberBindingGeneration: SubscriberBindingGeneration; newSubscriberBindingGeneration: SubscriberBindingGeneration; reauthorized: boolean; resultingSubscriptionState: SubscriptionState; deliveryGroups: DeliveryGroupMigrationLink[]; state: RebindMigrationState; createdAt: string; committedAt?: string; } export declare function parseSubscriberRebindMigration(value: unknown): SubscriberRebindMigrationRecord; export declare const SUPERVISOR_PRINCIPAL_KINDS: readonly ["ordinary_owner", "boss", "manager", "controller", "worker", "scout", "adversary", "council"]; export type SupervisorPrincipalKind = (typeof SUPERVISOR_PRINCIPAL_KINDS)[number]; export interface SupervisorPrincipal { principalId: string; kind: SupervisorPrincipalKind; state: "active" | "revoked"; bindingEpoch: SubscriberBindingEpoch; bindingGeneration: SubscriberBindingGeneration; participantId?: string; bossRunId?: string; ownedWorkerIds?: string[]; assignedParticipantIds?: string[]; } export interface SupervisionWorker { workerId: string; workerGeneration: WorkerGeneration; participantId?: string; role?: SupervisedRole; bossRunId?: string; active: boolean; } export interface SupervisorAclState { principals: Record; workers: Record; currentManagerByRun: Record; } export interface SupervisorAuthorizationRequest { actorPrincipalId: string; actorBindingEpoch: SubscriberBindingEpoch; actorBindingGeneration: SubscriberBindingGeneration; target: LifecycleTarget; followReplacement: boolean; } export type SupervisorDenialCode = "UNKNOWN_SUBSCRIBER" | "REVOKED_SUBSCRIBER" | "STALE_SUBSCRIBER_BINDING" | "UNKNOWN_TARGET" | "STALE_TARGET_GENERATION" | "CROSS_RUN_DENIED" | "ROLE_SELECTOR_DENIED" | "FOLLOW_REPLACEMENT_DENIED" | "SUPERVISION_EDGE_DENIED"; export type SupervisorAuthorizationDecision = { allowed: true; reason: "owner_to_worker" | "manager_to_assignment" | "boss_to_manager" | "controller_to_participant"; } | { allowed: false; code: SupervisorDenialCode; }; export declare function authorizeSupervisorSubscription(state: SupervisorAclState, request: SupervisorAuthorizationRequest): SupervisorAuthorizationDecision; export declare function aggregateDeliveryIntent(intents: readonly DeliveryIntent[]): DeliveryIntent; export declare const validateLifecycleSubscriptionStore: (value: unknown) => StoreValidationResult; export declare const validateAuthenticatedActivityStore: (value: unknown) => StoreValidationResult; export declare const validateActiveOperationLeaseStore: (value: unknown) => StoreValidationResult; export declare const validateExternalWaitLeaseStore: (value: unknown) => StoreValidationResult; export declare const validateLifecycleTriggerStore: (value: unknown) => StoreValidationResult; export declare const validateSubscriberRebindMigrationStore: (value: unknown) => StoreValidationResult; //# sourceMappingURL=supervision.d.ts.map