import { type PlacementInput, type PlacementSwitch } from "@opengeni/subscriptions"; import { type Database } from "../database.js"; import { type SubscriptionCoreProvider } from "./provider.js"; import { type SubscriptionCorePlacement, type SubscriptionCorePlacementEvaluation, type SubscriptionCorePlacementRequest, type SubscriptionCoreTurnIdentity } from "./turns.js"; import { type SubscriptionCoreFailoverWorld, type SubscriptionCoreFailoverWorldRequest } from "./failover-world.js"; export type SubscriptionCoreFailoverRequest = SubscriptionCorePlacementRequest & SubscriptionCoreFailoverWorldRequest; type Selection = { provider: string; modelId: string; reasoningLevel: string; }; /** Dormant B1 boundary only. C2 must surface this configuration diagnostic * instead of claiming all-provider capacity exhaustion; home retry deadlines * remain valid. Do not synthesize a target, tier or new accepted authority. */ type WithMappingReason = T extends { kind: "wait"; reason: string; } ? Omit & { reason: T["reason"] | "failover_no_model_mapping"; } : T; export type SubscriptionCoreFailoverPlacement = WithMappingReason & Partial & { candidateProviders?: string[]; }; export type SubscriptionCoreFailoverEvaluation = WithMappingReason & Partial & { candidateProviders?: string[]; }; /** Parity copy from turns.ts, kept local until the M4 stacks can share it. */ export declare function readAttemptFence(tx: Database, request: SubscriptionCorePlacementRequest): Promise; /** D-33 router: when disabled or pinned, delegate unchanged. Otherwise keep a * serving fallback out of the home-only path and retry the WHOLE world after * a home capacity wait. No first caller/worker wiring is installed by B1. */ export declare function placeSubscriptionCoreTurnWithFailover(db: Database, home: SubscriptionCoreProvider, request: SubscriptionCoreFailoverRequest): Promise; /** Read-only evaluation never acquires a binding lock or a lease. */ export declare function evaluateSubscriptionCorePlacementWithFailover(db: Database, home: SubscriptionCoreProvider, request: SubscriptionCoreFailoverWorldRequest): Promise; /** D-39 sums ledger evidence directly, including providers held or removed. */ export declare function countSubscriptionCoreTurnRefusalsAcrossProviders(db: Database, identity: SubscriptionCoreTurnIdentity): Promise; /** Scoped to eligible candidate providers, never legacy/held capacity. Personal * quarantine visibility remains subject to app-role RLS, as in M4. */ export declare function earliestHealthRetryAtAcrossProviders(tx: Database, identity: SubscriptionCoreTurnIdentity, world: Pick): Promise; /** Parity copy of M4 commitBinding: target row ONLY, immutable provider/pin, * compare-and-swap first insert, per-provider clock. All candidate rows were * locked before the lease's single connection lock. */ export declare function commitBinding(tx: Database, identity: SubscriptionCoreTurnIdentity, providerId: string, next: { decidedFrom: PlacementInput["session"]["binding"]; clockDecided: boolean; connectionId: string; modelId: string; placementSwitch: PlacementSwitch; now: Date; restartClock: boolean; }): Promise; export {};