Affective State¶
emotional_memory.state.AffectiveState
¶
Bases: BaseModel
Snapshot of the system's complete affective state at a point in time.
Immutable: the model fields are frozen (update() returns a new instance).
The private _history list is still assignable during construction (frozen
blocks field mutation, not private-attribute setup).
initial() -> AffectiveState
classmethod
¶
restore(data: dict[str, Any]) -> AffectiveState
classmethod
¶
Reconstruct an AffectiveState from a snapshot dict.
Restores the private momentum history that Pydantic excludes from
normal serialisation, so that the next update() call produces
correct momentum derivatives.
Source code in src/emotional_memory/state.py
snapshot() -> dict[str, Any]
¶
Serialise to a dict including the private momentum history.
Suitable for JSON persistence and later restoration via
AffectiveState.restore(). Pydantic's normal serialisation
excludes _history; this method adds it back.
Source code in src/emotional_memory/state.py
update(new_affect: CoreAffect, now: datetime | None = None, mood_alpha: float = 0.1, mood_decay: MoodDecayConfig | None = None) -> AffectiveState
¶
Return a new AffectiveState reflecting the updated affect.
Momentum is computed from finite differences over the last 3 history points (velocity = Δaffect, acceleration = Δvelocity).