syntax = "proto3";

package orka.memory;

// Match types for memory retrieval
enum MatchType {
  SEMANTIC = 0;
  EXACT = 1;
  FUZZY = 2;
  STREAM = 3;
  HYBRID = 4;
}

// Metadata associated with a memory entry
message MemoryMetadata {
  string source = 1;                    // Source of the memory (e.g., validation-guard)
  double confidence = 2;                // Confidence score (0.0 to 1.0)
  optional string reason = 3;           // Optional reason or explanation
  optional string fact = 4;             // Extracted fact or insight
  double timestamp = 5;                 // Unix timestamp when created
  string agent_id = 6;                  // ID of the agent that created this memory
  optional string query = 7;            // Original query that led to this memory
  repeated string tags = 8;             // Tags for categorization
  repeated double vector_embedding = 9; // Optional vector embedding for semantic search
  optional string category = 10;        // Category for memory separation (log, stored, etc.)
}

// Main memory entry record
message MemoryEntry {
  string id = 1;                        // Unique identifier for the memory entry
  string content = 2;                   // The actual content/text of the memory
  MemoryMetadata metadata = 3;          // Metadata associated with the memory entry
  optional double similarity = 4;       // Similarity score when retrieved from search
  int64 ts = 5;                        // Timestamp in nanoseconds
  MatchType match_type = 6;            // Type of match when retrieved
  string stream_key = 7;               // Stream/topic key for partitioning
}

// Memory operations for Kafka messages
message MemoryOperation {
  enum OperationType {
    CREATE = 0;
    UPDATE = 1;
    DELETE = 2;
    SEARCH = 3;
  }
  
  OperationType operation = 1;
  MemoryEntry entry = 2;
  optional string search_query = 3;     // For search operations
  optional int32 limit = 4;             // For search result limits
} 