Foresight.Reflect.MentalModelRanking (Foresight v0.2.1)

Copy Markdown View Source

Lexical relevance ranking + limit for the reflect search_mental_models tool .

The fallback behind Foresight.Reflect.MentalModels.rank/8: used when the query is blank, the bank's embedding profile cannot be resolved, or the query cannot be embedded. Ranks by query token overlap over title+original_text and takes the top limit; a blank query preserves input order (already external_id-ordered), and ties are stable.

Summary

Functions

Rank mental_models by lexical relevance to query, returning the top limit.

Functions

rank(mental_models, query, limit)

@spec rank([map()], String.t() | nil, non_neg_integer()) :: [map()]

Rank mental_models by lexical relevance to query, returning the top limit.

Each item may be any struct/map exposing :title and :original_text (atom or string keys). A blank/nil query preserves input order; equal-relevance ties keep input order (stable sort).