Class: Igniter::Store::Protocol::Handlers::DerivationHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/igniter/store/protocol/handlers/derivation_handler.rb

Overview

Derivation descriptors are metadata-only in OP1. Execution requires a rule callable which external descriptor packets cannot carry. The descriptor is stored in the schema graph for OP2 introspection.

Constant Summary collapse

REQUIRED =
%i[name inputs output].freeze

Instance Method Summary collapse

Constructor Details

#initialize(store) ⇒ DerivationHandler

Returns a new instance of DerivationHandler.



13
# File 'lib/igniter/store/protocol/handlers/derivation_handler.rb', line 13

def initialize(store) = @store = store

Instance Method Details

#call(descriptor) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/igniter/store/protocol/handlers/derivation_handler.rb', line 15

def call(descriptor)
  missing = REQUIRED.select { |f| descriptor[f].nil? }
  return Receipt.rejection("Missing required fields: #{missing.join(", ")}", kind: :derivation) if missing.any?

  name = descriptor[:name].to_sym
  warnings = ["derivation: #{name.inspect} registered as metadata only; attach a rule callable via register_derivation to enable execution"]
  Receipt.accepted(kind: :derivation, name: name, warnings: warnings)
end