/** * FEAT-507 — oversize-atom repair scanner. * * Finds memories that are BOTH oversize (see oversize.ts) and still flagged * `needs_vec_index` (issue #209's durable "not vector-indexed yet" marker — * cleared only on a successful embed/upsert), and enqueues a `reembed` job * for each one that doesn't already have a pending/running `reembed` job in * flight. reembedHandler's truncate-before-embed fix (see handlers/ * reembed.ts) is what actually repairs these once the job runs. * * This is a dedicated, shorter-cadence sweep on top of the existing generic * 24h `cleanup` job vec-index sweep (src/pipeline/handlers/cleanup.ts) — * that sweep would eventually re-enqueue every still-flagged row too, but * production was observed accumulating oversize poisons at ~16/hr; waiting * up to a day to repair them is too slow. This scanner also gives oversize * repairs their own observable counters, separate from the generic sweep. * * Dedup guard (FEAT-507 requirement): `listActiveReembedMemoryIds` skips a * memory that already has a job in any non-terminal state (`pending`, * `running`, `failed` awaiting retry, or `paused`), so re-running this scan * mid-drain (or on the next timer tick before a prior pass's jobs have * finished, or within a `failed` job's backoff window before it self-promotes * back to `pending` — see worker.ts) never double-enqueues the same atom. A * memory that successfully repairs also drops out of the candidate set on * the next scan (`needs_vec_index` is cleared on success — see reembedHandler). */ import type { DB } from '../storage/db.js'; /** * Cap on how many oversize memories one scan pass enqueues — mirrors * cleanup.ts's VEC_INDEX_SWEEP_LIMIT (500) so a large backlog drains * gradually across scan ticks instead of flooding the job queue in one pass. */ export declare const OVERSIZE_SCAN_LIMIT = 500; export interface OversizeScanResult { /** Oversize + needs_vec_index candidates found this pass (before the * already-queued filter below), capped at `limit`. */ candidates: number; /** New `reembed` jobs enqueued this pass. */ enqueued: number; /** Candidates skipped because a pending/running `reembed` job already * exists for that memory — the idempotency guarantee in action. */ alreadyQueued: number; } export declare function scanAndEnqueueOversizeRepairs(db: DB, limit?: number): OversizeScanResult;