> ## 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.

# Governance

> Deletion, decay, and the audit trail

Every delete, share, import, and sweep writes an audit entry. `memory_audit` (`GET /agentmemory/audit`) queries the trail.

## Explicit deletion

| Surface                                            | What it does                                                                                                                                                                   |
| -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `POST /agentmemory/forget`                         | Delete one memory by id, specific observations, or a whole session; removes search index entries and image references with it                                                  |
| `memory_governance_delete` / `governance/memories` | Delete specific memory ids with a reason recorded in the audit trail                                                                                                           |
| `governance/bulk-delete`                           | Filtered bulk delete by type, date range, or strength below a threshold. A non-dry-run requires at least one filter; `dryRun: true` returns the candidate ids without deleting |

## Automatic sweeps

All sweeps run inside the daemon; each is a plain function you can also trigger manually with `dryRun`.

| Sweep         | Default cadence                                                                | What it does                                                                                                                                                    |
| ------------- | ------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Auto-forget   | Hourly (`AUTO_FORGET_INTERVAL_MS`), disable with `AUTO_FORGET_ENABLED=false`   | Deletes memories whose `forgetAfter` TTL has passed, flags near-duplicate contradictions (similarity above 0.9), prunes low-value observations                  |
| Lesson decay  | Every 24h, disable with `LESSON_DECAY_ENABLED=false`                           | Applies each lesson's decay rate per week since last reinforcement, floors confidence at 0.05, and soft-deletes lessons that reach 0.1 with zero reinforcements |
| Insight decay | Every 24h, disable with `INSIGHT_DECAY_ENABLED=false`                          | Same decay treatment for synthesized insights                                                                                                                   |
| Consolidation | Every 2h (`CONSOLIDATION_INTERVAL_MS`), only when `CONSOLIDATION_ENABLED=true` | Runs the 4-tier pipeline; memories older than `CONSOLIDATION_DECAY_DAYS` without reinforcement decay                                                            |

## Eviction and retention scoring

`POST /agentmemory/evict` runs the eviction pass: stale sessions without summaries, low-importance observations, per-session caps, expired and superseded memories. `dryRun` counts without deleting.

The worker functions `mem::retention-score` and `mem::retention-evict` score every memory from type weight, confidence, and access count, bucket the scores into tiers, and evict the lowest-scoring records below a threshold, capped at `maxEvict` (default 50, max 1000), with `dryRun` support.

## TTL on save

A memory saved with `forgetAfter` expires at that timestamp; the auto-forget sweep enforces it. Deletions triggered this way are audited like manual ones.
