helixgraph

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Overview

Package helixgraph is a brain.Graph on HelixDB.

Helix does the work natively: filters apply before ranking (*Within searches over the readable candidates that pass them), a neighborhood walk of any depth is one request, and endpoints come back as object ids, not internal node ids. The graph embeds node text, edge notes and queries with its own Embedding and fuses its text and vector lists with its own Ranking. Open creates the indexes and waits until they are active.

Each node and edge stores its tenant key, which partitions the text and vector indexes, and its namespace attrs as one token set. A node also stores its Readers and its scalar properties as token sets. A token is a hash of an attr or a principal, so the graph holds no principal ids, and one property write replaces a whole set. A query reads a node when it covers the node's namespace and the node has no readers or shares a principal with it, as brain.Scope.CanRead decides.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Graph

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

Graph is a HelixDB knowledge graph.

func Open added in v0.5.0

func Open(ctx context.Context, client *helix.Client, opts Options) (*Graph, error)

Open returns a graph over client after it creates every index opts needs and they are active.

func (*Graph) Erase added in v0.5.0

func (g *Graph) Erase(ctx context.Context, scope brain.Scope) error

Erase implements brain.Index in one write: it drops every node the scope's namespace covers, whatever its readers, and Helix drops their edges.

func (g *Graph) FindLinks(ctx context.Context, lq brain.LinkSearch) ([]brain.EdgeSearchHit, error)

FindLinks implements brain.Graph in one request, like FindObjects, over the edges of one relation the namespace covers whose two ends the query can read. A tenant-wide scope excludes the edges of the tenant's hidden nodes. Helix rejects a relation not in Options.EdgeRelations.

func (*Graph) FindObjects added in v0.5.0

func (g *Graph) FindObjects(ctx context.Context, sq brain.ObjectSearch) ([]brain.ScoredID, error)

FindObjects implements brain.Graph in one request: a text and, with an Embedder, a vector ranking over the readable nodes that pass q.Filters, fused with the graph's Ranking. A tenant-wide scope with no filters ranks from the index (see visiblePlan); otherwise Helix ranks within the readable candidates that pass the filters.

func (g *Graph) Link(ctx context.Context, e brain.GraphEdge) error

Link implements brain.Graph: one write that drops any edge from→to with the relation and adds the new one, with the note's embedding when the graph has an Embedder.

func (*Graph) Neighborhood added in v0.5.0

func (g *Graph) Neighborhood(ctx context.Context, nq brain.NeighborhoodQuery) ([]brain.GraphNeighbor, error)

Neighborhood implements brain.Graph in one request. Hop d starts from the frontier node set of hop d-1; each (relation, direction) of a hop is one projection of source, edge and peer. Only nodes the namespace covers are returned or join a frontier. Each projection and frontier holds at most q.Limit rows. No relations follows every edge label, and each hit carries its edge's label.

func (*Graph) Put added in v0.5.0

func (g *Graph) Put(ctx context.Context, in brain.Indexed) error

Put implements brain.Graph: one write that updates the node in place when it exists (keeping its edges) and adds it otherwise. It embeds the text first when the graph has an Embedder.

func (*Graph) Remove added in v0.5.0

func (g *Graph) Remove(ctx context.Context, id uuid.UUID) error

Remove implements brain.Graph. Helix drops incident edges with the node.

func (g *Graph) Unlink(ctx context.Context, from, to uuid.UUID, rel string) error

Unlink implements brain.Graph via Helix DropEdgeLabeled.

type Options added in v0.5.0

type Options struct {
	// Dimension is the embedding length of nodes and edges. Zero means no
	// vector indexes: searches rank text only.
	Dimension uint
	// Metric is the vector distance (default cosine).
	Metric helix.VectorDistanceMetric
	// EdgeRelations are the relations whose edges FindLinks can rank; a
	// FindLinks without a relation ranks them all.
	EdgeRelations []string
	// MaxOverfetch is how many elements a tenant-wide search may skip because
	// the caller cannot read them, and still rank from the index (default
	// 256). Past it, Helix ranks within the readable candidates.
	MaxOverfetch uint
	// Embedding embeds node text, edge notes and queries. Its vectors must
	// have Dimension values. Without an Embedder, searches rank text only.
	Embedding brain.Embedding
	// Ranking fuses the text and vector lists and ages them by updated_at.
	Ranking brain.Ranking
}

Options configures Open.

Jump to

Keyboard shortcuts

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