/** * The provider-neutral settlement step for one classified upstream outcome * on a leased connection (design docs/design/subscription-core-2026-10-07.md, * 5.3 "API-key connectors on the shared core"): the request ledger outcome, * then the plan of `planSubscriptionCoreRefusal` applied through the core's * fenced writers. It is the settlement every adapter's turn path is to use (a * connector contributes only its classification and its health durations); * today the conformance suite drives it, and the live worker still settles * through its own provider-named step until it adopts this one (decision 5). */ import type { Settings } from "@opengeni/config"; import { type ProviderErrorOutcome, type SubscriptionCoreRefusalPlan } from "@opengeni/subscriptions"; import type { Database } from "../database.js"; import { type SubscriptionCoreProvider } from "./provider.js"; import { type SubscriptionCoreLeaseRef, type SubscriptionCoreTurnIdentity } from "./turns.js"; export type SubscriptionCoreSettlement = /** Retry the same connection once with the refreshed (or concurrently renewed) credential. */ { kind: "retry_same_connection"; } /** * The refusal is recorded; placement fails over. `receipt` and `health` * report each fenced write (false: the turn or its lease was no longer * current, or the credential had already moved on). */ | { kind: "settled"; receipt: boolean; health: boolean; } /** Not a refusal of the connection: nothing recorded, no failover. */ | { kind: "no_failover"; } /** The refresh could not run (lease lost, not visible, failed): nothing recorded. */ | { kind: "refresh_failed"; reason: string; }; export declare const subscriptionCoreSettlement: (provider: SubscriptionCoreProvider) => { applySubscriptionCoreRefusal: (db: Database, identity: SubscriptionCoreTurnIdentity, lease: SubscriptionCoreLeaseRef, plan: Extract, input: { refreshGeneration: number; now: number; }) => Promise<{ receipt: boolean; health: boolean; }>; settleSubscriptionCoreOutcome: (db: Database, settings: Settings, identity: SubscriptionCoreTurnIdentity, lease: SubscriptionCoreLeaseRef, input: { /** The connector's classification, or null when it could not classify. */ outcome: ProviderErrorOutcome | null; /** The refresh generation the refused request's credential held. */ refreshGeneration: number; /** The decoded credential the request carried (its format decides renewal). */ credential: unknown; /** This outcome follows a refresh of the same connection for this request. */ refreshed: boolean; /** The reserved request this outcome settles. */ request: { operationId: string; attemptId: string; executionGeneration: number; }; now?: number; }) => Promise; };