Help us shape the future of Go! Take the 2026 Go Developer Survey

graph

package
v0.0.0-...-e7a0919 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PropArchRole is the architectural role of a node (e.g., "controller", "service",
	// "repository", "middleware", "factory", "observer", "gateway").
	PropArchRole = "architectural_role"

	// PropDesignPattern is a comma-separated list of design patterns detected
	// (e.g., "repository,singleton", "factory", "observer").
	PropDesignPattern = "design_pattern"

	// PropLayerTag classifies nodes into architectural layers
	// (e.g., "presentation", "business", "data_access", "infrastructure").
	PropLayerTag = "layer"

	// PropGraphSource indicates which branch a node or edge came from
	// when using BranchStore. Set to the branch name on reads, never persisted.
	PropGraphSource = "graph_source"

	// PropContentHash is the SHA-256 hash of a file's content ("sha256:<hex>").
	PropContentHash = "content_hash"

	// PropMimeType is the MIME type of a file (e.g., "image/jpeg", "text/x-go").
	PropMimeType = "mime_type"

	// PropSymlinkTarget is the relative path of a symlink's resolved target.
	PropSymlinkTarget = "symlink_target"
)

Well-known property keys used for architectural classification.

View Source
const (
	// PropSpeakerLabel is the raw diarization label for a speaker ("Person 3", "You").
	PropSpeakerLabel = "speaker_label"
	// PropSpeakerSource is the audio source for a speaker ("mic" = recording owner,
	// "monitor" = remote participant).
	PropSpeakerSource = "speaker_source"
	// PropConfidence is a 0..1 confidence score rendered as a decimal string.
	PropConfidence = "confidence"
	// PropEvidence is a verbatim transcript quote supporting an inference.
	PropEvidence = "evidence"
	// PropResolution records how an identity was resolved: "owner_anchor",
	// "llm", "alias", or "manual".
	PropResolution = "resolution_method"
	// PropStartTime is an offset in seconds from the start of the meeting.
	PropStartTime = "start_time"
	// PropEndTime is an offset in seconds from the start of the meeting.
	PropEndTime = "end_time"
	// PropMeetingID is the source session ID of the owning meeting.
	PropMeetingID = "meeting_id"
	// PropRole distinguishes a speaker that is not a person — background
	// audio the recorder filed as a voice.
	PropRole = "role"
	// PropIncomplete marks a meeting whose projection into the graph did not
	// finish, so a reader can tell a meeting with no decisions from one whose
	// decisions were never written.
	PropIncomplete = "incomplete"
	// PropPlatform is the meeting platform ("Zoom", "Unknown", ...).
	PropPlatform = "platform"
	// PropDuration is the meeting duration in seconds.
	PropDuration = "duration_seconds"
	// PropSummary is a natural-language summary of a node's content.
	PropSummary = "summary"
	// PropStatus is the lifecycle state of an action item ("open", "done").
	PropStatus = "status"
	// PropDueDate is an ISO-8601 date an action item is due.
	PropDueDate = "due_date"
	// PropAssignee is the raw (unresolved) assignee name for an action item.
	PropAssignee = "assignee"
	// PropAliases is a comma-separated list of alternate spellings for a person,
	// including speech-recognition variants (e.g. "Imran,Imron").
	PropAliases = "aliases"
	// PropUtteranceCount is how many transcript segments a speaker contributed.
	PropUtteranceCount = "utterance_count"
	// PropSpeakingSeconds is the total seconds a speaker was talking.
	PropSpeakingSeconds = "speaking_seconds"
	// PropIsOwner marks the Person who owns the recordings (the "mic" speaker).
	PropIsOwner = "is_owner"
	// PropQuote is a representative verbatim quote.
	PropQuote = "quote"
	// PropIsTranscript marks a document that is also a meeting transcript.
	//
	// Such a file is both things at once: prose worth searching as a document,
	// and a record of who said what worth extracting as a meeting. It is
	// indexed as both, and this is what lets meeting indexing find the ones
	// that turned up during ordinary document indexing.
	PropIsTranscript = "is_transcript"
	// PropTranscriptFormat names the transcript layout recognized.
	PropTranscriptFormat = "transcript_format"
)

Well-known property keys used by meeting transcript entities.

Variables

This section is empty.

Functions

func NewNodeID

func NewNodeID(nodeType, filePath, name string) string

NewNodeID generates a deterministic node ID from the type, file path, and name. The ID is a hex-encoded SHA-256 hash prefix to keep keys compact and collision-resistant.

Types

type Direction

type Direction int

