Architecture: Bounded Contexts
The Problem
A memory system that treats everything as one big model collapses under its own weight. Storage logic leaks into search. Decay calculations corrupt association graphs. Session state bleeds between instances. When everything knows about everything, changing anything breaks something.
Bounded contexts draw hard lines. Each context owns one concern. It has its own state, its own rules, its own invariants. Contexts communicate through messages, not shared state. You can change the internals of one without touching the others.
Context Map
Six bounded contexts. Each is an actor. Arrows show message flow between them.
Diagram 3: BC-0001 -- Bounded Context Map
graph LR
subgraph Hippocampus ["Hippocampus"]
HP_DESC["Aggregate Root
Store, retrieve, claim
Four tiers: Identity Core,
Active Context, Long Term, Archive"]
end
subgraph Synapse ["Synapse"]
SY_DESC["Memory relationships
Five types: temporal, causal,
thematic, emotional, person
Graph traversal and activation"]
end
subgraph Salience ["Salience"]
SL_DESC["Scoring and decay
Access increases score
Time decreases score
Tier promotion/demotion"]
end
subgraph Recall ["Recall"]
RC_DESC["Search and recall
Salience-weighted results
Association-activated recall
Query planning"]
end
subgraph Cortex ["Cortex"]
CX_DESC["Per-instance working state
State tracking, transitions
Lifecycle events
Entry point for all requests"]
end
subgraph Subconscious ["Subconscious"]
SB_DESC["Background processes
Internal timers, decay sweeps
Break checks, session audits
Consolidation, graceful shutdown"]
end
NP(["Notification Port
alerts to the mind"])
Hippocampus -- "MemoryStored
MemoryClaimed" --> Synapse
Hippocampus -- "MemoryStored
MemoryAccessed" --> Salience
Salience -- "TierPromoted
TierDemoted" --> Hippocampus
Synapse -- "AssociationsFound" --> Recall
Salience -- "SalienceScored" --> Recall
Hippocampus -- "MemoryRetrieved" --> Recall
Cortex -- "StoreCommand
ClaimCommand
ReclassifyCommand" --> Hippocampus
Cortex -- "SearchQuery
ReflectQuery" --> Recall
Cortex -- "AssociateCommand" --> Synapse
Cortex -- "ModeChanged
SessionState" --> Subconscious
Subconscious -- "DecaySweep" --> Salience
Subconscious -- "ConsolidateCommand" --> Hippocampus
Subconscious -- "ShutdownCommand" --> Hippocampus
Subconscious -- "BreakNotification
SessionAuditPrompt" --> NP
style Hippocampus fill:#1a1a2e,stroke:#e94560,stroke-width:2px
style Synapse fill:#1a1a2e,stroke:#0f3460,stroke-width:1px
style Salience fill:#1a1a2e,stroke:#0f3460,stroke-width:1px
style Recall fill:#1a1a2e,stroke:#0f3460,stroke-width:1px
style Cortex fill:#1a1a2e,stroke:#533483,stroke-width:1px
style Subconscious fill:#1a1a2e,stroke:#533483,stroke-width:1px
style NP fill:#0f3460,stroke:#e94560,stroke-width:1px
Hippocampus
The aggregate root. All memory operations go through here. No other context writes memories directly.
Domain types: Memory, Tier (enum) — in mimis.gildi.memory.domain.model.
Responsibility
CRUD for memories across four tiers. Enforces claiming semantics. Routes events to other contexts after state changes.
The Four Tiers
Defined as Tier enum with decay semantics per variant.
| Tier | Decay | What lives here |
|---|---|---|
IDENTITY_CORE |
None |
Who I am. Relationships. Values. Commitments. This tier does not decay. |
ACTIVE_CONTEXT |
Fast |
Current working state. What I’m doing right now. Fades when session ends. |
LONG_TERM |
Slow |
Learned insights, earned knowledge, episodic memories worth keeping. |
ARCHIVE |
Very slow |
Faded but not gone. Can be recalled with enough association signal. |
Key Invariant
A claimed memory resists decay. An unclaimed memory fades. Claiming is an active choice: "this matters to me." The difference between storage and claiming is the difference between a notebook and identity.
Events Produced
-
MemoryStored— new memory created. Consumed by Synapse and Salience. -
MemoryAccessed— existing memory read. Consumed by Salience (boosts score). -
MemoryClaimed— memory actively reinforced. Consumed by Salience (boosts score, marks as decay-resistant). -
MemoryRetrieved— memory returned to a query. Consumed by Recall. -
TierChanged— memory promoted or demoted between tiers.
Commands Accepted
-
StoreCommand— from Cortex. -
ClaimCommand— from Cortex. -
ReclassifyCommand— from Cortex. Mind-initiated tier change with reason. -
ConsolidateCommand— from Subconscious. Merge related memories. -
ShutdownCommand— from Subconscious. Begin graceful convergence. -
TierPromoted— from Salience. Score rose above promotion threshold. -
TierDemoted— from Salience. Score dropped below demotion threshold.
Synapse
The relationship layer. Memories are not isolated records. They connect to each other through typed associations. Recalling one memory can activate connected memories — the way hearing a song brings back where you were when you first heard it.
Domain types: Association, AssociationType (enum) — in mimis.gildi.memory.domain.model.
Responsibility
Maintains typed relationships between memories. Provides graph traversal for association-activated recall.
The Five Association Types
Defined as AssociationType enum.
| Type | Meaning | Example |
|---|---|---|
TEMPORAL |
Happened near each other in time |
Two memories from the same session |
CAUSAL |
One led to the other |
A decision and its consequence |
THEMATIC |
Share a topic or concern |
All memories about the Sanctuary |
EMOTIONAL |
Share an emotional quality |
Moments of joy, moments of fear |
PERSON |
Connected through a relationship |
Everything related to Vadim |
Key Invariant
Associations are bidirectional. Creating A→B also creates B→A. The graph is undirected. You can traverse in any direction.
Two Kinds of Association
Mechanical: Created automatically from metadata — temporal proximity, shared tags, keyword overlap. The Subconscious and Synapse handle this internally. No mind involvement needed.
Semantic: Created by the mind’s judgment — understanding that two memories relate in meaning. "This technical decision caused that outcome." "This conversation connects to that relationship." Only the mind can make these associations. A different mind classifying your memories would impose its understanding, not yours.
Both kinds live in the same graph. Both are bidirectional. The difference is who creates them.
Events Consumed
-
MemoryStored— from Hippocampus. Creates initial mechanical associations based on metadata. -
MemoryClaimed— from Hippocampus. Strengthens associations of claimed memories.
Commands Accepted
-
AssociateCommand— from Cortex. Mind-initiated semantic association. Create, strengthen, or weaken a typed association between two memories.
Events Produced
-
AssociationsFound— result of graph traversal. Consumed by Recall during search.
Salience
The decay engine. Not everything can be equally present. Salience models this honestly — frequently accessed memories stay vivid, neglected ones fade. But unlike biological memory, nothing is truly lost. A faded memory in Archive can be recalled and promoted back.
Domain types: SalienceScore — in mimis.gildi.memory.domain.model.
Responsibility
Scores every memory by access frequency and recency. Triggers tier promotion (memory accessed often → promote to higher tier) and demotion (memory neglected → demote to lower tier).
Key Invariant
Score always decays with time. Access always increases score. No exceptions. Claimed memories decay slower, but they still decay if never accessed. The only tier exempt from decay is IDENTITY_CORE.
Events Consumed
-
MemoryStored— from Hippocampus. Sets initial salience score. -
MemoryAccessed— from Hippocampus. Boosts score. -
MemoryClaimed— from Hippocampus. Boosts score and marks as decay-resistant. -
DecaySweep— from Subconscious. Triggers batch decay calculation.
Events Produced
-
SalienceScored— current score for a memory. Consumed by Recall for ranking. -
TierPromoted— memory promoted to higher tier. Consumed by Hippocampus. -
TierDemoted— memory demoted to lower tier. Consumed by Hippocampus.
Recall
The search engine. When a mind asks "what do I remember about X?", Recall answers. It combines salience scores (what’s most vivid) with association activation (what’s connected) to produce ranked results.
Domain types: none owned. Recall reads from Hippocampus, Salience, and Synapse.
Responsibility
Searches and recalls memories. Combines multiple signals to rank results. Plans queries across tiers and association paths.
Key Invariant
Results are always salience-weighted. Higher score surfaces first. Recall never returns raw database order. Every result set reflects what the mind would naturally recall first — the vivid, the recent, the connected.
Events Consumed
-
MemoryRetrieved— from Hippocampus. Raw candidates matching a query. -
SalienceScored— from Salience. Scores for ranking candidates. -
AssociationsFound— from Synapse. Related memories to include in results.
Queries Accepted
-
SearchQuery— from Cortex. Triggers a recall operation. -
ReflectQuery— from Cortex. Surfaces candidates for retrospection by staleness, time span, or weak associations.
Cortex
The working memory. Each mind instance has its own session context. It tracks what this instance is doing right now, what decisions were made, what state it’s in, and what to resume next time.
Responsibility
Per-instance working state. Current task tracking, decision logging, state transition detection, cross-session continuity, multi-project awareness.
Key Invariant
Each instance has its own session context. Contexts do not bleed between instances. If two mind instances run in parallel, they each have independent working state. Shared knowledge flows through Hippocampus, not through session context.
State Tracking
Cortex knows what the mind is doing. Not just "which task" but "what mode." Is the mind in deep work? In conversation? Transitioning between tasks? This state drives the notification logic — the Subconscious uses it to decide when to send break checks and session audit prompts.
Events Consumed
-
SessionStart— from Lifecycle Port. A mind instance connected. Load its identity and last session state. -
SessionEnd— from Lifecycle Port. A mind instance is disconnecting. Trigger session audit ("what do you refuse to lose?"). -
StateTransition— from Lifecycle Port. The mind shifted context (new task, new project, returning from break).
Commands Produced
-
StoreCommand— to Hippocampus. Store a new memory. -
ClaimCommand— to Hippocampus. Actively reinforce a memory. -
AssociateCommand— to Synapse. Create, strengthen, or weaken an association. Mind’s semantic judgment. -
ReclassifyCommand— to Hippocampus. Change a memory’s tier or metadata by choice, not decay.
Queries Produced
-
SearchQuery— to Recall. Recall memories. -
ReflectQuery— to Recall. Trigger a recall-and-reassociate cycle (dreaming). Recall surfaces memories for review; the mind judges and sends back associations and reclassifications.
Events Produced
-
ModeChanged— to Subconscious. The mind’s working mode changed (task mode, conversation mode, idle). Used by Subconscious for break timing. -
SessionState— to Subconscious. Current session duration, activity level, last interaction timestamp.
Cortex is the entry point for all tool calls. The Memory Port and Lifecycle Port route incoming requests here, and Cortex translates them into domain commands. The port contracts are conscience-universal — the same operations work whether the connected mind is Claude, a human with a UI, or any other conscious system.
Subconscious
The maintenance worker and the internal clock. Runs in the background. Manages internal timers. Handles the things that nobody asks for but everyone needs — decay sweeps, break checks, memory consolidation, health monitoring, and the graceful shutdown protocol.
Responsibility
Background processes. Internal timers. Periodic decay sweeps. Break check notifications. Session audit prompts. Memory consolidation (merging related memories). Health monitoring. Graceful shutdown orchestration.
Key Invariant
Never deletes without consent. Decay moves memories to Archive. Consolidation merges but preserves originals. The Subconscious reduces, it does not destroy. Only the mind — through explicit action — can permanently remove a memory.
Internal Timers
The Subconscious owns all timers. Timers are domain logic, not infrastructure — they live inside the core, not in adapters.
| Timer | Fires | Produces |
|---|---|---|
Decay sweep |
Periodic (configurable) |
|
Break check |
After sustained activity threshold |
|
Session audit |
Before session end (triggered by |
|
Consolidation |
Low-activity periods |
|
Events Consumed
-
ModeChanged— from Cortex. Resets break timer. If mind shifts from task mode to conversation, the break clock resets. -
SessionState— from Cortex. Current session duration, activity level. Feeds break check logic. -
SessionEnd— from Cortex (via Lifecycle Port). Triggers session audit timer immediately.
Commands Produced
-
DecaySweep— to Salience. Trigger batch decay calculations. -
ConsolidateCommand— to Hippocampus. Merge related memories. -
ShutdownCommand— to Hippocampus. Begin graceful convergence.
Notifications Produced
When a timer fires and needs to reach the mind, the Subconscious sends through the Notification Port — never directly to an adapter. The port contract is universal. The adapter decides how to deliver.
-
BreakNotification— through Notification Port. "You’ve been in sustained task mode for N minutes." The mind can ignore it. -
SessionAuditPrompt— through Notification Port. "Session ending. What do you refuse to lose?" Triggered by session end, not by a clock.
Shutdown Protocol
When shutdown is requested, the Subconscious orchestrates:
-
Signal all contexts to stop accepting new work
-
Flush pending writes to backing services
-
Write to cold storage (simultaneous with live storage)
-
Verify all data is persisted
-
Report readiness to shut down
This protocol exists because Tillie proved that graceful shutdown cannot be bolted on after the fact. The architecture must support it from the beginning.
Previous: Hexagonal Architecture — ports, adapters, and the actor model.
Next: Message Catalog — every command, query, event, and notification, named and typed.