import { MemoryStatus, MemoryCategory, MemoryProjectionCurrentState, MemoryLifecycleEvent } from './types.js';
import BetterSqlite3 from 'better-sqlite3';

type MemoryGovernanceMode = "shadow" | "apply";
type MemoryGovernanceReasonCode = "exact_duplicate" | "semantic_duplicate_candidate" | "disputed_memory" | "speculative_low_confidence" | "archive_candidate" | "explicit_capture_review" | "malformed_import";
interface MemoryGovernanceReviewQueueEntry {
    entryId: string;
    memoryId: string;
    path: string;
    reasonCode: MemoryGovernanceReasonCode;
    severity: "low" | "medium" | "high";
    suggestedAction: "set_status" | "archive";
    suggestedStatus?: Extract<MemoryStatus, "pending_review" | "quarantined" | "rejected">;
    relatedMemoryIds: string[];
}
interface MemoryGovernanceAppliedAction {
    action: "set_status" | "archive";
    memoryId: string;
    reasonCode: MemoryGovernanceReviewQueueEntry["reasonCode"];
    beforeStatus: MemoryStatus;
    afterStatus?: MemoryStatus;
    originalPath: string;
    currentPath: string;
}
interface MemoryGovernanceRestoreEntry {
    action: MemoryGovernanceAppliedAction["action"];
    memoryId: string;
    reasonCode: MemoryGovernanceReviewQueueEntry["reasonCode"];
    originalPath: string;
    currentPath: string;
    beforeRaw: string;
    expectedCurrentRaw?: string;
    applied: boolean;
}
interface MemoryGovernanceRestoreManifest {
    runId: string;
    createdAt: string;
    entries: MemoryGovernanceRestoreEntry[];
}
interface MemoryGovernanceSummary {
    schemaVersion: 1;
    runId: string;
    traceId: string;
    mode: MemoryGovernanceMode;
    createdAt: string;
    scannedMemories: number;
    reviewQueueCount: number;
    proposedActionCount: number;
    appliedActionCount: number;
    ruleVersion: string;
}
interface MemoryGovernanceMetrics {
    reviewReasons: Record<MemoryGovernanceReasonCode, number>;
    proposedStatuses: Record<string, number>;
    keptMemoryCount: number;
    qualityScore: MemoryGovernanceQualityScore;
}
interface MemoryGovernanceQualityScore {
    score: number;
    maxScore: 100;
    grade: "excellent" | "good" | "fair" | "poor";
    deductions: Array<{
        reasonCode: MemoryGovernanceReasonCode;
        count: number;
        pointsLost: number;
    }>;
}
interface MemoryGovernanceTransitionReport {
    proposed: Record<string, MemoryGovernanceAppliedAction[]>;
    applied: Record<string, MemoryGovernanceAppliedAction[]>;
}
interface MemoryGovernanceManifest {
    schemaVersion: 1;
    runId: string;
    traceId: string;
    mode: MemoryGovernanceMode;
    createdAt: string;
    ruleVersion: string;
    artifacts: Record<string, string>;
}
interface MemoryGovernanceRunResult {
    runId: string;
    traceId: string;
    mode: MemoryGovernanceMode;
    summary: MemoryGovernanceSummary;
    summaryPath: string;
    reviewQueuePath: string;
    qualityScorePath: string;
    transitionReportPath: string;
    reportPath: string;
    keptMemoriesPath: string;
    appliedActionsPath: string;
    metricsPath: string;
    manifestPath: string;
    restorePath?: string;
    reviewQueue: MemoryGovernanceReviewQueueEntry[];
    proposedActions: MemoryGovernanceAppliedAction[];
    appliedActions: MemoryGovernanceAppliedAction[];
}
interface RestoreMemoryGovernanceRunResult {
    runId: string;
    restoredActions: number;
    restorePath: string;
}
declare function readMemoryGovernanceRunArtifact(memoryDir: string, runId: string): Promise<{
    summary: MemoryGovernanceSummary;
    metrics: MemoryGovernanceMetrics;
    qualityScore: MemoryGovernanceQualityScore;
    keptMemoryIds: string[];
    reviewQueue: MemoryGovernanceReviewQueueEntry[];
    appliedActions: MemoryGovernanceAppliedAction[];
    transitionReport: MemoryGovernanceTransitionReport;
    report: string;
    manifest: MemoryGovernanceManifest;
    restore?: MemoryGovernanceRestoreManifest;
}>;

type BetterSqlite3Database = BetterSqlite3.Database;

