← Back to blog
2025-12-087 min read

Long-Term Potentiation in Code: Making Memories Permanent

neurosciencealgorithmslearning
long-term-potentiation-code.md

Long-Term Potentiation in Code

In the brain, some memories become permanent. Not everything, but the important stuff. We implement the same principle.

What is LTP?

Long-Term Potentiation (LTP) is a biological process where repeated synaptic activation causes lasting strengthening. First observed in rabbit hippocampi by Bliss and Lømo in 1973.

Key properties:

1. **Input specificity**: Only activated synapses strengthen

2. **Cooperativity**: Multiple inputs strengthen more than one

3. **Persistence**: Changes last hours to lifetime

The Problem with Uniform Decay

Simple memory systems apply uniform decay:

```rust

// Naive approach

for memory in memories {

memory.strength *= DECAY_RATE; // Everything fades equally

}

```

This loses important knowledge. The user's core preferences shouldn't decay just because they weren't mentioned today.

Our LTP Implementation

Strength Tracking

Every memory and graph edge tracks:

```rust

pub struct MemoryMetadata {

strength: f32, // Current strength (0.0 - 1.0)

access_count: u32, // Total accesses

access_pattern: Vec<Timestamp>, // Recent access times

permanent: bool, // LTP achieved?

}

```

LTP Criteria

A memory becomes permanent when:

```rust

fn check_ltp(memory: &Memory) -> bool {

// Minimum strength threshold

if memory.strength < 0.8 {

return false;

}

// Minimum access count

if memory.access_count < 10 {

return false;

}

// Spaced repetition pattern

let intervals = compute_intervals(&memory.access_pattern);

if !has_spaced_pattern(&intervals) {

return false;

}

true // Achieves LTP

}

```

The spaced pattern check ensures the memory was accessed over an extended period, not just burst accessed.

Immunity to Decay

Once permanent, the memory is protected:

```rust

fn apply_decay(memory: &mut Memory) {

if memory.permanent {

// LTP memories don't decay

// But they can still be forgotten via explicit forget()

return;

}

// Normal decay for non-permanent memories

memory.strength *= calculate_decay_factor(memory);

}

```

What Becomes Permanent?

In practice, LTP captures:

Core user preferences ("prefers Rust")
Frequently-used patterns ("uses dependency injection")
Key decisions ("chose PostgreSQL for production")

Ephemeral context naturally fades:

Debugging sessions
One-off questions
Temporary workarounds

The Consolidation Report

Track what's becoming permanent:

```bash

$ shodh-memory consolidation-report

LTP Achieved (last 7 days):

- "User prefers functional programming patterns" (strength: 0.94)

- "Project uses Next.js with App Router" (strength: 0.91)

- "Testing strategy: unit tests with Jest" (strength: 0.88)

Approaching LTP:

- "Prefers explicit error handling over exceptions" (7/10 accesses)

- "Uses Tailwind CSS for styling" (8/10 accesses)

```

Results

With LTP enabled:

Core knowledge retention: 100% (never decays)
Memory database size: -34% (ephemera naturally prunes)
Retrieval quality: +12% (less noise from outdated context)

Memory should work like memory. Important things should last.