store: Fix: Use client.py reindex (not stats) to build _index.json from scratch on new deployments

This commit is contained in:
Cal Corum 2026-02-20 23:24:17 -06:00
parent ee3a0eb6f3
commit 938f3a6551

View File

@ -0,0 +1,42 @@
---
id: 8244e75b-f077-4f92-9ed1-904af7b9ba63
type: fix
title: "Fix: Use client.py reindex (not stats) to build _index.json from scratch on new deployments"
tags: [cognitive-memory, deployment, fix, homelab, reindex, index]
importance: 0.6
confidence: 0.8
created: "2026-02-21T05:24:17.159355+00:00"
updated: "2026-02-21T05:24:17.159355+00:00"
---
# Fix: client.py reindex Required for Fresh Memory Deployments
## Problem
When deploying cognitive memory to a new server, running `client.py stats` does NOT build an `_index.json`. It only reads an existing one. On a fresh deployment the index file does not exist, so stats returns nothing useful and memory search/recall will fail.
## Solution
Run `client.py reindex` after deploying files to a new server. This command:
1. Walks `graph/` and `vault/` directories
2. Parses YAML frontmatter from each `.md` file
3. Extracts 200-char content previews
4. Scans `graph/edges/` separately
5. Writes a single `_index.json` (approx 450KB for 538 memories, takes ~1 second)
## Integration with sync-memory.sh
On LXC 301, the `reindex` call is placed **inside the conditional block** that checks whether `git pull` brought in new commits (BEFORE/AFTER rev comparison). This prevents unnecessary reindex runs on no-op syncs.
```bash
BEFORE=$(git rev-parse HEAD)
git pull
AFTER=$(git rev-parse HEAD)
if [ "$BEFORE" != "$AFTER" ]; then
python3 client.py reindex
fi
```
## Tags
Applies to any new cognitive-memory deployment. Always reindex after first sync.