feat: era-rollup + narrative engine (consolidation steps 3-4)
Complete the consolidation pipeline: summaries -> profile + eras -> narrative.
- memory: eras table (per-month digests) + Era, summaries_by_month, store_era,
list_eras, recall_eras; narrative table + set/get_narrative
- lyra/era.py (lyra-era): groups session gists by the month the session occurred
(real timestamps) and map-reduces each month into a "what was happening" digest
- lyra/narrative.py (lyra-narrative): distills profile + recent eras into the
current arc/trends/callbacks ("remember when…", "you're trending toward…")
- chat.build_messages injects the narrative alongside the profile
Verified on the real corpus: 17 monthly eras (Dec 2024-Jun 2026) + a narrative
that surfaces specific callbacks (the $573 Hollywood session, 4 years sober).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -47,6 +47,13 @@ def build_messages(session_id: str, user_msg: str) -> list[Message]:
|
||||
{"role": "system", "content": "What you know about Brian:\n" + profile}
|
||||
)
|
||||
|
||||
# Time-aware memory: the current narrative (recent arc, trends, callbacks).
|
||||
narrative = memory.get_narrative()
|
||||
if narrative:
|
||||
messages.append(
|
||||
{"role": "system", "content": "What's going on with Brian lately:\n" + narrative}
|
||||
)
|
||||
|
||||
recent = memory.recent(session_id, n=RECENT_N)
|
||||
recent_ids = {ex.id for ex in recent}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user