Class RepresentationRowCodec

java.lang.Object
at.aimon.memory.postgres.internal.RepresentationRowCodec

public final class RepresentationRowCodec extends Object
Jackson codec for the mem_representation.payload_blob JSONB column.

The payload carries a self-contained snapshot of the Representation so that a row can be hydrated without joining against mem_observation. That immutability is deliberate: a representation is an append-only snapshot of "what we knew about this subject at time T", and must survive the later deletion of any underlying observation.

JSON shape (version 1)


 {
   "version": 1,
   "subject":  { "workspaceId": "ws", "principalType": "USER",
                 "principalId": "alice", "principalDisplayName": "Alice" },
   "observer": null | { ...same shape... },
   "sessionId": "s-1" | null,
   "summary":  "...",
   "tokenCount": 123,
   "generatedAt": "2026-04-28T10:00:00Z",
   "observations": [
     {
       "workspaceId": "ws",
       "localId":     "obs-1",
       "subject":  { ...peer... },
       "observer": { ...peer... },
       "content":  "...",
       "type":     "EXPLICIT",
       "sourceMessageIds": ["m1", "m2"],
       "createdAt": "...",
       "confidence": 0.7,
       "metadata":  { "k": "v" }
     }
   ]
 }
 
  • Field Details

    • SCHEMA_VERSION

      public static final int SCHEMA_VERSION
      Current payload schema version. Bump when the JSON shape changes.
      See Also:
  • Constructor Details

    • RepresentationRowCodec

      public RepresentationRowCodec(com.fasterxml.jackson.databind.ObjectMapper mapper)
  • Method Details

    • encode

      public String encode(at.aimon.core.memory.Representation representation)
    • decode

      public at.aimon.core.memory.Representation decode(String json)