> ## Documentation Index
> Fetch the complete documentation index at: https://agent-memory.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Recall

> How search ranks what comes back

`mem::search` and `mem::smart-search` rank through three streams: BM25 keyword, vector similarity (on-device embeddings by default), and knowledge-graph adjacency. Stream scores fuse per item over the streams that actually matched it, with a small bonus when streams agree, and deterministic ordering on ties.

Results carry session diversity caps so one session cannot monopolize a page. Superseded memory versions never appear; the current version does.

Lessons recall separately with confidence and recency weighting, from a dedicated index.

## Projects, branches, and worktrees

Memories carry a `project` field, and searches can filter on it, so recall stays scoped to the repo you're in rather than bleeding across unrelated codebases.

Git worktrees resolve to one shared memory, not one silo per checkout: `mem::detect-worktree` maps any worktree's cwd back to the main repository root (via `git rev-parse --git-common-dir`), so parallel worktrees of the same repo read and write the same project memory. `mem::list-worktrees` enumerates the checkouts and `mem::branch-sessions` groups sessions by repo root and branch — the REST forms are `branch/detect`, `branch/worktrees`, and `branch/sessions`. Outside a git repo, the cwd itself acts as the project root.
