How It Works
When you write to a key that already exists:- The current version is marked as superseded
- A new version is created with an incremented version number
- The new version becomes the current version
Viewing History
Uselist() with include_superseded=True to see all versions:
On-Disk Layout (Filesystem Adapter)
The filesystem adapter stores each version as a separate JSON file:_current.json— the active version_superseded.json— previous versions, kept for history
os.rename()) with advisory file locking (flock()) to prevent corruption from concurrent writes.
Conflict Handling
When two agents write to the same key concurrently, theconflict_policy determines behavior:
| Policy | Behavior |
|---|---|
LAST_WRITE_WINS | Default. The latest write takes precedence. |
RAISE | Raises StaleWriteError if another agent advanced the version since your last read. |
Why CoW?
- Auditability — Every change is recorded. You can always trace how knowledge evolved.
- Safety — No data is lost. Mistakes can be identified by comparing versions.
- Outcome tracking — Outcomes create new versions with updated confidence scores, preserving the score history.
