cooccurrence

package
v0.1.8-rc.24 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store tracks pairwise tool co-occurrence: which tools are used together in task runs. It maintains an in-memory count map with optional persistence to a graph.IStore.

func NewStore

func NewStore(graphStore graph.IStore) *Store

NewStore creates a co-occurrence store. If graphStore is nil, the store operates in ephemeral mode (in-memory only, no persistence).

func (*Store) HasData

func (s *Store) HasData() bool

HasData returns true if the store has any co-occurrence data.

func (*Store) Load

func (s *Store) Load(ctx context.Context) error

Load replaces the in-memory co-occurrence map with the state persisted in the graph store. It clears existing counts and maxWeight before hydrating, so any in-memory data that was not successfully persisted will be lost. Callers should treat Load as a "reset to durable state" operation, not an additive merge. Returns nil immediately if the graph store is nil.

Note: Load is not atomic with respect to concurrent Record calls. A Record that runs between the clear and the hydration may insert data that is not in the graph store. In practice this is safe because Load is only called during construction before the store is shared with other goroutines.

func (*Store) Record

func (s *Store) Record(ctx context.Context, toolNames []string)

Record records that the given tools were used together in a single task run. This increments all pairwise edges. The graph is symmetric.

func (*Store) Score

func (s *Store) Score(toolA, toolB string) float64

Score returns a normalized affinity score [0, 1] between two tools based on how frequently they appear together. Returns 0 if either tool is unknown or the store is empty.

Jump to

Keyboard shortcuts

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