import type { Database as DatabaseType } from "better-sqlite3"; /** ICI-1357: the Todos the operator keeps on Home. * * Home used to be `created_by = 'operator'`, so a Todo an agent raised was * reachable only from its department board. Keeping is the operator's gesture * for "follow this one" — PLA-172 removed the auto-keep on create, because * `created_by = 'operator'` is every caller holding the gateway credential * rather than the operator's own hand, and Home filled up with work they never * asked to follow. Since PLA-230 a pin is no longer the only thing on Home: * the operator's own Todos join it as a term in `HOME_SCOPE_SQL`, read at * query time, so nothing writes to the kept set on their behalf. * * Additive, never a column on `work_items`: the exact-shape verifier refuses * any drift in an existing table, so a new table is the only extension a * deployed database can survive. * * Keyed by Todo alone, documented as the operator's. This gateway has one * operator; a second one needs an actor column, which is a forward migration * rather than a rewrite. * * Every function takes the caller's `db` so it composes inside the caller's * transaction — and so this module never imports the database opener, which * would close a cycle back through `migrate.ts`. */ export declare const WORK_ITEM_KEPT_DDL = "\nCREATE TABLE IF NOT EXISTS work_item_kept (\n work_item_id TEXT PRIMARY KEY REFERENCES work_items(id) ON DELETE CASCADE,\n kept_at TEXT NOT NULL\n)"; /** Kept, as a correlated EXISTS that the list query AND-composes like any other * filter. It lives here so the table's one reader in SQL sits with the table. */ export declare const KEPT_EXISTS_SQL = "EXISTS (SELECT 1 FROM work_item_kept k WHERE k.work_item_id = work_items.id)"; /** The Home board's whole scope (PLA-230): what the operator pinned, plus what * they created. Parenthesised as one term so the OR survives AND-composition * with every other filter the board sends. */ export declare const HOME_SCOPE_SQL = "(EXISTS (SELECT 1 FROM work_item_kept k WHERE k.work_item_id = work_items.id) OR work_items.created_by = 'operator')"; /** Keep a Todo; true when it was not already kept. Idempotent, and keeping a * kept Todo leaves the original `kept_at` alone, so Home does not reshuffle * when something re-keeps what is already there. */ export declare function keepWorkItem(db: DatabaseType, workItemId: string, at: string): boolean; /** Set the Todo's kept state. Returns whether this changed anything, so a * caller can audit a real change and stay silent about a repeat. */ export declare function setWorkItemKept(db: DatabaseType, workItemId: string, kept: boolean): boolean; export declare function isWorkItemKept(db: DatabaseType, workItemId: string): boolean; /** Batch form for list payloads: ONE query for the whole page, never per item. */ export declare function keptSet(db: DatabaseType, workItemIds: string[]): Set; /** One-shot: empty the kept set that auto-keep and its `created_by` backfill * filled, so Home starts as nothing and holds what the operator pins. * * Marked in `meta` rather than inferred from the table being new: the point of * the flag is that a pin made after the cleanup survives the next boot. Every * row this deletes was written by machinery PLA-172 removed — the pin shipped * hours earlier and was invisible, so there is no hand-curated set to lose. */ export declare function clearAutoKeptOnce(db: DatabaseType): void; //# sourceMappingURL=kept.d.ts.map