import { ConfigManager } from '../../config/manager.js';
import type { ConfigKey } from '../../config/index.js';
export type SyncSurface = 'profiles' | 'managed' | 'settings-sync';
export type SyncDirection = 'export' | 'import' | 'apply' | 'pull' | 'push' | 'rollback';
export type SettingsSource = 'default' | 'local' | 'synced' | 'managed';
export interface SettingsSyncEvent {
    readonly surface: SyncSurface;
    readonly direction: SyncDirection;
    readonly path: string;
    readonly timestamp: number;
    readonly detail: string;
}
export interface ManagedSettingLock {
    readonly key: ConfigKey;
    readonly source: string;
    readonly reason: string;
    readonly updatedAt: number;
}
export interface SettingsLayerRecord {
    readonly key: ConfigKey;
    readonly value: unknown;
    readonly source: Exclude<SettingsSource, 'default' | 'local'>;
    readonly sourceLabel: string;
    readonly detail: string;
    readonly path?: string;
    readonly updatedAt: number;
    readonly locked?: boolean;
}
export interface SettingsConflictRecord {
    readonly key: ConfigKey;
    readonly localValue: unknown;
    readonly incomingValue: unknown;
    readonly source: Exclude<SettingsSource, 'default' | 'local'>;
    readonly path: string;
    readonly updatedAt: number;
}
export type SettingsConflictResolution = 'local' | 'synced';
export interface ManagedBundleChange {
    readonly key: ConfigKey;
    readonly previousValue: unknown;
    readonly nextValue: unknown;
    readonly changed: boolean;
    readonly locked: boolean;
    readonly source: string;
    readonly reason: string;
}
export interface StagedManagedBundle {
    readonly id: string;
    readonly profileName: string;
    readonly path: string;
    readonly importedAt: number;
    readonly changeCount: number;
    readonly risk: 'low' | 'medium' | 'high';
    readonly changes: readonly ManagedBundleChange[];
}
export interface ManagedRollbackRecord {
    readonly token: string;
    readonly profileName: string;
    readonly path: string;
    readonly appliedAt: number;
    readonly restoredKeys: readonly ConfigKey[];
    readonly previousValues: Readonly<Partial<Record<ConfigKey, unknown>>>;
}
export interface SettingsControlPlaneStore {
    readonly version: 2;
    readonly events: ReadonlyArray<SettingsSyncEvent>;
    readonly managedLocks: ReadonlyArray<ManagedSettingLock>;
    readonly failures: ReadonlyArray<{
        readonly surface: SyncSurface;
        readonly message: string;
        readonly timestamp: number;
    }>;
    readonly syncedSettings: ReadonlyArray<SettingsLayerRecord>;
    readonly managedSettings: ReadonlyArray<SettingsLayerRecord>;
    readonly conflicts: ReadonlyArray<SettingsConflictRecord>;
    readonly stagedManagedBundle?: StagedManagedBundle;
    readonly rollbackHistory: ReadonlyArray<ManagedRollbackRecord>;
}
export interface ResolvedSettingEntry {
    readonly key: ConfigKey;
    readonly category: string;
    readonly effectiveValue: unknown;
    readonly effectiveSource: SettingsSource;
    readonly defaultValue: unknown;
    readonly localValue: unknown;
    readonly syncedValue?: unknown;
    readonly managedValue?: unknown;
    readonly overriddenSources: readonly SettingsSource[];
    readonly locked: boolean;
    readonly lockReason?: string;
    readonly sourceLabel?: string;
    readonly updatedAt?: number;
    readonly conflict: boolean;
}
export interface SettingsControlPlaneSnapshot {
    readonly liveKeyCount: number;
    readonly profileCount: number;
    readonly managedLockCount: number;
    readonly resolvedCounts: Readonly<Record<SettingsSource, number>>;
    readonly lastSync?: SettingsSyncEvent;
    readonly recentEvents: ReadonlyArray<SettingsSyncEvent>;
    readonly recentFailures: SettingsControlPlaneStore['failures'];
    readonly managedLocks: ReadonlyArray<ManagedSettingLock>;
    readonly conflicts: ReadonlyArray<SettingsConflictRecord>;
    readonly stagedManagedBundle?: StagedManagedBundle;
    readonly rollbackHistory: ReadonlyArray<ManagedRollbackRecord>;
    readonly resolvedEntries: ReadonlyArray<ResolvedSettingEntry>;
}
export interface ResolvedSettingLookup {
    readonly entry: ResolvedSettingEntry;
    readonly lock?: ManagedSettingLock;
    readonly syncedLayer?: SettingsLayerRecord;
    readonly managedLayer?: SettingsLayerRecord;
}
export interface SettingsSyncBundle {
    readonly version: 1;
    readonly exportedAt: number;
    readonly source: 'settings-sync';
    readonly settings: Record<string, unknown>;
}
export declare function getConfigControlPlaneDir(configManager: ConfigManager): string;
export declare function defaultStore(): SettingsControlPlaneStore;
export declare function readStore(configDir: string): SettingsControlPlaneStore;
export declare function writeStore(store: SettingsControlPlaneStore, configDir: string): void;
export declare function trimStore(store: SettingsControlPlaneStore): SettingsControlPlaneStore;
export declare function configSnapshot(configManager: ConfigManager): Record<ConfigKey, unknown>;
export declare function sourcePriority(source: SettingsSource): number;
export declare function inferRisk(changes: readonly ManagedBundleChange[]): 'low' | 'medium' | 'high';
export declare function makeRollbackToken(): string;
export declare function toLayerRecord(key: ConfigKey, value: unknown, source: Exclude<SettingsSource, 'default' | 'local'>, sourceLabel: string, detail: string, path?: string, locked?: boolean): SettingsLayerRecord;
//# sourceMappingURL=control-plane-store.d.ts.map