HMX-E: Event Specification

Protocol: Hippocortex Memory Protocol (HMX)
Component: HMX-E (Events)
Version: HMX-1.0
Status: Stable


1. Overview

An HMX Event is the atomic unit of observable information in the Hippocortex memory system. Every interaction, observation, decision, or state change captured by an agent is represented as an event. Events are the raw inputs from which all higher-order memory structures (artifacts, fingerprints, context packs) are derived.

HMX Events are designed for:

  • Streaming ingestion at high throughput (millions of events per tenant)
  • Deterministic ordering via monotonic timestamps + sequence numbers
  • Cross-system correlation via trace and correlation IDs
  • Language-agnostic serialization as JSON

Relationship to Hippocortex Architecture

HMX Events wrap and standardize the existing EpisodeTrace type from @hippocortex/types. An EpisodeTrace is the internal representation; an HMX Event is the wire-format protocol envelope. Any valid EpisodeTrace can be projected into an HMX Event, and any valid HMX Event can be ingested into the EpisodeTrace pipeline.


2. Event Structure

2.1 Required Fields

FieldTypeDescription
hmx_versionstringProtocol version (e.g., "HMX-1.0")
event_idstringGlobally unique event identifier (UUIDv7 recommended)
event_typestringEvent type discriminator (see §3)
agent_idstringIdentifier of the agent that produced this event
tenant_idstringTenant scope for multi-tenancy isolation
session_idstringSession this event belongs to
timestampstringISO 8601 datetime with timezone (e.g., "2026-03-14T03:00:00.000Z")
sequenceintegerMonotonically increasing sequence number within a session (≥ 0)
contentobjectEvent payload (structure varies by event_type, see §4)
metadataobjectExtensible key-value metadata bag

2.2 Optional Fields

FieldTypeDescription
trace_idstringDistributed tracing ID for cross-service correlation
correlation_idstringCorrelation ID linking related events (e.g., request → response)
parent_event_idstringID of the causally preceding event
embeddingsnumber[]Pre-computed embedding vector for semantic search
saliencenumberNovelty/utility score in [0.0, 1.0]
sourcestringOrigin system or component (e.g., "claude-agent", "tool:gh")
provenance_refstringReference to raw evidence (message ID, file path, etc.)
tagsstring[]Categorization tags for filtering
ttl_secondsintegerTime-to-live hint for retention policies (≥ 0)

3. Event Types

HMX-1.0 defines the following event types. Implementations MUST accept all standard types and SHOULD pass through unknown types without error (forward compatibility).

Event TypeDescriptionMaps to EpisodeTrace
messageUser or agent messagemessage
tool_callAgent invokes a tooltool_call
tool_resultTool returns a resulttool_result
file_editFile creation or modificationfile_edit
test_runTest execution and resultstest_run
command_execShell command executioncommand_exec
browser_actionBrowser automation actionbrowser_action
api_resultExternal API call resultapi_result
decisionAgent makes a decisiondecision
errorError or exceptionerror
observationPassive observation (no action)(extension)
state_changeInternal state transition(extension)
feedbackUser feedback signal(extension)

Custom event types MUST use a namespaced format: x-{vendor}-{type} (e.g., x-acme-custom_signal).


4. Content Structure

The content field is a JSON object whose schema depends on event_type. The following are normative content schemas for standard event types.

4.1 message

{
  "role": "user" | "assistant" | "system",
  "text": "string",
  "attachments": [{ "type": "string", "url": "string" }]
}

4.2 tool_call

{
  "tool_name": "string",
  "arguments": {},
  "call_id": "string"
}

4.3 tool_result

{
  "tool_name": "string",
  "call_id": "string",
  "result": {},
  "success": true | false,
  "duration_ms": 0
}

4.4 decision

{
  "question": "string",
  "chosen_option": "string",
  "alternatives": ["string"],
  "reasoning": "string",
  "confidence": 0.0
}

4.5 error

{
  "error_type": "string",
  "message": "string",
  "stack": "string",
  "recoverable": true | false
}

4.6 feedback

{
  "signal": "positive" | "negative" | "correction",
  "target_event_id": "string",
  "comment": "string"
}

Implementations SHOULD validate content structure but MUST NOT reject events with unknown content fields (extensibility).


5. JSON Schema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hippocortex.dev/schemas/hmx-1.0/event.json",
  "title": "HMX Event",
  "type": "object",
  "required": [
    "hmx_version",
    "event_id",
    "event_type",
    "agent_id",
    "tenant_id",
    "session_id",
    "timestamp",
    "sequence",
    "content",
    "metadata"
  ],
  "properties": {
    "hmx_version": {
      "type": "string",
      "pattern": "^HMX-\\d+\\.\\d+$"
    },
    "event_id": {
      "type": "string",
      "minLength": 1
    },
    "event_type": {
      "type": "string",
      "minLength": 1
    },
    "agent_id": {
      "type": "string",
      "minLength": 1
    },
    "tenant_id": {
      "type": "string",
      "minLength": 1
    },
    "session_id": {
      "type": "string",
      "minLength": 1
    },
    "timestamp": {
      "type": "string",
      "format": "date-time"
    },
    "sequence": {
      "type": "integer",
      "minimum": 0
    },
    "content": {
      "type": "object"
    },
    "metadata": {
      "type": "object"
    },
    "trace_id": {
      "type": "string"
    },
    "correlation_id": {
      "type": "string"
    },
    "parent_event_id": {
      "type": "string"
    },
    "embeddings": {
      "type": "array",
      "items": { "type": "number" }
    },
    "salience": {
      "type": "number",
      "minimum": 0.0,
      "maximum": 1.0
    },
    "source": {
      "type": "string"
    },
    "provenance_ref": {
      "type": "string"
    },
    "tags": {
      "type": "array",
      "items": { "type": "string" }
    },
    "ttl_seconds": {
      "type": "integer",
      "minimum": 0
    }
  },
  "additionalProperties": false
}

