Consolidation
Consolidation merges a cluster of similar, low-worth facts into one of them. Done blindly it destroys useful evidence (see Consolidation gate), so the worker is conservative: it never merges pairs, and it restores a merge that fails validation.
Source
The worker is the internal package
packages/consolidation.
It is not on npm; it runs inside the server.
| File | What it holds |
|---|---|
scheduler.ts | The tick: candidates, clustering, merge, replay, finalize or restore |
ConsolidationGate.ts | The gate a cluster must pass |
ReplayValidator.ts | The check that the survivor can still be recalled |
When it runs
The server starts the scheduler at boot. It ticks every 60 seconds and looks at up to 20 candidate facts per workspace per tick. The interval and the batch size are not configurable today.
You can also run one tick for your workspace on demand:
curl -X POST http://localhost:3939/consolidation/trigger \
-H "Authorization: Bearer mns_live_..." \
-H "Content-Type: application/json" \
-d '{"mode": "fast"}'mode: "deep" and dryRun: true are reserved: both answer 422
(deep_mode_not_supported, dry_run_not_supported). The MCP tool
memory_consolidate calls the same route.
One tick, per workspace
- Recover. Merges left pending by a crashed process are restored first.
- Lock check. If consolidation is locked for the workspace
(
mnemo_consolidation_lock), the tick stops. An error while reading the lock also stops it. - Validator. The tick needs a replay validator, which needs an LLM. If none is available, the candidates are skipped.
- Candidates. Up to 20 active facts with
worthof 0.4 or less. Facts withconfidentialorrestrictedsensitivity are excluded. - Cluster. Greedy clustering on the stored embeddings: the seed is the
fact with the highest hit count (
hitCount), and members are facts with cosine similarity of 0.85 or more to the seed. Clusters of fewer than three facts are discarded. - Gate. Each cluster goes through the gate below.
- Merge. The fact with the highest
hitCountsurvives. The others are markedmerged, point to the survivor, and the survivor’s worth goes up. - Replay. The validator runs recall queries and checks that the survivor still comes back. If the merge is flagged, the absorbed facts are restored.
The gate
A cluster passes only if every condition holds. The gate returns the first
condition that fails, in failedCondition.
| Condition | failedCondition |
|---|---|
| At least 3 members | cluster_too_small |
| No member is canonical | canonical |
Every member has worth below 0.5 | high_worth |
| No member was recalled in the last 14 days | recently_recalled |
| No member has a Wilson lower bound above 0.7 | high_confidence |
| No member is pinned | pinned |
| No member is contested | contested |
| All members share one sensitivity level | sensitivity_mismatch |
| Every member has an embedding | missing_embeddings |
| Every pairwise cosine similarity is 0.85 or more | low_similarity |
Replay validation
The validator makes no durable change. It only evaluates:
- It takes up to ten distinct recent real queries that hit the merged facts, read from the recall log.
- If fewer than five exist, it asks the LLM to generate the missing ones, to reach five.
- It runs recall for each query and counts passes and failures.
| Result | Rule | What the scheduler does |
|---|---|---|
flagged | 60% or more of the queries fail | Restores the absorbed facts |
boosted | Otherwise, 80% or more pass | Keeps the merge and boosts the survivor |
neutral | Anything else | Keeps the merge |
skipped | The validator could not finish (an LLM or recall error, or fewer than five queries) | Restores the absorbed facts |
A failure of the infrastructure is never counted as a quality miss.
What is never merged
- Pinned facts and canonical facts: the gate rejects any cluster that contains one.
- Contested facts.
- Facts with
confidentialorrestrictedsensitivity. - Anything that is not a fact. The worker only reads facts, so episodes, decisions and the other kinds are left alone.
- Facts from different workspaces. Consolidation is scoped to one workspace.