Class: Woods::FlowAssembler

Inherits:
Object
  • Object
show all
Defined in:
lib/woods/flow_assembler.rb

Overview

Orchestrates execution flow tracing from an entry point through the dependency graph.

Given an entry point (e.g., “PostsController#create”), FlowAssembler:

  1. Loads the ExtractedUnit JSON from disk

  2. Parses its source_code with the AST layer

  3. Extracts operations in source line order

  4. Recursively expands targets that resolve to other units

  5. Detects cycles and respects max_depth

  6. Assembles a FlowDocument

Examples:

Assembling a flow

assembler = FlowAssembler.new(graph: graph, extracted_dir: "/tmp/woods")
flow = assembler.assemble("PostsController#create", max_depth: 5)
puts flow.to_markdown

Instance Method Summary collapse

Constructor Details

#initialize(graph:, extracted_dir:) ⇒ FlowAssembler

Returns a new instance of FlowAssembler.

Parameters:

  • graph (DependencyGraph)

    The dependency graph for resolving targets

  • extracted_dir (String)

    Directory containing extracted unit JSON files



30
31
32
33
34
35
36
# File 'lib/woods/flow_assembler.rb', line 30

def initialize(graph:, extracted_dir:)
  @graph = graph
  @extracted_dir = extracted_dir
  @parser = Ast::Parser.new
  @method_extractor = Ast::MethodExtractor.new(parser: @parser)
  @operation_extractor = FlowAnalysis::OperationExtractor.new
end

Instance Method Details

#assemble(entry_point, max_depth: 5) ⇒ FlowDocument

Assemble an execution flow from the given entry point.

Parameters:

  • entry_point (String)

    Unit identifier, optionally with #method_name

  • max_depth (Integer) (defaults to: 5)

    Maximum recursion depth

Returns:



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/woods/flow_assembler.rb', line 43

def assemble(entry_point, max_depth: 5)
  visited = Set.new
  steps = []

  expand(entry_point, steps, visited, depth: 0, max_depth: max_depth)

  route = extract_route(entry_point)

  FlowDocument.new(
    entry_point: entry_point,
    route: route,
    max_depth: max_depth,
    steps: steps
  )
end