@wipcomputer/memory-crystal 0.7.10 → 0.7.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -9,6 +9,91 @@
9
9
 
10
10
 
11
11
 
12
+
13
+ ## 0.7.11 (2026-03-13)
14
+
15
+ # Dev Update: Orphan Cleanup, DELETE Trigger, Doctor Fix
16
+
17
+ **Date:** 2026-03-13
18
+ **Author:** CC-Mini
19
+ **Session:** memory-db-fix
20
+
21
+ ---
22
+
23
+ ## What Happened
24
+
25
+ Parker ran the Memory Crystal install prompt and `crystal doctor` reported "Embeddings: FAILING ... no provider configured in env." Investigation revealed two separate issues:
26
+
27
+ ### Issue 1: Doctor False Positive
28
+
29
+ `checkEmbeddingProvider()` in `doctor.ts` only checked `process.env.OPENAI_API_KEY`. But the cron job and hooks resolve the key from 1Password via the SA token at `~/.openclaw/secrets/op-sa-token`. The doctor didn't know about this path.
30
+
31
+ **Fix:** Added `checkOpEmbeddings()` helper to `doctor.ts` that checks for the SA token file, then does a live `op read` to verify it works. Doctor now reports `ok: openai (via 1Password)` instead of `fail`.
32
+
33
+ ### Issue 2: Orphaned Vectors and FTS Entries
34
+
35
+ On 2026-03-11, 141,652 bulk file-scan chunks were correctly deleted from the `chunks` table. Parker said: "Why are we indexing documents?" These were raw file scans (Python venv packages, TypeScript source, vendor code) with no conversational context.
36
+
37
+ The deletion used raw SQL (`DELETE FROM chunks WHERE agent_id = 'system'`). But Memory Crystal had no DELETE trigger. The corresponding entries in `chunks_vec` (sqlite-vec) and `chunks_fts` (FTS5) were left orphaned.
38
+
39
+ **Impact:**
40
+ - 141,651 orphaned vectors (~875 MB)
41
+ - 141,652 orphaned FTS entries
42
+ - ~7% of search queries hit phantom results (silently filtered out)
43
+ - Database: 1.96 GB (should have been ~1 GB)
44
+
45
+ **Fix (three parts):**
46
+
47
+ 1. **DELETE trigger** added to `initChunksTables()` in `core.ts`:
48
+ ```sql
49
+ CREATE TRIGGER IF NOT EXISTS chunks_cleanup AFTER DELETE ON chunks
50
+ BEGIN
51
+ DELETE FROM chunks_vec WHERE chunk_id = OLD.id;
52
+ INSERT INTO chunks_fts(chunks_fts, rowid, text) VALUES('delete', OLD.id, OLD.text);
53
+ END;
54
+ ```
55
+
56
+ 2. **`cleanOrphans()` method** added to Crystal class in `core.ts`. Counts orphaned vec/FTS entries, deletes vec orphans in batches of 1000, rebuilds FTS5 from scratch.
57
+
58
+ 3. **`crystal cleanup` CLI command** added to `cli.ts`. Handles the full workflow: backup, pause cron, clean orphans, VACUUM, resume cron. Supports `--dry-run`.
59
+
60
+ **Cleanup results:**
61
+ - 141,651 orphaned vectors removed
62
+ - FTS rebuilt from 73,813 chunks in 5.7s
63
+ - Database: 1.96 GB -> 1.45 GB (525 MB saved)
64
+ - Verification: chunks = FTS entries = 73,813. Match: YES
65
+ - Zero orphans remaining
66
+
67
+ ### Side Discovery: Plaintext SA Token
68
+
69
+ During investigation, discovered that `~/.openclaw/secrets/op-sa-token` is a plaintext 1Password SA token readable by any process running as `lesa`. This is the bootstrap credential that unlocks all secrets. Bug report filed. Long-term fix: Lesa iOS app with remote biometrics (product doc written).
70
+
71
+ ### Product Rule Established
72
+
73
+ Memory Crystal indexes conversations only. File content that appears in conversation turns (agent reads a file, discusses it) is captured as part of the conversation. Raw directory scanning without conversational context is not what Memory Crystal is for.
74
+
75
+ ## Files Changed
76
+
77
+ | File | Change |
78
+ |------|--------|
79
+ | `src/core.ts` | Added `chunks_cleanup` DELETE trigger, `cleanOrphans()` method |
80
+ | `src/cli.ts` | Added `crystal cleanup` command, updated imports and USAGE |
81
+ | `src/doctor.ts` | Added `checkOpEmbeddings()` for 1Password detection |
82
+ | `ai/product/bugs/2026-03-13--orphaned-vectors-and-fts-after-bulk-delete.md` | Bug report |
83
+
84
+ ## Related (wip-secrets-ios-private)
85
+
86
+ | File | What |
87
+ |------|------|
88
+ | `ai/product/product-ideas/lesa-app-remote-biometrics.md` | Lesa app: remote biometrics for agent computers |
89
+ | `ai/product/bugs/2026-03-13--plaintext-sa-token-on-disk.md` | Plaintext SA token bug report |
90
+
91
+ ## Status
92
+
93
+ - Code deployed and running (cleanup already executed)
94
+ - Not yet committed / PR'd / released
95
+ - Needs: branch, commit, PR, merge, `wip-release patch`
96
+
12
97
  ## 0.7.10 (2026-03-13)
13
98
 
14
99
  # Dev Update: Orphan Cleanup, DELETE Trigger, Doctor Fix
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wipcomputer/memory-crystal",
3
- "version": "0.7.10",
3
+ "version": "0.7.11",
4
4
  "description": "Sovereign memory system — local-first with ephemeral encrypted relay. Your memory, your machine, your rules.",
5
5
  "type": "module",
6
6
  "main": "dist/core.js",
@@ -55,7 +55,7 @@ npm link
55
55
  - One command, done
56
56
 
57
57
  ```bash
58
- npm install -g memory-crystal
58
+ npm install -g @wipcomputer/memory-crystal
59
59
  ```
60
60
 
61
61
  If npm is not available, check if the user has Node.js installed (`node --version`). They need Node.js 20+. If not installed, tell them to install it from https://nodejs.org first.
@@ -280,7 +280,7 @@ If the user already has a Crystal Core on another machine:
280
280
 
281
281
  ### Step 1: Install the package
282
282
 
283
- Same as above (developer fork or `npm install -g memory-crystal`).
283
+ Same as above (developer fork or `npm install -g @wipcomputer/memory-crystal`).
284
284
 
285
285
  ### Step 2: Initialize as a Node
286
286