/** * LearningLoop — Store successful DAG patterns and prefer proven ones. * * After a TeamResult completes, `recordOutcome()` extracts the DAG shape * (agent→action edges, dependency structure) and scores it by success rate. * Before planning, `suggestPatterns()` returns the top matching patterns * so the GoalDecomposer or planner can bias toward proven approaches. * * @module LearningLoop */ /** Compressed representation of a DAG pattern */ export interface DAGPattern { id: string; /** Original goal (or goal hash) that produced this pattern */ goalSignature: string; /** Ordered agent→action pairs that form the pattern */ steps: PatternStep[]; /** Dependency edges: stepIndex → upstream stepIndex[] */ edges: number[][]; /** Number of times this pattern was used */ usageCount: number; /** Number of successful completions */ successCount: number; /** Number of failures */ failureCount: number; /** Success rate: successCount / usageCount */ successRate: number; /** Average execution duration in ms */ avgDurationMs: number; /** Tags for classification */ tags: string[]; /** First recorded timestamp */ createdAt: number; /** Last used timestamp */ lastUsedAt: number; } /** A single step in a pattern */ export interface PatternStep { agent: string; action: string; } /** Outcome of a team/DAG execution */ export interface DAGOutcome { goal: string; steps: PatternStep[]; edges: number[][]; success: boolean; durationMs: number; tags?: string[]; } /** Match result when searching for proven patterns */ export interface PatternMatch { pattern: DAGPattern; /** How well this pattern matches the query (0-1) */ relevance: number; } /** * Records DAG execution outcomes and recalls proven patterns. * * @example * ```ts * const loop = new LearningLoop(); * * // After execution: * loop.recordOutcome({ * goal: 'Review and fix code', * steps: [{ agent: 'reviewer', action: 'review' }, { agent: 'fixer', action: 'fix' }], * edges: [[], [0]], * success: true, * durationMs: 5000, * }); * * // Before planning: * const proven = loop.suggestPatterns('code review', ['review']); * ``` */ export declare class LearningLoop { private patterns; private maxPatterns; private minSuccessRate; constructor(options?: { maxPatterns?: number; minSuccessRate?: number; }); /** * Record the outcome of a DAG execution. * If a matching pattern exists (same signature), updates stats. * Otherwise creates a new pattern entry. */ recordOutcome(outcome: DAGOutcome): string; /** * Suggest proven patterns matching a goal description and tags. * Returns patterns sorted by (relevance × successRate). */ suggestPatterns(goalHint: string, tags?: string[], maxResults?: number): PatternMatch[]; /** Get a specific pattern by ID */ get(id: string): DAGPattern | undefined; /** Get all patterns */ getAll(): DAGPattern[]; /** Number of stored patterns */ size(): number; /** Clear all patterns */ clear(): void; /** Export patterns for persistence */ export(): DAGPattern[]; /** Import patterns from a persisted array */ import(patterns: DAGPattern[]): void; private computeSignature; private findBySignature; private tokenize; private evict; } //# sourceMappingURL=learning-loop.d.ts.map