Class: Lyra::Verification::WorkflowGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/lyra/verification/workflow_generator.rb

Overview

Generates Petri net workflows by introspecting Lyra's actual implementation. Uses metaprogramming to analyze callbacks, modes, and model configurations.

Constant Summary collapse

AVAILABLE_MODES =
[:monitor, :hijack, :es_sync, :es_async].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ WorkflowGenerator

Returns a new instance of WorkflowGenerator.



12
13
14
15
16
17
18
19
20
# File 'lib/lyra/verification/workflow_generator.rb', line 12

def initialize(options = {})
  @options = options
  @analysis = {
    modes: [],
    callbacks: {},
    models: [],
    event_types: []
  }
end

Instance Attribute Details

#analysis ⇒ Object (readonly)

Returns the value of attribute analysis.



8
9
10
# File 'lib/lyra/verification/workflow_generator.rb', line 8

def analysis
  @analysis
end

#options ⇒ Object (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/lyra/verification/workflow_generator.rb', line 8

def options
  @options
end

Instance Method Details

#generate!(mode: nil) ⇒ Object

Analyze Lyra implementation and generate workflow

Parameters:

  • mode (Symbol, nil) (defaults to: nil) —

    Specific mode to generate workflow for, or nil for all



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/lyra/verification/workflow_generator.rb', line 24

def generate!(mode: nil)
  analyze_modes
  analyze_callbacks
  analyze_monitored_models
  analyze_event_types

  result = {
    lifecycle_workflow: generate_lifecycle_workflow,
    analysis: @analysis
  }

  if mode
    # Generate workflow for specific mode
    validate_mode!(mode)
    result[:mode_workflow] = generate_workflow_for_mode(mode)
  else
    # Generate workflows for all modes
    result[:mode_workflows] = generate_all_mode_workflows
  end

  result
end