Problem
GET /api/brain/graph/search-index (server/routes/brainGraph.js:25-28) invokes getBrainGraphSearchIndex() (server/services/brainGraph.js:106-109), which calls loadNodes() (server/services/brainGraph.js:52-103). loadNodes() calls brainStorage.getAll(type) for 5 entity types (people, projects, ideas, admin, memories), plus getGoals(), plus brainStorage.getAll('journals'). This reads and JSON-parses full record bodies for every entity and daily log entry on disk, only for getBrainGraphSearchIndex() to discard all body/summary/tag fields and return { id, label, brainType }.
Impact
Opening or focusing the brain graph search input forces a complete disk walk and JSON parse of every brain entity and daily log file. As the store grows, this lightweight search dropdown causes significant disk I/O latency and memory overhead.
Fix
Optimize getBrainGraphSearchIndex() or loadNodes() to fetch only the minimal { id, label, brainType } projection (e.g., using collectionStore.listIds() or lightweight header metadata), avoiding reading full record content files from disk.
Files touched:
server/services/brainGraph.js
server/routes/brainGraph.js
Acceptance criteria
Problem
GET /api/brain/graph/search-index(server/routes/brainGraph.js:25-28) invokesgetBrainGraphSearchIndex()(server/services/brainGraph.js:106-109), which callsloadNodes()(server/services/brainGraph.js:52-103).loadNodes()callsbrainStorage.getAll(type)for 5 entity types (people,projects,ideas,admin,memories), plusgetGoals(), plusbrainStorage.getAll('journals'). This reads and JSON-parses full record bodies for every entity and daily log entry on disk, only forgetBrainGraphSearchIndex()to discard all body/summary/tag fields and return{ id, label, brainType }.Impact
Opening or focusing the brain graph search input forces a complete disk walk and JSON parse of every brain entity and daily log file. As the store grows, this lightweight search dropdown causes significant disk I/O latency and memory overhead.
Fix
Optimize
getBrainGraphSearchIndex()orloadNodes()to fetch only the minimal{ id, label, brainType }projection (e.g., usingcollectionStore.listIds()or lightweight header metadata), avoiding reading full record content files from disk.Files touched:
server/services/brainGraph.jsserver/routes/brainGraph.jsAcceptance criteria
GET /api/brain/graph/search-indexdoes not load full record content bodies from disk for all brain entity types and daily log entries.{ nodes: [{ id, label, brainType }] }projections with low latency.server/services/brainGraph.test.jspass.