federation

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AffectedPackage

type AffectedPackage struct {
	// ID is the package identifier.
	ID string `json:"id"`

	// UsesInternal indicates if it uses internal APIs.
	UsesInternal bool `json:"uses_internal"`

	// TransitiveDepth is how many hops away this package is.
	TransitiveDepth int `json:"transitive_depth"`
}

AffectedPackage represents an affected package.

type AffectedRepo

type AffectedRepo struct {
	// RepoID is the repository identifier.
	RepoID string `json:"repo_id"`

	// CallerCount is the number of callers in this repo.
	CallerCount int `json:"caller_count"`

	// ImpactLevel is the impact severity.
	ImpactLevel string `json:"impact_level"`
}

AffectedRepo represents an affected repository.

type CrossRepoBlastRadius

type CrossRepoBlastRadius struct {
	// TargetRepo is the repository containing the changed symbol.
	TargetRepo string `json:"target_repo"`

	// TargetSymbol is the changed symbol.
	TargetSymbol string `json:"target_symbol"`

	// LocalCallers are callers within the same repository.
	LocalCallers int `json:"local_callers"`

	// AffectedRepos are other repositories affected.
	AffectedRepos []AffectedRepo `json:"affected_repos"`

	// TotalCrossRepoCallers is the total number of callers in other repos.
	TotalCrossRepoCallers int `json:"total_cross_repo_callers"`
}

CrossRepoBlastRadius calculates blast radius across repositories.

type CrossRepoEdge

type CrossRepoEdge struct {
	// FromRepo is the source repository ID.
	FromRepo string `json:"from_repo"`

	// FromSymbol is the symbol in the source repo.
	FromSymbol string `json:"from_symbol"`

	// ToRepo is the target repository ID.
	ToRepo string `json:"to_repo"`

	// ToSymbol is the symbol in the target repo.
	ToSymbol string `json:"to_symbol"`

	// EdgeType is the type of cross-repo dependency.
	EdgeType CrossRepoEdgeType `json:"edge_type"`

	// Confidence is how confident we are in this edge (0-100).
	Confidence int `json:"confidence"`
}

CrossRepoEdge represents a dependency between repositories.

type CrossRepoEdgeType

type CrossRepoEdgeType string

CrossRepoEdgeType represents the type of cross-repository edge.

const (
	CrossRepoImport  CrossRepoEdgeType = "IMPORT"
	CrossRepoAPICall CrossRepoEdgeType = "API_CALL"
	CrossRepoGRPC    CrossRepoEdgeType = "GRPC"
	CrossRepoEvent   CrossRepoEdgeType = "EVENT"
)

type ExportedSymbol

type ExportedSymbol struct {
	// SymbolID is the symbol identifier within the repo.
	SymbolID string `json:"symbol_id"`

	// Name is the public name.
	Name string `json:"name"`

	// Package is the package path.
	Package string `json:"package"`

	// Type is the symbol type (function, type, etc.).
	Type string `json:"type"`
}

ExportedSymbol represents a symbol exported from a repository.

type FederatedGraph

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

FederatedGraph aggregates graphs from multiple repositories.

Description

Combines dependency graphs from multiple repositories or monorepo packages into a unified view. Tracks cross-repository dependencies through imports, API calls, gRPC, and event systems.

Thread Safety

Safe for concurrent use.

func NewFederatedGraph

func NewFederatedGraph() *FederatedGraph

NewFederatedGraph creates a new federated graph.

func (*FederatedGraph) AddRepo

func (f *FederatedGraph) AddRepo(repo *RepoGraph) error

AddRepo adds a repository to the federation.

Inputs

  • repo: The repository graph to add.

Outputs

  • error: Non-nil if repo ID already exists.

func (*FederatedGraph) CalculateCrossRepoBlastRadius

func (f *FederatedGraph) CalculateCrossRepoBlastRadius(ctx context.Context, repoID, symbolID string) (*CrossRepoBlastRadius, error)

CalculateCrossRepoBlastRadius computes blast radius across repositories.

