/** * Decision Memory module for CLEO BRAIN. * Uses brain.db via BrainDataAccessor for persistent storage. * * Provides functions to store, recall, search, and update decisions * with sequential ID generation (D001, D002, ...). * * @task T5155 * @epic T5149 */ import type { BrainDecisionRow } from '../store/schema/memory-schema.js'; /** Parameters for storing a new decision. */ export interface StoreDecisionParams { type: BrainDecisionRow['type']; decision: string; rationale: string; confidence: BrainDecisionRow['confidence']; outcome?: BrainDecisionRow['outcome']; alternatives?: string[]; contextEpicId?: string; contextTaskId?: string; contextPhase?: string; /** * Relative or absolute path to the ADR document on disk. * * @see T1826 Decision Storage Consolidation */ adrPath?: string; /** * ID of the `brain_decisions` row this decision supersedes. * * When provided, the referenced row's `supersededBy` is updated and its * `confirmationState` is set to `'superseded'`. */ supersedes?: string; /** * Lifecycle state in the confirmation workflow. * * Defaults to `'proposed'` for new rows. */ confirmationState?: BrainDecisionRow['confirmationState']; /** * Who approved / originated this decision. * * Defaults to `'agent'` for new rows. */ decidedBy?: BrainDecisionRow['decidedBy']; /** * T992: Internal flag — when true, bypasses the verifyAndStore gate. * Set only by storeVerifiedCandidate in extraction-gate.ts to avoid * infinite recursion (gate → storeVerifiedCandidate → storeDecision → gate). * External callers MUST NOT set this flag. */ _skipGate?: boolean; } /** Parameters for searching decisions. */ export interface SearchDecisionParams { type?: BrainDecisionRow['type']; confidence?: BrainDecisionRow['confidence']; outcome?: BrainDecisionRow['outcome']; query?: string; limit?: number; } /** Parameters for listing decisions. */ export interface ListDecisionParams { limit?: number; offset?: number; } /** * Result shape returned by {@link validateDecisionConflicts}. * * @task T1828 */ export interface DecisionValidationResult { /** Near-duplicate or collision entries found (by decision ID). */ collisions: string[]; /** Decisions that contradict the candidate (by decision ID). */ contradictions: string[]; /** Supersession-graph integrity violations detected. */ supersession_graph_violations: string[]; /** Overall validator confidence (0.0–1.0). */ confidence: number; } /** * Validate a candidate decision for collision, contradiction, and supersession- * graph integrity using the dialectic LLM evaluator. * * ## Scope * * Only runs for ADR-typed writes (where `adrPath` is provided on the params). * Non-ADR writes skip validation entirely. * * ## Env skip * * When `process.env.CLEO_ENV === 'test'`, returns a synthetic passing result * (`confidence: 1.0`, empty violation arrays) immediately so that unit test * suites that do not want to make real LLM calls are not affected. * * ## LLM call * * Uses `evaluateDialectic()` from `dialectic-evaluator.ts` (cold tier, * `claude-sonnet-4-6`). The "user message" describes the candidate decision; * the "system response" summarises existing decisions to provide contradiction * context. The LLM is prompted to identify conflicts and assign a confidence * score. * * When no LLM backend is available, the function returns `confidence: 1.0` so * that writes are never silently blocked due to infrastructure absence. * * ## Rejection * * If `confidence < threshold` (default 0.7, configurable via * `decisions.validatorConfidenceThreshold` in `.cleo/config.json`), * the caller MUST throw {@link DecisionValidatorFailedError}. * * @param params - The store params for the candidate decision. * @param existingDecisions - Snapshot of existing decisions for conflict checking. * @returns Validation result with conflict lists and overall confidence. * * @task T1828 */ export declare function validateDecisionConflicts(params: Pick, existingDecisions: Pick[]): Promise; /** * Store a new decision or update an existing one if a duplicate is found. * Duplicate detection: same decision text (case-insensitive). * * @task T5155 */ export declare function storeDecision(projectRoot: string, params: StoreDecisionParams): Promise; /** * Recall a specific decision by ID. * * @task T5155 */ export declare function recallDecision(projectRoot: string, id: string): Promise; /** * Search decisions by type, confidence, outcome, and/or free-text query. * Query searches across decision + rationale fields using LIKE. * * @task T5155 */ export declare function searchDecisions(projectRoot: string, params?: SearchDecisionParams): Promise; /** * List decisions with pagination. * * @task T5155 */ export declare function listDecisions(projectRoot: string, params?: ListDecisionParams): Promise<{ decisions: BrainDecisionRow[]; total: number; }>; /** * Update the outcome of a decision after learning from results. * * @task T5155 */ export declare function updateDecisionOutcome(projectRoot: string, id: string, outcome: BrainDecisionRow['outcome']): Promise; //# sourceMappingURL=decisions.d.ts.map