Skip to main content

Synchronicity Detection

Synchronicity detection discovers meaningful temporal co-occurrence patterns across anonymized user profiles. Inspired by Carl Jung’s concept of synchronicity — “meaningful coincidences” that are not causally related — this subsystem finds patterns that emerge organically from collective tool usage.
Synchronicity detection uses pure SQL analysis with no LLM calls. It operates entirely on the temporal_events table and stores discovered patterns in gut_patterns with pattern_type='synchronicity'.

How It Works

Temporal Event Collection

Every tool call and observation is recorded as a temporal event. Events are collected in a fire-and-forget manner — failures never block the critical path.
Only profile_hash is stored — never the raw profile UUID. This ensures that individual usage patterns cannot be traced back to specific users, even by database administrators.

Three Analysis Types

The synchronicity detector runs three independent analyses in parallel:
What it finds: Tool pairs that are frequently used together within a short time window.Algorithm:
  1. Identify active tools (those with >= 10 events in the last 30 days)
  2. Use SQL window functions (LEAD) to find sequential tool pairs within the same profile session
  3. Filter to pairs where the gap between uses is less than 5 minutes
  4. Group by tool pair and count distinct profiles
  5. Only surface patterns observed by 3+ unique profiles (k-anonymity)
Example output: “After using pluggedin_memory_search, users frequently use pluggedin_memory_details (47 profiles)”SQL core logic:

Pattern Storage

Discovered patterns are stored as gut_patterns entries:
1

Generate Description

Each pattern is formatted into a human-readable description.
2

Hash Check

The description is HMAC-SHA256 hashed and checked against existing patterns to avoid duplicates.
3

Embedding Generation

A vector embedding is generated for the pattern description to enable semantic search.
4

Store in gut_patterns

New patterns are inserted with pattern_type='synchronicity', initial confidence, and the anonymized profile count.
5

Reinforce Existing

If the pattern already exists, its occurrence_count is incremented and the profile count is updated.

Concurrency Protection

Synchronicity detection uses PostgreSQL advisory locks to prevent concurrent runs:

TABLESAMPLE for Scale

When the temporal events table exceeds 1,000,000 rows, the detector automatically uses TABLESAMPLE BERNOULLI(1%) to sample the data. This keeps analysis time constant regardless of table size while maintaining statistical accuracy.

Privacy Model

Profile Hashing

Raw profile UUIDs are hashed with HMAC-SHA256 before storage. The hash function uses a server-side secret key.

k-Anonymity

Patterns are only surfaced when observed by 3+ unique profile hashes. Individual behaviors cannot be singled out.

Retention Cleanup

Events older than 90 days (configurable) are automatically deleted via the cleanup cron endpoint.

API Reference

Record Temporal Events

Response:
In most cases, temporal events are recorded automatically by the memory system during observations. You only need to call this endpoint directly if building custom integrations.

Cleanup Old Events

Response:

Trigger Synchronicity Detection

Response:

Get Detected Patterns

Response:

SDK Usage

Configuration

Next Steps

Archetype System

How synchronicity patterns are delivered through archetype routing

Jungian Intelligence Overview

See how all four subsystems work together