6. Validation Rules

  1. hmx_version MUST match pattern HMX-\d+\.\d+
  2. event_id MUST be a non-empty string; UUIDv7 is RECOMMENDED for sortability
  3. timestamp MUST be valid ISO 8601 with timezone designator
  4. sequence MUST be a non-negative integer; MUST be monotonically increasing within a session
  5. salience (if present) MUST be in [0.0, 1.0]
  6. embeddings (if present) MUST be a non-empty array of finite numbers
  7. content MUST be a JSON object (not null, not array)
  8. metadata MUST be a JSON object (not null, not array)
  9. tags (if present) MUST be an array of strings
  10. ttl_seconds (if present) MUST be a non-negative integer

7. Ordering Guarantees

HMX Events support deterministic ordering via the following composite key:

ORDER BY (tenant_id, session_id, sequence ASC, timestamp ASC)
  • Within a session: sequence provides total order. Ties are broken by timestamp.
  • Across sessions: No global ordering is guaranteed. Consumers MUST handle out-of-order cross-session events.
  • Streaming: Events MAY arrive out of order. Consumers SHOULD buffer and reorder within a configurable window (default: 5 seconds).

8. Streaming Compatibility

HMX Events are designed for streaming ingestion:

  • NDJSON (newline-delimited JSON): One event per line
  • Server-Sent Events (SSE): Each event as an SSE data field
  • Message queues: Each event as a single message (Kafka, NATS, Redis Streams)
  • WebSocket: Each event as a single frame

Events MUST be self-contained (no references to previous events required for validation).


9. Example Events

User Message

{
  "hmx_version": "HMX-1.0",
  "event_id": "019e5a3b-7c4d-7000-8000-000000000001",
  "event_type": "message",
  "agent_id": "agent-claude-001",
  "tenant_id": "tenant-acme",
  "session_id": "session-2026-03-14-001",
  "timestamp": "2026-03-14T03:00:00.000Z",
  "sequence": 0,
  "content": {
    "role": "user",
    "text": "Deploy the staging environment",
    "attachments": []
  },
  "metadata": {
    "channel": "slack",
    "user_id": "U12345"
  },
  "source": "user",
  "salience": 0.7,
  "tags": ["deployment", "staging"]
}

Tool Call

{
  "hmx_version": "HMX-1.0",
  "event_id": "019e5a3b-7c4d-7000-8000-000000000002",
  "event_type": "tool_call",
  "agent_id": "agent-claude-001",
  "tenant_id": "tenant-acme",
  "session_id": "session-2026-03-14-001",
  "timestamp": "2026-03-14T03:00:01.500Z",
  "sequence": 1,
  "content": {
    "tool_name": "exec",
    "arguments": { "command": "kubectl apply -f staging.yaml" },
    "call_id": "call-001"
  },
  "metadata": {},
  "trace_id": "trace-deploy-staging",
  "correlation_id": "019e5a3b-7c4d-7000-8000-000000000001",
  "parent_event_id": "019e5a3b-7c4d-7000-8000-000000000001",
  "source": "claude-agent",
  "salience": 0.8
}

Error Event

{
  "hmx_version": "HMX-1.0",
  "event_id": "019e5a3b-7c4d-7000-8000-000000000003",
  "event_type": "error",
  "agent_id": "agent-claude-001",
  "tenant_id": "tenant-acme",
  "session_id": "session-2026-03-14-001",
  "timestamp": "2026-03-14T03:00:05.000Z",
  "sequence": 2,
  "content": {
    "error_type": "KubectlError",
    "message": "namespace staging not found",
    "stack": "",
    "recoverable": true
  },
  "metadata": { "exit_code": 1 },
  "trace_id": "trace-deploy-staging",
  "correlation_id": "019e5a3b-7c4d-7000-8000-000000000002",
  "source": "tool:kubectl",
  "salience": 0.9,
  "tags": ["error", "kubernetes"]
}

10. EpisodeTrace Mapping

HMX Event FieldEpisodeTrace FieldNotes
event_ididDirect mapping
event_typeeventTypeSame enum values
session_idsessionIdDirect mapping
timestamptimestampSame format
contentpayloadRenamed for clarity
saliencesalienceScoreDirect mapping
sourcesourceDirect mapping
provenance_refprovenanceRefDirect mapping
metadatametadataDirect mapping
agent_id(via metadata)Promoted to top-level
tenant_id(via metadata)Promoted to top-level
sequence(new)Added for deterministic ordering
hmx_version(new)Protocol envelope field

11. Size Constraints

  • Maximum event size: 1 MB (JSON serialized)
  • Maximum content size: 512 KB
  • Maximum embeddings length: 4096 dimensions
  • Maximum tags count: 64
  • Maximum metadata size: 64 KB

Implementations SHOULD reject events exceeding these limits with a clear error.