# QMD Backend Checklist

Date: 2026-02-16
Status: completed

## Scope

- Add an experimental QMD (query markdown database) backend for `memory.search`.
- Enable config-driven backend selection between hybrid embeddings, QMD, and keyword fallback.
- Update docs and plan state.

## Completed

- Added `memory.qmd` config schema in `src/config/schema.ts`:
  - `enabled` (default `false`)
  - `top_k` (default `8`)
  - `min_score` (default `0.15`)
- Implemented `QmdSearch` backend in `src/memory/qmd-search.ts`:
  - heading-aware scoring
  - token overlap + phrase bonus ranking
  - session namespace recency boost
- Wired backend selection in `src/daemon/memory.ts`:
  - embedding enabled -> hybrid backend
  - else if qmd enabled -> QMD backend
  - else keyword-only search
- Generalized memory search tool wiring:
  - introduced shared backend interface for `memory.search`
  - updated memory tool factory to accept any backend implementing `search(query, topK?)`
- Updated docs:
  - README memory section now documents QMD config and backend precedence.
  - OpenClaw gap docs updated to mark QMD backend as implemented.
- Added tests:
  - `src/memory/qmd-search.test.ts`
  - `src/config/schema.test.ts` coverage for `memory.qmd`

## Verification

- `pnpm test:run src/config/schema.test.ts src/memory/qmd-search.test.ts`
- `pnpm typecheck`
