> ## Documentation Index
> Fetch the complete documentation index at: https://docs.plugged.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Jungian Intelligence Layer

> Psychology-inspired memory subsystems for pattern detection, archetype-driven delivery, memory consolidation, and maturity scoring

# Jungian Intelligence Layer

The Jungian Intelligence Layer (v3.2.0) adds four psychology-inspired subsystems on top of the existing concentric memory rings and Collective Best Practices. Named after Carl Jung's analytical psychology, each subsystem maps to a core Jungian concept to transform raw memory data into meaningful, context-aware intelligence.

> [!NOTE]
>
> The Jungian Intelligence Layer builds on the memory infrastructure introduced in v3.1.0. If you are new to the memory system, start with the [Memory & Intelligent Knowledge](https://docs.plugged.in/platform/memory.md) page.

## The Four Subsystems

> [card] [Synchronicity Detection](https://docs.plugged.in/guides/synchronicity-detection.md)
>
> Discovers meaningful temporal co-occurrence patterns across anonymized profiles using pure SQL analysis. Three detection types: co-occurrence, failure correlation, and emergent workflows.

> [card] [Archetype System](https://docs.plugged.in/guides/archetype-system.md)
>
> Classifies patterns into four Jungian archetypes -- Shadow (warnings), Sage (best practices), Hero (workflows), and Trickster (creative solutions) -- using deterministic context mapping.

> [card] [Dream Processing](https://docs.plugged.in/guides/dream-processing.md)
>
> Consolidates clusters of semantically similar memories into single unified entries via LLM, reducing token consumption while preserving all key insights.

> [card] [Individuation Scoring](https://docs.plugged.in/guides/individuation-scoring.md)
>
> Per-profile maturity scoring across four components (Memory Depth, Learning Velocity, Collective Contribution, Self-Awareness) with five maturity levels from Nascent to Individuated.

***

## How It All Fits Together

The four subsystems operate on different layers of the memory stack but work together to create a self-improving intelligence system:

```
  Observations (tool calls, outcomes, errors)
         |
         v
  +-----------------------+     +-------------------------+
  | Temporal Events       | --> | Synchronicity Detector  |
  | (anonymized, hashed)  |     | (pure SQL, no LLM)      |
  +-----------------------+     +-------------------------+
         |                              |
         v                              v
  +-----------------------+     +-------------------------+
  | Fresh Memory          | --> | Archetype Router        |
  | (concentric rings)    |     | (deterministic mapping) |
  +-----------------------+     +-------------------------+
         |                              |
         v                              v
  +-----------------------+     +-------------------------+
  | Memory Ring           | --> | Dream Processor         |
  | (long-term store)     |     | (cluster + LLM merge)   |
  +-----------------------+     +-------------------------+
         |                              |
         v                              v
  +-----------------------+     +-------------------------+
  | Individuation Score   | <-- | All subsystems feed     |
  | (maturity metrics)    |     | into scoring components |
  +-----------------------+     +-------------------------+
```

1. **Temporal events** are recorded during every tool call and observation (fire-and-forget, non-blocking)
2. **Synchronicity detection** runs periodically (cron) to discover co-occurrence patterns, failure correlations, and emergent workflows across all anonymized profiles
3. **The archetype router** enriches every pattern injection with a Jungian archetype label and weighted score, ensuring the most contextually relevant patterns are surfaced first
4. **Dream processing** runs during the decay cron to discover clusters of related memories and consolidate them, saving tokens while preserving knowledge
5. **Individuation scoring** aggregates metrics from all subsystems into a single maturity score that tracks profile growth over time

## Privacy Model

> [card] Profile Hash Only
>
> Temporal events store `profile_hash` (HMAC-SHA256), never raw UUIDs. Individual usage patterns cannot be traced back to specific users.

> [card] k-Anonymity (k >= 3)
>
> Synchronicity patterns are only surfaced when observed by 3 or more unique profiles. Individual behaviors are never exposed.

## SDK & MCP Integration

### SDK Methods

All methods are available in the JavaScript, Python, and Go SDKs:

```typescript JavaScript theme={null}
import { PluggedInClient } from 'pluggedinkit-js';

const client = new PluggedInClient({ apiKey: 'your-api-key' });

// Archetype-aware memory search
const results = await client.jungian.searchWithContext({
  query: 'database migration patterns',
  toolName: 'drizzle_migrate',
  outcome: 'failure',
});

// Get individuation score
const score = await client.jungian.getIndividuationScore();
console.log(`Level: ${score.level}, Total: ${score.total}/100`);

// Get score history for charting
const history = await client.jungian.getIndividuationHistory(30);

// Get synchronicity patterns
const patterns = await client.jungian.getSynchronicityPatterns();

// Get dream consolidation history
const dreams = await client.jungian.getDreamHistory();
```

```python Python theme={null}
from pluggedinkit import PluggedInClient

client = PluggedInClient(api_key="your-api-key")

# Archetype-aware memory search
results = client.jungian.search_with_context(
    query="database migration patterns",
    tool_name="drizzle_migrate",
    outcome="failure"
)

# Get individuation score
score = client.jungian.get_individuation_score()
print(f"Level: {score.level}, Total: {score.total}/100")

# Get score history
history = client.jungian.get_individuation_history(days=30)

# Get synchronicity patterns
patterns = client.jungian.get_synchronicity_patterns()

# Get dream history
dreams = client.jungian.get_dream_history()
```

```go Go theme={null}
package main

import (
    "context"
    "fmt"
    pluggedinkit "github.com/veriteknik/pluggedinkit-go"
)

func main() {
    client := pluggedinkit.NewClient("your-api-key")
    ctx := context.Background()

    // Archetype-aware memory search
    results, _ := client.Jungian.SearchWithContext(ctx,
        "database migration patterns",
        "drizzle_migrate",
        "failure",
    )

    // Get individuation score
    score, _ := client.Jungian.GetIndividuationScore(ctx)
    fmt.Printf("Level: %s, Total: %d/100\n", score.Level, score.Total)

    // Get score history
    history, _ := client.Jungian.GetIndividuationHistory(ctx, 30)

    // Get synchronicity patterns
    patterns, _ := client.Jungian.GetSynchronicityPatterns(ctx)

    // Get dream history
    dreams, _ := client.Jungian.GetDreamHistory(ctx)
}
```

### MCP Tools

| Tool | Description |
| - | - |
| `pluggedin_memory_search_with_context` | Search memories with archetype-aware context. Accepts `query`, optional `toolName`, and optional `outcome`. Returns patterns enriched with archetype labels and weights. |
| `pluggedin_memory_individuation` | Get your individuation score with maturity level, component breakdown, weekly trend, and an actionable improvement tip. |

## Configuration

All settings have sensible defaults and can be tuned via environment variables:

> [tab] Synchronicity
>
> | Variable | Default | Description |
> | - | - | - |
> | `SYNC_RETENTION_DAYS` | `90` | How long temporal events are retained |
> | `SYNC_COOCCURRENCE_WINDOW_DAYS` | `30` | Lookback window for co-occurrence analysis |
> | `SYNC_COOCCURRENCE_GAP_MINUTES` | `5` | Max gap between co-occurring tool uses |
> | `SYNC_FAILURE_WINDOW_DAYS` | `90` | Lookback window for failure correlation |
> | `SYNC_WORKFLOW_WINDOW_DAYS` | `30` | Lookback window for emergent workflows |
> | `SYNC_WORKFLOW_GAP_MINUTES` | `15` | Max total gap for three-tool workflows |
> | `SYNC_MIN_EVENTS_THRESHOLD` | `10` | Minimum events for a tool to be analyzed |
> | `SYNC_CRON_ENABLED` | `true` | Enable/disable the synchronicity cron |

> [tab] Dream Processing
>
> | Variable | Default | Description |
> | - | - | - |
> | `DREAM_ENABLED` | `true` | Enable/disable dream processing |
> | `DREAM_MIN_CLUSTER_SIZE` | `3` | Minimum memories to form a cluster |
> | `DREAM_SIMILARITY_THRESHOLD` | `0.75` | Cosine similarity threshold for clustering |
> | `DREAM_MAX_CLUSTERS_PER_RUN` | `10` | Max clusters processed per decay cron |
> | `DREAM_CONSOLIDATION_MAX_INPUT_TOKENS` | `1500` | Max input tokens per LLM consolidation |
> | `DREAM_CONSOLIDATION_MAX_OUTPUT_TOKENS` | `300` | Max output tokens for consolidated memory |
> | `DREAM_COOLDOWN_DAYS` | `7` | Minimum days between dream runs |
> | `DREAM_TOP_K_NEIGHBORS` | `3` | Number of nearest neighbors per memory |

> [tab] Archetype Router
>
> | Variable | Default | Description |
> | - | - | - |
> | `ARCHETYPE_ENABLED` | `true` | Enable/disable archetype routing |
> | `ARCHETYPE_MAX_PATTERNS_PER_TYPE` | `2` | Max patterns returned per archetype |
> | `ARCHETYPE_SHADOW_BOOST` | `1.2` | Weight multiplier for Shadow in error contexts |
> | `ARCHETYPE_SAGE_BOOST` | `1.1` | Weight multiplier for Sage in error contexts |

> [tab] Individuation
>
> | Variable | Default | Description |
> | - | - | - |
> | `INDIVIDUATION_ENABLED` | `true` | Enable/disable individuation scoring |
> | `INDIVIDUATION_CACHE_TTL_MINUTES` | `60` | In-memory cache TTL for scores |
> | `INDIVIDUATION_HISTORY_DAYS` | `90` | Lookback window for score calculation |

## Next Steps

> [card] [Synchronicity Detection](https://docs.plugged.in/guides/synchronicity-detection.md)
>
> Deep dive into temporal pattern detection

> [card] [Archetype System](https://docs.plugged.in/guides/archetype-system.md)
>
> How archetype-driven pattern delivery works

> [card] [Dream Processing](https://docs.plugged.in/guides/dream-processing.md)
>
> Memory consolidation and token savings

> [card] [Individuation Scoring](https://docs.plugged.in/guides/individuation-scoring.md)
>
> Per-profile maturity metrics and trends


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.