# Configuration

## Global Config

Located at `~/.mempalace/config.json`. The Rust `Config` struct uses `#[serde(default)]` for every field, so missing keys fall back to defaults — and the full set of recognised fields is roughly 30+ (see `crates/core/src/config.rs`).

```json
{
  "palace_path": "/custom/path/to/palace",
  "collection_name": "mempalace_drawers",
  "people_map": {"Kai": "KAI", "Priya": "PRI"},
  "search_strategy": "contains",
  "max_cache_size_mb": 128,
  "embedding_model": "naive",
  "languages": ["en"]
}
```

| Key | Default | Description |
|-----|---------|-------------|
| `palace_path` | `~/.mempalace/palace` | Where the palace stores its drawers and SQLite databases |
| `collection_name` | `mempalace_drawers` | Drawer collection name (used by the vector store and SQLite fallback) |
| `people_map` | `{}` | Entity name → AAAK code mappings (`{"Alice": "ALC"}`) |
| `search_strategy` | `contains` | Default search strategy: `contains`, `naive`, `bm25`, or `embedding` |
| `max_cache_size_mb` | `128` | In-memory cache cap (low-resource tuning) |
| `embedding_model` | `naive` | Embedding backend: `naive`, `paraphrase-multilingual-MiniLM-L12-v2`, `all-MiniLM-L6-v2`, or `onnx` |
| `embedder_identity_strict` | `true` | Hard-fail on embedder fingerprint mismatch (set `false` to allow rebuild) |
| `languages` | `[]` | Languages the AI should expect in drawers (used by entity detection) |
| `topic_wings` | built-in list | Topic wing names used by auto-detection |
| `hall_keywords` | built-in map | Keyword sets used to classify drawers into halls |
| `llm_provider` | `null` | `ollama`, `openai`, etc. (used by `mpr init --llm-provider`) |
| `llm_model` | `null` | Model name for the chosen LLM provider |
| `consolidation_enabled` | `null` | Toggle the consolidation pipeline (`true` / `false`) |
| `auto_compress` | `null` | Auto-compress eligible drawers into AAAK |
| `graph_extraction_enabled` | `null` | Run entity/relationship extraction during mining |

Run `mpr config show` to print the merged config (file + env + defaults) and `mpr config path` to print the file path.

## Project Config

Generated by `mpr init` in your project directory.

### `entities.json`

```json
{
  "Kai": "KAI",
  "Priya": "PRI"
}
```

Wings are auto-detected during `mpr init` from:
- Directory names → project wings
- Detected people in file content → person wings
- Explicit `--wing` flag on `mpr mine`

## Identity

Located at `~/.mempalace/identity.txt`. Plain text. Loaded as **Layer 0** every wake-up.

```text
I am Atlas, a personal AI assistant for Alice.
Traits: warm, direct, remembers everything.
People: Alice (creator), Bob (Alice's partner).
Project: A journaling app that helps people process emotions.
```

::: tip
Write your identity file in first person from the AI's perspective. This becomes the AI's self-concept on wake-up.
:::

## Notes (AGENT.md / USER.md)

Created automatically by `mpr init` (skip with `--no-notes`). Both live next to the palace data dir:

- `AGENT.md` — the agent's persistent notes; appended to via `mpr remember`
- `USER.md` — key/value facts about the user; managed via `mpr user set/get/list`

Both are human-readable Markdown and version-controllable. See [CLI Commands → Notes](/reference/cli#notes--user-profile).

## Palace Path Override

All commands accept `--palace <path>` to override the default location:

```bash
mpr search "query" --palace /tmp/test-palace
mpr mine ~/data/ --palace /tmp/test-palace
```

The MCP server accepts the same flag:

```bash
mpr serve --palace /custom/palace
```

## Environment Variables

| Variable | Description |
|----------|-------------|
| `MEMPALACE_PALACE_PATH` | Override palace path (same as `--palace`). Legacy alias: `MEMPAL_PALACE_PATH`. |
| `MEMPALACE_HTTP_PORT` | HTTP REST API port when `mpr serve --http` (default `3111`). |
| `MEMPALACE_STREAM_PORT` | Stream port used by the engine (REST port + 1 by default). |
| `MEMPALACE_ENGINE_PORT` | Engine RPC port (REST port + 46023 by default). |
| `MEMPALACE_MAX_CHUNKS_PER_FILE` | Default chunk cap (overridable per-call with `--max-chunks-per-file`). |
| `MEMPALACE_MAX_BACKUPS` | Maximum palace backups retained by `mpr repair rebuild`. |
| `MEMPALACE_LLM_CONSENT` | Bypass the interactive consent prompt for external LLM usage. |
| `MEMPALACE_HOOKS_AUTO_SAVE` | `false` disables auto-save during hooks. |
| `MEMPALACE_NONINTERACTIVE` | `1` makes init/mine skip interactive prompts. |
| `MEMPAL_VERBOSE` | `1` enables verbose tracing output. |
