Repository navigation
fix(compaction): render APPROX_ATTRIBUTION kept_tail/pre ratio truthfully (>100% basis artifact) - #161
Merged
Conversation
…ully (>100% basis artifact)
The in-turn A-floor observability marker printed 'kept_tail 75378 / pre 74447 = 101.3%' — a
confusing >100% that reads as 'kept more than existed'. raw_tail_tokens is a documented UPPER BOUND
estimated on the RAW (pre-sanitize) suffix, while pre_tokens is counted on the sanitized/in-context
basis; the two are DIFFERENT bases, so the raw bound can legitimately exceed pre. Compaction itself is
unaffected — only the displayed fraction was misleading.
New _fmt_gross_frac() caps the displayed ratio at 100% and marks it as a bound with a basis note
('≥100% (raw-tail bound N ≥ pre M; raw vs sanitized basis)') when raw exceeds pre; normal within-bound
cases still render as a plain percent. The threshold COMPARISON is unchanged (a bound over the 10%
gross-error line still correctly triggers the two-line degrade) — this is display-only.
3 unit tests incl. the real captured 75378/74447 case; 116 compaction tests green, ruff clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The in-turn A-floor observability marker printed
kept_tail 75378 / pre 74447 = 101.3%in #logs (2026-07-01) — a confusing >100% that reads as "kept more than existed."Why it's not a real bug (just a display artifact)
raw_tail_tokensis a documented upper bound estimated on the raw (pre-sanitize) suffix;pre_tokensis counted on the sanitized/in-context basis. Different bases → the raw bound can legitimately exceedpre. Compaction itself is unaffected — only the displayed fraction was misleading.Fix (display-only)
New
_fmt_gross_frac()renders the ratio truthfully:≥100% (raw-tail bound N ≥ pre M; raw vs sanitized basis)(bounded + basis note)n/a (pre=0)(no divide-by-zero)The threshold comparison is unchanged — a bound over the 10% gross-error line still correctly triggers the two-line degrade. Only what's printed changed.
Tests
3 new unit tests incl. the real captured
75378/74447case; 116 compaction tests green, ruff clean.Reported via Apollo's 5-cron-alert investigation (Phase 6). Spec:
~/.hermes/plans/2026-07-01_five-cron-alerts-FIX-PRD.md.