/** * Thread-scoped semantic note archival — bulk expiry when a thread is * archived or a disposable worker is cleaned up. */ import type { Database } from "./schema.js"; /** * Why a note's valid_to was set. Every live writer that expires a note records * one, so restoreNotesForThread can tell a reversible archive-kill from a * deliberate retirement (the fix for dd47ea9's known limitation). The two * `*-legacy` values are written only by the migration-28 backfill over rows * that predate the column; live code never writes them. */ export type ExpiryReason = "thread-terminal" | "thread-archived" | "worker-cleanup" | "pruned" | "quality-gate" | "ttl" | "reflection-cap" | "superseded" | "merged" | "archived-legacy" | "unknown-legacy"; /** * Expire all active semantic notes belonging to a given thread, recording why. * Sets valid_to = NOW(). Returns the count of archived notes. */ export declare function archiveNotesForThread(db: Database, threadId: number, reason: Extract): number; /** * Restore notes previously expired by archiving a thread — the mirror of * archiveNotesForThread. Clears valid_to (and expiry_reason) for the thread's * restorable expired notes. * * Only notes whose expiry_reason marks an archive-kill are resurrected (see * RESTORABLE_EXPIRY_REASONS); a note that was pruned, gate-expired, cap-trimmed * or superseded stays dead. `unknown-legacy` (and NULL, which can only mean a * pre-column binary wrote the expiry) is included only when the caller asserts * the thread is being unarchived (`includeUnknownLegacy`) — for a thread that * was archived, the historical sweep is the overwhelmingly likely killer, so a * few wrongly-revived pruning singles are an accepted, disclosed cost. * * Returns the count of restored notes. */ export declare function restoreNotesForThread(db: Database, threadId: number, options?: { includeUnknownLegacy?: boolean; }): number; /** * Find thread IDs that have active (non-expired) semantic notes. * Returns distinct thread IDs (excluding null/global notes). */ export declare function getThreadIdsWithActiveNotes(db: Database): number[]; //# sourceMappingURL=note-archival.d.ts.map