recall

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Candidate

type Candidate struct {
	ChunkID      string
	EntryID      string
	WorkspaceID  string
	Scope        memcontract.Scope
	AgentName    string
	AgentTier    memcontract.AgentTier
	Type         memcontract.Type
	Slug         string
	Filename     string
	Title        string
	Body         string
	ContentHash  string
	ModTime      time.Time
	Injection    bool
	UnicodeScore float64
	TrigramScore float64
	RecallScore  float64
}

Candidate is one catalog chunk candidate returned by the storage source.

type Option

type Option func(*Recaller)

Option customizes a deterministic Recaller.

func WithClock

func WithClock(now func() time.Time) Option

WithClock injects a deterministic clock for tests.

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger injects the logger used for failure-safe side effects.

func WithSignalRecorder

func WithSignalRecorder(recorder *SignalRecorder) Option

WithSignalRecorder moves recall-signal writes onto a bounded async worker.

func WithWeights

func WithWeights(weights Weights) Option

WithWeights overrides the deterministic score-fusion weights.

type Recaller

type Recaller struct {
	// contains filtered or unexported fields
}

Recaller implements deterministic Slice 1 recall.

func New

func New(source Source, opts ...Option) *Recaller

New constructs a deterministic Recaller over a storage source.

func (*Recaller) Recall

Recall returns a prompt-ready package using deterministic lexical ranking.

type Shadow

type Shadow struct {
	WinnerChunkID string
	LoserChunkID  string
	WorkspaceID   string
	Scope         memcontract.Scope
	AgentName     string
	AgentTier     memcontract.AgentTier
	Type          memcontract.Type
	Slug          string
}

Shadow records one candidate suppressed by a deeper scope owner.

type Signal

type Signal struct {
	ChunkID      string
	WorkspaceID  string
	SurfaceID    string
	Score        float64
	SurfacedAt   time.Time
	SessionID    string
	SignalReason string
}

Signal records that one chunk was surfaced by recall.

type SignalRecorder

type SignalRecorder struct {
	// contains filtered or unexported fields
}

SignalRecorder owns the bounded async write path for recall signals.

func NewSignalRecorder

func NewSignalRecorder(
	ctx context.Context,
	source SignalRecorderSource,
	cfg SignalRecorderConfig,
	logger *slog.Logger,
) (*SignalRecorder, error)

NewSignalRecorder starts a bounded worker for one recall-signal authority.

func (*SignalRecorder) Close

func (r *SignalRecorder) Close(ctx context.Context) error

Close stops the worker after draining already-queued batches.

func (*SignalRecorder) Stats

Stats returns the current queue depth and cumulative worker counters.

func (*SignalRecorder) Submit

Submit enqueues recall signals without waiting for catalog writes.

type SignalRecorderConfig

type SignalRecorderConfig struct {
	QueueCapacity  int
	WorkerRetryMax int
	MetricsEnabled bool
}

SignalRecorderConfig controls the bounded asynchronous recall-signal worker.

type SignalRecorderSource

type SignalRecorderSource interface {
	RecordRecall(ctx context.Context, signals []Signal) error
	RecordRecallSignalFailed(ctx context.Context, query memcontract.Query, cause error) error
	RecordRecallSignalDropped(ctx context.Context, query memcontract.Query, signals []Signal, queueDepth int) error
}

SignalRecorderSource persists recall signal side effects for the worker.

type SignalRecorderStats

type SignalRecorderStats struct {
	Submitted  uint64
	Recorded   uint64
	Dropped    uint64
	Failed     uint64
	QueueDepth int
}

SignalRecorderStats is a point-in-time snapshot of recorder counters.

type SignalRecorderSubmitResult

type SignalRecorderSubmitResult struct {
	Submitted bool
	Dropped   bool
}

SignalRecorderSubmitResult describes whether Submit accepted the batch and whether it had to drop an older queued batch first.

type Source

type Source interface {
	Candidates(ctx context.Context, query memcontract.Query, opts memcontract.RecallOptions) ([]Candidate, error)
	RecordRecall(ctx context.Context, signals []Signal) error
	RecordRecallExecuted(ctx context.Context, query memcontract.Query, resultCount int) error
	RecordRecallSkipped(ctx context.Context, query memcontract.Query, reason string) error
	RecordRecallSignalFailed(ctx context.Context, query memcontract.Query, cause error) error
	RecordRecallSignalDropped(ctx context.Context, query memcontract.Query, signals []Signal, queueDepth int) error
	RecordShadow(ctx context.Context, shadow Shadow) error
}

Source supplies candidates and stores recall side effects.

type Weights

type Weights struct {
	Unicode float64
	Trigram float64
	Recency float64
	Signal  float64
}

Weights controls deterministic score fusion for Slice 1 recall.

Jump to

Keyboard shortcuts

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