@jungjaehoon/mama-server 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +146 -0
- package/package.json +2 -1
- package/src/db/migrations/001-initial-decision-graph.sql +140 -0
- package/src/db/migrations/002-add-error-patterns.sql +114 -0
- package/src/db/migrations/003-add-validation-fields.sql +28 -0
- package/src/db/migrations/004-add-trust-context.sql +17 -0
package/README.md
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# @jungjaehoon/mama-server
|
|
2
|
+
|
|
3
|
+
MCP server for MAMA (Memory-Augmented MCP Assistant) - Tracks decision evolution across your coding sessions.
|
|
4
|
+
|
|
5
|
+
## What is MAMA?
|
|
6
|
+
|
|
7
|
+
MAMA remembers why you made decisions, what you tried before, and what didn't work. It stores decisions with semantic search, so relevant context surfaces automatically when you need it.
|
|
8
|
+
|
|
9
|
+
**Key feature:** Session continuity - save your session state, resume tomorrow with full context.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
MAMA works with any MCP-compatible client. Add it to your client's configuration:
|
|
14
|
+
|
|
15
|
+
### Claude Code
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Quick install via marketplace
|
|
19
|
+
/plugin marketplace add jungjaehoon-lifegamez/claude-plugins
|
|
20
|
+
/plugin install mama
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The plugin automatically uses this MCP server via `npx -y @jungjaehoon/mama-server`.
|
|
24
|
+
|
|
25
|
+
### Claude Desktop
|
|
26
|
+
|
|
27
|
+
Add to `claude_desktop_config.json`:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"mcpServers": {
|
|
32
|
+
"mama": {
|
|
33
|
+
"command": "npx",
|
|
34
|
+
"args": ["-y", "@jungjaehoon/mama-server"]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Codex
|
|
41
|
+
|
|
42
|
+
Add to `~/.codex/config.toml`:
|
|
43
|
+
|
|
44
|
+
```toml
|
|
45
|
+
[mcp_servers.mama]
|
|
46
|
+
command = "npx"
|
|
47
|
+
args = ["-y", "@jungjaehoon/mama-server"]
|
|
48
|
+
disabled = false
|
|
49
|
+
disabled_tools = []
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Antigravity IDE (Gemini)
|
|
53
|
+
|
|
54
|
+
Add to `~/.gemini/antigravity/mcp_config.json`:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"mcpServers": {
|
|
59
|
+
"mama": {
|
|
60
|
+
"command": "npx",
|
|
61
|
+
"args": ["-y", "@jungjaehoon/mama-server"],
|
|
62
|
+
"disabled": false,
|
|
63
|
+
"disabledTools": []
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Other MCP Clients
|
|
70
|
+
|
|
71
|
+
Any MCP-compatible client can use MAMA with:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npx -y @jungjaehoon/mama-server
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Available Tools
|
|
78
|
+
|
|
79
|
+
The MCP server exposes these tools:
|
|
80
|
+
|
|
81
|
+
- `save_decision` - Save decisions with reasoning and confidence
|
|
82
|
+
- `recall_decision` - View full evolution history for a topic
|
|
83
|
+
- `suggest_decision` - Semantic search across all decisions
|
|
84
|
+
- `list_decisions` - Browse recent decisions chronologically
|
|
85
|
+
- `update_outcome` - Update decision outcomes (success/failure/partial)
|
|
86
|
+
- `save_checkpoint` - Save session state for later resumption
|
|
87
|
+
- `load_checkpoint` - Restore previous session context
|
|
88
|
+
|
|
89
|
+
## Usage Example
|
|
90
|
+
|
|
91
|
+
Once configured, use MAMA through your MCP client:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Save a decision (in Claude Code)
|
|
95
|
+
/mama-save topic="auth_strategy" decision="JWT with refresh tokens" reasoning="Need stateless auth for API scaling"
|
|
96
|
+
|
|
97
|
+
# Search for related decisions
|
|
98
|
+
/mama-suggest "How should I handle authentication?"
|
|
99
|
+
|
|
100
|
+
# View decision history
|
|
101
|
+
/mama-recall auth_strategy
|
|
102
|
+
|
|
103
|
+
# Save session before closing
|
|
104
|
+
/mama-checkpoint
|
|
105
|
+
|
|
106
|
+
# Resume next time
|
|
107
|
+
/mama-resume
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Features
|
|
111
|
+
|
|
112
|
+
- **Session Continuity** - Save/resume work sessions with full context
|
|
113
|
+
- **Decision Evolution** - Track how your thinking changes over time
|
|
114
|
+
- **Semantic Search** - Natural language queries find relevant decisions
|
|
115
|
+
- **Local-First** - All data stored on your device (~/.claude/mama-memory.db)
|
|
116
|
+
- **Multilingual** - Supports English, Korean, and other languages
|
|
117
|
+
- **Shared Database** - One database works across all your MCP clients
|
|
118
|
+
|
|
119
|
+
## Technical Details
|
|
120
|
+
|
|
121
|
+
- **Database:** SQLite + sqlite-vec extension
|
|
122
|
+
- **Embeddings:** Transformers.js (Xenova/all-MiniLM-L6-v2, 384-dim)
|
|
123
|
+
- **Transport:** stdio-based MCP protocol
|
|
124
|
+
- **Storage:** ~/.claude/mama-memory.db (configurable via MAMA_DB_PATH)
|
|
125
|
+
- **Node.js:** >= 18.0.0 required
|
|
126
|
+
- **Disk Space:** ~500MB for embedding model cache
|
|
127
|
+
|
|
128
|
+
## Links
|
|
129
|
+
|
|
130
|
+
- [GitHub Repository](https://github.com/jungjaehoon-lifegamez/MAMA)
|
|
131
|
+
- [Documentation](https://github.com/jungjaehoon-lifegamez/MAMA/tree/main/docs)
|
|
132
|
+
- [Issues](https://github.com/jungjaehoon-lifegamez/MAMA/issues)
|
|
133
|
+
- [Claude Code Plugin](https://github.com/jungjaehoon-lifegamez/claude-plugins/tree/main/mama)
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
MIT - see [LICENSE](https://github.com/jungjaehoon-lifegamez/MAMA/blob/main/LICENSE)
|
|
138
|
+
|
|
139
|
+
## Acknowledgments
|
|
140
|
+
|
|
141
|
+
MAMA was inspired by [mem0](https://github.com/mem0ai/mem0) (Apache 2.0). While MAMA is a distinct implementation focused on local-first SQLite/MCP architecture, we appreciate their pioneering work in LLM memory management.
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
**Author:** SpineLift Team
|
|
146
|
+
**Version:** 1.0.1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jungjaehoon/mama-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "MAMA MCP Server - Memory-Augmented MCP Assistant for Claude Code & Desktop",
|
|
5
5
|
"main": "src/server.js",
|
|
6
6
|
"bin": {
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
49
|
"src/**/*.js",
|
|
50
|
+
"src/db/migrations/*.sql",
|
|
50
51
|
"README.md",
|
|
51
52
|
"LICENSE"
|
|
52
53
|
]
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
-- ══════════════════════════════════════════════════════════════
|
|
2
|
+
-- MAMA (Memory-Augmented MCP Architecture) - Initial Schema
|
|
3
|
+
-- ══════════════════════════════════════════════════════════════
|
|
4
|
+
-- Version: 1.0
|
|
5
|
+
-- Date: 2025-11-14
|
|
6
|
+
-- Purpose: Decision Graph schema for Evolutionary Decision Memory
|
|
7
|
+
-- ══════════════════════════════════════════════════════════════
|
|
8
|
+
|
|
9
|
+
-- ══════════════════════════════════════════════════════════════
|
|
10
|
+
-- 1. Decision Nodes (Core)
|
|
11
|
+
-- ══════════════════════════════════════════════════════════════
|
|
12
|
+
-- Task 1.1: Create decisions table with all fields
|
|
13
|
+
|
|
14
|
+
CREATE TABLE IF NOT EXISTS decisions (
|
|
15
|
+
id TEXT PRIMARY KEY, -- "decision_mesh_structure_001"
|
|
16
|
+
topic TEXT NOT NULL, -- "mesh_structure", "auth_strategy"
|
|
17
|
+
decision TEXT NOT NULL, -- "COMPLEX", "JWT", "< 20 lines"
|
|
18
|
+
reasoning TEXT, -- "Flexibility is important initially"
|
|
19
|
+
|
|
20
|
+
-- Outcome Tracking (Learn-Unlearn-Relearn)
|
|
21
|
+
outcome TEXT, -- "SUCCESS", "FAILED", "PARTIAL", NULL
|
|
22
|
+
failure_reason TEXT, -- "Performance bottleneck at 10K+ meshes"
|
|
23
|
+
limitation TEXT, -- "Missing layer information"
|
|
24
|
+
duration_days INTEGER, -- Days until outcome determined
|
|
25
|
+
|
|
26
|
+
-- User Involvement
|
|
27
|
+
user_involvement TEXT, -- "requested", "approved", "rejected"
|
|
28
|
+
session_id TEXT, -- Foreign key to sessions
|
|
29
|
+
|
|
30
|
+
-- Relationships (Explicit)
|
|
31
|
+
supersedes TEXT, -- Previous decision ID
|
|
32
|
+
superseded_by TEXT, -- Next decision ID (NULL if current)
|
|
33
|
+
refined_from TEXT, -- JSON array: ["id1", "id2"]
|
|
34
|
+
|
|
35
|
+
-- Confidence Evolution
|
|
36
|
+
confidence REAL DEFAULT 0.5, -- Bayesian updated (0.0-1.0)
|
|
37
|
+
|
|
38
|
+
-- Timestamps
|
|
39
|
+
created_at INTEGER DEFAULT (unixepoch()),
|
|
40
|
+
updated_at INTEGER DEFAULT (unixepoch()),
|
|
41
|
+
|
|
42
|
+
FOREIGN KEY (supersedes) REFERENCES decisions(id),
|
|
43
|
+
FOREIGN KEY (superseded_by) REFERENCES decisions(id),
|
|
44
|
+
|
|
45
|
+
CHECK (confidence >= 0.0 AND confidence <= 1.0),
|
|
46
|
+
CHECK (outcome IN ('SUCCESS', 'FAILED', 'PARTIAL') OR outcome IS NULL),
|
|
47
|
+
CHECK (user_involvement IN ('requested', 'approved', 'rejected') OR user_involvement IS NULL)
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
-- Task 1.5: Add indexes for performance
|
|
51
|
+
CREATE INDEX IF NOT EXISTS idx_decisions_topic ON decisions(topic);
|
|
52
|
+
CREATE INDEX IF NOT EXISTS idx_decisions_outcome ON decisions(outcome);
|
|
53
|
+
CREATE INDEX IF NOT EXISTS idx_decisions_session ON decisions(session_id);
|
|
54
|
+
CREATE INDEX IF NOT EXISTS idx_decisions_supersedes ON decisions(supersedes);
|
|
55
|
+
CREATE INDEX IF NOT EXISTS idx_decisions_created_at ON decisions(created_at);
|
|
56
|
+
|
|
57
|
+
-- ══════════════════════════════════════════════════════════════
|
|
58
|
+
-- 2. Decision Edges (Explicit Relationships)
|
|
59
|
+
-- ══════════════════════════════════════════════════════════════
|
|
60
|
+
-- Task 1.2: Create decision_edges table
|
|
61
|
+
|
|
62
|
+
CREATE TABLE IF NOT EXISTS decision_edges (
|
|
63
|
+
from_id TEXT NOT NULL, -- Source decision
|
|
64
|
+
to_id TEXT NOT NULL, -- Target decision
|
|
65
|
+
relationship TEXT NOT NULL, -- "supersedes", "refines", "contradicts"
|
|
66
|
+
reason TEXT, -- "Learned from performance failure"
|
|
67
|
+
weight REAL DEFAULT 1.0, -- Strength of relationship
|
|
68
|
+
created_at INTEGER DEFAULT (unixepoch()),
|
|
69
|
+
|
|
70
|
+
PRIMARY KEY (from_id, to_id, relationship),
|
|
71
|
+
FOREIGN KEY (from_id) REFERENCES decisions(id),
|
|
72
|
+
FOREIGN KEY (to_id) REFERENCES decisions(id),
|
|
73
|
+
|
|
74
|
+
CHECK (relationship IN ('supersedes', 'refines', 'contradicts')),
|
|
75
|
+
CHECK (weight >= 0.0 AND weight <= 1.0)
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
-- Task 1.5: Add indexes for graph traversal
|
|
79
|
+
CREATE INDEX IF NOT EXISTS idx_edges_from ON decision_edges(from_id);
|
|
80
|
+
CREATE INDEX IF NOT EXISTS idx_edges_to ON decision_edges(to_id);
|
|
81
|
+
CREATE INDEX IF NOT EXISTS idx_edges_relationship ON decision_edges(relationship);
|
|
82
|
+
|
|
83
|
+
-- ══════════════════════════════════════════════════════════════
|
|
84
|
+
-- 3. Sessions (Context Preservation)
|
|
85
|
+
-- ══════════════════════════════════════════════════════════════
|
|
86
|
+
-- Task 1.3: Create sessions table
|
|
87
|
+
|
|
88
|
+
CREATE TABLE IF NOT EXISTS sessions (
|
|
89
|
+
id TEXT PRIMARY KEY, -- "session_2025-11-14-1000"
|
|
90
|
+
project_path TEXT, -- "/home/hoons/spineLiftWASM"
|
|
91
|
+
|
|
92
|
+
-- Rolling Summary (for next session)
|
|
93
|
+
rolling_summary TEXT, -- Condensed session summary
|
|
94
|
+
latest_exchange TEXT, -- Last 5 messages (JSON)
|
|
95
|
+
|
|
96
|
+
-- Metrics
|
|
97
|
+
action_count INTEGER DEFAULT 0,
|
|
98
|
+
decision_count INTEGER DEFAULT 0,
|
|
99
|
+
|
|
100
|
+
-- Timestamps
|
|
101
|
+
started_at INTEGER DEFAULT (unixepoch()),
|
|
102
|
+
last_active_at INTEGER DEFAULT (unixepoch()),
|
|
103
|
+
ended_at INTEGER,
|
|
104
|
+
|
|
105
|
+
CHECK (action_count >= 0),
|
|
106
|
+
CHECK (decision_count >= 0)
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
-- Task 1.5: Add indexes for session queries
|
|
110
|
+
CREATE INDEX IF NOT EXISTS idx_sessions_project ON sessions(project_path);
|
|
111
|
+
CREATE INDEX IF NOT EXISTS idx_sessions_ended ON sessions(ended_at);
|
|
112
|
+
CREATE INDEX IF NOT EXISTS idx_sessions_last_active ON sessions(last_active_at);
|
|
113
|
+
|
|
114
|
+
-- ══════════════════════════════════════════════════════════════
|
|
115
|
+
-- 4. Vector Search (sqlite-vss)
|
|
116
|
+
-- ══════════════════════════════════════════════════════════════
|
|
117
|
+
-- Task 1.4: Create vss_memories virtual table
|
|
118
|
+
-- Note: This will be initialized programmatically in memory-store.js
|
|
119
|
+
-- because sqlite-vss requires extension loading first
|
|
120
|
+
--
|
|
121
|
+
-- CREATE VIRTUAL TABLE vss_memories USING vss0(
|
|
122
|
+
-- embedding(384) -- multilingual-e5-small embeddings
|
|
123
|
+
-- );
|
|
124
|
+
|
|
125
|
+
-- ══════════════════════════════════════════════════════════════
|
|
126
|
+
-- Migration Metadata
|
|
127
|
+
-- ══════════════════════════════════════════════════════════════
|
|
128
|
+
|
|
129
|
+
CREATE TABLE IF NOT EXISTS schema_version (
|
|
130
|
+
version INTEGER PRIMARY KEY,
|
|
131
|
+
applied_at INTEGER DEFAULT (unixepoch()),
|
|
132
|
+
description TEXT
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
INSERT INTO schema_version (version, description)
|
|
136
|
+
VALUES (1, 'Initial Decision Graph schema');
|
|
137
|
+
|
|
138
|
+
-- ══════════════════════════════════════════════════════════════
|
|
139
|
+
-- End of Migration 001
|
|
140
|
+
-- ══════════════════════════════════════════════════════════════
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
-- ═══════════════════════════════════════════════════════════
|
|
2
|
+
-- MAMA (Memory-Augmented MCP Architecture) - Error Patterns Table
|
|
3
|
+
-- Migration 002: Add error_patterns table
|
|
4
|
+
--
|
|
5
|
+
-- Purpose: Store error patterns and their solutions for auto-resolution
|
|
6
|
+
-- Tasks: 3.1-3.4 (Error pattern schema)
|
|
7
|
+
-- AC #2, #3: Error pattern storage and auto-resolution
|
|
8
|
+
--
|
|
9
|
+
-- Version: 1.0
|
|
10
|
+
-- Date: 2025-11-14
|
|
11
|
+
-- ═══════════════════════════════════════════════════════════
|
|
12
|
+
|
|
13
|
+
-- Error Patterns Table
|
|
14
|
+
-- Stores error patterns, solutions, and success metrics
|
|
15
|
+
CREATE TABLE IF NOT EXISTS error_patterns (
|
|
16
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
17
|
+
|
|
18
|
+
-- Pattern Identification
|
|
19
|
+
error_pattern TEXT NOT NULL, -- Regex pattern or error signature
|
|
20
|
+
error_type TEXT, -- Error category (e.g., 'EADDRINUSE', 'ECONNREFUSED')
|
|
21
|
+
|
|
22
|
+
-- Solution
|
|
23
|
+
solution TEXT NOT NULL, -- Command or action to resolve
|
|
24
|
+
solution_type TEXT DEFAULT 'bash', -- 'bash', 'manual', 'code_fix'
|
|
25
|
+
|
|
26
|
+
-- Success Metrics
|
|
27
|
+
success_rate REAL DEFAULT 1.0, -- Success rate (0.0-1.0)
|
|
28
|
+
occurrences INTEGER DEFAULT 1, -- Total number of times encountered
|
|
29
|
+
successes INTEGER DEFAULT 1, -- Number of successful resolutions
|
|
30
|
+
|
|
31
|
+
-- Temporal Data
|
|
32
|
+
last_seen INTEGER NOT NULL, -- Last occurrence timestamp
|
|
33
|
+
first_seen INTEGER NOT NULL, -- First occurrence timestamp
|
|
34
|
+
|
|
35
|
+
-- Vector Embedding (for semantic matching)
|
|
36
|
+
embedding BLOB, -- 384-dim embedding (multilingual-e5-small)
|
|
37
|
+
|
|
38
|
+
-- Metadata
|
|
39
|
+
created_at INTEGER DEFAULT (unixepoch()),
|
|
40
|
+
updated_at INTEGER DEFAULT (unixepoch()),
|
|
41
|
+
|
|
42
|
+
-- Constraints
|
|
43
|
+
UNIQUE(error_pattern) -- One pattern per entry
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
-- Indexes for Performance
|
|
47
|
+
CREATE INDEX IF NOT EXISTS idx_error_patterns_last_seen
|
|
48
|
+
ON error_patterns(last_seen DESC);
|
|
49
|
+
|
|
50
|
+
CREATE INDEX IF NOT EXISTS idx_error_patterns_success_rate
|
|
51
|
+
ON error_patterns(success_rate DESC);
|
|
52
|
+
|
|
53
|
+
CREATE INDEX IF NOT EXISTS idx_error_patterns_error_type
|
|
54
|
+
ON error_patterns(error_type);
|
|
55
|
+
|
|
56
|
+
-- ═══════════════════════════════════════════════════════════
|
|
57
|
+
-- VSS Table Extension for Error Patterns
|
|
58
|
+
-- ═══════════════════════════════════════════════════════════
|
|
59
|
+
|
|
60
|
+
-- Note: Error pattern embeddings will be stored in the same vss_memories table
|
|
61
|
+
-- We'll use rowid mapping: error_patterns.id → vss_memories.rowid
|
|
62
|
+
-- This allows unified vector search across decisions AND error patterns
|
|
63
|
+
|
|
64
|
+
-- ═══════════════════════════════════════════════════════════
|
|
65
|
+
-- Sample Data (Optional - for testing)
|
|
66
|
+
-- ═══════════════════════════════════════════════════════════
|
|
67
|
+
|
|
68
|
+
-- Uncomment to insert sample error patterns for testing:
|
|
69
|
+
|
|
70
|
+
/*
|
|
71
|
+
INSERT INTO error_patterns (
|
|
72
|
+
error_pattern,
|
|
73
|
+
error_type,
|
|
74
|
+
solution,
|
|
75
|
+
solution_type,
|
|
76
|
+
success_rate,
|
|
77
|
+
occurrences,
|
|
78
|
+
successes,
|
|
79
|
+
last_seen,
|
|
80
|
+
first_seen
|
|
81
|
+
) VALUES
|
|
82
|
+
(
|
|
83
|
+
'EADDRINUSE.*port.*already in use',
|
|
84
|
+
'EADDRINUSE',
|
|
85
|
+
'lsof -ti:{{PORT}} | xargs kill',
|
|
86
|
+
'bash',
|
|
87
|
+
1.0,
|
|
88
|
+
5,
|
|
89
|
+
5,
|
|
90
|
+
unixepoch(),
|
|
91
|
+
unixepoch() - (30 * 24 * 60 * 60) -- 30 days ago
|
|
92
|
+
),
|
|
93
|
+
(
|
|
94
|
+
'ECONNREFUSED.*Connection refused',
|
|
95
|
+
'ECONNREFUSED',
|
|
96
|
+
'Check if service is running: systemctl status {{SERVICE}}',
|
|
97
|
+
'manual',
|
|
98
|
+
0.8,
|
|
99
|
+
3,
|
|
100
|
+
2,
|
|
101
|
+
unixepoch(),
|
|
102
|
+
unixepoch() - (7 * 24 * 60 * 60) -- 7 days ago
|
|
103
|
+
);
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
-- ═══════════════════════════════════════════════════════════
|
|
107
|
+
-- Migration Verification
|
|
108
|
+
-- ═══════════════════════════════════════════════════════════
|
|
109
|
+
|
|
110
|
+
-- Check table creation
|
|
111
|
+
SELECT
|
|
112
|
+
'Migration 002 Complete: error_patterns table created' AS status,
|
|
113
|
+
COUNT(*) AS row_count
|
|
114
|
+
FROM error_patterns;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
-- Migration 003: Add Validation Tracking Fields
|
|
2
|
+
-- Story: 014.7.6 - Interactive Learning Loop
|
|
3
|
+
-- Task: 1.2 - Add needs_validation field to decisions table
|
|
4
|
+
-- AC #1, #2: Validation tracking and user feedback collection
|
|
5
|
+
-- Date: 2025-11-14
|
|
6
|
+
|
|
7
|
+
-- Note: This migration is idempotent - duplicate column errors are handled gracefully
|
|
8
|
+
-- SQLite doesn't have "IF NOT EXISTS" for ALTER TABLE
|
|
9
|
+
-- The migration system treats "duplicate column" errors as success (idempotent)
|
|
10
|
+
|
|
11
|
+
-- Add validation tracking fields to decisions table (idempotent via migration system)
|
|
12
|
+
ALTER TABLE decisions ADD COLUMN needs_validation INTEGER DEFAULT 0 CHECK (needs_validation IN (0, 1));
|
|
13
|
+
ALTER TABLE decisions ADD COLUMN validation_attempts INTEGER DEFAULT 0;
|
|
14
|
+
ALTER TABLE decisions ADD COLUMN last_validated_at INTEGER;
|
|
15
|
+
ALTER TABLE decisions ADD COLUMN usage_count INTEGER DEFAULT 0;
|
|
16
|
+
|
|
17
|
+
-- Indexes for efficient queries (CREATE INDEX IF NOT EXISTS is supported)
|
|
18
|
+
CREATE INDEX IF NOT EXISTS idx_decisions_needs_validation ON decisions(needs_validation) WHERE needs_validation = 1;
|
|
19
|
+
CREATE INDEX IF NOT EXISTS idx_decisions_last_validated ON decisions(last_validated_at);
|
|
20
|
+
CREATE INDEX IF NOT EXISTS idx_decisions_usage_count ON decisions(usage_count) WHERE usage_count >= 10;
|
|
21
|
+
|
|
22
|
+
-- Update existing decisions: user_involvement='approved' don't need validation
|
|
23
|
+
-- Only update rows that don't have needs_validation set
|
|
24
|
+
UPDATE decisions SET needs_validation = 0 WHERE user_involvement = 'approved' AND needs_validation IS NULL;
|
|
25
|
+
UPDATE decisions SET needs_validation = 1 WHERE user_involvement = 'system_generated' AND needs_validation IS NULL;
|
|
26
|
+
|
|
27
|
+
-- Note: SQLite doesn't support DROP COLUMN, so rollback keeps columns
|
|
28
|
+
-- Rollback would require recreating the table (not recommended for production)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
-- Migration 004: Add Trust Context Support
|
|
2
|
+
-- Story 014.7.10: Claude-Friendly Context Formatting
|
|
3
|
+
-- AC #2: Trust Context Schema
|
|
4
|
+
-- Date: 2025-11-14
|
|
5
|
+
|
|
6
|
+
-- Add trust_context JSON field for 5 trust components
|
|
7
|
+
ALTER TABLE decisions ADD COLUMN trust_context TEXT;
|
|
8
|
+
|
|
9
|
+
-- Add usage tracking fields for implicit feedback
|
|
10
|
+
ALTER TABLE decisions ADD COLUMN usage_success INTEGER DEFAULT 0;
|
|
11
|
+
ALTER TABLE decisions ADD COLUMN usage_failure INTEGER DEFAULT 0;
|
|
12
|
+
ALTER TABLE decisions ADD COLUMN time_saved INTEGER DEFAULT 0; -- milliseconds saved
|
|
13
|
+
|
|
14
|
+
-- Indexes for performance
|
|
15
|
+
CREATE INDEX IF NOT EXISTS idx_decisions_usage_success ON decisions(usage_success DESC);
|
|
16
|
+
CREATE INDEX IF NOT EXISTS idx_decisions_time_saved ON decisions(time_saved DESC);
|
|
17
|
+
CREATE INDEX IF NOT EXISTS idx_decisions_needs_validation_usage ON decisions(needs_validation, usage_success) WHERE needs_validation = 1;
|