Documentation
¶
Overview ¶
Package recall is the one recall for memory notes and pages (itd-2610091918433290, itd-39; spc-2610111627213138). The prompt router calls it once per prompt, after rules.Inject, with the items the memory layers yield, and it returns one block headed "## MEMORY" for the hook to append after the rules block.
Matching is the loader's own (rules.TermMatcher), so a note's recall word and a rule domain's recall word hit on exactly the same prompts. The per-session ledger is SessionState.Recalled, keyed on each item's content, cleared by the loader's resets. The budget is what the rules leave of the loader's one per-turn budget (rules.InjectionBudgetBytes). Until the relevance ranking lands (step 4), the candidates are taken in id order.
Step 2 recalls notes; pages join the same path in step 3. Nothing here writes to stdout or knows a transport.
Index ¶
Constants ¶
const ( LayerProject = "project" LayerMachine = "machine" )
The layers an item comes from, as the diagnostic names them.
Variables ¶
This section is empty.
Functions ¶
func ReadLayers ¶
ReadLayers is the one reader of both note layers, for the recall and for the memory verb alike: the machine's under home, the project's under repoRoot, the root the rules loader resolved, each through memnote's layer reader. A layer that cannot be read is a Refusal and yields no notes, never an error: the hook still injects the rules, and the verb still shows what the other layer holds. It asks git nothing.
Types ¶
type Candidate ¶
Candidate is an item the prompt matched, with the recall words that hit.
func Matching ¶
Matching is candidates with each personal note's tie judged: a candidate tied to a root is kept only when root answers that same root. root is asked only when a tied item matched, and then once, so a prompt that matches no tied item costs no git call; a nil root answers "". When root errs, every tied candidate is left out and the error is returned beside the rest.
type Item ¶
Item is one thing the recall can bring back: a note now, a page from step 3. Key is its ledger key and its place in the id order — a note's id (mem-…), and a page's "page:<filename>" after every note. Tie is the root commit a personal note is tied to; nil for a note recalled everywhere and for every item in the project's file.
type Layers ¶
Layers is what a read of both note layers gave: the notes as they stand in the machine's file and in the project's.
type Refusal ¶
Refusal names a layer the recall could not read, and why, in words safe to print: the file in tilde or repository-relative form, the reason home-redacted and terminal-safe.
type Request ¶
type Request struct {
// Items are what the memory layers yield (noteItems, ReadNotes).
Items []Item
// Prompt is the prompt the hook was handed.
Prompt string
// Ledger is the session's recalled ledger (rules.SessionState.Recalled):
// item key to the content signature last sent.
Ledger map[string]string
// Budget is what the rules left of the loader's per-turn budget,
// rules.InjectionBudgetBytes less the rules text's length.
Budget int
// Disabled is the loader's kill switch: recall is the loader's, so the
// switch silences it too.
Disabled bool
// Root answers the repository's root commit, for the items tied to one;
// asked only once a tied item matched (Matching).
Root RootFunc
}
Request is one prompt's recall.
type Result ¶
type Result struct {
Text string
Recalled []string
Omitted []string
Ledger map[string]string
RootErr error
// contains filtered or unexported fields
}
Result is one prompt's recall. Text is empty when nothing new comes back. Recalled names each item Text carries, in order; Omitted each new candidate that did not fit the budget, not recorded and so retried on the next turn. Ledger is the updated recalled ledger, a copy. RootErr is the root-commit lookup's error (git did not answer in time) when a tied item matched and was left out for it — unrecorded, so retried on the next turn.
func Recall ¶
Recall matches the items against the prompt, drops every candidate already sent this session with unchanged content, and takes the rest in id order while they fit the budget: the first that does not fit stops the take, so an item never comes back ahead of one before it in the order. Its only I/O is req.Root, asked when a tied item matched, and it never reflects prompt bytes into the block.
type RootFunc ¶
RootFunc answers the repository's root commit, "" where there is none. The recall asks it only once matching has found a tied item, and at most once per call, so a prompt that matches no tied item costs no git call. A caller that hands the same RootFunc to more than one call memoises it (sync.OnceValues). An error is git not answering in time (gitutil.RootCommitContext): the tied items are then left out.