Files
msd-core/docs/how-to/enable-cross-session-memory-with-mempalace.md
Jakub Zych a9a7a328e6 refactor: hard-fork GSD -> MSD (Make Software Done)
Mechanical rename produced by scripts/msd-rename.cjs: gsd/Gsd/GSD -> msd/Msd/MSD
across contents and paths, upstream package/repo coordinates -> @golem15/msd-core
and golem15com/msd-core. Deep links into upstream history, sibling upstream
packages, the GSD-2 import feature, CHANGELOG.md and .changeset/ are kept as-is.

Hand edits on top: MSD block-letter banner and logos, LICENSE copyright line,
package/plugin identity, regenerated lockfile, install-tree fixtures, derived
registries and benchmark baseline; migration checksum baseline re-locked
(MSD keeps its own install state, so no install had applied the old sums);
sort-order and regex-escaped expectations in tests adjusted.
2026-10-06 01:47:40 +02:00

141 lines
6.7 KiB
Markdown

# How to enable cross-session memory with MemPalace
Give MSD durable memory across sessions and projects. When MemPalace is connected, MSD recalls prior decisions and patterns before you plan, and captures phase artifacts verbatim at each phase boundary.
**What you need:** [MemPalace](https://github.com/MemPalace/mempalace) installed locally. MSD never installs MemPalace for you — `pip install mempalace` is your action. A working MemPalace install is not required to complete MSD work; the capability is `onError: skip` at every hook, so an absent or unreachable MemPalace leaves the loop unchanged.
---
## Step 1 — Install MemPalace
Follow the [MemPalace installation guide](https://github.com/MemPalace/mempalace#installation). The quick path:
```bash
pip install mempalace
mempalace init # creates the local palace (ChromaDB + SQLite)
mempalace status # verify the server is reachable
```
For interactive use (Claude Code), MemPalace's MCP server must be running so `mempalace_*` tool calls resolve. For headless or cron runs, the CLI path (`mempalace wake-up`, `mempalace search`, etc.) is used automatically — no MCP server needed.
---
## Step 2 — Enable the capability
Inside your MSD project:
```bash
msd-tools query config-set mempalace.enabled true
```
That is the only required step — `mempalace.enabled` is the master switch that gates all loop hooks. All other `mempalace.*` keys are optional refinements of the enabled behavior; they are honored at runtime by the skills, curator, and fragments.
---
## Step 3 — Choose a memory mode
The `mempalace.memory_mode` key controls how authoritative MemPalace is during recall and capture — how tightly it couples to MSD's native memory (`.planning/graphs/`, STATE, learnings). All three modes are wired. Every mode is `onError: skip` and default-resilient: an unreachable palace degrades to native memory, and MSD keeps writing `.planning/graphs/`, so no mode risks memory loss.
| Mode | What it does | When to use it |
|------|-------------|----------------|
| `augment` (default) | The palace is an *additional* recall layer alongside `.planning/graphs/` and learnings. Lowest coupling — native memory stays authoritative and the palace supplements it. | Most users. Safe to enable immediately. |
| `kg_backend` | Knowledge-graph queries resolve against the palace's temporal KG as the *primary* source; `.planning/graphs/` becomes the fallback. Non-KG drawer recall stays additive. | You want the palace's temporal KG to drive decision recall while keeping native graphs as a safety net. |
| `replace` | Recall resolves *through the palace as the source of truth*; native artifacts are consulted only as a fallback when the palace is unreachable. | You want the palace to be the authoritative memory store for this project. |
Set the mode with:
```bash
# augment is the default; most users need no change.
msd-tools query config-set mempalace.memory_mode kg_backend # or: replace
```
> **Note — cross-mode migration.** Switching an established project to `kg_backend` or `replace` changes how *new* recall and capture resolve; it does **not** retro-migrate memory already written to `.planning/graphs/` into the palace. Backfilling existing native memory into the palace is a separate, not-yet-implemented concern — choose the mode you want at the start of a project for the cleanest result.
---
## Step 4 — Run a phase and observe recall and capture
With `mempalace.enabled: true`, here is what you will see at each loop point:
**Discuss phase (`/msd-discuss-phase`):**
1. At `discuss:pre` — MemPalace recall fires: prior decisions, patterns, and surprises are surfaced as context before the discussion begins.
2. At `discuss:post` — `CONTEXT.md` is filed into the `decisions` room in MemPalace.
**Plan phase (`/msd-plan-phase`):**
3. At `plan:pre` — a `MEMORY-RECALL.md` file appears in the phase directory containing prior decisions, patterns, and surprises retrieved from the palace.
4. At `plan:post` — `PLAN.md` is filed into the `planning` room.
**Verify phase (`/msd-verify-work`):**
5. At `verify:post` — `SUMMARY.md` is filed into `milestones` in MemPalace.
**Ship phase (`/msd-ship`):**
6. At `ship:post` — the `msd-mempalace-curator` agent writes a diary entry and (if enabled) proposes cross-project tunnels.
**Execute phase (`/msd-execute-phase`, each wave):**
7. At `execute:wave:post` — confirmed problem→fix pairs are captured into the `problems` room via the `capture-problems` fragment.
If MemPalace is unreachable at any step, a skip-notice is written and the loop continues normally.
---
## Optional configuration
### Turn off recall or capture independently
```bash
# Disable recall injection at discuss:pre (keeps capture)
msd-tools query config-set mempalace.recall_on_discuss false
# Disable the MEMORY-RECALL.md step at plan:pre
msd-tools query config-set mempalace.recall_on_plan false
# Disable artifact capture at phase boundaries
msd-tools query config-set mempalace.capture_artifacts false
```
### Cross-project tunnels
Enable tunnel proposals at `ship:post` to connect related rooms across projects:
```bash
msd-tools query config-set mempalace.cross_project_tunnels true
```
The curator agent will call `mempalace_find_tunnels` and propose connections to the wings it finds semantically related to this project's wing.
### Passive mid-session capture (reserved — not yet implemented)
`mempalace.auto_capture_hooks` is a forward-declared key reserved for a future "Connected Capability" phase. Setting it to `true` currently has no effect — no native Claude Code hooks (`stop`, `precompact`, `session-start`) are installed by this key yet. The capability's hooks array is empty; the deliberate loop hooks are the only active integration today.
```bash
# Not yet functional — reserved for a future release
# msd-tools query config-set mempalace.auto_capture_hooks true
```
### Override the wing name
By default, the wing name derives from `project_code` or the project directory. Override it:
```bash
msd-tools query config-set mempalace.wing my-project-name
```
---
## What to expect when MemPalace is absent
If MemPalace is not installed, not running, or unreachable:
- Every hook logs a skip notice and continues.
- `MEMORY-RECALL.md` is written with an "unavailable" stub (the planner can still proceed without it).
- No phase step fails or blocks.
- Loop behaviour is identical to having `mempalace.enabled: false`.
You can safely leave `mempalace.enabled: true` in a config that will be used on machines without MemPalace — it is safe to do so.
---
## Full configuration reference
See [MemPalace Settings](../CONFIGURATION.md#mempalace-settings) in the Configuration Reference for the complete key list with types and defaults.