namematcher

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package namematcher implements cross-domain entity name matching for Synapses. It creates MENTIONS edges between entities that share the same logical name across different domains (code, infra, API, docs).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Matcher

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

Matcher scans the graph after each reindex and creates MENTIONS edges between entities that share the same logical name across domains.

At most one pass runs at a time — if a new reindex completes while a prior pass is still running, the new trigger is silently dropped. The next reindex will trigger a fresh pass, so no data is permanently lost.

The pass is skipped entirely when changedFiles contains only code-domain files AND no cross-domain entities have ever been observed in the graph. This avoids wasteful full-graph scans on code-only projects.

func New

func New(brainClient *brain.Client) *Matcher

New creates a Matcher. brainClient may be nil (brain-enhanced path is optional).

func (*Matcher) PrimeCrossDomain

func (m *Matcher) PrimeCrossDomain(g *graph.Graph)

PrimeCrossDomain scans g once to determine whether any non-code-domain entities are already present. Must be called after the graph is loaded from disk so that subsequent incremental reindex events with code-only changed files are not incorrectly skipped by the hasCrossDomain gate.

Safe to call concurrently — reads g under its own lock and writes via an atomic store. Idempotent: calling more than once is harmless.

func (*Matcher) RunAsync

func (m *Matcher) RunAsync(ctx context.Context, g *graph.Graph, st *store.Store, changedFiles []string)

RunAsync implements watcher.NameMatcherRunner.

changedFiles is the list of files processed in the triggering applyBatch. Pass nil to indicate a full re-walk (all domains affected — always run).

The pass is skipped when changedFiles contains only code files AND no cross-domain entities have ever been observed, avoiding unnecessary work on code-only projects. Once a cross-domain entity is seen (hasCrossDomain=true), the check is never re-enabled — cross-domain entities typically persist.

At most one invocation runs at a time — concurrent calls return immediately. Respects ctx cancellation. All errors are logged and skipped (fail-open).

Jump to

Keyboard shortcuts

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