fix(hooks): V3 MCP hook handlers now persist data to database#1059
fix(hooks): V3 MCP hook handlers now persist data to database#1059ahmedibrahim085 wants to merge 1 commit intoruvnet:mainfrom
Conversation
BREAKING FIX: hooksPostEdit, hooksPostTask, and hooksPostCommand were
returning success without actually storing any data. This fix makes
them call getRealStoreFunction() to persist to the memory database.
Changes:
- hooksPostEdit: Now stores to 'patterns' namespace with HNSW indexing
- hooksPostTask: Now stores to 'trajectories' namespace with HNSW indexing
- hooksPostCommand: Now stores to 'commands' namespace with HNSW indexing
- getLearningStats: Now queries real SELECT COUNT(*) instead of file_size/2KB
Before:
- handlers returned {recorded: true} without database INSERT
- hooksPostTask returned Math.random() for duration (fake data)
- statusline showed file_size/2KB as "patterns" count (misleading)
After:
- handlers call storeEntry() with generateEmbeddingFlag: true
- real pattern IDs returned from database
- statusline queries actual table row counts
Verified:
- ✅ post-edit: PERSISTED - "Pattern stored with HNSW indexing"
- ✅ post-task: PERSISTED - "Trajectory stored with HNSW indexing"
- ✅ post-command: PERSISTED - "Command pattern stored with HNSW indexing"
Closes ruvnet#1058
Independent Verification ResultsI independently discovered the same issues and can confirm this PR fixes them. Here are my findings: Problem VerifiedCLI trajectory commands fail with MCP error: But MCP tools work when called directly from Claude Code: {
"trajectoryId": "traj-xxx",
"status": "recording",
"implementation": "real-trajectory-tracking"
}Current Workaround (Partial)The
However, SONA learning and EWC++ consolidation don't trigger because Tested Components
RequestThis fix would enable proper learning for users running hooks via bash scripts. The Would appreciate expedited review as this affects all hook-based learning workflows. Tested on: claude-flow v3.0.0-alpha.190, Node.js v22, macOS |
…istence fix(hooks): V3 MCP hook handlers now persist data (upstream ruvnet#1059)
Summary
V3 MCP hook handlers (
hooksPostEdit,hooksPostTask,hooksPostCommand) were returning success responses but not actually persisting any data. This PR fixes them to callgetRealStoreFunction()and store to the database with HNSW indexing.Problem Evidence
Before (Stub Handlers)
hooksPostEdit(lines 621-645):hooksPostTask(lines 1049-1080):Statusline (hooks.ts:3314-3318):
Database Reality:
Solution
Updated handlers to call
getRealStoreFunction()(which already exists at line 50-60):hooksPostEdit{recorded: true}patternsnamespace with HNSWhooksPostTasktrajectoriesnamespace with HNSWhooksPostCommand{recorded: true}commandsnamespace with HNSWgetLearningStatsfile_size / 2KBSELECT COUNT(*)queriesTest Results
Database verification after fix:
Files Changed
v3/@claude-flow/cli/src/mcp-tools/hooks-tools.tsv3/@claude-flow/cli/src/commands/hooks.tsImpact
Related
🤖 Generated with Claude Code