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.Three Analysis Types
The synchronicity detector runs three independent analyses in parallel:- Co-occurrence
- Failure Correlation
- Emergent Workflows
What it finds: Tool pairs that are frequently used together within a short time window.Algorithm:
- Identify active tools (those with >= 10 events in the last 30 days)
- Use SQL window functions (
LEAD) to find sequential tool pairs within the same profile session - Filter to pairs where the gap between uses is less than 5 minutes
- Group by tool pair and count distinct profiles
- Only surface patterns observed by 3+ unique profiles (k-anonymity)
pluggedin_memory_search, users frequently use pluggedin_memory_details (47 profiles)”SQL core logic:Pattern Storage
Discovered patterns are stored asgut_patterns entries:
Hash Check
The description is HMAC-SHA256 hashed and checked against existing patterns to avoid duplicates.
Embedding Generation
A vector embedding is generated for the pattern description to enable semantic search.
Store in gut_patterns
New patterns are inserted with
pattern_type='synchronicity', initial confidence, and the anonymized profile count.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 usesTABLESAMPLE 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
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
Trigger Synchronicity Detection
Get Detected Patterns
SDK Usage
Configuration
| Variable | Default | Description |
|---|---|---|
SYNC_RETENTION_DAYS | 90 | Temporal event retention period |
SYNC_COOCCURRENCE_WINDOW_DAYS | 30 | Lookback for co-occurrence |
SYNC_COOCCURRENCE_GAP_MINUTES | 5 | Max gap between co-occurring tools |
SYNC_FAILURE_WINDOW_DAYS | 90 | Lookback for failure correlation |
SYNC_WORKFLOW_WINDOW_DAYS | 30 | Lookback for emergent workflows |
SYNC_WORKFLOW_GAP_MINUTES | 15 | Max total gap for three-step workflows |
SYNC_MIN_EVENTS_THRESHOLD | 10 | Minimum events for a tool to be included |
SYNC_ACTIVE_TOOLS_LIMIT | 200 | Max tools analyzed per run |
SYNC_TABLESAMPLE_PERCENT | 1 | Sampling percentage for large tables |
SYNC_TABLESAMPLE_TRIGGER_ROWS | 1000000 | Row count that triggers sampling |
SYNC_CRON_ENABLED | true | Enable/disable the detection cron |

