ProgramFacts.Graph (program_facts v0.2.1)

Copy Markdown View Source

Converts ProgramFacts models and facts into libgraph graphs.

ProgramFacts manifests stay JSON-friendly lists and maps. This module is a runtime adapter for analyzers and tests that want Graph.t() values for reachability, path, cycle, and module-dependency checks.

Summary

Functions

Builds the graph used by architecture facts.

Returns call edges from a generated program or model.

Builds a function-level call graph from a generated program or model.

Returns strongly connected components that represent cycles in the call graph.

Returns graph metrics useful for search scoring and shrink decisions.

Builds a module-level graph by collapsing function-level call edges to modules.

Returns true when every consecutive pair in path is an edge in the call graph.

Returns true when target is reachable from source in the call graph.

Returns the induced call subgraph for vertices.

Validates graph-derived facts declared by the model.

Types

graph_input()

@type graph_input() :: ProgramFacts.Program.t() | ProgramFacts.Model.t()

Functions

architecture_graph(input)

Builds the graph used by architecture facts.

Architecture fixtures express dependency violations through the same call-edge model, so this currently aliases module_graph/1.

call_edges(input)

Returns call edges from a generated program or model.

call_graph(input)

Builds a function-level call graph from a generated program or model.

cycles(input)

Returns strongly connected components that represent cycles in the call graph.

metrics(input)

Returns graph metrics useful for search scoring and shrink decisions.

module_graph(input)

Builds a module-level graph by collapsing function-level call edges to modules.

path?(input, path)

Returns true when every consecutive pair in path is an edge in the call graph.

reachable?(input, source, target)

Returns true when target is reachable from source in the call graph.

subgraph(input, vertices)

Returns the induced call subgraph for vertices.

validate!(input)

Validates graph-derived facts declared by the model.

Currently validates all declared call paths and declared architecture cycles. Raises ArgumentError if a declared graph fact is impossible for the edges.