import { type ICodexCreationScope, type IBeginCodexCreationInput } from './classes.codexcreationstore.js'; import type { ICodexCreationRuntime, IControllerCodexCreationDocument } from './classes.codexcreationmodels.js'; import { type TControllerSessionId } from '../dist_ts_interfaces/index.js'; import type { IControllerSessionIdentity, IControllerSessionRuntimeBinding } from './interfaces.identity.js'; import { type IControllerFlexCleanupEntry, type IControllerManagedSessionDocument, type TControllerManagedSessionAdmissionSource, type TControllerSessionCreationObligationState } from './classes.managedsessionmodels.js'; export declare const controllerSessionIdentitySnapshotEntryLimit = 65536; export declare const controllerSessionIdentityScopedLocatorLimit = 131072; export declare const controllerManagedSessionRecoveryEntryLimit = 65536; export declare const controllerManagedSessionRecoveryPageEntryLimit = 1024; type TControllerSessionHarnessId = TControllerSessionId['harnessId']; export type TControllerSessionIdentityErrorCode = 'invalid_input' | 'not_found' | 'concurrent_change' | 'provider_generation_mismatch' | 'deleting' | 'tombstoned' | 'limit_exceeded' | 'corrupt_state' | 'closed'; export declare class ControllerSessionIdentityError extends Error { readonly code: TControllerSessionIdentityErrorCode; constructor(code: TControllerSessionIdentityErrorCode, messageArg: string, optionsArg?: ErrorOptions); } export interface IObserveControllerSessionIdentityInput { projectIdentityId: string; runtimeId: TControllerSessionId; supervisorGeneration: string; providerSessionGeneration?: string; sessionGenerationId?: string; sessionGenerationSequence?: number; observedAt?: Date; signal?: AbortSignal; } export interface IControllerSessionIdentityObservation { identity: IControllerSessionIdentity; binding: IControllerSessionRuntimeBinding; } export interface IAdmitControllerManagedSessionInput extends IObserveControllerSessionIdentityInput { admissionSource: TControllerManagedSessionAdmissionSource; codexOrigin?: IControllerCodexOrigin; } export interface IRequireControllerManagedSessionInput { projectIdentityId: string; runtimeId: TControllerSessionId; supervisorGeneration: string; /** When present, the provider generation must match exactly. */ providerSessionGeneration?: string; } export interface IResolveRetiredManagedSessionIdentityInput { projectIdentityId: string; runtimeId: TControllerSessionId; sessionIdentityId: string; signal?: AbortSignal; } export interface IControllerSessionManagedObservation extends IControllerSessionIdentityObservation { managedAt: number; admissionSource: TControllerManagedSessionAdmissionSource; } export interface IBeginControllerManagedSessionDeletionInput { projectIdentityId: string; runtimeId: TControllerSessionId; supervisorGeneration: string; providerSessionGeneration?: string; flexCleanupCohort?: readonly unknown[]; operationId: string; startedAt: Date; } export interface IMarkControllerManagedSessionDeletionDispatchedInput { projectIdentityId: string; runtimeId: TControllerSessionId; operationId: string; dispatchStartedAt: Date; } export interface ICancelControllerManagedSessionDeletionInput { projectIdentityId: string; runtimeId: TControllerSessionId; operationId: string; cancelledAt: Date; } export interface ICompleteControllerManagedSessionDeletionInput { projectIdentityId: string; runtimeId: TControllerSessionId; operationId: string; retiredAt: Date; } export interface IListControllerManagedSessionDeletionObligationsInput { projectIdentityId: string; harnessId?: TControllerSessionHarnessId; signal?: AbortSignal; } export interface IRetireControllerProjectManagedSessionsInput { projectIdentityId: string; retiredAt: Date; signal?: AbortSignal; } export interface IControllerManagedSessionDeletionObligation { id: string; issuerId: string; projectIdentityId: string; runtimeId: TControllerSessionId; sessionIdentityId: string; managedAt: number; admissionSource: TControllerManagedSessionAdmissionSource; operationId: string; expectedBindingId: string; supervisorGeneration: string; providerSessionGeneration: string; flexCleanupCohort?: IControllerFlexCleanupEntry[]; startedAt: number; dispatchStartedAt?: number; } export interface IBeginControllerManagedSessionCreationInput { projectIdentityId: string; runtimeId: TControllerSessionId; operationId: string; requestedAt: Date; expectedFlexSessionGenerationId?: string; } export interface IMarkControllerManagedSessionCreationDispatchedInput { projectIdentityId: string; runtimeId: TControllerSessionId; operationId: string; dispatchStartedAt: Date; } export interface ICompleteControllerManagedSessionCreationAdmissionInput { projectIdentityId: string; runtimeId: TControllerSessionId; operationId: string; supervisorGeneration: string; providerSessionGeneration: string; sessionGenerationId?: string; sessionGenerationSequence?: number; terminalAt: Date; signal?: AbortSignal; } export interface IRetireControllerManagedSessionCreationInput { projectIdentityId: string; runtimeId: TControllerSessionId; operationId: string; terminalAt: Date; } export interface IListControllerSessionCreationObligationsInput { projectIdentityId: string; harnessId?: TControllerSessionHarnessId; signal?: AbortSignal; } export interface IGetControllerSessionCreationObligationInput { projectIdentityId: string; runtimeId: TControllerSessionId; } export interface IControllerSessionCreationObligation { id: string; issuerId: string; projectIdentityId: string; runtimeId: TControllerSessionId; operationId: string; state: TControllerSessionCreationObligationState; requestedAt: number; dispatchStartedAt?: number; expectedFlexSessionGenerationId?: string; providerSessionGeneration?: string; sessionIdentityId?: string; terminalAt?: number; } export interface IControllerSessionSnapshotEntry { nativeId: string; providerSessionGeneration: string; sessionGenerationId?: string; sessionGenerationSequence?: number; parentNativeId?: string; } export type TControllerFlexHostSessionAuthority = 'active' | 'pending_creation_load' | 'deleting_cleanup' | 'project_removal_cleanup' | 'definitively_unmanaged' | 'uncertain'; export interface IResolveControllerFlexHostSessionAuthorityInput { projectIdentityId: string; runtimeId: TControllerSessionId & { harnessId: 'flex'; }; providerSessionGeneration: string; signal?: AbortSignal; } export type TControllerPendingFlexProjectManagementLoadAuthority = Extract | 'definitively_unmanaged'; export interface IResolveControllerPendingFlexProjectManagementLoadAuthorityInput { projectIdentityId: string; runtimeId: TControllerSessionId & { harnessId: 'flex'; }; expectedFlexSessionGenerationId: string; signal?: AbortSignal; } export type TControllerFlexProjectManagementRegistrationLoadAuthority = 'active_load' | 'pending_creation_empty_load' | 'historical_unmanaged_empty_load'; export interface IResolveControllerFlexProjectManagementRegistrationLoadAuthorityInput { projectIdentityId: string; runtimeId: TControllerSessionId & { harnessId: 'flex'; }; providerSessionGeneration: string; expectedFlexSessionGenerationId: string; signal?: AbortSignal; } export type TControllerSessionLayoutAuthority = 'managed' | 'definitively_unmanaged'; export interface IResolveControllerSessionLayoutAuthorityInput { projectIdentityId: string; runtimeId: TControllerSessionId; signal?: AbortSignal; } export interface IListControllerFlexManagedCleanupRootsInput { projectIdentityId: string; signal?: AbortSignal; } export interface IReconcileControllerSessionSnapshotInput { projectIdentityId: string; harnessId: TControllerSessionHarnessId; supervisorGeneration: string; sourceAdmissionFenced: true; snapshotComplete: true; managedMembershipsOnly?: true; sessions: readonly IControllerSessionSnapshotEntry[]; observedAt?: Date; signal?: AbortSignal; } export interface IControllerSessionSnapshotObservation { runtimeId: TControllerSessionId; identity: IControllerSessionIdentity; binding: IControllerSessionRuntimeBinding; managed: boolean; } export interface IControllerSessionPendingDeletion { runtimeId: TControllerSessionId; operationId: string; expectedBindingId: string; state: 'deleting' | 'completing'; startedAt: number; } export interface IReconciledControllerSessionSnapshot { status: 'reconciled'; observations: IControllerSessionSnapshotObservation[]; detachedBindings: IControllerSessionRuntimeBinding[]; } export interface IBlockedControllerSessionSnapshot { status: 'blocked_by_deletion'; observations: []; detachedBindings: []; pendingDeletions: IControllerSessionPendingDeletion[]; } export type TControllerSessionSnapshotResult = IReconciledControllerSessionSnapshot | IBlockedControllerSessionSnapshot; export interface IDetachControllerSessionIdentityInput { projectIdentityId: string; runtimeId: TControllerSessionId; expectedBindingId: string; detachedAt?: Date; } export interface IBeginControllerSessionDeletionInput { projectIdentityId: string; runtimeId: TControllerSessionId; expectedBindingId: string; operationId: string; startedAt?: Date; } export interface ICancelControllerSessionDeletionInput { projectIdentityId: string; runtimeId: TControllerSessionId; operationId: string; cancelledAt?: Date; } export interface ICompleteControllerSessionDeletionInput { projectIdentityId: string; runtimeId: TControllerSessionId; operationId: string; completedAt?: Date; } export declare const buildControllerFlexCleanupCohort: (sessionsArg: readonly IControllerSessionSnapshotEntry[], targetRootsArg: readonly IControllerFlexCleanupEntry[]) => IControllerFlexCleanupEntry[]; export declare class ControllerSessionIdentityService { private readonly issuerId; private closeStarted; private readonly activeOperations; private readonly scopeMutationTails; private readonly codexCreations; constructor(issuerId: string); beginCodexCreation(inputArg: IBeginCodexCreationInput): Promise; listCodexMemberships(projectIdArg: string, signalArg?: AbortSignal): Promise; codexOrigin(projectIdArg: string, nativeIdArg: string, signalArg?: AbortSignal): Promise; /** Rebind a provider-observed Codex thread without enrolling any unowned thread. */ observeManagedCodexSession(inputArg: IObserveControllerSessionIdentityInput): Promise; getCodexCreation(scopeArg: ICodexCreationScope): Promise; listCodexCreations(projectIdArg: string, signalArg?: AbortSignal): Promise; dispatchCodexCreation(scopeArg: ICodexCreationScope, runtimeArg: ICodexCreationRuntime): Promise; bindCodexCreation(scopeArg: ICodexCreationScope, generationArg: string, nativeIdArg: string, createdAtArg: number): Promise; admitCodexCreation(scopeArg: ICodexCreationScope, supervisorGenerationArg: string): Promise; findUnmaterializedCodexCreation(projectIdArg: string, nativeIdArg: string): Promise; finalizeCodexCreationMetadata(scopeArg: ICodexCreationScope): Promise; prepareCodexTurn(projectIdArg: string, nativeIdArg: string): Promise; cancelUndispatchedCodexTurn(projectIdArg: string, nativeIdArg: string): Promise; markCodexMaterialized(projectIdArg: string, nativeIdArg: string): Promise; completeCodexCreationDeletion(projectIdArg: string, nativeIdArg: string): Promise; /** Retires only a never-submitted creation whose exact dispatch runtime is conclusively gone. */ retireCodexCreation(scopeArg: ICodexCreationScope, assertRuntimeTerminatedArg: (runtimeArg: ICodexCreationRuntime) => Promise): Promise; private runOperation; private runScopeMutation; private runScopedOperation; private runProjectHarnessScopesOperation; close(): Promise; private resolveSnapshotScope; private resolveLocatorInput; private readLocator; private requireLocator; private assertLocatorScope; private readManagedSession; private assertManagedSessionScope; private snapshotMembershipIsActive; private transitionManagedSessionDocument; private readSessionCreationObligation; private assertSessionCreationObligationScope; private transitionSessionCreationObligationDocument; private readManagedSessionStatePages; private readSessionCreationObligationStatePages; private readSnapshotLocators; private hasSnapshotLocatorCapacity; private readSnapshotLocatorsByIds; private pendingDeletionFromLocator; private transitionLocator; private identityFromLocator; private bindingFromPending; private identityDocumentsEqual; private bindingDocumentsEqual; private ensureIdentity; private ensureBinding; private requireIdentityForLocator; private readParentRelationship; private assertParentRelationshipScope; private parentRelationshipDocumentsMatch; private assertNoParentRelationshipCycle; private insertParentRelationship; private reconcileSnapshotParentRelationship; private requireBindingForLocator; private detachBinding; private retireIdentity; private insertLocatorCandidate; private finishBindingCleanup; private finishDetaching; private finishBinding; private finishInitializing; private finalDetachedAt; private finishCompletion; private settleCoordinator; private assertProviderGeneration; private observationFromAttached; private replaceStableFlexLocatorGeneration; private observeSessionInScope; private admitManagedMembershipInScope; private resolveManagedLookupInput; private resolveManagedSessionInScope; private managedObservationFromLookupResult; private requireManagedMembershipForLocator; private requireIdentityPendingManagedDeletion; private requireAttachedIdentityForManagedDeletion; private settleIdentityCancellationForManagedDeletion; observeSession(inputArg: IObserveControllerSessionIdentityInput): Promise; admitManagedSession(inputArg: IAdmitControllerManagedSessionInput): Promise; requireManagedSession(inputArg: IRequireControllerManagedSessionInput): Promise; resolveManagedSession(inputArg: IRequireControllerManagedSessionInput): Promise; private resolveSessionLayoutAuthorityInScope; resolveSessionLayoutAuthority(inputArg: IResolveControllerSessionLayoutAuthorityInput): Promise; /** DB-only terminal proof for one exact managed attachment identity. */ resolveRetiredManagedSessionIdentity(inputArg: IResolveRetiredManagedSessionIdentityInput): Promise; private hasDispatchedFlexCleanupAuthority; /** DB-only callback authority lookup; it never calls a provider or controller runtime. */ resolveFlexHostSessionAuthority(inputArg: IResolveControllerFlexHostSessionAuthorityInput): Promise; beginManagedSessionDeletion(inputArg: IBeginControllerManagedSessionDeletionInput): Promise; markManagedSessionDeletionDispatched(inputArg: IMarkControllerManagedSessionDeletionDispatchedInput): Promise; cancelManagedSessionDeletion(inputArg: ICancelControllerManagedSessionDeletionInput): Promise; completeManagedSessionDeletion(inputArg: ICompleteControllerManagedSessionDeletionInput): Promise; listManagedSessionDeletionObligations(inputArg: IListControllerManagedSessionDeletionObligationsInput): Promise; listFlexManagedCleanupRoots(inputArg: IListControllerFlexManagedCleanupRootsInput): Promise; retireProjectManagedSessions(inputArg: IRetireControllerProjectManagedSessionsInput): Promise; beginManagedSessionCreation(inputArg: IBeginControllerManagedSessionCreationInput): Promise; markManagedSessionCreationDispatched(inputArg: IMarkControllerManagedSessionCreationDispatchedInput): Promise; completeManagedSessionCreationAdmission(inputArg: ICompleteControllerManagedSessionCreationAdmissionInput): Promise; retireManagedSessionCreation(inputArg: IRetireControllerManagedSessionCreationInput): Promise; listPendingSessionCreationObligations(inputArg: IListControllerSessionCreationObligationsInput): Promise; getSessionCreationObligation(inputArg: IGetControllerSessionCreationObligationInput): Promise; /** DB-only bootstrap authority; it does not infer or grant managed membership. */ resolvePendingFlexProjectManagementLoadAuthority(inputArg: IResolveControllerPendingFlexProjectManagementLoadAuthorityInput): Promise; /** * DB-only registration authority. Empty loads expose no persisted project-management state and * never grant managed membership; the controller retains the exact host admission while loading. */ resolveFlexProjectManagementRegistrationLoadAuthority(inputArg: IResolveControllerFlexProjectManagementRegistrationLoadAuthorityInput): Promise; private detachSessionInScope; detachSession(inputArg: IDetachControllerSessionIdentityInput): Promise; private reconcileFencedSnapshotInScope; /** * Reconciles only a complete provider snapshot captured while the caller's * provider mutation admission is sealed and drained. Live periodic snapshots * must not use this method because absence is authoritative only under that fence. */ reconcileFencedProviderSnapshot(inputArg: IReconcileControllerSessionSnapshotInput): Promise; private beginSessionDeletionInScope; beginSessionDeletion(inputArg: IBeginControllerSessionDeletionInput): Promise; private cancelSessionDeletionInScope; cancelSessionDeletion(inputArg: ICancelControllerSessionDeletionInput): Promise; private verifyTombstoneSideRecords; /** * Call only after the exact admitted provider delete is confirmed complete or * confirms that exact native session absent. Snapshot absence is only detach. */ private completeSessionDeletionInScope; completeSessionDeletion(inputArg: ICompleteControllerSessionDeletionInput): Promise; } import { type IControllerCodexOrigin } from './classes.codexconnectionmodels.js'; export {};