Class: Insika::Workflow::Definition

Inherits:
Data
  • Object
show all
Defined in:
lib/insika/workflow.rb

Overview

Bundles a registered workflow's callable factory with its metadata (schemas + description). Built lazily by WorkflowRegistry#definition — it does NOT resolve the factory (the Executor resolves inside the fiber; the contract forbids instantiating outside it). Schema validation touches only the schemas.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



24
25
26
# File 'lib/insika/workflow.rb', line 24

def description
  @description
end

#factoryObject (readonly)

Returns the value of attribute factory

Returns:

  • (Object)

    the current value of factory



24
25
26
# File 'lib/insika/workflow.rb', line 24

def factory
  @factory
end

#input_schemaObject (readonly)

Returns the value of attribute input_schema

Returns:

  • (Object)

    the current value of input_schema



24
25
26
# File 'lib/insika/workflow.rb', line 24

def input_schema
  @input_schema
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



24
25
26
# File 'lib/insika/workflow.rb', line 24

def name
  @name
end

#output_schemaObject (readonly)

Returns the value of attribute output_schema

Returns:

  • (Object)

    the current value of output_schema



24
25
26
# File 'lib/insika/workflow.rb', line 24

def output_schema
  @output_schema
end

Instance Method Details

#call(input, context:, tools:) ⇒ Object

Resolves the factory (INSIDE the fiber) and invokes the orchestrator with the canonical signature #call(input, context:, tools:).



37
38
39
# File 'lib/insika/workflow.rb', line 37

def call(input, context:, tools:)
  factory.call.call(input, context: context, tools: tools)
end

#catalog_entryObject

Discovery view (GET /v1/workflows): name + description + the I/O contract. A JSON-Schema-backed schema exposes its schema Hash; a duck-typed validator (dry-schema etc.) is opaque to introspection -> "opaque".



44
45
46
47
48
49
50
51
# File 'lib/insika/workflow.rb', line 44

def catalog_entry
  {
    "name" => name,
    "description" => description,
    "input_schema" => schema_view(input_schema),
    "output_schema" => schema_view(output_schema)
  }
end

#validate_input!(input) ⇒ Object

Raises WorkflowSchemaError (< ValidationError) when the input does not conform. No-op without an input_schema (parity). Called synchronously by TriggerWorkflow -> a bad input is a 422 with no run created.



28
# File 'lib/insika/workflow.rb', line 28

def validate_input!(input) = enforce!(input_schema, input, :input)

#validate_output!(output) ⇒ Object

Raises WorkflowSchemaError when the RETURN does not conform. No-op without an output_schema. Called inside the fiber after the workflow returns -> a bad output fails the run at the :workflow_schema stage.



33
# File 'lib/insika/workflow.rb', line 33

def validate_output!(output) = enforce!(output_schema, output, :output)