/**
 * Database initialization and connection management
 */
import type Database from 'better-sqlite3';
type RuntimeKind = 'installed' | 'npx-cache' | 'project-checkout' | 'unknown';
interface RuntimeInfo {
    kind: RuntimeKind;
    entryPath: string;
}
interface DatabaseInspection {
    integrity: string;
    count: number | null;
}
interface BackupCandidate {
    path: string;
    count: number;
    mtimeMs: number;
}
declare function resolveRuntimeInfo(): RuntimeInfo;
declare function enforceSafeRuntimePath(expandedPath: string, explicitDbPath: boolean): void;
declare function inspectDatabaseFile(dbPath: string): DatabaseInspection;
declare function listHealthyBackups(dbPath: string): BackupCandidate[];
declare function acquireStartupLock(dbPath: string): void;
declare function isLikelyFtsIntegrityIssue(integrityResult: string): boolean;
declare function attemptFtsRecovery(database: Database.Database): boolean;
declare function verifyOnDiskIntegrity(dbPath: string): string;
export declare const __databaseTestUtils: {
    isLikelyFtsIntegrityIssue: typeof isLikelyFtsIntegrityIssue;
    attemptFtsRecovery: typeof attemptFtsRecovery;
    verifyOnDiskIntegrity: typeof verifyOnDiskIntegrity;
    inspectDatabaseFile: typeof inspectDatabaseFile;
    listHealthyBackups: typeof listHealthyBackups;
    resolveRuntimeInfo: typeof resolveRuntimeInfo;
    enforceSafeRuntimePath: typeof enforceSafeRuntimePath;
    acquireStartupLock: typeof acquireStartupLock;
};
/**
 * Initialize the database connection
 */
export declare function initDatabase(dbPath?: string): Database.Database;
/**
 * Get the current database instance
 */
export declare function getDatabase(): Database.Database;
/**
 * Check whether the database has been initialized.
 * Useful for library consumers (e.g. OpenClaw extensions) that import
 * the defence pipeline without running the full MCP server.
 */
export declare function isDatabaseInitialized(): boolean;
/**
 * Close the database connection with proper cleanup
 */
export declare function closeDatabase(): void;
/**
 * Repair or verify database health.
 * Intended for `shieldcortex doctor` CLI command.
 */
export declare function repairDatabase(): {
    status: 'ok' | 'repaired' | 'recreated';
    message: string;
};
/**
 * Manually checkpoint the WAL file (call periodically for long-running processes)
 */
export declare function checkpointWal(): {
    walPages: number;
    checkpointed: number;
};
/**
 * Check database file size for bloat prevention
 */
export interface DatabaseSizeInfo {
    size: number;
    sizeFormatted: string;
    warning: boolean;
    blocked: boolean;
    message: string;
}
export declare function checkDatabaseSize(): DatabaseSizeInfo;
/**
 * Check if database operations should be blocked due to size
 */
export declare function isDatabaseBlocked(): boolean;
/**
 * Execute a function within a transaction (auto-commits on success, rollback on error)
 * Use this for batch operations that need atomicity
 */
export declare function withTransaction<T>(fn: () => T): T;
/**
 * Execute a function within an IMMEDIATE transaction (acquires write lock immediately)
 * Use this for critical operations that must not conflict with concurrent writes
 */
export declare function withImmediateTransaction<T>(fn: () => T): T;
export {};
