Delta-encoded episodes
Mnemosyne is alpha, on the 3.6.x line, and the API can still change within 3.x.
The idea
Many episodes repeat an earlier one with small changes. Storing each in full duplicates the shared part. Mnemosyne links a similar episode to its nearest predecessor and stores what differs:
ROOT: "Firmware 4.0 rollout"
/ | \
"4.1 rollout" "4.2 rollout" "4.3 rollout"
(Δ canary site) (Δ docking fix) (Δ rollback)
|
"4.2.1 hotfix rollout"
(Δ skipped canary)How it works
Source: packages/core/src/cognitive/delta-episode.ts.
When an episode is about to be created, by POST /remember or by a session
collapse:
- The narrative is embedded.
- The nearest existing episode is looked up.
- If its cosine is at least 0.85, the new episode becomes its child:
parentEpisodeIdpoints at it anddeltaContentholds the difference between the new narrative and the parent’s full narrative. - Otherwise the episode is created as a root.
Recall folds the chain from the root to the leaf (reconstructEpisode), so
an episode hit carries the full narrative.
Fields
On MnemoEpisode (packages/types/src/primitives.ts):
| Field | Meaning |
|---|---|
parentEpisodeId | The episode this one is a delta of |
deltaContent | What differs from the parent |
isRoot | true when it has no parent |
depth | Distance from the root |
Delta-linking needs an embedding provider. Without one, or when the embedding call fails, the episode is stored as a root.