flow

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

@index Persisted flow rebuild service for namespace-scoped stored flows.

@index Flow tracing engine that walks call edges into reusable flow records.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder rebuilds persisted flows from graph data. @intent persists traced flows per entrypoint back into the flows table.

func NewBuilder

func NewBuilder(uow analyzeapp.FlowUnitOfWork) *Builder

NewBuilder creates a persisted flow builder. @intent binds the database and graph reader to create a stored flow rebuild service.

func (*Builder) Rebuild

func (b *Builder) Rebuild(ctx context.Context, cfg Config) ([]Stats, error)

Rebuild recreates persisted flows for the current namespace. @intent refreshes list_flows by replacing all stored flows within the namespace. @param ctx extracts the namespace from the shared request context to determine the work scope. @param cfg placeholder for future rebuild options; currently ignored. @return a list of rebuilt stored flows and the number of member nodes for each. @sideEffect deletes and recreates flow/flow_membership records for the current namespace. @mutates namespace-scoped rows in the flows and flow_memberships tables. @domainRule rebuilds stored flows by running TraceFlow for each entrypoint within the namespace. @ensures partial updates are not persisted if the transaction fails.

type Config

type Config struct{}

Config controls persisted flow rebuild behavior. @intent provides an extension point for stored flow rebuild configuration.

type EdgeReader

type EdgeReader interface {
	GetEdgesFromNodes(ctx context.Context, nodeIDs []uint) ([]graph.Edge, error)
	GetNodeByID(ctx context.Context, id uint) (*graph.Node, error)
}

EdgeReader exposes graph traversal primitives needed for flow tracing. @intent abstract graph reads so flow tracing can follow call edges from any store

type Stats

type Stats struct {
	Flow      graph.Flow
	NodeCount int
}

Stats summarizes one rebuilt stored flow. @intent returns the size of the rebuilt stored flow as a post-process result.

type TraceOptions

type TraceOptions struct {
	MaxNodes             int
	IncludeFallbackCalls *bool
}

TraceOptions bounds how far a single flow trace is allowed to expand. @intent let callers cap traversal cost when tracing large call graphs

type TraceResult

type TraceResult struct {
	Flow          *graph.Flow
	Truncated     bool
	MaxNodes      int
	ReturnedNodes int
	// ContainsFallbackCalls indicates whether the traced flow used at least one fallback call edge.
	ContainsFallbackCalls bool
	// FallbackEdgesCount counts fallback call edges that participated in flow expansion.
	FallbackEdgesCount int
}

TraceResult wraps a built flow with the metadata needed to detect truncation. @intent communicate truncation status alongside the produced flow

type Tracer

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

Tracer builds call-chain flows from a starting node. @intent produce reusable flow records that describe reachable call paths

func New

func New(store EdgeReader) *Tracer

New creates a flow tracer. @intent construct a tracer bound to a graph edge reader

func (*Tracer) TraceFlow

func (t *Tracer) TraceFlow(ctx context.Context, startNodeID uint) (*graph.Flow, error)

TraceFlow traverses outgoing call edges from a start node. @intent capture the reachable call chain from one entry node as a flow @param startNodeID graph node where traversal begins @return flow containing visited nodes in traversal order @domainRule only calls edges expand the traced flow @ensures each reachable node is included at most once

func (*Tracer) TraceFlowBounded

func (t *Tracer) TraceFlowBounded(ctx context.Context, startNodeID uint, opts TraceOptions) (*TraceResult, error)

TraceFlowBounded performs the BFS traversal that backs TraceFlow with explicit limits. @intent expose a flow trace variant that can stop early when MaxNodes is reached @param startNodeID graph node where traversal begins @param opts traversal limits applied during BFS @return TraceResult with the built flow and truncation metadata @domainRule only calls edges enqueue new BFS nodes; outgoing edges are fetched once per BFS depth @ensures Truncated is true only when MaxNodes stopped traversal

Jump to

Keyboard shortcuts

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