/** * Deriver — Main Derivation Logic * * Processes a single claimed deriver queue item and writes derived outputs * to the appropriate BRAIN tables. Each item type has a dedicated derivation * function. * * Derived observations always carry: * - level='inductive' * - provenanceClass='deriver-synthesized' (M6 gate, T1260 E3) * - source_ids=[sourceItemId] (lineage tracking) * - sourceType='deriver' * * LLM calls: routed through `resolveLLMForRole('derivation')` (T9255) so * the provider + model + credential come from * `config.llm.roles.derivation` → `config.llm.default` → `config.llm.daemon` * → implicit fallback. If no credential is reachable, derivation falls back * to a deterministic title-concatenation summary. No LLM = silent degrade * (no throw). * * @task T1145 * @epic T1145 */ import type { DatabaseSync } from 'node:sqlite'; import type { ClaimedItem } from './queue-manager.js'; /** Result of a single derivation pass. */ export interface DerivationResult { /** Item ID from the deriver_queue. */ queueItemId: string; /** Whether the derivation produced new output. */ produced: boolean; /** ID of the synthesized brain_observations row (if produced). */ outputObservationId?: string; /** Human-readable reason if no output was produced. */ skipReason?: string; } /** Options for {@link deriveItem}. */ export interface DeriveOptions { /** Inject a DatabaseSync for testing without touching the real brain.db. */ db?: DatabaseSync | null; /** * Absolute path to the project root. Forwarded to * `resolveLLMForRole('derivation')` so the derivation LLM picks up * project-config (`llm.roles.derivation`) and project-scoped credential * tiers. Defaults to `process.cwd()` when omitted. * * @task T9255 */ projectRoot?: string; } /** * Process a single claimed deriver queue item. * * Dispatches to the appropriate derivation handler based on `item.itemType`. * Never throws — all errors are caught and returned as `produced: false`. * * @param item - The claimed queue item. * @param options - Optional db injection for tests. * @returns DerivationResult with the output observation ID if successful. * * @task T1145 */ export declare function deriveItem(item: ClaimedItem, options?: DeriveOptions): Promise; //# sourceMappingURL=deriver.d.ts.map