Repository navigation
Description
Bug Description
recent-activity can return misleadingly empty or stale results because the date filter is applied to search_index.created_at instead of search_index.updated_at.
This means notes/entities that were created before the requested timeframe but edited/updated inside the timeframe are excluded from recent activity, even though they are the most important results for a “what changed recently?” query.
Steps to Reproduce
- Create an entity/note older than the requested recent-activity timeframe.
- Update that existing entity/note within the timeframe.
- Query recent activity, for example:
bm tool recent-activity --project main --timeframe 14dor through the v2 memory/recent activity endpoint that uses the search repository date filter.
Expected Behavior
Recent activity should include entities/notes whose updated_at falls within the requested timeframe, even when their created_at is older.
Unranked recent-activity results should be ordered by recency, e.g. newest updated_at first.
Actual Behavior
The search repository filters after_date against search_index.created_at, so updated older notes are omitted.
In unranked recent-activity calls, ordering is also not recency-first; it sorts by a constant/null rank and id before updated recency is considered.
Suspected Root Cause
Both SQLite and Postgres search repositories use created_at for after_date filtering where recent-activity semantics require updated_at:
src/basic_memory/repository/sqlite_search_repository.pysrc/basic_memory/repository/postgres_search_repository.py
The unranked ordering should prefer:
updated_at DESC, id ASCrather than rank/id ahead of recency.
Suggested Fix
- Change
after_datefilters fromcreated_at >= after_datetoupdated_at >= after_datein both SQLite and Postgres search repositories. - For unranked/recent-activity search, order by
updated_at DESC, id ASC. - Add regression coverage that verifies:
- an old-created but recently-updated entity is included,
- a stale entity outside the timeframe is excluded,
- results are ordered newest
updated_atfirst.
Validation Notes
A local regression test was drafted against tests/api/v2/test_memory_router.py and passed with the repository changes:
uv run pytest tests/api/v2/test_memory_router.py -q
# 13 passed
uv run pytest \
tests/services/test_search_service.py::test_after_date \
tests/api/v2/test_search_router.py::test_search_with_date_filter \
-q
# 2 passedEnvironment
- Repo:
basicmachines-co/basic-memory - Observed from local checkout on
mainaround commitdd91b490 - Affected behavior: Basic Memory recent activity / search date filtering
Activity
claude commentedon May 10, 2026
Claude finished @groksrc's task in 4m 38s —— View job •
claude/issue-811-20260510-1912• Create PR ➔Triage & Fix: Recent activity filters on
created_atinstead ofupdated_atafter_datefilters fromcreated_attoupdated_atupdated_at DESCbeforeid ASCtest_after_dateto verifyupdated_atsemanticsbug)Triage Summary
Changes Made
src/basic_memory/repository/sqlite_search_repository.pydatetime(search_index.created_at) > datetime(:after_date)→datetime(search_index.updated_at) > datetime(:after_date)src/basic_memory/repository/postgres_search_repository.pysearch_index.created_at > :after_date→search_index.updated_at > :after_dateORDER BY score DESC, search_index.id ASC {order_by_clause}→ORDER BY score DESC {order_by_clause}, search_index.id ASCupdated_at DESCtakes priority overid ASCfor unranked (no text search) queriestests/services/test_search_service.pytest_after_dateto assertupdated_at > past_date(instead ofcreated_at)test_after_date_uses_updated_at: regression test that directly indexes an entity with oldcreated_at(2015) but recentupdated_at(2023), verifies it's included after a 2020 cutoff, verifies the stale entity (oldupdated_at) is excluded, and verifies results are ordered newest-updated-first|