@wipcomputer/memory-crystal 0.7.15 → 0.7.16
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 +85 -0
- package/dist/installer.js +1 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -14,6 +14,91 @@
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
|
|
18
|
+
## 0.7.16 (2026-03-13)
|
|
19
|
+
|
|
20
|
+
# Dev Update: Orphan Cleanup, DELETE Trigger, Doctor Fix
|
|
21
|
+
|
|
22
|
+
**Date:** 2026-03-13
|
|
23
|
+
**Author:** CC-Mini
|
|
24
|
+
**Session:** memory-db-fix
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## What Happened
|
|
29
|
+
|
|
30
|
+
Parker ran the Memory Crystal install prompt and `crystal doctor` reported "Embeddings: FAILING ... no provider configured in env." Investigation revealed two separate issues:
|
|
31
|
+
|
|
32
|
+
### Issue 1: Doctor False Positive
|
|
33
|
+
|
|
34
|
+
`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.
|
|
35
|
+
|
|
36
|
+
**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`.
|
|
37
|
+
|
|
38
|
+
### Issue 2: Orphaned Vectors and FTS Entries
|
|
39
|
+
|
|
40
|
+
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.
|
|
41
|
+
|
|
42
|
+
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.
|
|
43
|
+
|
|
44
|
+
**Impact:**
|
|
45
|
+
- 141,651 orphaned vectors (~875 MB)
|
|
46
|
+
- 141,652 orphaned FTS entries
|
|
47
|
+
- ~7% of search queries hit phantom results (silently filtered out)
|
|
48
|
+
- Database: 1.96 GB (should have been ~1 GB)
|
|
49
|
+
|
|
50
|
+
**Fix (three parts):**
|
|
51
|
+
|
|
52
|
+
1. **DELETE trigger** added to `initChunksTables()` in `core.ts`:
|
|
53
|
+
```sql
|
|
54
|
+
CREATE TRIGGER IF NOT EXISTS chunks_cleanup AFTER DELETE ON chunks
|
|
55
|
+
BEGIN
|
|
56
|
+
DELETE FROM chunks_vec WHERE chunk_id = OLD.id;
|
|
57
|
+
INSERT INTO chunks_fts(chunks_fts, rowid, text) VALUES('delete', OLD.id, OLD.text);
|
|
58
|
+
END;
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
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.
|
|
62
|
+
|
|
63
|
+
3. **`crystal cleanup` CLI command** added to `cli.ts`. Handles the full workflow: backup, pause cron, clean orphans, VACUUM, resume cron. Supports `--dry-run`.
|
|
64
|
+
|
|
65
|
+
**Cleanup results:**
|
|
66
|
+
- 141,651 orphaned vectors removed
|
|
67
|
+
- FTS rebuilt from 73,813 chunks in 5.7s
|
|
68
|
+
- Database: 1.96 GB -> 1.45 GB (525 MB saved)
|
|
69
|
+
- Verification: chunks = FTS entries = 73,813. Match: YES
|
|
70
|
+
- Zero orphans remaining
|
|
71
|
+
|
|
72
|
+
### Side Discovery: Plaintext SA Token
|
|
73
|
+
|
|
74
|
+
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).
|
|
75
|
+
|
|
76
|
+
### Product Rule Established
|
|
77
|
+
|
|
78
|
+
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.
|
|
79
|
+
|
|
80
|
+
## Files Changed
|
|
81
|
+
|
|
82
|
+
| File | Change |
|
|
83
|
+
|------|--------|
|
|
84
|
+
| `src/core.ts` | Added `chunks_cleanup` DELETE trigger, `cleanOrphans()` method |
|
|
85
|
+
| `src/cli.ts` | Added `crystal cleanup` command, updated imports and USAGE |
|
|
86
|
+
| `src/doctor.ts` | Added `checkOpEmbeddings()` for 1Password detection |
|
|
87
|
+
| `ai/product/bugs/2026-03-13--orphaned-vectors-and-fts-after-bulk-delete.md` | Bug report |
|
|
88
|
+
|
|
89
|
+
## Related (wip-secrets-ios-private)
|
|
90
|
+
|
|
91
|
+
| File | What |
|
|
92
|
+
|------|------|
|
|
93
|
+
| `ai/product/product-ideas/lesa-app-remote-biometrics.md` | Lesa app: remote biometrics for agent computers |
|
|
94
|
+
| `ai/product/bugs/2026-03-13--plaintext-sa-token-on-disk.md` | Plaintext SA token bug report |
|
|
95
|
+
|
|
96
|
+
## Status
|
|
97
|
+
|
|
98
|
+
- Code deployed and running (cleanup already executed)
|
|
99
|
+
- Not yet committed / PR'd / released
|
|
100
|
+
- Needs: branch, commit, PR, merge, `wip-release patch`
|
|
101
|
+
|
|
17
102
|
## 0.7.15 (2026-03-13)
|
|
18
103
|
|
|
19
104
|
# Dev Update: Orphan Cleanup, DELETE Trigger, Doctor Fix
|
package/dist/installer.js
CHANGED
|
@@ -434,9 +434,7 @@ async function runInstallOrUpdate(options) {
|
|
|
434
434
|
try {
|
|
435
435
|
execSync("npm install -g @wipcomputer/memory-crystal 2>&1", { encoding: "utf-8", timeout: 6e4, stdio: "pipe" });
|
|
436
436
|
steps.push(`Installed @wipcomputer/memory-crystal@${npmV}`);
|
|
437
|
-
steps.push("
|
|
438
|
-
execSync("crystal init", { stdio: "inherit", timeout: 12e4 });
|
|
439
|
-
return { action: "updated", version: npmV, deployedTo: ["global", "ldm", "openclaw"], steps };
|
|
437
|
+
steps.push("Continuing with updated code...");
|
|
440
438
|
} catch (err) {
|
|
441
439
|
steps.push(`npm upgrade failed: ${err.message}. Continuing with local code.`);
|
|
442
440
|
}
|
package/package.json
CHANGED