Skip to content
This repository was archived by the owner on Sep 23, 2025. It is now read-only.

Commit e793bf4

Browse files
committed
Complete Hippo memory system design
- Comprehensive design doc with MCP tool specifications - LLM usage prompts separated for independent iteration - Realistic example dialog showing full workflow - Delegate experiment validating natural AI behavior - Array-based context for better semantic matching - Hybrid reinforcement with AI suggestions + user control - Importance-weighted scoring with lazy decay evaluation Ready for implementation. See issue #11 for tracking.
1 parent 1305e67 commit e793bf4

File tree

4 files changed

+660
-10
lines changed

4 files changed

+660
-10
lines changed

src/hippo/design-doc.md

Lines changed: 211 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ The key insight: Generate insights cheaply and frequently, let natural selection
3232
{
3333
"uuid": "abc123-def456-789",
3434
"content": "User prefers dialogue format over instruction lists for collaboration prompts",
35-
"context": "design discussion about hippo",
35+
"context": [
36+
"design discussion about hippo",
37+
"defining collaboration patterns",
38+
"comparing instruction vs dialogue formats"
39+
],
3640
"importance": 0.7,
3741
"created_at": "2025-07-23T17:00:00Z",
3842
"content_last_modified_at": "2025-07-23T17:00:00Z",
@@ -47,13 +51,30 @@ The key insight: Generate insights cheaply and frequently, let natural selection
4751

4852
- **created_at**: When the insight was first generated (never changes)
4953
- **content_last_modified_at**: When the content or context was last edited
54+
- **context**: Array of independent situational aspects describing when/where the insight occurred
5055
- **importance**: AI-generated 0-1 rating of insight significance (set at creation)
5156
- **score_at_last_change**: The score when it was last modified (starts at 1.0)
5257
- **score_last_modified_at**: When the score was last explicitly changed (upvote/downvote)
5358

5459
### Score Computation
5560

56-
Current score computed on-demand: `(score_at_last_change * importance) * (0.9 ^ days_since_score_last_modified)`
61+
Current score computed on-demand using research-backed weighting:
62+
63+
```
64+
current_score = base_score * importance * recency_factor
65+
66+
where:
67+
base_score = score_at_last_change
68+
recency_factor = 0.9 ^ days_since_score_last_modified
69+
importance = AI-generated 0-1 rating (acts as importance weight from research)
70+
```
71+
72+
For search ranking, we'll eventually incorporate the full research formula:
73+
```
74+
Relevance = 0.3×Recency + 0.2×Frequency + 0.35×Importance + 0.15×Context_Similarity
75+
```
76+
77+
MVP implementation focuses on Recency (decay) and Importance (AI rating), with Frequency and Context_Similarity planned for future iterations.
5778

5879
#### Score Evolution Examples
5980

@@ -101,17 +122,195 @@ Current score (computed on-demand) is a primary factor in search results:
101122
- **MCP tool interface** - AI uses automatically, no manual commands needed
102123
- **JSON format** for simplicity in MVP
103124

104-
## Technical Architecture
125+
## MCP Tool Interface
126+
127+
### Server Configuration
128+
The Hippo MCP server takes a `--hippo-file` argument specifying the path to the JSON storage file:
129+
```bash
130+
hippo-server --hippo-file /path/to/hippo.json
131+
```
132+
133+
### Tool Definitions
134+
135+
#### `hippo_record_insight`
136+
```json
137+
{
138+
"name": "hippo_record_insight",
139+
"description": "Record a new insight during consolidation moments",
140+
"inputSchema": {
141+
"type": "object",
142+
"properties": {
143+
"content": {
144+
"type": "string",
145+
"description": "The insight content - should be atomic and actionable"
146+
},
147+
"context": {
148+
"type": "array",
149+
"items": {"type": "string"},
150+
"description": "Array of independent situational aspects describing when/where this insight occurred. Include: 1) General activity (e.g. 'debugging authentication flow', 'design discussion about hippo'), 2) Specific problem/goal (e.g. 'users getting logged out randomly', 'defining MCP tool interface'), 3) Additional relevant details (e.g. 'race condition suspected', 'comparing dialogue vs instruction formats'). Each element should be independently meaningful for search matching."
151+
},
152+
"importance": {
153+
"type": "number",
154+
"minimum": 0,
155+
"maximum": 1,
156+
"description": "AI-assessed importance rating: 0.8+ breakthrough insights, 0.6-0.7 useful decisions, 0.4-0.5 incremental observations, 0.1-0.3 routine details"
157+
}
158+
},
159+
"required": ["content", "context", "importance"]
160+
}
161+
}
162+
```
163+
164+
#### `hippo_search_insights`
165+
```json
166+
{
167+
"name": "hippo_search_insights",
168+
"description": "Search for relevant insights based on content and context",
169+
"inputSchema": {
170+
"type": "object",
171+
"properties": {
172+
"query": {
173+
"type": "string",
174+
"description": "Search query for insight content"
175+
},
176+
"context_filter": {
177+
"type": "array",
178+
"items": {"type": "string"},
179+
"description": "Filter results by matching any context elements using partial matching. Examples: ['debugging authentication'] matches insights with 'debugging authentication flow', ['users getting logged out'] matches specific problem contexts. Can provide multiple filters - results match if ANY context element partially matches ANY filter."
180+
},
181+
"limit": {
182+
"type": "object",
183+
"properties": {
184+
"offset": {"type": "integer", "default": 0},
185+
"count": {"type": "integer", "default": 10}
186+
},
187+
"description": "Result pagination. Default: {offset: 0, count: 10} returns first 10 results. Examples: {offset: 10, count: 5} for next 5 results",
188+
"default": {"offset": 0, "count": 10}
189+
},
190+
"score_range": {
191+
"type": "object",
192+
"properties": {
193+
"min": {"type": "number", "default": 0.1},
194+
"max": {"type": "number", "default": null}
195+
},
196+
"description": "Score range filter. Examples: {min: 0.6, max: 1.0} for decent insights, {min: 1.0} for highly reinforced insights, {max: 0.4} for low-quality insights"
197+
}
198+
},
199+
"required": ["query"]
200+
}
201+
}
202+
```
203+
204+
**Returns:**
205+
```json
206+
{
207+
"insights": [
208+
{
209+
"uuid": "abc123-def456-789",
210+
"content": "User prefers dialogue format over instruction lists",
211+
"context": [
212+
"design discussion about hippo",
213+
"defining collaboration patterns",
214+
"comparing instruction vs dialogue formats"
215+
],
216+
"importance": 0.7,
217+
"current_score": 1.2,
218+
"created_at": "2025-07-23T17:00:00Z",
219+
"days_since_created": 3,
220+
"days_since_score_modified": 1
221+
}
222+
],
223+
"total_matching": 15,
224+
"returned_count": 10,
225+
"score_distribution": {
226+
"below_0.2": 2,
227+
"0.2_to_0.4": 1,
228+
"0.4_to_0.6": 2,
229+
"0.6_to_0.8": 3,
230+
"0.8_to_1.0": 4,
231+
"above_1.0": 3
232+
}
233+
}
234+
```
235+
236+
#### `hippo_modify_insight`
237+
```json
238+
{
239+
"name": "hippo_modify_insight",
240+
"description": "Modify an existing insight's content, context, or importance",
241+
"inputSchema": {
242+
"type": "object",
243+
"properties": {
244+
"uuid": {
245+
"type": "string",
246+
"description": "UUID of the insight to modify"
247+
},
248+
"content": {
249+
"type": "string",
250+
"description": "New insight content (optional - only provide if changing)"
251+
},
252+
"context": {
253+
"type": "array",
254+
"items": {"type": "string"},
255+
"description": "New situational context array (optional - only provide if changing)"
256+
},
257+
"importance": {
258+
"type": "number",
259+
"minimum": 0,
260+
"maximum": 1,
261+
"description": "New importance rating (optional - only provide if changing)"
262+
},
263+
"reinforce": {
264+
"type": "string",
265+
"enum": ["upvote", "downvote", "none"],
266+
"description": "Reinforcement to apply with modification. Default: 'upvote' (since modification usually signals value)",
267+
"default": "upvote"
268+
}
269+
},
270+
"required": ["uuid"]
271+
}
272+
}
273+
```
274+
275+
#### `hippo_reinforce_insight`
276+
```json
277+
{
278+
"name": "hippo_reinforce_insight",
279+
"description": "Apply reinforcement feedback to multiple insights",
280+
"inputSchema": {
281+
"type": "object",
282+
"properties": {
283+
"upvotes": {
284+
"type": "array",
285+
"items": {"type": "string"},
286+
"description": "Array of UUIDs to upvote (2.0x score multiplier)",
287+
"default": []
288+
},
289+
"downvotes": {
290+
"type": "array",
291+
"items": {"type": "string"},
292+
"description": "Array of UUIDs to downvote (0.1x score multiplier)",
293+
"default": []
294+
}
295+
},
296+
"required": []
297+
}
298+
}
299+
```
300+
301+
### LLM Usage Prompts
302+
303+
See [prompts.md](./prompts.md) for detailed guidance on how LLMs should use the Hippo MCP tools during insight generation, consolidation, and search.
105304

106305
### Core Operations
107306
```
108-
record_insight(content, context) → uuid
109-
search_insights(query, context_filter?) → List[InsightResult]
110-
reinforce_insight(uuid, feedback: upvote|downvote)
111-
decay_insights() → updates all scores
307+
record_insight(content, context, importance) → uuid
308+
search_insights(query, context_filter?, score_range?, limit?) → InsightResults
309+
reinforce_insight(upvotes[], downvotes[]) → success
310+
modify_insight(uuid, content?, context?, importance?, reinforce?) → success
112311
```
113312

114-
### Decay Function (Simple)
313+
## Technical Architecture
115314
```
116315
score = score * (0.9 ^ days_since_last_reinforcement)
117316
```
@@ -150,7 +349,9 @@ score = score * (0.9 ^ days_since_last_reinforcement)
150349
- **Reinforcement patterns**: Which types of insights get consistently upvoted?
151350
- **Search effectiveness**: Do context-based searches return relevant results?
152351

153-
## Implementation Plan
352+
## Example Usage
353+
354+
See [example-dialog.md](./example-dialog.md) for a detailed walkthrough showing all four MCP operations in realistic collaborative sessions.
154355

155356
### Phase 1: Basic Infrastructure
156357
- JSON storage with decay function
@@ -167,7 +368,7 @@ score = score * (0.9 ^ days_since_last_reinforcement)
167368
- Collect metrics on insight utility
168369
- Refine generation triggers and reinforcement
169370

170-
## Future Extensions (Post-MVP)
371+
## Implementation Plan
171372

172373
### Memory Hierarchy
173374
```

0 commit comments

Comments
 (0)