/** * BRAIN Ingester — Tier-2 proposal candidate source. * * Queries brain.db for recurring-pain observations (citation_count >= 3, * last 7 days, quality_score >= 0.5) and returns ranked ProposalCandidate[]. * * Design principles: * - NO LLM calls. All data comes from structured SQL queries. * - Title is template-generated: `[T2-BRAIN] Recurring issue: {title}`. * This is the prompt-injection defence from T1008 §3.6. * - Failures are swallowed: returns empty array + pushes a non-fatal warning * (`W_SENTIENT_INGESTER_DEGRADED`) into the active LAFS envelope (T9773). * Brain.db absence must never crash the propose tick. * * @task T1008 * @see ADR-054 — Sentient Loop Tier-2 */ import type { DatabaseSync } from 'node:sqlite'; import type { ProposalCandidate } from '@cleocode/contracts'; /** Maximum candidates returned from a single brain ingester pass. */ export declare const BRAIN_INGESTER_LIMIT = 10; /** Minimum citation count for a brain entry to be considered. */ export declare const BRAIN_MIN_CITATION_COUNT = 3; /** Minimum quality score for a brain entry to be considered. */ export declare const BRAIN_MIN_QUALITY_SCORE = 0.5; /** Lookback window in days for brain observations. */ export declare const BRAIN_LOOKBACK_DAYS = 7; /** * Compute candidate weight from citation_count and quality_score. * Formula: `(citation_count / 10) * quality_score` capped at 1.0. */ export declare function computeBrainWeight(citationCount: number, qualityScore: number): number; /** * Run the BRAIN ingester against the provided DatabaseSync handle. * * Returns at most {@link BRAIN_INGESTER_LIMIT} candidates, sorted by weight * descending. Returns an empty array if the database has no matching entries * or if any error occurs (errors are swallowed to never crash the tick). * * @param nativeDb - Open DatabaseSync handle to brain.db. May be null if * brain.db has not been initialised; this is treated as zero candidates. * @returns Ranked ProposalCandidate array (may be empty). */ export declare function runBrainIngester(nativeDb: DatabaseSync | null): ProposalCandidate[]; //# sourceMappingURL=brain-ingester.d.ts.map