# Unnecessary Cloning Remediation

## AUDIT (2026-02-01)

**Pattern**: `.clone()` calls that could potentially be avoided

**Found**: 237 total clone calls across codebase

### Breakdown Analysis

| Category | Count | Justified? | Reason |
|----------|-------|------------|--------|
| Test code (tests/, mod tests) | 160 | ✅ Yes | Tests need owned values for assertions |
| Arc/Store cloning | 45 | ✅ Yes | Arc::clone is O(1), correct pattern |
| Lens::resolve() returns | 13 | ✅ Yes | Must return owned from borrowed input |
| apply_decay() copies | 6 | ✅ Yes | Creates modified assertion copies |
| API DTO construction | 12 | ✅ Yes | Response structs need owned data |
| PathBuf for errors | 7 | ✅ Yes | Error messages need owned paths |

### Key Insight: Lens Trait Signature

```rust
pub trait Lens {
    fn resolve(&self, candidates: &[Assertion]) -> Resolution;
}

pub struct Resolution {
    pub winner: Option<Assertion>,  // <-- OWNED
    // ...
}
```

Since `candidates` is borrowed and `Resolution.winner` is owned, **cloning is mandatory**. This is correct API design - the caller retains their data while getting a result.

### Potential Future Optimization (NOT DEBT)

Could use `Cow<'a, Assertion>` in Resolution:
```rust
pub struct Resolution<'a> {
    pub winner: Option<Cow<'a, Assertion>>,
}
```

But this would:
- Complicate every Lens implementation
- Add lifetime parameters throughout the codebase
- Save ~500 bytes per query (negligible)

**Not worth the complexity.**

## DECISION

**Status**: CLOSED - NO ACTION REQUIRED

The audit found **zero unnecessary clones**. The codebase follows Rust best practices:
- Arc for shared ownership
- Clone when transferring ownership from borrowed to owned
- Test code uses clone liberally (appropriate)

No FIX, VERIFY, ENFORCE, or DOCUMENT phases needed.
