Documentation
¶
Overview ¶
Package weave provides a composable RAG pipeline engine for Go.
Weave handles the full document lifecycle: ingest documents, chunk text, generate embeddings, store vectors, retrieve relevant context, and assemble prompts. It is tenant-scoped, plugin-extensible, and Forge-native.
The engine is built around pluggable interfaces:
- loader.Loader: extract text from various document formats
- chunker.Chunker: split text into manageable chunks
- embedder.Embedder: generate vector embeddings
- vectorstore.VectorStore: store and search vectors
- retriever.Retriever: retrieve relevant chunks
All operations are tenant-scoped via forge.Scope for data isolation.
Index ¶
- Variables
- func AppFromContext(ctx context.Context) string
- func RequireTenant(ctx context.Context) (string, error)
- func TenantFromContext(ctx context.Context) string
- func WithApp(ctx context.Context, app string) context.Context
- func WithTenant(ctx context.Context, tenant string) context.Context
- type ComponentInfo
- type Config
- type Context
- type Describer
- type Entity
- type ID
- type Prefix
- type ScoreKind
Constants ¶
This section is empty.
Variables ¶
var ( // Store errors. ErrNoStore = errors.New("weave: no store configured") ErrStoreClosed = errors.New("weave: store closed") ErrMigrationFailed = errors.New("weave: migration failed") // ErrTenantRequired is returned by a call made on a context with no // tenant (see WithTenant). Nothing reads or writes across tenants. ErrTenantRequired = errors.New("weave: tenant required") // Not found errors. ErrCollectionNotFound = errors.New("weave: collection not found") ErrDocumentNotFound = errors.New("weave: document not found") ErrChunkNotFound = errors.New("weave: chunk not found") ErrIngestJobNotFound = errors.New("weave: ingest job not found") // Conflict errors. ErrCollectionAlreadyExists = errors.New("weave: collection already exists") ErrDocumentAlreadyExists = errors.New("weave: document already exists") ErrDuplicateDocument = errors.New("weave: duplicate document (same content hash)") // State errors. ErrInvalidState = errors.New("weave: invalid state transition") ErrEmptyContent = errors.New("weave: empty content") ErrInvalidArgument = errors.New("weave: invalid argument") // Pipeline errors. ErrNoEmbedder = errors.New("weave: no embedder configured") ErrNoVectorStore = errors.New("weave: no vector store configured") ErrNoChunker = errors.New("weave: no chunker configured") // ErrDimensionMismatch reports an embedding whose length differs from // the dimensions the collection or vector table was set up with. ErrDimensionMismatch = errors.New("weave: embedding dimensions do not match") // ErrIngestInterrupted marks a document whose ingest stopped before it // finished, for example because the process was killed. ErrIngestInterrupted = errors.New("weave: ingest interrupted before it finished") )
Functions ¶
func AppFromContext ¶
AppFromContext extracts the app identifier from the context. Returns an empty string if no app is set.
func RequireTenant ¶
RequireTenant returns the tenant on ctx, or ErrTenantRequired when there is none. Every store call and every engine call that touches data needs one.
func TenantFromContext ¶
TenantFromContext extracts the tenant identifier from the context. Returns an empty string if no tenant is set.
Types ¶
type ComponentInfo ¶
type ComponentInfo struct {
Kind string `json:"kind"`
Params map[string]string `json:"params,omitempty"`
// Score is set by retrievers and vector stores.
Score ScoreKind `json:"score,omitempty"`
// TenantFilter is set by vector stores: "verified" when an exact
// tenant_id metadata filter is known to work, otherwise "unverified".
TenantFilter string `json:"tenant_filter,omitempty"`
// Children are wrapped components, such as a hybrid retriever's parts.
Children []ComponentInfo `json:"children,omitempty"`
}
ComponentInfo describes one pipeline component for an operator.
type Config ¶
type Config struct {
// DefaultChunkSize is the target chunk size in tokens.
DefaultChunkSize int
// DefaultChunkOverlap is the overlap between chunks in tokens.
DefaultChunkOverlap int
// DefaultEmbeddingModel is the embedding model name used when
// a collection does not specify one.
DefaultEmbeddingModel string
// DefaultChunkStrategy is the chunking strategy used when
// a collection does not specify one.
DefaultChunkStrategy string
// DefaultTopK is the default number of results for retrieval.
DefaultTopK int
// ShutdownTimeout is the maximum time to wait for graceful shutdown.
ShutdownTimeout time.Duration
// IngestConcurrency is the maximum number of documents processed
// concurrently during batch ingestion.
IngestConcurrency int
}
Config holds configuration for the Weave engine.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults.
type Context ¶
Context is the execution context for Weave operations. It is a simple alias for context.Context. Scope is injected via forge.WithScope on the stdlib context.
type Describer ¶
type Describer interface {
Describe() ComponentInfo
}
Describer is implemented by components that can describe themselves.
type Entity ¶
type Entity struct {
CreatedAt time.Time `json:"created_at" bun:"created_at,notnull,default:current_timestamp"`
UpdatedAt time.Time `json:"updated_at" bun:"updated_at,notnull,default:current_timestamp"`
}
Entity is the base type embedded by all weave domain objects.
type ScoreKind ¶
type ScoreKind string
ScoreKind names what a retrieval score means, so a page never shows an RRF sum or a rerank score as though it were cosine similarity.
const ( // ScoreCosine is cosine similarity between query and chunk vectors. ScoreCosine ScoreKind = "cosine" // ScoreVectorSimilarity is whatever similarity the vector store reports, // when the store does not say which metric it uses. ScoreVectorSimilarity ScoreKind = "vector_similarity" // ScoreMMR is the vector relevance score, with results in MMR order. ScoreMMR ScoreKind = "mmr_relevance" // ScoreRRF is a reciprocal rank fusion sum. It is not comparable to cosine. ScoreRRF ScoreKind = "rrf" // ScoreRerank is a reranker's score. The vector score is not kept. ScoreRerank ScoreKind = "rerank" // ScoreUnknown means the component does not describe its score. ScoreUnknown ScoreKind = "unknown" )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package api provides Forge-style HTTP handlers for the Weave RAG engine.
|
Package api provides Forge-style HTTP handlers for the Weave RAG engine. |
|
Package assembler builds context strings from retrieved chunks for use in LLM prompts, with token budgeting and citation tracking.
|
Package assembler builds context strings from retrieved chunks for use in LLM prompts, with token budgeting and citation tracking. |
|
Package audithook bridges Weave lifecycle events to an audit trail backend.
|
Package audithook bridges Weave lifecycle events to an audit trail backend. |
|
Package chunk defines the Chunk entity.
|
Package chunk defines the Chunk entity. |
|
Package chunker defines the interface for splitting text into manageable chunks for embedding and retrieval.
|
Package chunker defines the interface for splitting text into manageable chunks for embedding and retrieval. |
|
Package collection defines the Collection entity.
|
Package collection defines the Collection entity. |
|
Package document defines the Document entity and its lifecycle states.
|
Package document defines the Document entity and its lifecycle states. |
|
Package embedder defines the interface for generating vector embeddings from text.
|
Package embedder defines the interface for generating vector embeddings from text. |
|
nexus
module
|
|
|
Package engine provides the central Weave RAG pipeline coordinator.
|
Package engine provides the central Weave RAG pipeline coordinator. |
|
Package ext defines the extension system for Weave.
|
Package ext defines the extension system for Weave. |
|
Package extension provides the Forge extension adapter for Weave.
|
Package extension provides the Forge extension adapter for Weave. |
|
contract
Package contract wires Weave into the Forge dashboard's contract path.
|
Package contract wires Weave into the Forge dashboard's contract path. |
|
Package id defines TypeID-based identity types for all Weave entities.
|
Package id defines TypeID-based identity types for all Weave entities. |
|
internal
|
|
|
embedtest
Package embedtest holds a deterministic embedder for tests.
|
Package embedtest holds a deterministic embedder for tests. |
|
migrateretry
Package migrateretry runs grove migration groups on PostgreSQL and retries the one failure replicas booting together can hit.
|
Package migrateretry runs grove migration groups on PostgreSQL and retries the one failure replicas booting together can hit. |
|
mongotest
Package mongotest gives each test that writes to a live MongoDB a database of its own, and drops it when the test ends.
|
Package mongotest gives each test that writes to a live MongoDB a database of its own, and drops it when the test ends. |
|
pgtest
Package pgtest confines each test that writes to a live PostgreSQL to a schema of its own.
|
Package pgtest confines each test that writes to a live PostgreSQL to a schema of its own. |
|
sqllike
Package sqllike escapes user text for use inside a SQL LIKE pattern.
|
Package sqllike escapes user text for use inside a SQL LIKE pattern. |
|
telemetry
Package telemetry holds the OpenTelemetry plumbing the engine and the embedders share: the tracer, the span attribute keys, how an error is named, the bounded component labels, and the metric families recorded on a go-utils metrics sink.
|
Package telemetry holds the OpenTelemetry plumbing the engine and the embedders share: the tracer, the span attribute keys, how an error is named, the bounded component labels, and the metric families recorded on a go-utils metrics sink. |
|
tenancy
Package tenancy holds the tenant checks every Weave metadata store runs before it touches data.
|
Package tenancy holds the tenant checks every Weave metadata store runs before it touches data. |
|
Package loader defines the interface for extracting text from various document formats.
|
Package loader defines the interface for extracting text from various document formats. |
|
Package middleware provides composable middleware for the Weave pipeline.
|
Package middleware provides composable middleware for the Weave pipeline. |
|
Package observability provides a metrics extension for Weave that records lifecycle event counts via go-utils MetricFactory.
|
Package observability provides a metrics extension for Weave that records lifecycle event counts via go-utils MetricFactory. |
|
Package pipeline provides a composable pipeline engine for orchestrating multi-step RAG operations (load, chunk, embed, store, retrieve, assemble).
|
Package pipeline provides a composable pipeline engine for orchestrating multi-step RAG operations (load, chunk, embed, store, retrieve, assemble). |
|
Package plugins defines the plugin system for Weave.
|
Package plugins defines the plugin system for Weave. |
|
Package retriever defines the interface for retrieving relevant chunks based on a query.
|
Package retriever defines the interface for retrieving relevant chunks based on a query. |
|
Package store defines the composite metadata store interface for Weave.
|
Package store defines the composite metadata store interface for Weave. |
|
memory
Package memory provides an in-memory implementation of the Weave composite store.
|
Package memory provides an in-memory implementation of the Weave composite store. |
|
mongo
Package mongo provides a MongoDB implementation of the Weave composite store using Grove ORM with the mongodriver.
|
Package mongo provides a MongoDB implementation of the Weave composite store using Grove ORM with the mongodriver. |
|
postgres
Package postgres provides a PostgreSQL implementation of the Weave composite store using grove ORM with grove migrations.
|
Package postgres provides a PostgreSQL implementation of the Weave composite store using grove ORM with grove migrations. |
|
sqlite
Package sqlite provides a SQLite implementation of the Weave composite store using Grove ORM with Grove migrations.
|
Package sqlite provides a SQLite implementation of the Weave composite store using Grove ORM with Grove migrations. |
|
storetest
Package storetest is the conformance suite every Weave store backend runs.
|
Package storetest is the conformance suite every Weave store backend runs. |
|
Package vectorstore defines the pluggable interface for vector storage and similarity search.
|
Package vectorstore defines the pluggable interface for vector storage and similarity search. |
|
fabriq
Package fabriqvec provides a fabriq VectorQuerier-backed implementation of the vectorstore.VectorStore interface.
|
Package fabriqvec provides a fabriq VectorQuerier-backed implementation of the vectorstore.VectorStore interface. |
|
memory
Package memory provides an in-memory vector store using brute-force cosine similarity.
|
Package memory provides an in-memory vector store using brute-force cosine similarity. |
|
pgvector
Package pgvector provides a PostgreSQL + pgvector implementation of the VectorStore interface.
|
Package pgvector provides a PostgreSQL + pgvector implementation of the VectorStore interface. |