Quality Score Fix
The Context Quality status line now reflects reality after /compact. Before v5.0.3, running /compact on a busy editing session rarely moved the score, even after the context was visibly cleaner. Two signals were at fault.
detect_stale_reads is now honest
Previously the signal flagged every Read followed by an Edit on the same file as stale, which is the normal agent edit workflow. Sessions with 50 reads and 30 edits could show a 70% stale ratio and drag the composite score toward zero, even when every read was genuinely used to plan the edit.
The detector now flags two real patterns instead:
- Re-read after write — the same file was already written earlier in the session, so the second read is wasted tokens.
- Far-distance stale — a read whose edit happens more than 120 records later with no intervening reads, meaning the original snapshot has aged out of the active working set.
Normal Read then Edit pairs within a working distance are no longer counted against you.
Scoring curves are softer
stale_readsdrops linearly from 100 at 0% to 0 at 100% (was 0 at 50%).compaction_depthgradient: 0 compactions → 100, 1 → 90 (was 60), 2 → 65 (was 25), 3+ → 35 (was 0). Running/compactonce no longer tanks the bar you just acted to fix.
Before/after on a real session
Same underlying JSONL, same hook, just the new signal code:
| Signal | Before | After |
|---|---|---|
| stale_reads | 0 | 53.3 |
| compaction_depth | 60 | 90 |
| Composite | 58.7 (C) | 73.0 (B) |
Rollback
Revert the commit and patch-bump. Signal-only changes. No schema migration, no hook contract change, no persistent state alteration.