InternalsConsolidation

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.

FileWhat it holds
scheduler.tsThe tick: candidates, clustering, merge, replay, finalize or restore
ConsolidationGate.tsThe gate a cluster must pass
ReplayValidator.tsThe 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

  1. Recover. Merges left pending by a crashed process are restored first.
  2. Lock check. If consolidation is locked for the workspace (mnemo_consolidation_lock), the tick stops. An error while reading the lock also stops it.
  3. Validator. The tick needs a replay validator, which needs an LLM. If none is available, the candidates are skipped.
  4. Candidates. Up to 20 active facts with worth of 0.4 or less. Facts with confidential or restricted sensitivity are excluded.
  5. 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.
  6. Gate. Each cluster goes through the gate below.
  7. Merge. The fact with the highest hitCount survives. The others are marked merged, point to the survivor, and the survivor’s worth goes up.
  8. 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.

ConditionfailedCondition
At least 3 memberscluster_too_small
No member is canonicalcanonical
Every member has worth below 0.5high_worth
No member was recalled in the last 14 daysrecently_recalled
No member has a Wilson lower bound above 0.7high_confidence
No member is pinnedpinned
No member is contestedcontested
All members share one sensitivity levelsensitivity_mismatch
Every member has an embeddingmissing_embeddings
Every pairwise cosine similarity is 0.85 or morelow_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.
ResultRuleWhat the scheduler does
flagged60% or more of the queries failRestores the absorbed facts
boostedOtherwise, 80% or more passKeeps the merge and boosts the survivor
neutralAnything elseKeeps the merge
skippedThe 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 confidential or restricted sensitivity.
  • 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.