Skip to main content

Guard System

The Guard is SharedMemory's quality control layer. Every memory entry passes through validation before being accepted.

Why a Guard?​

Without validation:

  • The same fact gets stored 50 times
  • Contradictory facts coexist
  • Low-quality data pollutes the knowledge graph

Tiered Architecture​

Tier 1: Similarity Threshold (instant)​

Similarity ScoreDecision
< 0.55Auto-approve — New knowledge
> 0.97Auto-reject — Near-duplicate
0.55 – 0.97Escalate to Tier 2

This fast path handles ~70% of entries without an LLM call.

Tier 2: LLM Guard​

For ambiguous cases, an LLM evaluates the new entry against existing knowledge.

DecisionAction
approvedNew, non-conflicting → index it
rejectedContradicts existing → discard
flaggedPotentially conflicting — needs review
mergedComplementary — combined with existing
duplicateSemantically identical — skip

Examples​

New: "John moved to Seattle in 2024"
Existing: "John lives in San Francisco"
Score: 0.72
Decision: flagged (potential conflict)
New: "John is a software engineer"
Existing: "John Smith works as a senior software engineer at Google"
Score: 0.89
Decision: duplicate (existing is more specific)
New: "John completed his AWS certification in March 2024"
Existing: "John has experience with cloud computing"
Score: 0.61
Decision: approved (new specific fact that complements existing)

Monitoring​

Guard decisions are logged in Postgres, broadcast via WebSocket, visible in the dashboard activity feed, and exposed through webhooks.