-
Notifications
You must be signed in to change notification settings - Fork 0
Fix memory expiration logic and Makefile warnings #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -319,7 +319,7 @@ func (d *DB) cleanupExpired(ctx context.Context) error { | |
| d.mu.RUnlock() | ||
|
|
||
| _, err := d.db.ExecContext(ctx, | ||
| `DELETE FROM memories WHERE expires_at IS NOT NULL AND expires_at < datetime('now')`, | ||
| `DELETE FROM memories WHERE expires_at IS NOT NULL AND datetime(expires_at) < datetime('now')`, | ||
| ) | ||
|
Comment on lines
321
to
323
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1 | Confidence: High The change wraps |
||
| return err | ||
| } | ||
|
|
@@ -423,7 +423,7 @@ func (d *DB) Retrieve(ctx context.Context, namespace, key string) (*Memory, erro | |
| SELECT id, namespace, key, value, embedding, metadata, tags, created_at, updated_at, ttl, expires_at | ||
| FROM memories | ||
| WHERE namespace = ? AND key = ? | ||
| AND (expires_at IS NULL OR expires_at > datetime('now')) | ||
| AND (expires_at IS NULL OR datetime(expires_at) > datetime('now')) | ||
| ` | ||
|
|
||
| row := d.db.QueryRowContext(ctx, query, namespace, key) | ||
|
|
@@ -444,7 +444,7 @@ func (d *DB) RetrieveByID(ctx context.Context, id string) (*Memory, error) { | |
| SELECT id, namespace, key, value, embedding, metadata, tags, created_at, updated_at, ttl, expires_at | ||
| FROM memories | ||
| WHERE id = ? | ||
| AND (expires_at IS NULL OR expires_at > datetime('now')) | ||
| AND (expires_at IS NULL OR datetime(expires_at) > datetime('now')) | ||
| ` | ||
|
|
||
| row := d.db.QueryRowContext(ctx, query, id) | ||
|
|
@@ -588,7 +588,7 @@ func (d *DB) List(ctx context.Context, namespace string, limit, offset int) ([]* | |
| SELECT id, namespace, key, value, embedding, metadata, tags, created_at, updated_at, ttl, expires_at | ||
| FROM memories | ||
| WHERE namespace = ? | ||
| AND (expires_at IS NULL OR expires_at > datetime('now')) | ||
| AND (expires_at IS NULL OR datetime(expires_at) > datetime('now')) | ||
| ORDER BY created_at DESC | ||
| LIMIT ? OFFSET ? | ||
|
Comment on lines
588
to
593
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2 | Confidence: Medium Speculative: Applying Code Suggestion: CREATE INDEX idx_memories_expires_at_datetime ON memories(datetime(expires_at));Evidence: method:Retrieve |
||
| ` | ||
|
|
@@ -697,7 +697,7 @@ func (d *DB) Search(ctx context.Context, namespace string, queryEmbedding []floa | |
| FROM memories | ||
| WHERE namespace = ? | ||
| AND embedding IS NOT NULL | ||
| AND (expires_at IS NULL OR expires_at > datetime('now')) | ||
| AND (expires_at IS NULL OR datetime(expires_at) > datetime('now')) | ||
| ` | ||
|
|
||
| rows, err := d.db.QueryContext(ctx, query, namespace) | ||
|
|
@@ -766,7 +766,7 @@ func (d *DB) SearchAll(ctx context.Context, queryEmbedding []float32, limit int, | |
| SELECT id, namespace, key, value, embedding, metadata, tags, created_at, updated_at, ttl, expires_at | ||
| FROM memories | ||
| WHERE embedding IS NOT NULL | ||
| AND (expires_at IS NULL OR expires_at > datetime('now')) | ||
| AND (expires_at IS NULL OR datetime(expires_at) > datetime('now')) | ||
| ` | ||
|
|
||
| rows, err := d.db.QueryContext(ctx, query) | ||
|
|
@@ -821,7 +821,7 @@ func (d *DB) Count(ctx context.Context, namespace string) (int64, error) { | |
|
|
||
| var count int64 | ||
| err := d.db.QueryRowContext(ctx, | ||
| `SELECT COUNT(*) FROM memories WHERE namespace = ? AND (expires_at IS NULL OR expires_at > datetime('now'))`, | ||
| `SELECT COUNT(*) FROM memories WHERE namespace = ? AND (expires_at IS NULL OR datetime(expires_at) > datetime('now'))`, | ||
| namespace, | ||
| ).Scan(&count) | ||
|
Comment on lines
822
to
826
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2 | Confidence: High The |
||
| if err != nil { | ||
|
|
@@ -843,7 +843,7 @@ func (d *DB) CountAll(ctx context.Context) (int64, error) { | |
|
|
||
| var count int64 | ||
| err := d.db.QueryRowContext(ctx, | ||
| `SELECT COUNT(*) FROM memories WHERE expires_at IS NULL OR expires_at > datetime('now')`, | ||
| `SELECT COUNT(*) FROM memories WHERE expires_at IS NULL OR datetime(expires_at) > datetime('now')`, | ||
| ).Scan(&count) | ||
| if err != nil { | ||
| return 0, fmt.Errorf("failed to count memories: %w", err) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2 | Confidence: High
The Makefile changes correctly eliminate duplicate target warnings by replacing directory rule dependencies with explicit
mkdir -pin recipes. This simplifies the Makefile and follows best practices. However, it introduces minor redundancy—themkdir -pcommand appears in five targets (build,build-mcp,test-coverage,dist, and implicitly in any recipe writing to those directories). This is acceptable but could be centralized using a macro or variable if more directories are added.Code Suggestion: