77 lines
11 KiB
Plaintext
77 lines
11 KiB
Plaintext
[2026-05-14T17:36:28.087Z] RESULT
|
|
============================================================
|
|
{
|
|
"success": true,
|
|
"output": "## Performance Analysis: `/home/code/infinite`\n\n**Honest finding first:** This codebase has no custom application source code — no React components, no ORM queries, no business logic. It's a configuration-only setup for the claude-flow agent orchestration runtime. The requested analysis areas (N+1 queries, React re-renders, memory leaks, redundant computations) have no code to apply to.\n\nWhat I *can* analyze is the SQLite schema (`data/memory/schema.sql`) and configuration. Here's what's there:\n\n---\n\n### Schema: Missing Composite Indexes\n\nThe current indexes are single-column, but the most common query patterns will filter on multiple columns simultaneously.\n\n**Problem:** Queries like \"find active patterns by type sorted by confidence\" hit three separate indexes and force SQLite to intersect them.\n\n**Fix — add composite indexes to `schema.sql`:**\n\n```sql\n-- patterns: most common access pattern is active + high-confidence by type\nCREATE INDEX IF NOT EXISTS idx_patterns_active_type_conf\n ON patterns(status, pattern_type, confidence DESC)\n WHERE status = 'active';\n\n-- memory_entries: filtered reads by namespace + status + recency\nCREATE INDEX IF NOT EXISTS idx_memory_ns_status_accessed\n ON memory_entries(namespace, status, last_accessed_at DESC)\n WHERE status = 'active';\n\n-- trajectory_steps: step ordering within a trajectory\nCREATE INDEX IF NOT EXISTS idx_steps_traj_step\n ON trajectory_steps(trajectory_id, step_number);\n```\n\n---\n\n### Schema: Embeddings Stored as JSON TEXT\n\n**Problem:** `embedding TEXT` columns store float arrays serialized as JSON strings (e.g., `\"[0.1, 0.2, ...]\"`). Every vector similarity operation deserializes and re-serializes these. SQLite has no native vector type, but this pattern compounds badly at scale.\n\n**Current state (`schema.sql:23`):**\n```sql\nembedding TEXT, -- stored as JSON array\n```\n\n**Mitigation:** Store embeddings as `BLOB` (raw binary floats) instead. This halves storage and avoids JSON parse overhead on every vector read:\n\n```sql\n-- Instead of TEXT JSON array, use BLOB for raw float32 array\nembedding BLOB,\nembedding_model TEXT DEFAULT 'local',\nembedding_dimensions INTEGER NOT NULL DEFAULT 384,\n```\n\nThis is a breaking change to the schema — the HNSW layer in `ruvector.db` handles actual ANN search, so this only matters if embeddings are ever read back from SQLite directly.\n\n---\n\n### Documented Bug #1947 — Vector Dimension Mismatch\n\nThe schema itself documents a known defect at line 305:\n\n```sql\n-- HNSW rejects inserts whose dim does not match this row,\n-- so a 768 here breaks every memory_store --vector and\n-- memory_search on a fresh install (#1947).\nINSERT OR IGNORE INTO vector_indexes (id, name, dimensions) VALUES\n ('default', 'default', 384), -- fixed: was 768\n ('patterns', 'patterns', 384);\n```\n\n**Impact:** Any existing `ruvector.db` or `memory.db` created before this fix was applied with `dimensions=768` will silently reject all new vector inserts. If the system was initialized before this schema patch, run:\n\n```bash\nsqlite3 data/memory/memory.db \\\n \"UPDATE vector_indexes SET dimensions=384 WHERE dimensions=768;\"\n```\n\nThen rebuild the HNSW index:\n```bash\nnpx @claude-flow/cli@latest memory search --rebuild-index\n```\n\n---\n\n### Config: Cache Size vs. Memory Footprint\n\n**`claude-flow.config.json:21`:**\n```json\n\"cacheSize\": 1000\n```\n\nWith `embedding_dimensions: 384` floats per entry (4 bytes each = 1.5KB/entry), 1,000 cached entries = ~1.5MB of embedding data alone, plus content. This is fine for development but monitor in long-running sessions with large memory namespaces.\n\n---\n\n### Summary\n\n| Finding | Severity | Actionable |\n|---|---|---|\n| Missing composite indexes on `patterns` and `memory_entries` | Medium | Yes — add to `schema.sql` |\n| `trajectory_steps` missing `(trajectory_id, step_number)` index | Low | Yes — add to `schema.sql` |\n| Bug #1947 dimension mismatch on pre-fix installs | High | Yes — one SQL UPDATE + index rebuild |\n| Embeddings as JSON TEXT vs BLOB | Low | Yes, but breaking change |\n\nThere is no application source code in this project to analyze for React re-renders, N+1 patterns, memory leaks, or redundant computations. If you have a specific service or library built on top of this runtime you'd like reviewed, point me to that codebase.\n",
|
|
"parsedOutput": {
|
|
"sections": [
|
|
{
|
|
"title": "Performance Analysis: `/home/code/infinite`",
|
|
"content": "\n**Honest finding first:** This codebase has no custom application source code — no React components, no ORM queries, no business logic. It's a configuration-only setup for the claude-flow agent orchestration runtime. The requested analysis areas (N+1 queries, React re-renders, memory leaks, redundant computations) have no code to apply to.\n\nWhat I *can* analyze is the SQLite schema (`data/memory/schema.sql`) and configuration. Here's what's there:\n\n---\n\n",
|
|
"level": 2
|
|
},
|
|
{
|
|
"title": "Schema: Missing Composite Indexes",
|
|
"content": "\nThe current indexes are single-column, but the most common query patterns will filter on multiple columns simultaneously.\n\n**Problem:** Queries like \"find active patterns by type sorted by confidence\" hit three separate indexes and force SQLite to intersect them.\n\n**Fix — add composite indexes to `schema.sql`:**\n\n```sql\n-- patterns: most common access pattern is active + high-confidence by type\nCREATE INDEX IF NOT EXISTS idx_patterns_active_type_conf\n ON patterns(status, pattern_type, confidence DESC)\n WHERE status = 'active';\n\n-- memory_entries: filtered reads by namespace + status + recency\nCREATE INDEX IF NOT EXISTS idx_memory_ns_status_accessed\n ON memory_entries(namespace, status, last_accessed_at DESC)\n WHERE status = 'active';\n\n-- trajectory_steps: step ordering within a trajectory\nCREATE INDEX IF NOT EXISTS idx_steps_traj_step\n ON trajectory_steps(trajectory_id, step_number);\n```\n\n---\n\n",
|
|
"level": 3
|
|
},
|
|
{
|
|
"title": "Schema: Embeddings Stored as JSON TEXT",
|
|
"content": "\n**Problem:** `embedding TEXT` columns store float arrays serialized as JSON strings (e.g., `\"[0.1, 0.2, ...]\"`). Every vector similarity operation deserializes and re-serializes these. SQLite has no native vector type, but this pattern compounds badly at scale.\n\n**Current state (`schema.sql:23`):**\n```sql\nembedding TEXT, -- stored as JSON array\n```\n\n**Mitigation:** Store embeddings as `BLOB` (raw binary floats) instead. This halves storage and avoids JSON parse overhead on every vector read:\n\n```sql\n-- Instead of TEXT JSON array, use BLOB for raw float32 array\nembedding BLOB,\nembedding_model TEXT DEFAULT 'local',\nembedding_dimensions INTEGER NOT NULL DEFAULT 384,\n```\n\nThis is a breaking change to the schema — the HNSW layer in `ruvector.db` handles actual ANN search, so this only matters if embeddings are ever read back from SQLite directly.\n\n---\n\n",
|
|
"level": 3
|
|
},
|
|
{
|
|
"title": "Documented Bug #1947 — Vector Dimension Mismatch",
|
|
"content": "\nThe schema itself documents a known defect at line 305:\n\n```sql\n-- HNSW rejects inserts whose dim does not match this row,\n-- so a 768 here breaks every memory_store --vector and\n-- memory_search on a fresh install (#1947).\nINSERT OR IGNORE INTO vector_indexes (id, name, dimensions) VALUES\n ('default', 'default', 384), -- fixed: was 768\n ('patterns', 'patterns', 384);\n```\n\n**Impact:** Any existing `ruvector.db` or `memory.db` created before this fix was applied with `dimensions=768` will silently reject all new vector inserts. If the system was initialized before this schema patch, run:\n\n```bash\nsqlite3 data/memory/memory.db \\\n \"UPDATE vector_indexes SET dimensions=384 WHERE dimensions=768;\"\n```\n\nThen rebuild the HNSW index:\n```bash\nnpx @claude-flow/cli@latest memory search --rebuild-index\n```\n\n---\n\n",
|
|
"level": 3
|
|
},
|
|
{
|
|
"title": "Config: Cache Size vs. Memory Footprint",
|
|
"content": "\n**`claude-flow.config.json:21`:**\n```json\n\"cacheSize\": 1000\n```\n\nWith `embedding_dimensions: 384` floats per entry (4 bytes each = 1.5KB/entry), 1,000 cached entries = ~1.5MB of embedding data alone, plus content. This is fine for development but monitor in long-running sessions with large memory namespaces.\n\n---\n\n",
|
|
"level": 3
|
|
},
|
|
{
|
|
"title": "Summary",
|
|
"content": "| Finding | Severity | Actionable |\n|---|---|---|\n| Missing composite indexes on `patterns` and `memory_entries` | Medium | Yes — add to `schema.sql` |\n| `trajectory_steps` missing `(trajectory_id, step_number)` index | Low | Yes — add to `schema.sql` |\n| Bug #1947 dimension mismatch on pre-fix installs | High | Yes — one SQL UPDATE + index rebuild |\n| Embeddings as JSON TEXT vs BLOB | Low | Yes, but breaking change |\n\nThere is no application source code in this project to analyze for React re-renders, N+1 patterns, memory leaks, or redundant computations. If you have a specific service or library built on top of this runtime you'd like reviewed, point me to that codebase.",
|
|
"level": 3
|
|
}
|
|
],
|
|
"codeBlocks": [
|
|
{
|
|
"language": "sql",
|
|
"code": "-- patterns: most common access pattern is active + high-confidence by type\nCREATE INDEX IF NOT EXISTS idx_patterns_active_type_conf\n ON patterns(status, pattern_type, confidence DESC)\n WHERE status = 'active';\n\n-- memory_entries: filtered reads by namespace + status + recency\nCREATE INDEX IF NOT EXISTS idx_memory_ns_status_accessed\n ON memory_entries(namespace, status, last_accessed_at DESC)\n WHERE status = 'active';\n\n-- trajectory_steps: step ordering within a trajectory\nCREATE INDEX IF NOT EXISTS idx_steps_traj_step\n ON trajectory_steps(trajectory_id, step_number);"
|
|
},
|
|
{
|
|
"language": "sql",
|
|
"code": "embedding TEXT, -- stored as JSON array"
|
|
},
|
|
{
|
|
"language": "sql",
|
|
"code": "-- Instead of TEXT JSON array, use BLOB for raw float32 array\nembedding BLOB,\nembedding_model TEXT DEFAULT 'local',\nembedding_dimensions INTEGER NOT NULL DEFAULT 384,"
|
|
},
|
|
{
|
|
"language": "sql",
|
|
"code": "-- HNSW rejects inserts whose dim does not match this row,\n-- so a 768 here breaks every memory_store --vector and\n-- memory_search on a fresh install (#1947).\nINSERT OR IGNORE INTO vector_indexes (id, name, dimensions) VALUES\n ('default', 'default', 384), -- fixed: was 768\n ('patterns', 'patterns', 384);"
|
|
},
|
|
{
|
|
"language": "bash",
|
|
"code": "sqlite3 data/memory/memory.db \\\n \"UPDATE vector_indexes SET dimensions=384 WHERE dimensions=768;\""
|
|
},
|
|
{
|
|
"language": "bash",
|
|
"code": "npx @claude-flow/cli@latest memory search --rebuild-index"
|
|
},
|
|
{
|
|
"language": "json",
|
|
"code": "\"cacheSize\": 1000"
|
|
}
|
|
]
|
|
},
|
|
"durationMs": 106921,
|
|
"model": "sonnet",
|
|
"sandboxMode": "permissive",
|
|
"workerType": "optimize",
|
|
"timestamp": "2026-05-14T17:36:28.086Z",
|
|
"executionId": "optimize_1778780081165_i6x90p"
|
|
}
|