/** * Deriver Queue — Consumer / Batch Worker * * Implements the `runDeriverBatch()` function — the main entry point for * processing pending deriver queue items. Called from the sentient tick * (analogous to `checkAndDream`) and from `runBrainMaintenance`. * * Flow per batch: * 1. Run stale-claim recovery (re-queue stuck in_progress items) * 2. Claim next pending item * 3. Derive output via deriveItem() * 4. Mark item done (success) or fail (with retry logic) * 5. Repeat up to batchSize items * * Each item is processed atomically — a crash mid-derivation triggers * stale-claim recovery on the next batch run. * * @task T1145 * @epic T1145 */ import type { DatabaseSync } from 'node:sqlite'; /** Default number of items to process per batch. */ export declare const DEFAULT_BATCH_SIZE = 5; /** Options for {@link runDeriverBatch}. */ export interface DeriverBatchOptions { /** * Maximum number of items to process in this batch. * Default: {@link DEFAULT_BATCH_SIZE}. */ batchSize?: number; /** * Worker identifier prefix for claim ownership. * Default: `worker--`. */ workerId?: string; /** Inject a DatabaseSync for testing. */ db?: DatabaseSync | null; } /** Result of a full batch run. */ export interface DeriverBatchResult { /** Number of items successfully processed (derived + marked done). */ processed: number; /** Number of items that failed (moved to failed or re-queued with retry). */ failed: number; /** Number of stale items re-queued before the batch started. */ staleRequeued: number; /** Total items attempted (claimed). */ attempted: number; } /** * Process a batch of pending deriver queue items. * * Designed to be called from the sentient tick (every 5 min) and from * `runBrainMaintenance`. Safe to call even if queue is empty — returns * immediately with all-zero counts. * * @param projectRoot - Absolute path to project root (contains `.cleo/`). * @param options - Batch size, workerId, db injection for tests. * @returns Summary counts for monitoring. * * @task T1145 */ export declare function runDeriverBatch(projectRoot: string, options?: DeriverBatchOptions): Promise; //# sourceMappingURL=consumer.d.ts.map