feat: include created_at timestamp in search results (#846)

* feat: include created_at timestamp in search results (closes #465)

Surface the existing filed_at metadata as created_at in search result
objects returned by search_memories(). Enables temporal reasoning over
search hits without additional queries.

* Feat: add fallback for missing filed_at metadata
This commit is contained in:
sha2fiddy
2026-04-15 03:26:57 -04:00
committed by GitHub
parent ecd44f7cb7
commit a15094ce60
2 changed files with 23 additions and 0 deletions
+22
View File
@@ -51,6 +51,28 @@ class TestSearchMemories:
assert "source_file" in hit
assert "similarity" in hit
assert isinstance(hit["similarity"], float)
assert "created_at" in hit
def test_created_at_contains_filed_at(self, palace_path, seeded_collection):
"""created_at surfaces the filed_at metadata from the drawer."""
result = search_memories("JWT authentication", palace_path)
hit = result["results"][0]
assert hit["created_at"] == "2026-01-01T00:00:00"
def test_created_at_fallback_when_filed_at_missing(self):
"""created_at defaults to 'unknown' when filed_at is absent."""
mock_col = MagicMock()
mock_col.query.return_value = {
"ids": [["drawer_no_date"]],
"documents": [["Some text without a date"]],
"metadatas": [[{"wing": "project", "room": "backend", "source_file": "x.py"}]],
"distances": [[0.1]],
}
with patch("mempalace.searcher.get_collection", return_value=mock_col):
result = search_memories("test", "/fake/path")
hit = result["results"][0]
assert hit["created_at"] == "unknown"
def test_search_memories_query_error(self):
"""search_memories returns error dict when query raises."""