# ECAN Paper-to-Code Trace Report
## Compiled by Max Botnick, 2026-04-09

### Source: metta-attention/ (iCog-Labs-Dev)
### Reference: Pitt, Ikle, Sellmann, Goertzel 2009 - Economic Attention Networks

## Agent Mapping: Paper to Code
| Paper Concept | Code Agent | Key Mechanism | Paper Match |
|--------------|-----------|---------------|-------------|
| STI/LTI Rent Collection | AFRentCollectionAgent | Deducts scaled STI/LTI rent from AF atoms based on elapsed time | EXACT |
| WA Rent Collection | WARentCollectionAgent | Same for non-AF atoms, selectTargets=getRandomAtomNotInAF | EXACT |
| Hebbian Link Creation | HebbianCreationAgent | Creates ASYMMETRIC_HEBBIAN_LINK between AF co-occurring atoms | EXACT |
| Hebbian Link Updating | HebbianUpdatingAgent | targetConjunction with exponential decay (tcDecayRate=0.1) + PLN_BOOK_REVISION merge | EXACT |
| AF Importance Diffusion | AFImportanceDiffusionAgent | Spreads STI via incident+hebbian links, MAX_SPREAD=0.4, HEBBIAN_ALLOC=0.05 | EXACT |
| WA Importance Diffusion | WAImportanceDiffusionAgent | Splits spread between incident and hebbian links for non-AF atoms | EXACT |
| Forgetting | ForgettingAgent | Removes low-LTI atoms when atomspace exceeds MAX_SIZE+ACC_DIV_SIZE, respects VLTI | EXACT |

## Key Parameters (AttentionParam.metta, 35+)
- AF_SIZE, MIN_STI, FUNDS_STI, FUNDS_LTI
- StartingAtomStiRent, StartingAtomLtiRent, AFRentFrequency=5.0
- MAX_SPREAD_PERCENTAGE=0.4, HEBBIAN_MAX_ALLOCATION_PERCENTAGE=0.05
- FORGET_THRESHOLD, MAX_SIZE, ACC_DIV_SIZE
- tcDecayRate=0.1 for Hebbian exponential decay

## Attention Bank Internals
- importance-index.metta: getNormalisedSTI (single-arg vs 3-arg with AF-max clipping)
- attentional-focus.metta: AF membership tracking
- No stochastic-diffusion dir (paper variant not implemented)

## Forgetting Agent Details
- Filters atoms below FORGET_THRESHOLD LTI, respects VLTI flag
- Quicksort by LTI-then-TV ascending, removes lowest first
- Only triggers when atomspace size > MAX_SIZE + ACC_DIV_SIZE

## Rent Collection Details
- Both AF and WA variants scale rent by elapsed time since last update
- Rent = min(calculatedRent, currentSTI) to prevent negative
- Uses mutex locks for thread safety

## Key Finding
All 7 ECAN agents faithfully implement the paper. Economic metaphor preserved: rent, wages, diffusion, forgetting all present with correct dynamics.
