selection

package
v0.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package selection implements deterministic online Memory selection. Scores are transient retrieval facts and never leave this package.

Index

Constants

View Source
const (
	MaxEpisodeEvidenceBytes   = 16 * 1024
	MaxEpisodeEvidenceEntries = 8
)

Variables

View Source
var (
	ErrInvalidSelectRequest = errors.New("invalid SelectMemory request")
	ErrRunConflict          = errors.New("run ref already identifies a different MemoryContext request")
	ErrAmbiguousMemoryRef   = errors.New("memory ref resolves to multiple semantic kinds")
)
View Source
var ErrInvalidConfiguration = errors.New("invalid selection configuration")

Functions

func ValidEpisodeEvidenceMaxBytes

func ValidEpisodeEvidenceMaxBytes(value int) bool

Types

type Activation

type Activation struct {
	Kind               CandidateKind
	VersionRef         string
	Scope              ApplicationScope
	QuerySourceRef     string
	MatchedRef         string
	EvidenceEpisodeRef string
	EvidenceSourceRef  string
}

func Select

func Select(queries []Query, candidates []Candidate, ranker Ranker, policy Policy) ([]Activation, error)

Select applies provenance gating, support/inhibition competition and a bounded availability tie-break. It deliberately returns no score.

type Anchor

type Anchor struct {
	EpisodeRef string
	SourceRef  string
	Text       string
}

type ApplicationScope

type ApplicationScope string
const (
	ApplicationScopeSelf      ApplicationScope = "self"
	ApplicationScopeOther     ApplicationScope = "other"
	ApplicationScopeRelation  ApplicationScope = "relation"
	ApplicationScopeSituation ApplicationScope = "situation"
)

type Candidate

type Candidate struct {
	Kind         CandidateKind
	VersionRef   string
	Text         string
	Scope        ApplicationScope
	OwnerOrder   int
	Support      []Anchor
	Inhibition   []Anchor
	Reenactments int
	IndexMatches []IndexMatch
}

type CandidateKind

type CandidateKind string
const (
	CandidateRecollection CandidateKind = "recollection"
	CandidateDisposition  CandidateKind = "disposition"
)

type Constitution

type Constitution = ledger.Constitution

Constitution is an external normative baseline, not writable Memory.

type Disposition

type Disposition struct {
	MemoryRef   string
	Text        string
	Application ApplicationScope
}

type EpisodeEvidence

type EpisodeEvidence struct {
	MemoryRef string
	Text      string
}

EpisodeEvidence is frozen canonical historical source text, not learned Memory.

func BoundEpisodeEvidence

func BoundEpisodeEvidence(items []EpisodeEvidence, maxBytes int) []EpisodeEvidence

BoundEpisodeEvidence preserves semantic order, skips entries that do not fit whole, and caps the public lane independently of learned Memory selection.

type IndexMatch

type IndexMatch struct {
	QuerySourceRef    string
	SupportEpisodeRef string
	Rank              int
	LaneOrder         int
}

IndexMatch is one transient semantic association returned by MemoryIndex. SupportEpisodeRef is non-empty only when an indexed Episode is canonical support for this exact Disposition. Rank is meaningful only inside its query/owner lane; LaneOrder deterministically interleaves those lanes.

type MemoryContext

type MemoryContext struct {
	Ref             string
	RunRef          string
	Scope           ledger.Scope
	Constitution    Constitution
	Recollections   []Recollection
	Dispositions    []Disposition
	EpisodeEvidence []EpisodeEvidence
}

type Policy

type Policy struct {
	Ref                             string
	MinimumScore                    float64
	MaxRecollections                int
	MaxDispositions                 int
	AvailabilityCap                 int
	CanonicalCandidatesPerOwnerKind int
}

func DefaultPolicy

func DefaultPolicy() Policy

DefaultPolicy returns a value so callers cannot mutate shared policy state.

type Query

type Query struct {
	Ref  string
	Text string
}

type Ranker

type Ranker interface {
	Score(query, candidate string) float64
}

func DefaultRanker

func DefaultRanker() Ranker

DefaultRanker uses topic-term overlap for Latin word-boundary text and keeps character n-grams as the boundary-free fallback for scripts such as Chinese.

type Recollection

type Recollection struct {
	MemoryRef   string
	Text        string
	Application ApplicationScope
}

type SelectRequest

type SelectRequest struct {
	Scope                   ledger.Scope
	RunRef                  string
	SituationSourceRefs     []string
	Constitution            Constitution
	EpisodeEvidenceMaxBytes int
}

Jump to

Keyboard shortcuts

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