# Keep memory healthy

BrigadeStack memory care is a local scanner for durable memory cards. It detects cards that need review, writes a refresh queue, and routes review tasks into the existing work inbox.

## Commands

```bash
brigadestack memory care init
brigadestack memory care scan
brigadestack memory care plan-fixes
brigadestack memory care backfill
brigadestack memory care status
brigadestack memory care doctor
brigadestack memory care import-issues
brigadestack memory care closeout
```

`init` writes `.brigade/memory-care.toml`. The config is host-local and should stay gitignored.

## Config

The local config supports:

- `card_roots`: directories containing memory card Markdown files.
- `index_paths`: memory indexes such as `MEMORY.md`.
- `stale_after_days`: review age threshold.
- `expiry_warning_days`: days before `fresh_until` or `expires_at` counts as expired.
- `minimum_confidence`: `unknown`, `low`, `medium`, or `high`.
- `require_evidence`: whether cards without evidence metadata are flagged.
- `include_paths` and `exclude_paths`: relative path prefixes.
- `output_path`: where `scan-latest.json` and `refresh-queue.json` are written.
- `enabled_checks`: enabled issue types.
- `max_card_bytes`: oversized-card threshold.
- `read_only_paths`: globs for policy cards. `scan`, `plan-fixes` and `backfill` skip matching cards, and `brigadestack memory proposal create` and `apply` refuse them with an error that names the pattern. `status` and `doctor` list the active patterns.

## Issue Types

Memory care can emit:

- `stale`
- `unconsolidated-evidence`
- `expired`
- `undersourced`
- `contradictory`
- `missing-index-link`
- `orphaned-card`
- `oversized-card`
- `missing-frontmatter`
- `missing-reviewed`
- `missing-freshness`
- `missing-evidence-ref`

`unconsolidated-evidence` flags a card when evidence logged by ingest is newer than its last consolidation (or last review). `missing-evidence-ref` flags a card that cites evidence it cannot resolve. Neither has an automatic fix, because both need a judgment about the evidence.

Contradiction detection in `scan` is deliberately conservative. It flags only explicit duplicate card identities or metadata hints. Checking whether a card's facts still hold is done by the model-backed `memory verify`, described below.

## Safe Fix Planning and Backfill

`brigadestack memory care plan-fixes` reads the latest scan and builds a plan for low-risk metadata repairs such as missing reviewed dates or missing freshness dates. In 0.31.0 it does not write card files (see 0.32.0 beta under [What it writes](#what-it-writes) for `--apply`). Plan items include candidate metadata fields, source fingerprints, blockers, and the next review command.

`brigadestack memory care backfill` handles the bulk version of the same repair for setups whose cards predate the freshness convention. It derives `last_reviewed` from each card's last git commit date (file mtime outside git, labeled as the lower-confidence source) and proposes `fresh_until` from the configured stale window. It is dry-run by default. `--apply` writes the derived values into card frontmatter, never overwrites an existing value, and records the run under `.brigade/memory-care/backfills/`. Backfilled dates reflect the real age, so an old card lands as stale immediately.

## Refresh Queue

`brigadestack memory care scan` writes:

```text
.brigade/memory-care/decay/scan-latest.json
.brigade/memory-care/decay/refresh-queue.json
```

Scanner state lives under `.brigade/`, outside your `memory/cards/` tree. An explicit `output_path` in the config is honored unchanged, and readers (`import-issues`, `status`, `doctor`) fall back to the legacy `memory/cards/decay/` location when it still holds the latest scan.

Queue entries include card identity, issue type, severity, priority, safe summary, evidence references, suggested refresh action, acceptance criteria, source item key, and source fingerprint. `brigadestack memory care import-issues` imports those entries as source `memory-care` task imports with dedupe and dismissed-until-changed behavior.

## Closeout

`brigadestack memory care closeout` records review metadata for the current refresh queue, closing the loop opened by `import-issues`. It marks the current queue as reviewed. Use `--reason` to annotate the closeout and `--defer` to mark the queue deferred instead of reviewed. `--json` prints machine-readable output.

## What it writes

In 0.31.0, memory care does not edit card content, sync remotely, or promote imports. The one command that changes cards is `backfill --apply`, which fills missing frontmatter dates and keeps existing values. Refreshes go through work tasks or the Memory Handoff flow.

**0.32.0 beta.** Memory care tends cards on its own, with an undo for every change:

- `brigadestack memory care tend` runs five stages: retry pending backend operations, apply low-risk fixes, report retirement eligibility, drain the review inbox, and report instruction-file budgets. `--stage` picks one, `--dry-run` previews, and `[tend] enabled = false` in `.brigade/memory-care.toml` turns it off.
- The fixes stage fills `fresh_until` from the review date and `last_reviewed` from the card's last git commit. It reports the other issue types and leaves them alone. `plan-fixes --apply` applies the same list.
- A successful `brigadestack ingest` drains the review inbox itself. Drafts whose content already sits in the destination are resolved, stale ones are retried, and anything uncertain stays held for a person. `ingest --no-tend` skips it once.
- Every automatic change is journaled with the card's before-bytes. `brigadestack memory care undo <decision-id>` restores it, and `recover <decision-id>` finishes a change that was interrupted.
- `brigadestack memory care archive --from-file decisions.jsonl` moves cards to `memory/archive/cards/` with the same undo. Automatic archiving of unused cards is switched off in code for now, so only this explicit command archives.
- `tend` runs when you call it and after ingest. The daily care pass that `brigadestack care install` schedules also calls it.

For model-backed checking, see [reflection and model-backed verification](/docs/commands/memory-care#reflection-and-model-backed-verification). `brigadestack memory verify` asks two agents to check cards against their evidence, `memory reflect` proposes duplicate merges without a model, and `brigadestack care install` can schedule both. They open proposals, and need configuration before they run.