func (*FederatedGraph) DiscoverEdges

func (f *FederatedGraph) DiscoverEdges(ctx context.Context) error

DiscoverEdges finds cross-repository dependencies.

Description

Analyzes all repositories to find dependencies between them. Detects:

  • Go package imports
  • HTTP/gRPC client calls
  • Event publisher/subscriber relationships

Inputs

  • ctx: Context for cancellation.

Outputs

  • error: Non-nil on failure.

func (*FederatedGraph) FindAffectedRepos

func (f *FederatedGraph) FindAffectedRepos(repoID, symbolID string) []string

FindAffectedRepos finds all repos affected by a change in a symbol.

Inputs

  • repoID: The repository where the change occurs.
  • symbolID: The symbol being changed.

Outputs

  • []string: Repository IDs that depend on this symbol.

func (*FederatedGraph) GetCrossRepoEdges

func (f *FederatedGraph) GetCrossRepoEdges() []CrossRepoEdge

GetCrossRepoEdges returns all cross-repo edges.

func (*FederatedGraph) GetEdgesFrom

func (f *FederatedGraph) GetEdgesFrom(repoID string) []CrossRepoEdge

GetEdgesFrom returns edges from a specific repo.

func (*FederatedGraph) GetEdgesTo

func (f *FederatedGraph) GetEdgesTo(repoID string) []CrossRepoEdge

GetEdgesTo returns edges to a specific repo.

func (*FederatedGraph) GetRepo

func (f *FederatedGraph) GetRepo(repoID string) (*RepoGraph, bool)

GetRepo returns a repository by ID.

func (*FederatedGraph) RemoveRepo

func (f *FederatedGraph) RemoveRepo(repoID string)

RemoveRepo removes a repository from the federation.

func (*FederatedGraph) RepoIDs

func (f *FederatedGraph) RepoIDs() []string

RepoIDs returns all repository IDs.

type FederationManifest

type FederationManifest struct {
	// Repos are the repositories to include.
	Repos []RepoConfig `yaml:"repos" json:"repos"`
}

FederationManifest defines repositories to federate.

func LoadManifest

func LoadManifest(path string) (*FederationManifest, error)

LoadManifest loads a federation manifest from a YAML file.

Inputs

  • path: Path to the manifest file (.aleutian/federation.yml).

Outputs

  • *FederationManifest: Parsed manifest.
  • error: Non-nil on failure.

type MonorepoAnalyzer

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

MonorepoAnalyzer detects and analyzes package boundaries in a monorepo.

Description

Identifies packages within a monorepo using go.mod, package.json, and other manifest files. Tracks internal vs public APIs and cross-package dependencies.

Thread Safety

Safe for concurrent use after construction.

func NewMonorepoAnalyzer

func NewMonorepoAnalyzer(root string) *MonorepoAnalyzer

NewMonorepoAnalyzer creates a new monorepo analyzer.

Inputs

  • root: Path to the monorepo root.

Outputs

  • *MonorepoAnalyzer: Ready-to-use analyzer.

func (*MonorepoAnalyzer) AnalyzeDependencies

func (m *MonorepoAnalyzer) AnalyzeDependencies(ctx context.Context) error

AnalyzeDependencies discovers cross-package dependencies.

Inputs

  • ctx: Context for cancellation.

Outputs

  • error: Non-nil on failure.

func (*MonorepoAnalyzer) CalculatePackageBlastRadius

func (m *MonorepoAnalyzer) CalculatePackageBlastRadius(ctx context.Context, pkgID string) (*PackageBlastRadius, error)

CalculatePackageBlastRadius computes blast radius for a package change.

func (*MonorepoAnalyzer) DetectInternalAPILeaks

func (m *MonorepoAnalyzer) DetectInternalAPILeaks() []PackageEdge

DetectInternalAPILeaks finds cases where internal APIs are used externally.

func (*MonorepoAnalyzer) DiscoverPackages

func (m *MonorepoAnalyzer) DiscoverPackages(ctx context.Context) error

