/** * @module memory/brain-noise-detector * * T1147 Wave 7: BRAIN noise detector for the 2440-entry sweep. * * Scans all four brain content tables (`brain_observations`, `brain_learnings`, * `brain_decisions`, `brain_patterns`) for entries that match noise criteria: * - `quality_score < 0.3` (below QUALITY_SCORE_THRESHOLD) * - `verified = 0` (not owner-verified) * - `invalid_at IS NULL` (not already superseded) * * Produces `brain_observations_staging` rows anchored to a `brain_backfill_runs` * row of kind `noise-sweep-2440`. The 100-entry stratified sample is written to * `.cleo/agent-outputs/T1147-sweep-validation-.json` for autonomous validation. * * @task T1147 * @epic T1075 */ /** Per-table count of detected noise candidates. */ export interface NoiseCandidateCounts { observations: number; learnings: number; decisions: number; patterns: number; total: number; } /** Result of the full `detectNoiseCandidates` pass. */ export interface DetectNoiseCandidatesResult { /** Run ID created in `brain_backfill_runs`. */ runId: string; /** Per-table candidate counts. */ counts: NoiseCandidateCounts; /** Absolute path to the 100-entry stratified sample JSON file. */ sampleFilePath: string; /** Whether this was a dry-run (no rows inserted into brain_observations_staging). */ dryRun: boolean; } /** Shape of one entry in the stratified sample JSON. */ export interface SampleEntry { sourceTable: string; sourceId: string; qualityScore: number | null; sourceConfidence: string | null; content: string | null; } /** * Detects noise candidates across all four brain content tables and writes * staging rows to `brain_observations_staging`. * * The function: * 1. Opens `brain.db` for the given `projectRoot`. * 2. Queries each brain table for rows matching noise criteria. * 3. Inserts one `brain_backfill_runs` row (`kind='noise-sweep-2440'`, `status='staged'`). * 4. Inserts `brain_observations_staging` rows for each noise candidate. * 5. Extracts a 100-entry proportional stratified sample and writes it to * `.cleo/agent-outputs/T1147-sweep-validation-.json`. * * In `dryRun` mode, steps 3–4 are skipped (no DB writes). The sample file * is still written for preview. * * @param projectRoot - Absolute path to the project root. * @param options - Optional configuration. * @returns Result containing the run ID, candidate counts, and sample file path. * * @example * ```typescript * const result = await detectNoiseCandidates('/mnt/projects/cleocode', { dryRun: true }); * console.log(`Found ${result.counts.total} noise candidates`); * ``` */ export declare function detectNoiseCandidates(projectRoot: string, options?: { dryRun?: boolean; }): Promise; /** * Returns a 100-entry stratified sample from `brain_observations_staging` for a given * sweep run. Useful for re-sampling without re-running the full detector. * * @param projectRoot - Absolute path to the project root. * @param runId - The sweep run ID to sample from. */ export declare function sampleNoiseCandidates(projectRoot: string, runId: string): Promise; //# sourceMappingURL=brain-noise-detector.d.ts.map