Class MemoryEntry

java.lang.Object
com.tnsai.memory.strategy.MemoryEntry

public final class MemoryEntry extends Object
A single memory entry with tier, strength, provenance, and versioning.

Provenance fields track where a memory came from (source session, agent) and its version chain (supersedes/superseded-by). Stale memories are flagged when their source is invalidated via cascading staleness.

  • Constructor Details

  • Method Details

    • recordAccess

      public void recordAccess()
      Record an access — reinforces strength (Ebbinghaus spacing effect).
    • applyDecay

      public double applyDecay(double hoursElapsed)
      Apply time-based decay. Returns new strength.
    • promote

      public void promote()
      Promote to next tier.
    • withProvenance

      public MemoryEntry withProvenance(String sessionId, String agentId)
    • withConfidence

      public MemoryEntry withConfidence(double confidence)
    • markSupersededBy

      public void markSupersededBy(String newEntryId)
      Marks this entry as superseded by a newer entry. The superseded entry is flagged stale and its strength is halved.
    • setSupersedes

      public void setSupersedes(String oldEntryId)
      Records that this entry supersedes an older entry.
    • markStale

      public void markStale(String reason)
      Marks this entry as stale with a reason. Reduces confidence and strength.
    • clearStale

      public void clearStale()
      Clears the stale flag (e.g., after re-validation).
    • id

      public String id()
    • content

      public String content()
    • tier

      public MemoryTier tier()
    • strength

      public double strength()
    • createdAt

      public Instant createdAt()
    • lastAccessedAt

      public Instant lastAccessedAt()
    • accessCount

      public int accessCount()
    • sourceSessionId

      public String sourceSessionId()
    • sourceAgentId

      public String sourceAgentId()
    • confidence

      public double confidence()
    • supersedes

      public String supersedes()
    • supersededBy

      public String supersededBy()
    • supersededAt

      public Instant supersededAt()
    • isStale

      public boolean isStale()
    • staleReason

      public String staleReason()
    • isSuperseded

      public boolean isSuperseded()
    • isActive

      public boolean isActive()
    • isWeak

      public boolean isWeak()
      Whether this entry should be considered for eviction.
    • isPromotable

      public boolean isPromotable(double threshold)
      Whether this entry is strong enough for promotion.
    • toString

      public String toString()
      Overrides:
      toString in class Object