Package com.tnsai.memory.strategy
Class MemoryEntry
java.lang.Object
com.tnsai.memory.strategy.MemoryEntry
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintdoubleapplyDecay(double hoursElapsed) Apply time-based decay.voidClears the stale flag (e.g., after re-validation).doublecontent()id()booleanisActive()booleanisPromotable(double threshold) Whether this entry is strong enough for promotion.booleanisStale()booleanbooleanisWeak()Whether this entry should be considered for eviction.voidMarks this entry as stale with a reason.voidmarkSupersededBy(String newEntryId) Marks this entry as superseded by a newer entry.voidpromote()Promote to next tier.voidRecord an access — reinforces strength (Ebbinghaus spacing effect).voidsetSupersedes(String oldEntryId) Records that this entry supersedes an older entry.doublestrength()tier()toString()withConfidence(double confidence) withProvenance(String sessionId, String agentId)
-
Constructor Details
-
MemoryEntry
-
-
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
-
withConfidence
-
markSupersededBy
Marks this entry as superseded by a newer entry. The superseded entry is flagged stale and its strength is halved. -
setSupersedes
Records that this entry supersedes an older entry. -
markStale
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
-
content
-
tier
-
strength
public double strength() -
createdAt
-
lastAccessedAt
-
accessCount
public int accessCount() -
sourceSessionId
-
sourceAgentId
-
confidence
public double confidence() -
supersedes
-
supersededBy
-
supersededAt
-
isStale
public boolean isStale() -
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
-