import { type Database } from "./database.js"; export type ConnectionAuthorityClassificationReport = { schemaVersion: 1; organizationId: string; runKey: string | null; rewroteConnectionRows: false; receiptId?: string; connections: { total: number; workspaceOwned: number; userOwned: number; deterministicRepairPending: number; unresolved: number; }; }; export type ConnectionAuthorityBackfillReport = { schemaVersion: 1; organizationId: string; dryRun: boolean; limit: number; candidates: number; upgraded: number; moreLikely: boolean; }; export type ConnectionAuthorityConvergenceClassification = "connection_backfill_ready" | "membership_backfill_eligible" | "membership_lifecycle_review_required" | "external_subject_requires_classification" | "missing_login_identity" | "organization_identity_mismatch" | "missing_owner_workspace_membership" | "conflicting_authority_rows" | "legacy_shape_unrecognized"; export type ConnectionAuthorityConvergenceAction = "run_connection_backfill" | "run_membership_backfill_then_connection_backfill" | "review_membership_lifecycle_do_not_reactivate_automatically" | "classify_external_subject_then_migrate_via_authorized_connection_lifecycle" | "restore_login_identity_then_recheck" | "correct_organization_identity_through_supported_account_lifecycle_then_recheck" | "establish_owner_workspace_membership_through_supported_membership_lifecycle_then_recheck" | "repair_conflicting_connection_authority_rows_under_incident_procedure" | "repair_unrecognized_connection_authority_shape_under_incident_procedure"; export type ConnectionAuthorityConvergenceEvidence = { schemaVersion: 1; organizationId: string; limit: number; afterConnectionId: string | null; items: Array<{ connectionId: string; subjectId: string | null; classification: ConnectionAuthorityConvergenceClassification; action: ConnectionAuthorityConvergenceAction; }>; returned: number; hasMore: boolean; nextCursor: string | null; /** Full-organization totals. They are deliberately independent of the page cursor. */ remaining: { total: number; autoRemediable: number; manualReview: number; byClassification: { connectionBackfillReady: number; membershipBackfillEligible: number; membershipLifecycleReviewRequired: number; externalSubjectRequiresClassification: number; missingLoginIdentity: number; organizationIdentityMismatch: number; missingOwnerWorkspaceMembership: number; conflictingAuthorityRows: number; legacyShapeUnrecognized: number; }; }; }; /** * Read one bounded evidence page while also returning cursor-independent * full-organization residual totals. The database routine holds a read-only, * invocation-exact FORCE-RLS capability and never writes connection authority. */ export declare function inspectOrganizationConnectionAuthorityConvergence(db: Database, input: { organizationId: string; limit?: number; afterConnectionId?: string | null; }): Promise; /** * Full-population connection authority classification. Supplying a fresh run * key writes one immutable migration-0300 receipt and exact unresolved rows. */ export declare function classifyOrganizationConnectionAuthority(db: Database, input: { organizationId: string; runKey?: string | null; }): Promise; /** * One bounded, resumable legacy_user -> user upgrade batch. Dry-run is the * default; candidates are claimed with SKIP LOCKED when applying. */ export declare function backfillOrganizationConnectionAuthority(db: Database, input: { organizationId: string; limit?: number; dryRun?: boolean; }): Promise;