embeddingstest

package
v1.4.0 Latest Latest
Warning

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

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

Documentation

Overview

Package embeddingstest provides a deterministic, test-grade `embeddings.Embedder` for conformance suites and integration tests that need meaningful similarity without provider traffic.

The embedder is NEVER registered with the embeddings driver registry and is never a production default (AGENTS.md §13 — test stubs stay out of operator-facing seams). It lives in its own clearly-named subpackage, mirroring the conformance-suite precedent, so test authors across subsystems (memory, skills, integration) share one implementation instead of growing private fakes.

Vector model: a bag-of-words hash projection. Each lowercase whitespace-separated token hashes (FNV-1a) onto one of `Dim` buckets; the bucket counts are L2-normalised. Texts sharing more tokens therefore land closer under cosine similarity — enough signal for retrieval-ranking assertions, fully deterministic, and identity-respecting (the embedder itself holds no per-call state).

Index

Constants

View Source
const Dim = 64

Dim is the fixed vector dimension the deterministic embedder produces.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deterministic

type Deterministic struct {

	// Calls counts Embed invocations (not texts). Tests assert on it
	// to prove a consumer actually drove the embedder.
	Calls atomic.Int64
	// contains filtered or unexported fields
}

Deterministic is the test-grade embedder. Construct with `New`. Safe for concurrent use: the only mutable field is the atomic closed flag; `Calls` is an atomic counter tests may assert on.

func New

func New() *Deterministic

New constructs a deterministic test embedder.

func (*Deterministic) Close

func (d *Deterministic) Close(_ context.Context) error

Close implements embeddings.Embedder. Idempotent.

func (*Deterministic) Embed

func (d *Deterministic) Embed(ctx context.Context, texts []string) ([][]float32, error)

Embed implements embeddings.Embedder. Identity-mandatory like the production edge: tests that forget to stamp an identity fail the same way production would.

Jump to

Keyboard shortcuts

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