Episodic-to-semantic memory consolidation (experimental)#578
Draft
kimjune01 wants to merge 3 commits intoSoarGroup:developmentfrom
Draft
Episodic-to-semantic memory consolidation (experimental)#578kimjune01 wants to merge 3 commits intoSoarGroup:developmentfrom
kimjune01 wants to merge 3 commits intoSoarGroup:developmentfrom
Conversation
Periodically scan episodic memory for stable WME structures and write
them to semantic memory as new LTIs. This implements the compose+test
framework (Casteigts et al., 2019) for automatic episodic-to-semantic
knowledge transfer — the operation Soar's long-term declarative stores
have been missing.
Algorithm:
compose — union of constant WMEs currently active in epmem
test — continuous presence >= consolidate-threshold episodes
write — create smem LTI with qualifying augmentations via CLI_add
New parameters (all under epmem):
consolidate on/off (default off)
consolidate-interval integer (default 100) — episodes between runs
consolidate-threshold integer (default 10) — min episode persistence
Deduplication via epmem_consolidated tracking table prevents repeated
writes across consolidation runs. Table is dropped on reinit alongside
other epmem graph tables.
Off by default — zero behavior change until explicitly enabled.
Limitations (deferred to follow-up):
- Only consolidates constant-valued WMEs, not identifier edges
- No back-invalidation across the WM/smem tier boundary
- last-consolidation stat does not persist across agent reinit
Motivation: Derbinsky & Laird (2013) proved forgetting is essential to
Soar's scaling but only built it for working and procedural memory.
Episodic and semantic memory have no eviction and no capacity bound.
This patch addresses the first half: automatic semantic learning from
episodic experience. With semantic entries derived from episodes,
episodic eviction becomes safe (merged episodes leave no reconstruction
debt), and R4's forgettable WME scope expands automatically.
Reference:
Casteigts et al. (2019), "Computing Parameters of Sequence-Based
Dynamic Graphs," Theory of Computing Systems.
Derbinsky & Laird (2013), "Effective and efficient forgetting of
learned knowledge in Soar's working and procedural memories,"
Cognitive Systems Research.
https://june.kim/prescription-soar — full prescription
After consolidation writes stable WMEs to smem, old episodes become redundant. Delete point entries and episode rows older than consolidate-evict-age episodes. This is safe: the consolidated knowledge is in smem, so there is no reconstruction debt. New parameter: consolidate-evict-age integer (default 0 = off) — min age before an episode is eligible for eviction Range and _now interval entries are preserved (they span multiple episodes). Only point entries and episode rows are removed. Reference: Derbinsky & Laird (2013), §5 — "forgotten working-memory knowledge may be recovered via deliberate reconstruction from semantic memory." Consolidation creates the semantic entries; eviction removes the source episodes that are no longer needed for reconstruction.
- Delete _range entries whose intervals end before the eviction cutoff (previously only _point entries were evicted, leaving dead weight) - Wrap all eviction DELETEs in BEGIN/COMMIT when lazy_commit is off for atomicity (when lazy_commit is on, already inside a transaction) Retrieval of evicted episodes is already safe: epmem_install_memory checks valid_episode and returns ^retrieved no-memory.
Contributor
|
Wow, this and the other pull request. I need to review these, but thanks! These look exciting. |
This was referenced Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Experimental / demonstration only. This PR adds episodic-to-semantic consolidation and episodic eviction — steps 1 and 2 of the Prescription: Soar. Together they close the loop that Derbinsky & Laird (2013) left open: semantic memory learns from experience, and episodes that have been consolidated become safely evictable.
Consolidation (step 1)
Periodically scans episodic memory for stable WME structures and writes them to semantic memory as new LTIs via
CLI_add. Implements the compose+test framework from Casteigts et al. (2019).Eviction (step 2)
After consolidation, deletes old episode point and range entries and episode rows past the eviction age. Safe because the consolidated knowledge is in smem — no reconstruction debt. Retrieval of evicted episodes returns
^retrieved no-memoryvia the existingvalid_episodecheck.Off by default — zero behavior change until explicitly enabled.
Parameters
consolidateconsolidate-intervalconsolidate-thresholdconsolidate-evict-ageAlgorithm
_nowtableconsolidate-thresholdepisodesepmem_consolidatedtracking table prevents repeated writesconsolidate-intervalepisodesThe compose+test scan is O(n) in active WMEs per consolidation run. Casteigts et al. prove this is optimal for any parameter computable through their framework.
Motivation
Derbinsky & Laird (2013) proved forgetting is essential to Soar's scaling but only built it for working and procedural memory. Episodic and semantic memory have no eviction and no capacity bound. The root cause (Diagnosis: Soar): you can only safely forget what you can reconstruct (R4), and semantic memory — the reconstruction target — doesn't learn automatically.
This patch addresses both halves:
With these in place:
Changes
episodic_memory.hepisodic_memory.cppepmem_consolidate()with eviction (~200 lines), hook inepmem_go()EpMemFunctionalTests.hppEpMemFunctionalTests.cpp.soartest agentsTests
46/46 epmem tests pass (43 existing + 3 new), zero regressions:
testConsolidation— stable WMEs written to smem after consolidation firestestConsolidationOff— smem stays empty when feature is disabledtestConsolidationEviction— old episodes evicted, recent episodes preserved, smem entries intactKnown limitations (deferred)
_nowintervals preserved — active WME intervals are never split; only completed ranges and points are evictedReference
See also: #577 — RL convergence gate for chunking (prescription step 4)