Direction specifies the traversal direction for edge queries.

const (
	Outgoing Direction = iota
	Incoming
	Both
)

type Edge

type Edge struct {
	ID         string            `json:"id"`
	Type       EdgeType          `json:"type"`
	SourceID   string            `json:"source_id"`
	TargetID   string            `json:"target_id"`
	Properties map[string]string `json:"properties,omitempty"`
}

Edge represents a relationship between two nodes in the knowledge graph.

type EdgeType

type EdgeType string

EdgeType represents a relationship between two nodes.

const (
	EdgeContains    EdgeType = "Contains"
	EdgeImports     EdgeType = "Imports"
	EdgeDependsOn   EdgeType = "DependsOn"
	EdgeCalls       EdgeType = "Calls"
	EdgeImplements  EdgeType = "Implements"
	EdgeExposes     EdgeType = "Exposes"
	EdgeConsumes    EdgeType = "Consumes"
	EdgeDocuments   EdgeType = "Documents"
	EdgeTests       EdgeType = "Tests"
	EdgeMigrates    EdgeType = "Migrates"
	EdgeConfigures  EdgeType = "Configures"
	EdgeHasTopic    EdgeType = "HasTopic"
	EdgeAppearsIn   EdgeType = "AppearsIn"
	EdgeUpdatedOn   EdgeType = "UpdatedOn"
	EdgeDuplicateOf EdgeType = "DuplicateOf"
	EdgeSymLink     EdgeType = "SymLink"

	// EdgeAttended links a Person to a Meeting they participated in.
	EdgeAttended EdgeType = "Attended"
	// EdgeIdentifiedAs links a Speaker (diarization label) to the Person it
	// resolves to, carrying confidence, evidence, and resolution method.
	EdgeIdentifiedAs EdgeType = "IdentifiedAs"
	// EdgeAssignedTo links an ActionItem to the Person responsible for it.
	EdgeAssignedTo EdgeType = "AssignedTo"
	// EdgeRaisedBy links a Decision or ActionItem to the Person who raised it.
	EdgeRaisedBy EdgeType = "RaisedBy"
	// EdgeMentions links a meeting entity to something it refers to — a code
	// entity (Service, File, Function) or another Person.
	EdgeMentions EdgeType = "Mentions"
	// EdgeFollowsUp links an ActionItem to the Decision it implements, or a
	// Meeting to an earlier Meeting in the same series.
	EdgeFollowsUp EdgeType = "FollowsUp"
	// EdgeRelatedTo links two Topics whose subjects overlap, carrying the
	// probability that a meeting filed under either is worth showing to
	// someone asking about the other. It is undirected: one edge is written
	// per pair, from the lower node id to the higher, and every judged pair
	// is recorded, including those found unrelated, so a reader must always
	// apply a probability threshold.
	EdgeRelatedTo EdgeType = "RelatedTo"
)

type Exporter

type Exporter interface {
	Export(ctx context.Context, w io.Writer) error
}

Exporter can serialize all graph data (nodes and edges) to a writer.

type GraphStats

type GraphStats struct {
	NodeCount   int64              `json:"node_count"`
	EdgeCount   int64              `json:"edge_count"`
	NodesByType map[NodeType]int64 `json:"nodes_by_type"`
	EdgesByType map[EdgeType]int64 `json:"edges_by_type"`
}

GraphStats holds aggregate statistics about the knowledge graph.

type Importer

type Importer interface {
	Import(ctx context.Context, r io.Reader) error
}

Importer can deserialize graph data from a reader, replacing all existing data.

type Node

type Node struct {
	ID            string             `json:"id"`
	Type          NodeType           `json:"type"`
	Name          string             `json:"name"`
	QualifiedName string             `json:"qualified_name"`
	FilePath      string             `json:"file_path"`
	Line          int                `json:"line"`
	EndLine       int                `json:"end_line"`
	Package       string             `json:"package"`
	Language      string             `json:"language"`
	Exported      bool               `json:"exported"`
	Signature     string             `json:"signature,omitempty"`
	DocComment    string             `json:"doc_comment,omitempty"`
	Properties    map[string]string  `json:"properties,omitempty"`
	Metrics       map[string]float64 `json:"metrics,omitempty"`
	UpdatedAt     time.Time          `json:"updated_at,omitempty"`
}

Node represents a source code or documentation entity in the knowledge graph.

type NodeFilter

