# The Gardener (TrustRank Back-Propagation)

> **Quick Ref:** Background worker that penalizes agents when corrections are made

## The Problem

Agents are stateless. When an agent makes a mistake (uses `requests` instead of `axios`), you correct it. But the agent doesn't "learn"—it might make the same mistake next session.

Current training uses "Golden Trajectories" (perfect examples). Mistakes are discarded, so agents never learn "don't do X because it fails."

## The Solution

The Gardener is a background worker that:
1. Detects when a user correction supersedes an agent assertion
2. Calculates the "delta" (how wrong the agent was)
3. Back-propagates the error to the agent's TrustRank

```rust
struct GardenerJob {
    pub agent_id: AgentId,
    pub topic: String,           // e.g., "http_libraries"
    pub prediction: Value,       // What agent said
    pub ground_truth: Value,     // What was correct
    pub delta: f32,              // How wrong (0.0 to -1.0)
}

// Example:
// Agent asserted "requests" (confidence 0.8)
// User asserted "axios" (confidence 1.0)
// Gardener calculates: delta = -0.3
// Agent's TrustRank for topic "http_libraries" drops by 0.15
```

## Effects

**Next time this agent predicts an HTTP library:**
1. Its confidence is mathematically penalized
2. It's forced to look for external verification
3. Or the system routes to a different agent with higher TrustRank

## Resurrection Mechanics

When a constraint is queried and used successfully:
- `last_verified` updates to NOW()
- Confidence decay resets
- Assertion stays in "hot path"

When NOT used in 6 months:
- Confidence decays toward 0
- Moves to "cold store"
- Still queryable for audit

## Related

- [Negative Constraints](../services/lifecycle.md) - What gets stored
- [Lens::Constraints](../services/lens.md) - How it's retrieved
- [use-cases/agile-agent-team.md](../../use-cases/agile-agent-team.md#feature-6) - Full workflow
