memory / contradiction_log.py — ContradictionLog
Append-only audit log of belief revisions. Drives "I previously thought X, but updated because…" explanations.
Storage
- JSON at
memory_dir/contradiction_log.json. - FIFO cap
MAX_ENTRIES = 200. - Atomic temp +
os.replace;threading.RLock.
Entry shape
{
"timestamp": "ISO",
"new_fact": str,
"superseded": [{ "id": str, "text": str }],
"deleted_ids": [str],
"reason": str
}
API
| Method | Purpose |
|---|---|
__init__(memory_dir) | Open log file. |
record(new_fact, old_facts, deleted_ids, reason="") | Append revision. |
get_recent(limit=10) | Most recent entries. |
explain_belief_change(query) | Search recent entries by substring. |
clear() | Wipe. |