Repository navigation
feat(editor): rank suggestions and make targets by frecency (#140) - #188
Merged
Merged
Conversation
The ghost, Alt-N/Alt-P and `make <TAB>` now prefer what is run often and lately: each distinct line scores the sum of 2^16 >> (age / 64) over its occurrences in the HELLISH_SUGGEST_MAX window, ties to the newest. HELLISH_SUGGEST_STRATEGY=recent restores newest-first; read every prompt. One ranking primitive (rl_suggest_rank) feeds the ghost and the cycle; it groups by sort over a reused scratch buffer instead of libft's t_hash, which strdups every key (per-key malloc churn). The fast path is kept: a score does not depend on the prefix, so a winner that still matches a longer line stays the best of the smaller set. make TAB turns readline's match sort off only for its own answer; every attempt starts with it on. libc qsort, not ft_qsort: ft_qsort pivots on the last element and is O(n^2) on runs of identical entries, which arrive already in ranking order: 6.76 s for one key over 20000 copies (F13 red), under 1.5 s with qsort. Tests: autosuggest F1-F13 plus a randomized model-vs-shell cycle check, case_cycle_dupes pinned to `recent` with a frecent twin (the only existing case whose order changes), make cases 25-29 (order, sort-flag restore, recent, user complete spec, -C/-f), frontend budget with 1000 distinct entries and Backspace: 6.0 syscalls / 1.1 writes per key. Mutants MF1-MF11 (age, frequency, tie, direction, strategy x2, window, sort flag, make history, cycle order, clean filter) each turn cases red.
This was referenced Oct 18, 2026
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.
Part of #140 (PR3c, the last part). It implements the issue's example: with
make rerun 3 times andmake cleanmost recent,makesuggestsre.Ranking
Σ 2^16 >> (age/64)over its occurrences in theHELLISH_SUGGEST_MAXwindow. Ties go to the newest.make <TAB>: run targets first, the rest alphabetical.HELLISH_SUGGEST_STRATEGY=recentgives the old newest-first order. It's read at every prompt.Design
rl_suggest_rank), built by sorting a reused buffer: no hash table, no allocation per key.Perf fix found in review:
ft_qsort(last-element pivot) is O(n²) on runs of identical entries: 6.76 s for one key over 20,000 copies. libcqsortbrings it under 1.5 s. Test F13 covers it.Tests
case_cycle_dupesis the only existing case whose order changes. It's pinned torecent, and a frecent twin is added.recent, usercompletespec,-C/-f.Mutants: MF1–MF11 (age, frequency, tie, direction, strategy ×2, window, sort flag, make history, cycle order, clean filter) each turn cases red. Every mutant build was checked to compile.
Local gates
make re/OPT=1/OPT=1 SAFE=1verify_allocmake help-testHELLISH_ALLOC_STATSCaveats (in code):
make a && make bover-credits, andsudo make xisn't counted.🤖 Generated with Claude Code