Repository navigation
Expand file tree
/
Copy pathtest_cli_memory.py
More file actions
52 lines (43 loc) · 1.92 KB
/
Copy pathtest_cli_memory.py
File metadata and controls
52 lines (43 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""DETERMINISTIC EVAL - the CLI /memory command reads local SQLite state."""
from __future__ import annotations
from prometheus.db import connect
from prometheus.gateway.cli import _memory_snapshot
def test_memory_snapshot_reads_seeded_home(tmp_path):
conn = connect(tmp_path)
conn.execute(
"INSERT INTO facts (subject, content, source) VALUES (?, ?, ?)",
("project", "Prometheus stays local-first", "user"),
)
conn.execute(
"INSERT INTO facts (subject, content, source) VALUES (?, ?, ?)",
("alex", "Alex prefers morning meetings", "consolidation"),
)
conn.execute(
"INSERT INTO episodes (happened_at, summary) VALUES (?, ?)",
("2026-07-16", "Planned the launch"),
)
conn.execute(
"INSERT INTO episodes (happened_at, summary) VALUES (?, ?)",
("2026-07-17", "Reviewed the launch checklist"),
)
conn.execute("INSERT INTO chat_log (role, content, consolidated) VALUES ('user', 'old', 1)")
conn.execute(
"INSERT INTO chat_log (role, content, consolidated) VALUES ('user', 'new question', 0)"
)
conn.execute(
"INSERT INTO chat_log (role, content, consolidated) VALUES ('assistant', 'new answer', 0)"
)
conn.commit()
snapshot = _memory_snapshot(conn)
assert "Semantic facts (2)" in snapshot
assert "[alex] Alex prefers morning meetings" in snapshot
assert "[project] Prometheus stays local-first" in snapshot
assert "Recent episodes (2)" in snapshot
assert "2026-07-17 - Reviewed the launch checklist" in snapshot
assert "2026-07-16 - Planned the launch" in snapshot
assert "Unconsolidated chat messages: 2" in snapshot
def test_memory_snapshot_handles_empty_home(tmp_path):
snapshot = _memory_snapshot(connect(tmp_path))
assert "Semantic facts (0)\n- none yet" in snapshot
assert "Recent episodes (0)\n- none yet" in snapshot
assert "Unconsolidated chat messages: 0" in snapshot