relation

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package relation provides causal classification for observation pairs.

Package relation provides async relation and conflict detection for observations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShouldClassify added in v1.7.0

func ShouldClassify(obs *models.Observation) bool

ShouldClassify returns true if this observation type warrants causal classification.

Types

type CausalClassifier added in v1.7.0

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

CausalClassifier uses LLM to classify causal relationships between observation pairs.

func NewCausalClassifier added in v1.7.0

func NewCausalClassifier(llmClient learning.LLMClient) *CausalClassifier

NewCausalClassifier creates a new classifier. Returns nil if no LLM client available.

func (*CausalClassifier) ClassifyPair added in v1.7.0

func (c *CausalClassifier) ClassifyPair(ctx context.Context, obsA, obsB *models.Observation) (string, error)

ClassifyPair determines the causal relationship between two observations. Returns one of: "fixed_by", "corrects", "unrelated", or "" on error.

type Detector

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

Detector performs async relation and conflict detection after observation creation.

func NewDetector

func NewDetector(
	vectorClient vector.Client,
	relationStore *gorm.RelationStore,
	conflictStore *gorm.ConflictStore,
	observationStore *gorm.ObservationStore,
	promptStore *gorm.PromptStore,
) *Detector

NewDetector creates a new relation detector. All parameters are required; passing nil for any will cause panics at detection time.

func (*Detector) BackfillRelations added in v1.1.0

func (d *Detector) BackfillRelations(ctx context.Context, project string, batchSize int, onProgress func(processed, total int)) (int, int, error)

BackfillRelations processes existing observations to detect relations. Processes in batches, calling Detect() for each observation. Returns the number of observations processed and relations created.

func (*Detector) Detect

func (d *Detector) Detect(ctx context.Context, obsID int64, project string) error

Detect runs relation and conflict detection for a single observation.

func (*Detector) Enqueue

func (d *Detector) Enqueue(obsID int64, project string)

Enqueue adds a detection request to the queue. Non-blocking: drops the request and logs a warning if the queue is full.

func (*Detector) SetCausalClassifier added in v1.7.0

func (d *Detector) SetCausalClassifier(c *CausalClassifier)

SetCausalClassifier sets the LLM-based causal classifier for FR-44/FR-45.

func (*Detector) Start

func (d *Detector) Start(ctx context.Context)

Start launches the background goroutine that processes detection requests. It blocks until ctx is cancelled; callers should run this in a goroutine.

Jump to

Keyboard shortcuts

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