-
Notifications
You must be signed in to change notification settings - Fork 59
Cortex Learning System
geoffrey fernald edited this page Feb 1, 2026
·
1 revision
The Learning System enables Cortex V2 to improve from corrections and feedback, creating a continuously improving knowledge base.
When you correct the AI, Cortex V2:
- Analyzes the correction to understand what went wrong
- Categorizes it into one of 10 correction types
- Extracts generalizable principles
- Creates new memories from the learning
- Calibrates confidence based on evidence
| Category | Description | Example |
|---|---|---|
security |
Security-related corrections | "Don't use MD5, use bcrypt" |
performance |
Performance improvements | "Use pagination for large lists" |
style |
Code style preferences | "Use early returns" |
architecture |
Structural decisions | "Services shouldn't call controllers" |
naming |
Naming conventions | "Use camelCase for functions" |
error_handling |
Error handling patterns | "Always wrap async in try-catch" |
testing |
Testing practices | "Mock external services" |
documentation |
Documentation standards | "Add JSDoc to public functions" |
api_design |
API design patterns | "Use REST conventions" |
data_handling |
Data management | "Validate input at boundaries" |
βββββββββββββββββββ
β Correction β
β "Use bcrypt" β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Analyzer β
β - Diff code β
β - Extract why β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Categorizer β
β β "security" β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Principle β
β Extractor β
β β "Use secure β
β hashing" β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Memory Factory β
β - Tribal β
β - Pattern β
β - Smell β
βββββββββββββββββββ
await cortex.learn(
'Use MD5 for hashing', // Original (wrong)
'MD5 is insecure. Use bcrypt.', // Correction
'const hash = await bcrypt.hash(password, 10);', // Correct code
{
activeFile: 'src/auth.ts',
intent: 'fix_bug',
severity: 'high'
}
);// Confirm a memory is correct
await cortex.feedback('mem_abc123', 'confirmed');
// Reject a memory
await cortex.feedback('mem_abc123', 'rejected', {
reason: 'This pattern is outdated'
});
// Modify a memory
await cortex.feedback('mem_abc123', 'modified', {
newContent: 'Updated guidance...'
});Confidence is calculated from multiple signals:
interface ConfidenceMetrics {
usageCount: number; // Times memory was used
confirmations: number; // Positive feedback
rejections: number; // Negative feedback
age: number; // Days since creation
sourceReliability: number; // Trust in source
}
function calculateConfidence(metrics: ConfidenceMetrics): number {
const usageScore = Math.min(metrics.usageCount / 10, 1) * 0.3;
const feedbackScore = (metrics.confirmations - metrics.rejections) /
(metrics.confirmations + metrics.rejections + 1) * 0.4;
const ageDecay = Math.exp(-metrics.age / 365) * 0.1;
const sourceScore = metrics.sourceReliability * 0.2;
return Math.max(0, Math.min(1, usageScore + feedbackScore + ageDecay + sourceScore));
}The system identifies memories that need validation:
interface ValidationCandidate {
memoryId: string;
reason: 'low_confidence' | 'conflicting' | 'stale' | 'unused';
priority: number;
suggestedPrompt: string;
}const candidates = await cortex.getValidationCandidates(5);
// Returns memories that need human review
for (const candidate of candidates) {
console.log(candidate.suggestedPrompt);
// "Is this still accurate? 'Always use bcrypt for passwords'"
}Created when learning reveals team conventions:
{
type: 'tribal_knowledge',
content: 'Always use bcrypt for password hashing',
source: 'correction',
confidence: 0.8,
category: 'security'
}Created when learning explains why a pattern exists:
{
type: 'pattern_rationale',
content: 'JWT tokens are used because the API is stateless',
patternId: 'jwt-auth-pattern',
source: 'correction',
confidence: 0.75
}Created when learning identifies anti-patterns:
{
type: 'code_smell',
content: 'Using MD5 for password hashing is insecure',
severity: 'high',
source: 'correction',
confidence: 0.9
}Learn from a correction:
{
"original": "Use MD5 for hashing",
"correction": "MD5 is insecure. Use bcrypt.",
"correctCode": "const hash = await bcrypt.hash(password, 10);",
"context": {
"file": "src/auth.ts",
"intent": "fix_bug"
}
}Provide feedback on a memory:
{
"memoryId": "mem_abc123",
"action": "confirmed"
}Get memories needing validation:
{
"limit": 5,
"includePrompts": true
}Track learning system health:
const health = await cortex.getLearningHealth();
// {
// totalCorrections: 47,
// categorizedCorrections: 45,
// principlesExtracted: 32,
// memoriesCreated: 28,
// averageConfidence: 0.78,
// validationBacklog: 5
// }- Provide context β Include file and intent when learning
- Be specific β Explain WHY something is wrong
- Include correct code β Show the right way
- Review candidates β Regularly validate low-confidence memories
- Track metrics β Monitor learning health
- Cortex V2 Overview
- Memory Setup Wizard
- Memory CLI
- Universal Memory Types
- Learning System
- Token Efficiency
- Causal Graphs
- Code Generation
- Predictive Retrieval
- Architecture
- Call Graph Analysis
- Impact Analysis
- Security Analysis
- Data Boundaries
- Test Topology
- Coupling Analysis
- Error Handling Analysis
- Wrappers Detection
- Environment Variables
- Constants Analysis
- Styling DNA
- Constraints
- Contracts
- Decision Mining
- Speculative Execution
- Watch Mode
- Trends Analysis
- Projects Management
- Package Context
- Monorepo Support
- Reports & Export
- Dashboard
- 10 Languages
- 21 Frameworks
- 16 ORMs
- 400+ Detectors
- 50+ MCP Tools
- 60+ CLI Commands
- 23 Memory Types