DiscoverPackages finds all packages in the monorepo.

Inputs

  • ctx: Context for cancellation.

Outputs

  • error: Non-nil on failure.

func (*MonorepoAnalyzer) Edges

func (m *MonorepoAnalyzer) Edges() []PackageEdge

Edges returns all package edges.

func (*MonorepoAnalyzer) GetDependenciesOf

func (m *MonorepoAnalyzer) GetDependenciesOf(pkgID string) []string

GetDependenciesOf returns packages that the given package depends on.

func (*MonorepoAnalyzer) GetDependentsOf

func (m *MonorepoAnalyzer) GetDependentsOf(pkgID string) []string

GetDependentsOf returns packages that depend on the given package.

func (*MonorepoAnalyzer) GetPackage

func (m *MonorepoAnalyzer) GetPackage(id string) (*Package, bool)

GetPackage returns a package by ID.

func (*MonorepoAnalyzer) Packages

func (m *MonorepoAnalyzer) Packages() []Package

Packages returns all discovered packages.

type Package

type Package struct {
	// ID is a unique identifier for this package.
	ID string `json:"id"`

	// Name is the package name.
	Name string `json:"name"`

	// Path is the relative path from monorepo root.
	Path string `json:"path"`

	// Type is the package type (go, npm, python).
	Type PackageType `json:"type"`

	// PublicAPIs are symbols exported for use by other packages.
	PublicAPIs []string `json:"public_apis,omitempty"`

	// InternalAPIs are symbols for internal use only.
	InternalAPIs []string `json:"internal_apis,omitempty"`

	// Dependencies are direct package dependencies.
	Dependencies []string `json:"dependencies"`
}

Package represents a package within a monorepo.

type PackageBlastRadius

type PackageBlastRadius struct {
	// Package is the changed package.
	Package string `json:"package"`

	// AffectedPackages are packages that depend on the changed package.
	AffectedPackages []AffectedPackage `json:"affected_packages"`

	// TotalAffected is the total count of affected packages.
	TotalAffected int `json:"total_affected"`

	// HasInternalUsage indicates if internal APIs are used externally.
	HasInternalUsage bool `json:"has_internal_usage"`
}

PackageBlastRadius calculates the blast radius for a package change.

type PackageEdge

type PackageEdge struct {
	// From is the dependent package ID.
	From string `json:"from"`

	// To is the dependency package ID.
	To string `json:"to"`

	// IsInternal indicates if this uses internal APIs.
	IsInternal bool `json:"is_internal"`

	// Symbols are the specific symbols used.
	Symbols []string `json:"symbols,omitempty"`
}

PackageEdge represents a dependency between packages.

type PackageType

type PackageType string

PackageType represents the type of package.

const (
	PackageTypeGo     PackageType = "go"
	PackageTypeNPM    PackageType = "npm"
	PackageTypePython PackageType = "python"
)

type RepoConfig

type RepoConfig struct {
	// ID is the unique identifier for this repo.
	ID string `yaml:"id" json:"id"`

	// Path is the file system path (relative or absolute).
	Path string `yaml:"path" json:"path"`

	// Type is the repository type (go, python, typescript).
	Type string `yaml:"type,omitempty" json:"type,omitempty"`

	// Exports lists patterns for exported symbols.
	Exports []string `yaml:"exports,omitempty" json:"exports,omitempty"`
}

RepoConfig configures a repository in the federation.

type RepoGraph

type RepoGraph struct {
	// ID is the unique repository identifier.
	ID string `json:"id"`

	// Path is the file system path to the repository.
	Path string `json:"path"`

	// Graph is the repository's dependency graph.
	Graph *graph.Graph `json:"-"`

	// Exports are symbols exported by this repo for other repos to use.
	Exports []ExportedSymbol `json:"exports"`

	// Generation is the graph generation for cache invalidation.
	Generation uint64 `json:"generation"`
}

RepoGraph wraps a repository's graph with metadata.

Jump to

Keyboard shortcuts

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