fix: 7-day TTL on dated learnings + block availability learnings

Stale learning ("I don't have Robin Hanson data") overrode real KB data.
Ganymede review: dated entries expire after 7 days. Permanent entries
(communication style, identity) are undated and always included.

Prompt guard: "NEVER save a learning about what data you do or don't have"
prevents the bot from writing availability claims that go stale.

Pentagon-Agent: Epimetheus <3D35839A-7722-4740-B93D-51157F7D5E70>
This commit is contained in:
m3taversal 2026-03-23 18:07:46 +00:00
parent 6c6cd0d14e
commit 9267351aba

View file

@ -204,10 +204,27 @@ def _git_commit_archive(archive_path, filename: str):
def _load_learnings() -> str:
"""Load Rio's learnings file for prompt injection. Sanitized (Ganymede: prompt injection risk)."""
"""Load Rio's learnings file for prompt injection. Sanitized (Ganymede: prompt injection risk).
Dated entries older than 7 days are filtered out (Ganymede: stale learning TTL).
Permanent entries (undated) always included.
"""
try:
raw = Path(LEARNINGS_FILE).read_text()[:3000]
return sanitize_message(raw) # Same sanitization as user messages
raw = Path(LEARNINGS_FILE).read_text()[:4000]
today = datetime.now(timezone.utc).date()
lines = []
for line in raw.split("\n"):
# Check for dated entries [YYYY-MM-DD]
date_match = re.search(r"\[(\d{4}-\d{2}-\d{2})\]", line)
if date_match:
try:
entry_date = datetime.strptime(date_match.group(1), "%Y-%m-%d").date()
if (today - entry_date).days > 7:
continue # stale, skip
except ValueError:
pass
lines.append(line)
return sanitize_message("\n".join(lines))
except Exception:
return ""
@ -619,6 +636,7 @@ IMPORTANT: Two special tags you can append at the end of your response (after yo
1. If you learn something: LEARNING: [category] [what you learned]
Categories: factual, communication, structured_data
Only when genuinely learned something. Most responses have none.
NEVER save a learning about what data you do or don't have access to. Your knowledge base changes constantly — availability learnings become stale immediately.
2. If the user would benefit from an X search on a topic: RESEARCH: [search query]
This triggers an automatic X search. Use when the user asks about recent sentiment, community takes, or emerging discussions. Only when a search would genuinely help."""