# Decay Recency-weighted structured compaction for Pi. Load `extensions/decay/index.ts` through Pi's package discovery. Set the optional compaction model in Pi settings: ```json { "decay": { "model": "provider/classifier-model", "summarizerModel": "provider/summarizer-model" } } ``` Omit `model` or set it to `null` to use the current session model. Omit `summarizerModel` or set it to `null` to reuse the classifier model. Failed Decay runs delegate to Pi's default compactor and append a bounded `decay-diagnostic` custom entry containing the outcome, stage, model, sanitized reason, and timestamp. The custom entry is persisted in session JSONL but excluded from model context. Failure handling differs per stage because only some stages can degrade without inventing memory. A transient classifier failure, or a stream that omits chunks, triggers up to two gap-fill rounds that reclassify only the missing chunks before falling back. Exact duplicate records for one chunk are tolerated, while conflicting reclassification, total-count drift, invalid indexes, authentication errors, and misconfigured models fall back immediately. Unclassified chunks are never given default records, since inventing or silently dropping memory would fail invisibly. A summarizer failure salvages instead of falling back: Decay renders the ranked atoms deterministically into the same section structure without a model call, marks the compaction `degraded: "summarizer"`, and records a `salvage` diagnostic. Salvaged summaries keep the classified facts, provenance, ranking, and recurrence identity, and lose only prose synthesis. Repeated compactions provide the classifier a bounded prior-atom identity catalog so paraphrased facts can reuse exact recurrence keys without counting catalog entries as new occurrences. Interactive progress uses a passive, borderless five-row widget above Pi's editor, preserving native steering submission and Escape cancellation during compaction. The aligned `CTX`, `FACTS`, and `NEW` maps use compact human-readable counts and reversed semantic colors so overlaid labels remain legible across themes. Classifier records replace muted pending cells with durable and context regions as they arrive. After reconciliation, selected canonical facts turn to the accent color before streamed summary cells grow at the start of `NEW`. `CTX` and `NEW` share a token scale, so the retained suffix keeps the same approximate width and follows the growing summary in the resulting context. `keepRecentTokens` is Pi's configured target, not an exact count or minimum guarantee. Pi chooses whole-entry boundaries, which can retain more or fewer tokens than the target. Decay preserves `firstKeptEntryId` unchanged and does not send the retained suffix to its classifier. The displayed retained count and `estimatedKeptTokens` details field use Pi's message-token estimator over the actual retained suffix, including older summaries when present. `~` marks estimates; unavailable boundaries display `?`, never the configured target as a measured count. The [original Decay plan](../../docs/super/plans/2026-08-22-decay-compaction.md) contains earlier visual artifacts. The current widget uses five contiguous lines at every terminal height; aligned evidence-driven maps replace that plan's eight-line design. That plan's blanket "any non-abort failure uses default compaction" rule is superseded by the staged policy above.