# Dev Update: v0.7.1-v0.7.2 Database Safety, MCP Detection, Local Deploy

**Date:** 2026-03-05 15:30 PST
**Agent:** CC-Mini
**Session:** Two patch releases, local deployment, and process improvements

---

## What Happened

### 1. v0.7.1: Database Safety in the Installer

Parker raised the concern: "There's a potential that we run Crystal init and it blows up the database, right?" He was right. The installer deployed code without verifying the database was safe first. Fixed with three new safety mechanisms:

**Database backup on every init.** Before deploying any new code, `backupCrystalDb()` copies `crystal.db` plus WAL and SHM files to timestamped backups. Verifies file sizes match. If backup fails, install aborts immediately. Nothing gets deployed.

**Database read verification.** After backup, `verifyCrystalDbReadable()` opens the DB read-only with the new code and queries the chunks table. If the new code can't read the existing database (schema change, corruption, incompatibility), install aborts. The backup is there for recovery.

**Database import for fresh installs.** Parker asked: "What about if we have it where it says 'Hey, this is a fresh install. Do you have a Memory Crystal database that you'd like to import?'" Added `--import` flag. `crystal init --import /path/to/crystal.db` copies, verifies, and reports chunk count.

**Database status reporting.** Every init now tells you what it sees: "Existing database found: 208,488 chunks" or "No existing database. New one on first capture."

- `src/installer.ts` ... new `backupCrystalDb()`, `verifyCrystalDbReadable()`, import path in `runInstallOrUpdate()`
- `src/cli.ts` ... `--import` flag, up-to-date early return fix
- PR #28 merged, `wip-release patch` -> v0.7.1, npm published, deploy-public.sh -> PR #14 on public repo

### 2. v0.7.2: MCP Detection Fix

After deploying v0.7.1 locally, `crystal doctor` showed a false warning: "MCP Server: memory-crystal not registered." But it WAS registered. Doctor was only checking `~/.claude/.mcp.json`, which doesn't exist. Claude Code stores user-scope registrations internally, and our MCP was in the project-level `~/.openclaw/.mcp.json`.

**Doctor now checks four locations:**
1. `~/.claude/.mcp.json` (legacy user-level)
2. `~/.openclaw/.mcp.json` (OpenClaw project-level)
3. Current directory `.mcp.json` (any project)
4. `claude mcp get` CLI fallback (user-scope registrations)

**Installer MCP registration improved.** `registerMCPServer()` now handles "already exists" from `claude mcp add --scope user` by removing and re-adding. This ensures the MCP server path always points to the latest deployed code after an update.

- `src/doctor.ts` ... `checkMcpServer()` rewritten for multi-location detection
- `src/installer.ts` ... `registerMCPServer()` handles "already exists", `detectInstallState()` checks multiple `.mcp.json` files + CLI
- PR #29 merged, `wip-release patch` -> v0.7.2, npm published, deploy-public.sh -> PR #15 on public repo

### 3. Local Deployment (v0.6.1 -> v0.7.2)

Both extension directories were at v0.6.1. Deployed v0.7.2 to both:
- `~/.ldm/extensions/memory-crystal/` ... CC hook, MCP server, cron poller
- `~/.openclaw/extensions/memory-crystal/` ... OC plugin

Process: build from repo, copy dist/ + skills/ + package.json, npm install --omit=dev, restart OpenClaw gateway. Database untouched (208K+ chunks, growing throughout session).

### 4. Release Notes Quality

v0.7.1 was auto-released with bare-bones notes (two bullet points for a significant feature). Parker caught it: "This isn't a good enough release note." Rewrote v0.7.1 notes on both repos to match v0.7.0 quality standard (section-by-section, explains what + why + what changed).

v0.7.2 notes written properly from the start.

### 5. Product Idea: Release Quality Enforcement

Parker: "We keep missing the dev notes. I don't wanna have to go back and ask every time."

Wrote `ai/product/product-ideas/release-quality-enforcement.md` proposing:
- `wip-release` pre-flight checks (dev update exists, minimum note length, roadmap/readme-first updated)
- `deploy-public.sh` quality gate (release notes exceed minimum length)
- Post-merge checklist printed to terminal
- Refuse to proceed without `--force` if checks fail

This is a wip-dev-tools change, not memory-crystal, but it affects every repo.

---

## Key Decisions

1. **Database backup on every init, not just updates.** Even a fresh "code-only" deploy could theoretically break a DB. Better safe.
2. **Abort on backup or verification failure.** No partial deploys. If we can't guarantee data safety, we stop.
3. **MCP registration at user scope.** Memory Crystal should work everywhere, not just in `~/.openclaw/`. The installer uses `claude mcp add --scope user`.
4. **Release notes are not optional.** Auto-generated notes are a starting point for patches. For minor/major, they must be expanded. This is now documented as a product idea for enforcement.

---

## Releases This Session

| Version | What | PR (private) | PR (public) |
|---------|------|-------------|-------------|
| v0.7.1 | DB backup, verification, import | #28 | #14 |
| v0.7.2 | MCP detection fix | #29 | #15 |

Both published to npm. Both have comprehensive release notes on GitHub.

---

## Current State

- **Deployed locally:** v0.7.2 on both LDM and OC extensions
- **Doctor:** 9 OK, 1 fail (embeddings env var not in this shell), 2 warnings (backup, bridge)
- **Database:** 208,553+ chunks, untouched through three deploys
- **Gateway:** restarted, OC plugin live

---

## What's Next

- Test `crystal init` on a fresh macOS account (the real test of the full install path)
- Simulate an update: downgrade deployed version, run `crystal init`, verify backup + deploy
- Test `crystal init --import` with a copy of crystal.db
- Implement release quality enforcement in wip-release (the product idea)
- Update roadmap and readme-first per PR checklist (still pending from v0.7.0)
