proactive

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package proactive implements proactive context preloading for yaad. When a trigger fires (file open, git checkout, terminal cd), yaad predicts which memory nodes are likely relevant and preloads them before the user asks. This reduces perceived latency and keeps the context window warm.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PreloadResult

type PreloadResult struct {
	NodeIDs  []string      // node IDs predicted to be relevant
	Reason   string        // human-readable explanation of the prediction
	Duration time.Duration // how long the preload took
}

PreloadResult holds the set of preloaded memory entries.

func Preload

func Preload(ctx context.Context, trigger PreloadTrigger, searcher Searcher, limit int) (*PreloadResult, error)

Preload predicts and fetches relevant memory nodes based on the trigger. It constructs one or more search queries from the trigger, executes them, deduplicates the results, and returns the top candidates.

type PreloadTrigger

type PreloadTrigger struct {
	Kind      TriggerKind // what triggered the preload
	Value     string      // file path, branch name, directory, or query prefix
	Project   string      // the active project
	Timestamp time.Time   // when the trigger fired
}

PreloadTrigger describes the event that should initiate preloading.

type Searcher

type Searcher interface {
	// Search returns node IDs matching the query, scoped to a project.
	Search(ctx context.Context, query string, project string, limit int) ([]string, error)
}

Searcher is the interface that proactive preloading uses to find relevant nodes. Implementations wrap yaad's graph search.

type TriggerKind

type TriggerKind int

TriggerKind identifies what caused the preload.

const (
	TriggerFileOpen     TriggerKind = iota // editor opened a file
	TriggerGitCheckout                     // switched branches
	TriggerDirChange                       // cd into a directory
	TriggerQuery                           // user started typing a query
	TriggerSessionStart                    // new coding session began
)

func (TriggerKind) String

func (tk TriggerKind) String() string

String returns a human-readable label for the trigger kind.

Jump to

Keyboard shortcuts

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