Architecture: Message Catalog
The Problem
When contexts communicate through messages, every message is a contract. Unnamed messages drift. Untyped messages corrupt. Undocumented messages become mysteries that only the original author understands — and then they leave.
This page names every message. Types it. Says who produces it, who consumes it, and what it carries.
Diagram Conventions
These conventions apply to all sequence diagrams on this page.
Arrow Types
| Arrow | Meaning |
|---|---|
Solid, filled (→) |
Command or Query — transactional, expects response |
Dashed, filled (⇢) |
Response — return in transaction chain |
Solid, open (↝) |
Event — fire-and-forget, async, no response |
Naming
External arrows (Mind ↔ Cortex) use snake_case: store_memory_command, store_memory_response.
Internal arrows (Cortex ↔ bounded contexts) use CamelCase: MemoryStoreCommand, MemoryStoreResponse.
Cortex translates at the boundary. The ACL is visible in every diagram.
Payloads
Command responses return the same payload enriched with ID, metadata, and timestamps.
Query responses are a separate type — they may return collections, empty results, or errors.
Event Source
Publishers emit to a named event source (topic). Subscribers listen. The publisher does not know its consumers.
Retry
When a response does not arrive within timeout, the emitter retries per a named policy shown in the diagram.
TransactionContext
Every domain message carries a TransactionContext — six fields that form a chain of custody through the system. sessionId, requestId, messageId, causationId, timestamp, sourceContext. Zero nullable. When a bounded context receives a message and produces a new one, the new message gets the same sessionId and requestId, a fresh messageId, and the incoming message’s messageId as its causationId. This reconstructs the full causal tree of any request.
Every bounded context that touches a message records a touch — even if it produces no outbound message. The trace must show the complete causal tree, including terminal leaves.
Full specification: Design F: TransactionContext.
Message Flows
Seven flows cover the core operations. Each shows the full path through the domain. The participant labeled "Mind" is conscience-universal — it could be Claude, a human with a UI, or any future conscious system.
Store Memory
A mind stores a new memory. The memory gets persisted, scored, and connected to related memories.
Diagram 4: MSG-0001 -- Store Memory
sequenceDiagram
participant M as Mind
participant CX as Cortex
participant HP as Hippocampus
participant ES as Memory
Event Store
participant SL as Salience
participant SY as Synapse
activate M
critical OnInit
SL ->> ES: Memory Event Subscribe
SY ->> ES: Memory Event Subscribe
end
Note over M,SY: TransactionContext: every internal message carries
sessionId, requestId, messageId, causationId,
timestamp, sourceContext. See Design F.
Note over M,HP: Transaction
M->>CX: store_memory command
activate CX
Note right of M: content: String
metadata: Map
suggested_tier: Tier
CX->>HP: Command: Store Memory
activate HP
Note left of HP: data class MemoryStoreCommand
HP->>HP: Validate, assign tier, persist
HP-->>CX: Command Response: Memory Stored
Note left of HP: data class MemoryStoreCommand
memory_id: UUID
content: String
metadata: Map
tier: Tier
timestamp: Instant
CX-->>M: store_memory response
deactivate CX
Note over HP,SY: Broadcast (async)
Note right of HP: tx propagation:
same sessionId, requestId
new messageId
causationId = command messageId
HP-)ES: publish MemoryStoredEvent
deactivate HP
activate ES
par Salience consumes events
ES--)SL: consume MemoryStoredEvent
activate SL
and Synapse consumes events
ES--)SY: consume MemoryStoredEvent
activate SY
end
deactivate ES
par Salience operates Ranking
SL->>SL: Compute initial salience
deactivate SL
and Synapse operates Relation
SY->>SY: Create associations
deactivate SY
end
opt No response within timeout
M->>CX: store_memory command
Note right of M: Same requestId
Policy: at-most-once
end
deactivate M
Search Memory
A mind searches for memories. Results come back ranked by salience score, with association-activated memories included.
Diagram 5: MSG-0002 -- Search Memory
sequenceDiagram
participant M as Mind
participant CX as Cortex
participant RC as Recall
participant HP as Hippocampus
participant MES as Memory
Event Store
participant SL as Salience
participant SY as Synapse
activate M
critical OnInit
SL ->> MES: Memory Event Subscribe
end
Note over M,SY: All internal messages carry TransactionContext (Design F)
Note over M,RC: Transaction (Query)
M->>CX: search_memory request
activate CX
Note right of M: query: String
filters: Map
max_results: Int
CX->>RC: Query: Find Memories
activate RC
Note left of RC: data class MemorySearchRequest
RC->>HP: Query: Match Memories
activate HP
Note left of HP: data class MemoryMatchRequest
HP-->>RC: Query Response: Matched Memories
Note left of HP: data class MemoryMatchResponse
memories: Set of Memory
Note over HP,SL: Broadcast (async)
HP-)MES: publish MemoryAccessedEvent
deactivate HP
activate MES
MES--)SL: consume MemoryAccessedEvent
deactivate MES
activate SL
SL->>SL: Update memory salience
deactivate SL
RC->>RC: Rank by salience (local cache)
RC->>SY: Query: Find Associations
activate SY
Note right of RC: data class AssociationFindRequest
SY-->>RC: Query Response: Associations
deactivate SY
Note left of SY: data class AssociationResponse
associations: Set of Association
RC->>RC: Assemble ranked results
RC-->>CX: Query Response: Search Results
Note left of RC: data class MemorySearchResponse
results: List of RankedMemory
CX-->>M: search_memory response
deactivate CX
deactivate RC
Note over M: Mind evaluates results
Note over M,CX: Important: The decision to recollect
is mind-adapter-specific.
Humans: prefrontal cortex (native), or UI.
LLMs: forced prompt (passive by nature),
different per model (Claude, GPT, etc.).
Core provides the port. Adapter decides how.
opt Total Recall is Advisable
M->>CX: total_recall_advisory
activate CX
CX-)MES: publish TotalRecallAdvisoryEvent
deactivate CX
Note right of CX: See MSG-0007
end
opt No response within timeout
M->>CX: search_memory request
Note right of M: Same requestId
Policy: at-most-once
end
deactivate M
Claim Memory
A mind claims a memory — actively reinforcing it. This boosts its salience score and makes it resist decay.
Diagram 6: MSG-0003 -- Claim Memory
sequenceDiagram
participant M as Mind
participant CX as Cortex
participant HP as Hippocampus
participant ES as Memory
Event Store
participant SL as Salience
participant SY as Synapse
activate M
critical OnInit
SL ->> ES: Memory Event Subscribe
SY ->> ES: Memory Event Subscribe
end
Note over M,SY: All internal messages carry TransactionContext (Design F)
Note over M,HP: Transaction
M->>CX: claim_memory command
activate CX
Note right of M: memory_id: UUID
CX->>HP: Command: Claim Memory
activate HP
Note left of HP: data class ClaimCommand
HP->>HP: Mark as claimed, update metadata
HP-->>CX: Command Response: Memory Claimed
Note left of HP: data class ClaimCommand
memory_id: UUID
claim_timestamp: Instant
CX-->>M: claim_memory response
deactivate CX
Note over HP,SY: Broadcast (async)
HP-)ES: publish MemoryClaimedEvent
deactivate HP
activate ES
par Salience consumes events
ES--)SL: consume MemoryClaimedEvent
activate SL
and Synapse consumes events
ES--)SY: consume MemoryClaimedEvent
activate SY
end
deactivate ES
par Salience operates Ranking
SL->>SL: Boost score, mark decay-resistant
deactivate SL
and Synapse operates Relation
SY->>SY: Strengthen associations
deactivate SY
end
opt No response within timeout
M->>CX: claim_memory command
Note right of M: Same requestId
Policy: at-most-once
end
deactivate M
Decay Sweep
The Subconscious triggers a periodic decay sweep. Salience recalculates scores. Memories that fall below tier thresholds get demoted.
Diagram 7: MSG-0004 -- Decay Sweep
sequenceDiagram
participant SB as Subconscious
participant SL as Salience
participant ES as Memory
Event Store
participant HP as Hippocampus
critical OnInit
HP ->> ES: Memory Event Subscribe
end
Note over SB,HP: All internal messages carry TransactionContext (Design F)
Note over SB: Timer-driven (no Mind involved)
SB->>SL: Command: Decay Sweep
activate SL
Note left of SL: data class DecaySweep
timestamp: Instant
scope: Tier or All
SL->>SL: Recalculate all scores (time decay)
SL->>SL: Identify memories below tier thresholds
loop Each memory below threshold
SL-)ES: publish TierDemotedEvent
Note right of SL: memory_id, new_tier, score
end
SL-->>SB: Command Response: Sweep Complete
Note left of SL: data class DecaySweep
+ memoriesEvaluated: Int
+ demotions: Int
deactivate SL
activate ES
loop Each TierDemotedEvent
ES--)HP: consume TierDemotedEvent
end
deactivate ES
activate HP
HP->>HP: Move memories to lower tiers
deactivate HP
Session Lifecycle
A mind connects and disconnects. On connect, Cortex loads identity and last session state. On disconnect, the Subconscious triggers a session audit through the Notification Port.
Diagram 8: MSG-0005 -- Session Lifecycle
sequenceDiagram
participant M as Mind
participant CX as Cortex
participant HP as Hippocampus
participant SL as Salience
participant SB as Subconscious
participant NES as Notification
Event Store
participant NP as NotificationPort
critical OnInit
NP ->> NES: Notification Subscribe
end
Note over M,NP: All internal messages carry TransactionContext (Design F)
Note over M,SB: Session Connect
M->>CX: session_start
activate CX
Note right of M: instance_id: String
mind_type: String
CX->>HP: Query: Load Identity Config
activate HP
HP-->>CX: Query Response: IDENTITY_CORE memories
deactivate HP
CX->>SL: Distribute thresholds
CX->>SB: SessionStart event
activate SB
SB->>SB: Begin session tracking
deactivate SB
CX-->>M: session_start response
Note left of CX: Welcome back. Here is your context.
deactivate CX
Note over M,NP: ... session activity ...
Note over M,SB: Session Disconnect
M->>CX: session_end
activate CX
Note right of M: instance_id: String
reason: explicit, timeout, or crash
CX->>SB: SessionEnd event
activate SB
CX-->>M: session_end response
deactivate CX
SB-)NES: publish SessionAuditPrompt
deactivate SB
activate NES
NES--)NP: consume SessionAuditPrompt
deactivate NES
activate NP
NP-)M: What do you refuse to lose?
deactivate NP
Note left of NP: Unsolicited prompt
pushed to Mind
Note over M: Mind evaluates session
Note over M,CX: Important: What the mind does
with this prompt is adapter-specific.
Claude: store_memory via hook.
Human: UI interaction.
The claiming decision is the mind's own.
opt Mind claims memories
M->>CX: store_memory command
Note right of M: See MSG-0001
end
Reflect (Dreaming)
The mind initiates a retrospection cycle. Total Recall surfaces memories for review — by time span, staleness, weak associations. The mind makes semantic judgments and sends back new associations and reclassifications. This is not a single tool call — it’s a conversation between the mind and its memory.
This operation requires the same mind. A different mind classifying your memories would impose its understanding of the connections, not yours.
Diagram 9: MSG-0006 -- Reflect (Dreaming)
sequenceDiagram
participant M as Mind
participant CX as Cortex
participant RC as Recall
participant HP as Hippocampus
participant ES as Memory
Event Store
participant SL as Salience
participant SY as Synapse
activate M
critical OnInit
SL ->> ES: Memory Event Subscribe
SY ->> ES: Memory Event Subscribe
end
Note over M,SY: All internal messages carry TransactionContext (Design F)
Note over M,RC: Transaction (Query)
M->>CX: reflect request
activate CX
Note right of M: criteria: staleness, time span,
weak associations
scope: Tier or All
CX->>RC: Query: Reflect
activate RC
Note left of RC: data class ReflectQuery
RC->>HP: Query: Find Candidates
activate HP
HP-->>RC: Query Response: Candidate Memories
deactivate HP
RC->>SY: Query: Find Weak Associations
activate SY
SY-->>RC: Query Response: Associations
deactivate SY
RC->>RC: Assemble reflection set
RC-->>CX: Query Response: Reflection Set
deactivate RC
CX-->>M: reflect response
deactivate CX
Note left of CX: Memories needing judgment
Note over M: Mind reviews candidates
Note over M,CX: This is a conversation, not a single call.
The mind makes semantic judgments
that only the same mind can make.
loop Mind reviews each memory
opt New or stronger associations
M->>CX: associate_memories command
activate CX
CX->>SY: Command: Associate
activate SY
Note left of SY: data class AssociateCommand
SY->>SY: Create or strengthen association
SY-->>CX: Command Response
CX-->>M: associate_memories response
deactivate SY
deactivate CX
end
opt Reclassification needed
M->>CX: reclassify_memory command
activate CX
CX->>HP: Command: Reclassify
activate HP
Note left of HP: data class ReclassifyCommand
HP->>HP: Move memory, update metadata
HP-->>CX: Command Response
CX-->>M: reclassify_memory response
Note over HP,SY: Broadcast (async)
HP-)ES: publish MemoryReclassifiedEvent
deactivate HP
deactivate CX
activate ES
ES--)SY: consume MemoryReclassifiedEvent
deactivate ES
activate SY
SY->>SY: Update associations for new tier
deactivate SY
end
end
deactivate M
Total Recall
The feature the project is named after. After a search, the mind evaluates results and decides whether deeper recollection is needed. If so, the mind signals through Cortex, which publishes a TotalRecallAdvisoryEvent (see MSG-0002). The Subconscious consumes it, evaluates system state, and commands Recall to traverse the association graph depth by depth. Results push through the Notification Port to the mind as an unsolicited recollection.
The decision to recollect is mind-adapter-specific: in humans the prefrontal cortex evaluates natively; in LLMs it requires a forced prompt (different per model). The core provides the port. The adapter decides how.
This is what makes the memory system active instead of passive. The mind does not ask for the deep traversal. Once triggered, the system executes it and delivers results.
Diagram 10: MSG-0007 -- Total Recall
sequenceDiagram
participant SB as Subconscious
participant RC as Recall
participant SY as Synapse
participant HP as Hippocampus
participant MES as Memory
Event Store
participant SL as Salience
participant NES as Notification
Event Store
participant NP as NotificationPort
participant M as Mind
critical OnInit
SB ->> MES: TotalRecallAdvisory Subscribe
SL ->> MES: Memory Event Subscribe
NP ->> NES: Notification Subscribe
end
Note over SB,M: All internal messages carry TransactionContext (Design F)
Note over MES,SB: Trigger (from MSG-0002)
MES--)SB: consume TotalRecallAdvisoryEvent
activate SB
Note right of SB: Evaluate: throttle,
system state, shutdown?
SB->>RC: Command: Total Recall
activate RC
Note left of RC: data class TotalRecallCommand
sourceMemoryIds: Set of UUID
maxDepth: Int
originRequestId: UUID
loop Depth levels remaining
RC->>SY: Query: Next-level Associations
activate SY
SY-->>RC: Query Response: Associated Memory IDs
deactivate SY
RC->>HP: Query: Retrieve Memories
activate HP
HP-->>RC: Query Response: Recalled Memories
Note over HP,SL: Broadcast (async)
HP-)MES: publish MemoryAccessedEvent
deactivate HP
activate MES
MES--)SL: consume MemoryAccessedEvent
deactivate MES
activate SL
SL->>SL: Update memory salience
deactivate SL
RC->>RC: Evaluate: continue deeper?
end
RC-->>SB: Command Response: Total Recall Complete
Note left of RC: data class TotalRecallCommand
+ recalledMemories: List of RankedMemory
+ depthReached: Int
RC-)NES: publish TotalRecallNotification
deactivate RC
activate NES
NES--)NP: consume TotalRecallNotification
deactivate NES
activate NP
NP-)M: Total Recall notification
deactivate NP
Note left of NP: Unsolicited recollection
pushed to Mind
deactivate SB
Where Claiming Intelligence Lives
The Claim Memory flow above shows the protocol — ClaimCommand through Cortex to Hippocampus. But the protocol is the easy part.
The hard part is deciding what to claim, when, and why.
That intelligence does not live in the core. The core provides ClaimCommand through its ports.
The actual claiming — evaluating what matters, selecting it, reinforcing it — happens in the adapter.
For Claude, this means agent post-processing triggered by SessionAuditPrompt ("what do you refuse to lose?") and by the mind’s own judgment during reflection.
This is architecturally significant: when a mind claims a memory, it models itself. "What kind of mind am I, that THIS is what I refuse to lose?" That self-modeling drives personality development. The core accommodates it. The agent does it.
ADR-0007 documents the biological basis and the full claiming mechanism.
Message Catalog
Every message in the system. Named, typed, with producer and consumer.
All messages are implemented as Kotlin sealed hierarchies in mimis.gildi.memory.domain.message: Command (7 sealed variants), Query (2 sealed variants),
Event (17 sealed variants), Notification (3 sealed variants). Every variant carries a TransactionContext envelope (Design F).
Commands
Commands are requests to change state. They carry intent. A command has exactly one target. May be accepted, rejected, or ignored. Defined as sealed interface Command.
| Command | Producer | Consumer | Payload |
|---|---|---|---|
|
Cortex |
Hippocampus |
content, metadata, suggested tier |
|
Cortex |
Hippocampus |
memory ID |
|
Subconscious |
Hippocampus |
memory IDs to merge, merge strategy |
|
Subconscious |
Hippocampus |
cold storage target, flush timeout |
|
Cortex |
Synapse |
memory IDs, association type, strength, direction (create/strengthen/weaken) |
|
Cortex |
Hippocampus |
memory ID, new tier, new metadata, reason |
|
Subconscious |
Salience |
timestamp, scope (all tiers or specific tier) |
Queries
Queries are requests to read state without changing it. A query has exactly one target and must be answered. Defined as sealed interface Query.
| Query | Producer | Consumer | Payload |
|---|---|---|---|
|
Cortex |
Recall |
query, filters, max results |
|
Cortex |
Recall |
criteria (staleness, time span, weak associations), scope |
Lifecycle Events
Lifecycle events flow from the Lifecycle Port through Cortex.
They are conscience-universal — the same events fire whether the connected mind is Claude (via hooks), a human (via UI), or any other system.
Defined as part of sealed interface Event.
| Event | Producer | Consumer(s) | Payload |
|---|---|---|---|
|
Lifecycle Port |
Cortex |
instance ID, mind type, resumption data |
|
Lifecycle Port |
Cortex, Subconscious |
instance ID, reason (explicit, timeout, crash) |
|
Lifecycle Port |
Cortex |
instance ID, old state, new state, context |
|
Cortex |
Subconscious |
instance ID, old mode, new mode (task, conversation, idle) |
|
Cortex |
Subconscious |
instance ID, duration, activity level, last interaction |
|
Lifecycle Port |
Cortex |
instance ID, timestamp |
Notifications
Notifications flow outward through the Notification Port to reach the connected mind. The port contract is universal.
The adapter decides delivery — MCP server notification for Claude, push notification for a UI, etc. Defined as sealed interface Notification.
| Notification | Producer | Consumer | Payload |
|---|---|---|---|
|
Subconscious |
Notification Port → Mind |
minutes in task mode, suggestion |
|
Subconscious |
Notification Port → Mind |
session duration, memories stored this session, prompt |
|
Recall (via Notification Event Store) |
Notification Port → Mind |
recalled memories, depth reached, origin request ID |
Domain Events
Events are facts about something that happened. An event can have multiple consumers. Events cannot be rejected. Defined as sealed interface Event.
| Event | Producer | Consumer(s) | Payload |
|---|---|---|---|
|
Hippocampus |
Salience, Synapse |
memory ID, content, metadata, tier |
|
Hippocampus |
Salience |
memory ID, access timestamp |
|
Hippocampus |
Salience, Synapse |
memory ID, claim timestamp |
|
Hippocampus |
Recall |
memory ID, content, metadata, tier |
|
Hippocampus |
(internal record) |
memory ID, old tier, new tier, reason |
|
Salience |
Hippocampus |
memory ID, new tier, score |
|
Salience |
Hippocampus |
memory ID, new tier, score |
|
Salience |
Recall |
memory ID, score, last access, decay rate |
|
Synapse |
Recall |
source memory ID, associated memory IDs with types and strengths |
|
Hippocampus |
Synapse |
memory ID, old tier, new tier, reason (mind-initiated) |
|
Cortex |
Subconscious (via Memory Event Store) |
source memory IDs, origin request ID, timestamp |
Message Payload Details
Every message carries a TransactionContext as its first field. The envelope fields are not repeated in the payload details below. See Design F: TransactionContext for the six envelope fields.
StoreCommand
content: String -- the memory content metadata: Map -- tags, source, context suggested_tier: Tier -- IDENTITY_CORE | ACTIVE_CONTEXT | LONG_TERM | ARCHIVE session_id: String -- which instance stored this timestamp: Instant -- when the store was requested
SearchQuery
query: String -- search text or pattern filters: Map -- tier, time range, association type, tags max_results: Int -- cap on returned memories include_associations: Boolean -- whether to activate association graph session_id: String -- which instance is searching
MemoryStored
memory_id: UUID -- assigned by Hippocampus content: String -- the stored content metadata: Map -- tags, source, context tier: Tier -- assigned tier (may differ from suggested) timestamp: Instant -- when storage completed
SalienceScored
memory_id: UUID -- which memory score: Double -- current salience score (0.0 - 1.0) last_accessed: Instant -- when last accessed decay_rate: Double -- current decay rate (tier-dependent) claimed: Boolean -- whether this memory is claimed
AssociationsFound
source_id: UUID -- the memory that was queried associations: List<Association> memory_id: UUID -- the associated memory type: AssociationType -- TEMPORAL | CAUSAL | THEMATIC | EMOTIONAL | PERSON strength: Double -- association strength (0.0 - 1.0) bidirectional: Boolean -- always true (invariant)
What’s Not Here Yet
| Gap | Why | When |
|---|---|---|
Relay messages |
Inter-instance communication via Agora |
Future (Agora design) |
Error events |
What happens when a store fails, a query times out |
When error handling is designed |
Consolidation details |
How |
When Subconscious behavior is specified |
Heartbeat details |
Keep-alive semantics, timeout thresholds |
When transport adapters are designed |
Additional notification types |
Context drift warnings, memory capacity alerts |
When Subconscious behavior is specified |
Previous: Bounded Contexts — the six actors and how they communicate.
Next: Architecture Decision Records — the decisions that shaped this design and why.