Class PostgresObservationStore
- All Implemented Interfaces:
at.aimon.core.memory.ObservationStore
ObservationStore implementing the metadata side of the C3 split (design doc §5.2).
Search (semanticSearch) is intentionally not implemented here: vector search is delegated to the
KnowledgeStore via an ObservationIndex so the memory layer does not build a parallel RAG stack.
Callers needing semantic search should compose this store with another one that owns indexing — calling
semanticSearch(at.aimon.core.memory.PeerView, java.lang.String, int) directly throws UnsupportedOperationException.
Every write to mem_observation is paired with an outbox row in mem_outbox written inside the same
JDBC transaction (design §5.2 outbox). A separate worker drains the outbox and pushes embeddings to the
KnowledgeStore, giving us at-least-once delivery without a 2PC across heterogeneous backends.
merge(ObservationId, ObservationId, Observation) performs a soft-delete on the loser
(sets soft_deleted_at = now()), keeping it for the 30-day audit window described in §5.2.
delete(ObservationId) is a hard delete because the audit retention belongs to merge(), not to
arbitrary deletes.
Wraps SQLException as AimonException (the project-wide pattern, see
at.aimon.session.base.exception.IdempotencyStoreException).
-
Constructor Summary
ConstructorsConstructorDescriptionPostgresObservationStore(DataSource dataSource, com.fasterxml.jackson.databind.ObjectMapper mapper) Creates a new store. -
Method Summary
Modifier and TypeMethodDescriptionlongcount(at.aimon.core.memory.PeerView subject) voiddelete(at.aimon.core.memory.ObservationId id) List<at.aimon.core.memory.Observation>findByConfidenceBelow(at.aimon.core.memory.PeerView subject, double threshold, int limit) Optional<at.aimon.core.memory.Observation>findById(at.aimon.core.memory.ObservationId id) List<at.aimon.core.memory.Observation>findBySubject(at.aimon.core.memory.PeerView subject, int limit) List<at.aimon.core.memory.PeerView>findSubjects(at.aimon.core.memory.Workspace workspace, int limit) at.aimon.core.memory.Observationmerge(at.aimon.core.memory.ObservationId winner, at.aimon.core.memory.ObservationId loser, at.aimon.core.memory.Observation merged) at.aimon.core.memory.Observationsave(at.aimon.core.memory.Observation observation) List<at.aimon.core.memory.Observation>semanticSearch(at.aimon.core.memory.PeerView subject, String query, int topK) Always throwsUnsupportedOperationException.
-
Constructor Details
-
PostgresObservationStore
public PostgresObservationStore(DataSource dataSource, com.fasterxml.jackson.databind.ObjectMapper mapper) Creates a new store.- Parameters:
dataSource- JDBC pool against the Postgres schema indb/postgres/V1__init.sql; must not be nullmapper- Jackson mapper used forsource_message_idsandmetadatajsonb columns; injected so multi-instance configs can control Jackson features (e.g., FAIL_ON_UNKNOWN_PROPERTIES)- Throws:
NullPointerException- if any argument is null
-
-
Method Details
-
save
public at.aimon.core.memory.Observation save(at.aimon.core.memory.Observation observation) - Specified by:
savein interfaceat.aimon.core.memory.ObservationStore
-
findById
- Specified by:
findByIdin interfaceat.aimon.core.memory.ObservationStore
-
findBySubject
public List<at.aimon.core.memory.Observation> findBySubject(at.aimon.core.memory.PeerView subject, int limit) - Specified by:
findBySubjectin interfaceat.aimon.core.memory.ObservationStore
-
count
public long count(at.aimon.core.memory.PeerView subject) - Specified by:
countin interfaceat.aimon.core.memory.ObservationStore
-
semanticSearch
public List<at.aimon.core.memory.Observation> semanticSearch(at.aimon.core.memory.PeerView subject, String query, int topK) Always throwsUnsupportedOperationException.Per design §5.2 (review C3) the metadata store and the search index are split: vector search lives in the
KnowledgeStorevia anObservationIndex. To get semantic search, wrap this store in anotherObservationStorethat owns indexing (the in-memory reference does this withInMemoryObservationIndex).- Specified by:
semanticSearchin interfaceat.aimon.core.memory.ObservationStore
-
findByConfidenceBelow
public List<at.aimon.core.memory.Observation> findByConfidenceBelow(at.aimon.core.memory.PeerView subject, double threshold, int limit) - Specified by:
findByConfidenceBelowin interfaceat.aimon.core.memory.ObservationStore
-
findSubjects
public List<at.aimon.core.memory.PeerView> findSubjects(at.aimon.core.memory.Workspace workspace, int limit) - Specified by:
findSubjectsin interfaceat.aimon.core.memory.ObservationStore
-
delete
public void delete(at.aimon.core.memory.ObservationId id) - Specified by:
deletein interfaceat.aimon.core.memory.ObservationStore
-
merge
public at.aimon.core.memory.Observation merge(at.aimon.core.memory.ObservationId winner, at.aimon.core.memory.ObservationId loser, at.aimon.core.memory.Observation merged) - Specified by:
mergein interfaceat.aimon.core.memory.ObservationStore
-