Class PostgresRepresentationStore
- All Implemented Interfaces:
at.aimon.core.memory.RepresentationStore
RepresentationStore per design §5.3 / §5.5.
Representations are append-only. save(at.aimon.core.memory.Representation) always inserts a new row in
mem_representation; the typed columns (subject_*,
observer_*, session_id, generated_at) drive the two
indexes that satisfy findLatestGlobal(at.aimon.core.memory.PeerView) and findLatestLocal(at.aimon.core.memory.PeerView, at.aimon.core.memory.PeerView, java.lang.String),
while a self-contained JSONB snapshot (encoded by
RepresentationRowCodec) lives in payload_blob and is the
single source of truth for hydration. Storing the full snapshot in JSONB
preserves immutability across later observation deletions: a representation
captures "what we knew at time T", and that capture must not be silently
mutated when the underlying observations are later GC'd.
The observation_local_ids JSONB column is written for cross-table
audits / housekeeping queries (e.g. "which representations referenced this
observation?") but is not required for read-side hydration.
-
Constructor Summary
ConstructorsConstructorDescriptionPostgresRepresentationStore(DataSource dataSource, com.fasterxml.jackson.databind.ObjectMapper mapper) -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteOlderThan(at.aimon.core.memory.Workspace workspace, Instant cutoff) Optional<at.aimon.core.memory.Representation>findLatestGlobal(at.aimon.core.memory.PeerView subject) Optional<at.aimon.core.memory.Representation>findLatestLocal(at.aimon.core.memory.PeerView subject, at.aimon.core.memory.PeerView observer, String sessionId) at.aimon.core.memory.Representationsave(at.aimon.core.memory.Representation representation)
-
Constructor Details
-
PostgresRepresentationStore
public PostgresRepresentationStore(DataSource dataSource, com.fasterxml.jackson.databind.ObjectMapper mapper)
-
-
Method Details
-
save
public at.aimon.core.memory.Representation save(at.aimon.core.memory.Representation representation) - Specified by:
savein interfaceat.aimon.core.memory.RepresentationStore
-
findLatestGlobal
public Optional<at.aimon.core.memory.Representation> findLatestGlobal(at.aimon.core.memory.PeerView subject) - Specified by:
findLatestGlobalin interfaceat.aimon.core.memory.RepresentationStore
-
findLatestLocal
public Optional<at.aimon.core.memory.Representation> findLatestLocal(at.aimon.core.memory.PeerView subject, at.aimon.core.memory.PeerView observer, String sessionId) - Specified by:
findLatestLocalin interfaceat.aimon.core.memory.RepresentationStore
-
deleteOlderThan
- Specified by:
deleteOlderThanin interfaceat.aimon.core.memory.RepresentationStore
-