Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions internal/mcp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,25 @@ func (srv *MCPServer) handleRecall(ctx context.Context, args map[string]interfac
return nil, fmt.Errorf("retrieval failed: %w", err)
}

// Filter patterns and abstractions by exclude_concepts
if len(excludeConcepts) > 0 {
var filteredPatterns []store.Pattern
for _, p := range result.Patterns {
if !conceptOverlap(p.Concepts, excludeConcepts) {
filteredPatterns = append(filteredPatterns, p)
}
}
result.Patterns = filteredPatterns

var filteredAbstractions []store.Abstraction
for _, a := range result.Abstractions {
if !conceptOverlap(a.Concepts, excludeConcepts) {
filteredAbstractions = append(filteredAbstractions, a)
}
}
result.Abstractions = filteredAbstractions
}

// Save traversal data and access snapshot for feedback loop
var retrievedIDs []string
var snapshot []store.AccessSnapshotEntry
Expand Down
12 changes: 11 additions & 1 deletion internal/store/sqlite/patterns.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (s *SQLiteStore) UpdatePattern(ctx context.Context, p store.Pattern) error
SET pattern_type = ?, title = ?, description = ?, evidence_ids = ?, strength = ?,
project = ?, concepts = ?, embedding = ?, access_count = ?, last_accessed = ?,
state = ?, updated_at = ?
WHERE id = ?`,
WHERE id = ? AND state != 'archived'`,
p.PatternType,
p.Title,
p.Description,
Expand All @@ -88,6 +88,16 @@ func (s *SQLiteStore) UpdatePattern(ctx context.Context, p store.Pattern) error

rowsAffected, _ := result.RowsAffected()
if rowsAffected == 0 {
// Check if the pattern exists but is archived (dismissed by user).
// In that case, the WHERE state != 'archived' guard prevented the update — this is expected.
var state string
row := s.db.QueryRowContext(ctx, `SELECT state FROM patterns WHERE id = ?`, p.ID)
if err := row.Scan(&state); err != nil {
return fmt.Errorf("pattern with id %s: %w", p.ID, store.ErrNotFound)
}
if state == "archived" {
return nil // silently skip — pattern was dismissed
}
return fmt.Errorf("pattern with id %s: %w", p.ID, store.ErrNotFound)
}
return nil
Expand Down