Identity Anchor
Stable self-vector preventing catastrophic forgetting
The Identity Anchor plugin maintains a stable representation of your core coding identity across multiple training runs.
Why It Matters
Without an anchor, repeated LoRA training can cause catastrophic forgetting — the model drifts away from your fundamental preferences and coding style.
How It Works
- Capture: Watches
SELECTION_PROMOTEfor short, high-surprise declarative statements- Language-agnostic structural detection: 20-200 char fragments with surpriseScore ≥ threshold
- No English keywords needed — works for Polish, Japanese, Chinese, any language
- Vectorize: Builds a self-vector from fragments with embeddings (requires ≥3 for stability)
- Detect Drift: Before each training run, computes cosine similarity between current and baseline
- Boost: If drift exceeds threshold, repeats anchor fragments N times in training data
Configuration
{
"plugins": [
{
"name": "@the-brain-dev/plugin-identity-anchor",
"enabled": true,
"config": {
"driftThreshold": 0.3,
"boostFactor": 5,
"maxAnchorFragments": 20
}
}
]
}How It Integrates
During overnight training, the Identity Anchor injects boosted fragments before MLX training:
DEEP_CONSOLIDATE hook fires
↓
Identity Anchor: computeDrift()
↓ drift > 0.3?
Identity Anchor: getBoostedFragments()
↓
MLX Trainer: [boostedFragments, ...trainingData]Regression Fingerprinting (Phase 2)
The Identity Anchor now includes a HarnessFingerprintStore for tracking per-model per-benchmark performance over time. This enables the-brain to serve as a cognitive layer for meta-harness systems.
How It Works
- Auto-update:
ON_INTERACTIONhook detectslm-evalsource interactions and updates fingerprints - Welford's algorithm: Running mean and std per model/benchmark/metric — no raw data storage needed
- Anomaly detection: >2σ from baseline triggers anomaly flag (>3 samples required for confidence)
- Drift detection: Sliding window Z-score against historical baseline
Custom Hooks
| Hook | Purpose |
|---|---|
identity-anchor:predictRegression | Predict expected score ranges for a model+benchmark pair |
identity-anchor:assessSurprise | Compare observed score against fingerprint — returns z-score and anomaly flag |
identity-anchor:getFingerprints | Get all stored performance fingerprints |
identity-anchor:detectDrift | Check if a model is systematically degrading on a benchmark |
identity-anchor:fingerprintSummary | Human-readable summary of all stored fingerprints |
Persistence
Fingerprints are stored at ~/.the-brain/identity/harness-fingerprints.json. The store is auto-saved when dirty and loaded on daemon start.
Multi-User Mode
In team mode, each user gets a dedicated identity file at ~/.the-brain/identity/{userId}.json. The identity-anchor:switchUser(userId) hook swaps active user state, and SELECTION_PROMOTE saves to the correct per-user file based on interaction metadata.
MCP Integration
These hooks are exposed via MCP tools (brain_predict_regression, brain_record_run, brain_get_fingerprint, etc.) for use by external meta-harness systems like AHE and Meta-Harness.