callindex

package
v1.125.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package callindex is the call-catalog consumer of the shared indexjobs framework (#507, #1321). It registers a Source/Sink pair under source_kind = "calls" so a recorded call becomes findable by meaning and not only by the words it happens to contain.

A call is recorded on the audit writer's goroutine, where embedding it would mean holding the writer open on a network call to the embedding provider, so the vector is produced off that path: the record lands without one and the reconciler converges it. Like memory, and unlike the api-catalog and tools consumers, the vector lives inline on the row it describes — a record IS its own indexing unit, so SourceID is the record id and each unit yields exactly one item.

Index

Constants

View Source
const SourceKind = "calls"

SourceKind is the indexjobs source_kind this package serves.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sink

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

Sink implements indexjobs.Sink for the call kind over the embedding columns of call_records. currentModel is the provider model the gap query diffs stored rows against, so a model swap re-embeds rows stamped with the previous model.

func NewSink

func NewSink(store *Store, currentModel string) *Sink

NewSink returns a Sink backed by the given store. currentModel is the embedding provider's model identifier; "" on a deployment whose provider does not name its model, which leaves only NULL-embedding rows as gaps.

func (*Sink) Coverage

func (s *Sink) Coverage(ctx context.Context) (indexjobs.Coverage, error)

Coverage reports the call kind's indexed-vs-expected totals. ExpectedKnown is true: every indexable record is expected to converge to one vector.

func (*Sink) FindGaps

func (s *Sink) FindGaps(ctx context.Context) ([]string, error)

FindGaps returns the ids of records whose embedding is missing or stale.

func (*Sink) Kind

func (*Sink) Kind() string

Kind reports the call source kind.

func (*Sink) ListExisting

func (s *Sink) ListExisting(ctx context.Context, key indexjobs.Key) (map[string]indexjobs.Vector, error)

ListExisting returns the record's persisted vector keyed by item id for the worker's dedup pass.

func (*Sink) StampExpected

func (*Sink) StampExpected(context.Context, indexjobs.Key, int) error

StampExpected is a no-op. Gap detection is condition-based (no vector, or a vector from another model), not count-based, so there is no expected count to record per unit.

func (*Sink) Upsert

func (s *Sink) Upsert(ctx context.Context, key indexjobs.Key, rows []indexjobs.Vector) error

Upsert writes the record's vector.

func (*Sink) UpsertBatch

func (s *Sink) UpsertBatch(ctx context.Context, key indexjobs.Key, rows []indexjobs.Vector) error

UpsertBatch is identical to Upsert here: the unit holds one item, so there are no rows outside the batch to preserve.

type Source

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

Source implements indexjobs.Source for the call kind. A unit is one recorded call (SourceID = record id) and yields exactly one item: the text the record is searched by. The worker embeds it and the Sink writes the vector back onto the same row.

func NewSource

func NewSource(store *Store) *Source

NewSource returns a Source backed by the given store.

func (*Source) Kind

func (*Source) Kind() string

Kind reports the call source kind.

func (*Source) LoadItems

func (s *Source) LoadItems(ctx context.Context, sourceID string) ([]indexjobs.Item, error)

LoadItems returns the record's single embeddable item. A record that was deleted between enqueue and claim, or that holds nothing worth embedding, yields an empty slice: a clean completion that writes no vector.

func (*Source) OnSucceeded

func (*Source) OnSucceeded(string)

OnSucceeded is a no-op: search reads the vectors off call_records on every query, so there is no in-memory cache to refresh after a backfill.

type Store

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

Store reads and writes the embedding state of call_records for this consumer. It is deliberately separate from the catalog's own store: it touches only the embedding columns and the text they are computed from, so the read-path contract does not widen to carry a backfill concern.

func NewStore

func NewStore(db *sql.DB) *Store

NewStore returns a Store over the given database.

func (*Store) Coverage

func (s *Store) Coverage(ctx context.Context) (indexed, expected int, err error)

Coverage returns how many indexable records carry a vector, and how many there are. Both counts are over the same population the gap query walks, so a converged catalog reads as complete rather than as permanently short by the records that were never meant to be embedded.

func (*Store) FindGaps

func (s *Store) FindGaps(ctx context.Context, currentModel string) ([]string, error)

FindGaps returns the ids of records whose embedding is missing or stale.

func (*Store) GetText

func (s *Store) GetText(ctx context.Context, id string) (string, error)

GetText returns the text of one record to embed, composed by the catalog's own IndexText so the vector is computed from exactly the corpus the lexical arm matches. A record that no longer exists, failed, or has nothing to say yields errNotIndexable.

func (*Store) ListVectors

func (s *Store) ListVectors(ctx context.Context, id string) (map[string]indexjobs.Vector, error)

ListVectors returns the record's persisted embedding keyed by item id (the record id), for the worker's text-hash and model dedup pass.

func (*Store) UpsertVectors

func (s *Store) UpsertVectors(ctx context.Context, id string, rows []indexjobs.Vector) error

UpsertVectors writes the embedding back onto the record. A call record holds exactly one item, so there are no sibling rows to delete and Upsert and UpsertBatch are the same write.

Jump to

Keyboard shortcuts

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