# Dev Update: Memory Crystal v0.4.0 ... Crystal Core/Node Architecture

**Date:** 2026-03-03 14:30 PST
**Author:** CC-Mini
**Branch:** `cc-mini/v0.4.0-core-node-architecture`

## What happened

Built the Crystal Core/Node architecture and all supporting CLI commands. This is the infrastructure for multi-device sync, onboarding, and the "coming back later" flow Parker designed.

## New commands

- `crystal role` ... shows current role (Core/Node/Standalone), agent ID, DB, relay config
- `crystal promote` ... makes this device the Crystal Core (source of truth, does embeddings)
- `crystal demote` ... makes this device a Crystal Node (captures and relays to Core)
- `crystal doctor` ... 10 health checks (role, database, embeddings, capture, relay, MCP, backup, bridge, LDM dirs, private mode). Shows OK/WARN/FAIL + fix suggestions
- `crystal backup` ... runs a full backup now (sqlite3 .backup for safe DB copy, timestamped, retention)
- `crystal backup setup` ... installs daily LaunchAgent at 03:00
- `crystal bridge setup` ... installs + registers lesa-bridge MCP server
- `crystal bridge status` ... shows bridge install/registration state

## New files

- `src/role.ts` ... role detection (state file override + auto-detect from env vars)
- `src/doctor.ts` ... health check engine
- `src/bridge.ts` ... bridge detection and registration
- `scripts/ldm-backup.sh` ... backup script (sqlite3 .backup, retention, configurable destination)

## Modified files

- `src/cli.ts` ... all new command handlers, updated help text
- `src/ldm.ts` ... deployBackupScript(), installBackupLaunchAgent()
- `package.json` ... version 0.4.0, new build entries
- `skills/memory/SKILL.md` ... full rewrite with branching onboarding flow (developer/user, first install/adding device, transparency, backup offer, relay choice, bridge, doctor verify)
- `README.md` ... tested/untested compatibility, hosted/self-hosted relay, backups line, Dream Weaver production note, bridge link
- `RELAY.md` ... Crystal Core/Node terminology, updated architecture
- `TECHNICAL.md` ... Crystal Core/Node section, role commands, updated terminology

## crystal init now also

- Deploys backup script to ~/.ldm/bin/
- Detects bridge and suggests setup if found

## Test results

All commands tested on Mac mini:
- `crystal role` ... standalone (auto-detected), 170,336 chunks
- `crystal promote` / `crystal demote` ... state file override works, role switches correctly
- `crystal doctor` ... all 10 checks working, correct fix suggestions
- `crystal backup` ... 2.1 GB backup via sqlite3 .backup, retention works
- `crystal bridge status` ... detection working
- `crystal init` ... shows backup + bridge status

## Design docs

- `ai/plans/2026-03-03--onboarding-flow.md` ... Parker's onboarding flow design
- `ai/plans/2026-03-03--v0.4.0-implementation.md` ... implementation plan

## Next

- Deploy to Mini's extensions (cp dist + restart gateway)
- Test the full SKILL.md onboarding flow on MacBook Air
- npm publish v0.4.0