declare const MEMORY_PROJECTION_SCHEMA_VERSION = 2;
interface ProjectedMemoryBrowseOptions {
    query?: string;
    status?: string;
    category?: string;
    sort?: "updated_desc" | "updated_asc" | "created_desc" | "created_asc";
    limit: number;
    offset: number;
}
interface ProjectedMemoryBrowseRow {
    id: string;
    path: string;
    category: MemoryCategory;
    status: MemoryStatus;
    created?: string;
    updated?: string;
    tags: string[];
    entityRef?: string;
    preview: string;
}
interface ProjectedMemoryBrowsePage {
    total: number;
    memories: ProjectedMemoryBrowseRow[];
}
interface ProjectedEntityMentionRow {
    memoryId: string;
    entityRef: string;
    mentionSource: string;
    created: string;
    updated: string;
}
interface ProjectedNativeKnowledgeChunkRow {
    chunkId: string;
    sourcePath: string;
    title: string;
    sourceKind: string;
    startLine: number;
    endLine: number;
    derivedDate?: string;
    sessionKey?: string;
    workflowKey?: string;
    author?: string;
    agent?: string;
    namespace?: string;
    privacyClass?: string;
    sourceHash?: string;
    preview: string;
}
interface MemoryProjectionGovernanceReviewQueueRow {
    runId: string;
    entryId: string;
    memoryId: string;
    path: string;
    reasonCode: MemoryGovernanceReviewQueueEntry["reasonCode"];
    severity: MemoryGovernanceReviewQueueEntry["severity"];
    suggestedAction: MemoryGovernanceReviewQueueEntry["suggestedAction"];
    suggestedStatus?: MemoryGovernanceReviewQueueEntry["suggestedStatus"];
    relatedMemoryIds: string[];
}
interface MemoryProjectionGovernanceAppliedActionRow {
    runId: string;
    rowKey: string;
    action: MemoryGovernanceAppliedAction["action"];
    memoryId: string;
    reasonCode: MemoryGovernanceAppliedAction["reasonCode"];
    beforeStatus: MemoryGovernanceAppliedAction["beforeStatus"];
    afterStatus?: MemoryGovernanceAppliedAction["afterStatus"];
    originalPath: string;
    currentPath: string;
}
interface ProjectedReviewQueueSnapshot {
    found: boolean;
    runId?: string;
    summary?: MemoryGovernanceSummary;
    metrics?: MemoryGovernanceMetrics;
    reviewQueue?: MemoryGovernanceReviewQueueEntry[];
    appliedActions?: MemoryGovernanceAppliedAction[];
    report?: string;
}
declare function getMemoryProjectionPath(memoryDir: string): string;
declare function memoryCurrentSelectExpressions(db: BetterSqlite3Database): {
    tagsJson: string;
    previewText: string;
};
declare function initializeMemoryProjectionDb(db: BetterSqlite3Database): void;
declare function parseCurrentRow(memoryDir: string, row: Record<string, unknown> | undefined): MemoryProjectionCurrentState | null;
declare function parseTimelineRows(rows: Array<Record<string, unknown>>): MemoryLifecycleEvent[];
declare function readProjectedMemoryState(memoryDir: string, memoryId: string): MemoryProjectionCurrentState | null;
declare function readProjectedMemoryTimeline(memoryDir: string, memoryId: string, limit: number): MemoryLifecycleEvent[] | null;
declare function readProjectedMemoryBrowse(memoryDir: string, options: ProjectedMemoryBrowseOptions): ProjectedMemoryBrowsePage | null;
declare function readProjectedEntityMentions(memoryDir: string, memoryIds?: Set<string>): ProjectedEntityMentionRow[] | null;
declare function readProjectedNativeKnowledgeChunks(memoryDir: string): ProjectedNativeKnowledgeChunkRow[] | null;
declare function readProjectedLatestReviewQueue(memoryDir: string): ProjectedReviewQueueSnapshot | null;
declare function readProjectedGovernanceRecord(memoryDir: string): {
    runId: string;
    summary: unknown;
    metrics: unknown;
    reviewQueueRows: MemoryProjectionGovernanceReviewQueueRow[];
    appliedActionRows: MemoryProjectionGovernanceAppliedActionRow[];
    report: string;
} | null;

export { readProjectedMemoryState as A, readProjectedMemoryTimeline as B, readProjectedNativeKnowledgeChunks as C, type MemoryGovernanceRunResult as M, type ProjectedMemoryBrowseOptions as P, type RestoreMemoryGovernanceRunResult as R, type ProjectedMemoryBrowsePage as a, readProjectedGovernanceRecord as b, type MemoryGovernanceSummary as c, type MemoryGovernanceMetrics as d, type MemoryGovernanceQualityScore as e, type MemoryGovernanceReviewQueueEntry as f, type MemoryGovernanceAppliedAction as g, type MemoryGovernanceTransitionReport as h, type MemoryGovernanceManifest as i, type MemoryGovernanceRestoreManifest as j, MEMORY_PROJECTION_SCHEMA_VERSION as k, type MemoryProjectionGovernanceAppliedActionRow as l, type MemoryProjectionGovernanceReviewQueueRow as m, type ProjectedEntityMentionRow as n, type ProjectedMemoryBrowseRow as o, type ProjectedNativeKnowledgeChunkRow as p, type ProjectedReviewQueueSnapshot as q, readMemoryGovernanceRunArtifact as r, getMemoryProjectionPath as s, initializeMemoryProjectionDb as t, memoryCurrentSelectExpressions as u, parseCurrentRow as v, parseTimelineRows as w, readProjectedEntityMentions as x, readProjectedLatestReviewQueue as y, readProjectedMemoryBrowse as z };