type NodeFilter struct {
	Type        NodeType
	FilePath    string
	Package     string
	Language    string
	NamePattern string // glob pattern matched against Name
	// NameMatch, when set, must accept a node's Name for the node to match.
	// A glob answers one pattern per scan; a predicate lets a caller test
	// every term of a query in a single pass over the graph.
	NameMatch func(name string) bool
	Exported  *bool
	// Properties filters nodes by property key-value pairs.
	// All specified entries must match (AND logic).
	Properties map[string]string
}

NodeFilter specifies criteria for querying nodes.

type NodeType

type NodeType string

NodeType represents the kind of entity in the knowledge graph.

const (
	NodeRepository   NodeType = "Repository"
	NodeService      NodeType = "Service"
	NodeModule       NodeType = "Module"
	NodePackage      NodeType = "Package"
	NodeFile         NodeType = "File"
	NodeFunction     NodeType = "Function"
	NodeMethod       NodeType = "Method"
	NodeClass        NodeType = "Class"
	NodeStruct       NodeType = "Struct"
	NodeInterface    NodeType = "Interface"
	NodeEnum         NodeType = "Enum"
	NodeType_        NodeType = "Type"
	NodeConstant     NodeType = "Constant"
	NodeVariable     NodeType = "Variable"
	NodeAPIEndpoint  NodeType = "APIEndpoint"
	NodeDBModel      NodeType = "DBModel"
	NodeDomainModel  NodeType = "DomainModel"
	NodeViewModel    NodeType = "ViewModel"
	NodeDTO          NodeType = "DTO"
	NodeMigration    NodeType = "Migration"
	NodeDependency   NodeType = "Dependency"
	NodeDocument     NodeType = "Document"
	NodeAIGuideline  NodeType = "AIGuideline"
	NodeTestFunction NodeType = "TestFunction"
	NodeTestFile     NodeType = "TestFile"
	NodeDirectory    NodeType = "Directory"
	NodeTopic        NodeType = "Topic"
	NodePerson       NodeType = "Person"
	NodeYear         NodeType = "Year"
	NodeMonth        NodeType = "Month"
	NodeDate         NodeType = "Date"

	// NodeMeeting is a single recorded meeting/session.
	NodeMeeting NodeType = "Meeting"
	// NodeSpeaker is a per-meeting diarization label (e.g. "Person 3").
	// It is an *unresolved* identity: it becomes meaningful only once an
	// IdentifiedAs edge links it to a Person.
	NodeSpeaker NodeType = "Speaker"
	// NodeTopicSegment is a contiguous span of a meeting about one topic.
	NodeTopicSegment NodeType = "TopicSegment"
	// NodeDecision is a decision reached during a meeting.
	NodeDecision NodeType = "Decision"
	// NodeActionItem is a follow-up/TODO arising from a meeting.
	NodeActionItem NodeType = "ActionItem"
)

func MeetingNodeTypes

func MeetingNodeTypes() []NodeType

MeetingNodeTypes lists the node types produced by meeting transcript indexing.

type Store

type Store interface {
	// AddNode inserts a new node into the graph.
	AddNode(ctx context.Context, node *Node) error

	// UpdateNode replaces an existing node (matched by ID).
	UpdateNode(ctx context.Context, node *Node) error

	// DeleteNode removes a node by ID along with its connected edges.
	DeleteNode(ctx context.Context, id string) error

	// GetNode retrieves a single node by ID.
	GetNode(ctx context.Context, id string) (*Node, error)

	// QueryNodes returns all nodes matching the given filter.
	QueryNodes(ctx context.Context, filter NodeFilter) ([]*Node, error)

	// AddEdge inserts a new edge into the graph.
	AddEdge(ctx context.Context, edge *Edge) error

	// DeleteEdge removes an edge by ID.
	DeleteEdge(ctx context.Context, id string) error

	// GetEdges returns edges connected to nodeID with the given type.
	// If edgeType is empty, all edge types are returned.
	GetEdges(ctx context.Context, nodeID string, edgeType EdgeType) ([]*Edge, error)

	// GetNeighbors returns nodes connected to nodeID via edges of the given type
	// in the specified direction. If edgeType is empty, all edge types are traversed.
	GetNeighbors(ctx context.Context, nodeID string, edgeType EdgeType, direction Direction) ([]*Node, error)

	// DeleteByFile removes all nodes (and their edges) associated with the given file path.
	// This supports incremental updates: delete everything from a file before re-indexing it.
	DeleteByFile(ctx context.Context, filePath string) error

	// Stats returns aggregate statistics about the graph.
	Stats(ctx context.Context) (*GraphStats, error)

	// Close releases resources held by the store.
	Close() error
}

Store is the interface for knowledge graph persistence.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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