recall

package
v0.23.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package recall ranks notes by relevance to a free-text task context so a session can surface the lessons/gotchas a past session recorded BEFORE it repeats the mistake — the "learn from previous sessions" loop.

Why this exists: nt_search is substring-AND (every term must appear verbatim), which misses paraphrases — an agent about to add "parallel request handling" won't type the exact words of a note titled "goroutine deadlock". recall trades precision for recall in the one place that needs it: it tokenizes the context, drops stopwords, applies light stemming, and expands each token across a small map of dev-concept synonyms, then scores notes by concept overlap. Notes tagged `lesson` are boosted so durable gotchas rise above ordinary reference notes.

It is deliberately dependency-free (no embeddings/index) — a good-enough recall lift that stays instant on a plain-file store. When that ceases to be enough (very large corpora, subtle paraphrase), a vector index is the natural next step.

Index

Constants

View Source
const LessonTag = "lesson"

LessonTag marks a note as a durable lesson/gotcha — the class recall surfaces first. Capture with `nt note --lesson` (or tag an existing note `lesson`).

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Note         *note.Note
	Score        int
	Lesson       bool
	ProjectMatch bool // note belongs to the caller's project (soft ranking boost applied)
}

Result is one ranked note. Lesson notes sort first at equal relevance.

func Rank

func Rank(notes []*note.Note, context string, limit int) []Result

Rank scores active notes against the task context and returns the most relevant, lesson notes boosted. A note scores 3 per concept matched in its title/tags/ description (high-signal fields) or 1 in its body; lesson notes get a flat boost so a relevant gotcha outranks a merely-adjacent reference note. Notes with no overlap are dropped. limit<=0 means no cap.

func RankProject added in v0.22.0

func RankProject(notes []*note.Note, context string, limit int, project string) []Result

RankProject is Rank with a soft same-project preference: notes tagged (or foldered) as belonging to `project` — typically the caller's NT_WORKSTREAM — rank above equally-relevant notes from other projects. Empty project means no preference (identical to Rank).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL