Module: FlowEngine

Defined in:
lib/flowengine.rb,
lib/flowengine/dsl.rb,
lib/flowengine/llm.rb,
lib/flowengine/node.rb,
lib/flowengine/engine.rb,
lib/flowengine/errors.rb,
lib/flowengine/version.rb,
lib/flowengine/evaluator.rb,
lib/flowengine/rules/all.rb,
lib/flowengine/rules/any.rb,
lib/flowengine/definition.rb,
lib/flowengine/llm/client.rb,
lib/flowengine/rules/base.rb,
lib/flowengine/transition.rb,
lib/flowengine/llm/adapter.rb,
lib/flowengine/introduction.rb,
lib/flowengine/llm/adapters.rb,
lib/flowengine/llm/provider.rb,
lib/flowengine/rules/equals.rb,
lib/flowengine/rules/contains.rb,
lib/flowengine/llm/auto_client.rb,
lib/flowengine/rules/less_than.rb,
lib/flowengine/rules/not_empty.rb,
lib/flowengine/dsl/flow_builder.rb,
lib/flowengine/dsl/rule_helpers.rb,
lib/flowengine/dsl/step_builder.rb,
lib/flowengine/rules/greater_than.rb,
lib/flowengine/validation/adapter.rb,
lib/flowengine/clarification_result.rb,
lib/flowengine/graph/mermaid_exporter.rb,
lib/flowengine/engine/state_serializer.rb,
lib/flowengine/validation/null_adapter.rb,
lib/flowengine/llm/intake_prompt_builder.rb,
lib/flowengine/llm/sensitive_data_filter.rb,
lib/flowengine/llm/system_prompt_builder.rb,
lib/flowengine/llm/adapters/gemini_adapter.rb,
lib/flowengine/llm/adapters/openai_adapter.rb,
lib/flowengine/llm/adapters/anthropic_adapter.rb

Overview

Declarative flow definition and execution engine for wizards, intake forms, and multi-step decision graphs. Separates flow logic, data schema, and UI rendering.

Examples:

Define and run a flow

definition = FlowEngine.define do
  start :earnings
  step :earnings do
    type :multi_select
    question "What are your main earnings?"
    options %w[W2 1099 BusinessOwnership]
    transition to: :business_details, if: contains(:earnings, "BusinessOwnership")
  end
  step :business_details do
    type :number_matrix
    question "How many business types?"
    fields %w[RealEstate SCorp CCorp]
  end
end
engine = FlowEngine::Engine.new(definition)
engine.answer(["W2", "BusinessOwnership"])
engine.current_step_id # => :business_details

Defined Under Namespace

Modules: DSL, Errors, Graph, LLM, Rules, Validation Classes: ClarificationResult, Definition, Engine, Evaluator, Introduction, Node, Transition

Constant Summary collapse

ROOT =

Root directory of the flowengine gem

File.expand_path("..", __dir__)
VERSION =

Semantic version of the flowengine gem (major.minor.patch).

"0.4.1"

Class Method Summary collapse

Class Method Details

.constantize(name) ⇒ Class, Module

Resolves a fully-qualified constant name string to the actual constant.

Parameters:

  • name (String) —

    e.g. "FlowEngine::LLM::Adapters::AnthropicAdapter"

Returns:

  • (Class, Module)


70
71
72
# File 'lib/flowengine.rb', line 70

def self.constantize(name)
  name.split("::").inject(Object) { |mod, const| mod.const_get(const) }
end

.define { ... } ⇒ Definition

Builds an immutable Definition from the declarative DSL block.

Yields:

Returns:

  • (Definition) —

    frozen flow definition with start step and nodes

Raises:



44
45
46
47
48
# File 'lib/flowengine.rb', line 44

def self.define(&)
  builder = DSL::FlowBuilder.new
  builder.instance_eval(&)
  builder.build
end

.load_dsl(text) ⇒ Definition

Evaluates a string of DSL code and returns the resulting definition. Intended for loading flow definitions from files or stored text.

Parameters:

  • text (String) —

    Ruby source containing FlowEngine.define { ... }

Returns:

  • (Definition) —

    the definition produced by evaluating the DSL

Raises:



56
57
58
59
60
61
62
63
64
# File 'lib/flowengine.rb', line 56

def self.load_dsl(text)
  # rubocop:disable Security/Eval
  eval(text, TOPLEVEL_BINDING.dup, "(dsl)", 1)
  # rubocop:enable Security/Eval
rescue SyntaxError => e
  raise Errors::DefinitionError, "DSL syntax error: #{e.message}"
rescue StandardError => e
  raise Errors::DefinitionError, "DSL evaluation error: #{e.message}"
end