Module: Ace::Hitl::Hermes::Molecules::HermesNotifications

Defined in:
lib/ace/hitl/hermes/molecules/hermes_notifications.rb

Overview

Deterministic single-line notification texts (spec 8wm.t.vs1 §9): no clock, no colors, only provided values. The address is the message address <machine>/<folder>/<id>. Emission is an injectable sink (default silent in Box).

Constant Summary collapse

EVENTS =
%w[
  question_received
  answer_written
  delivered
  acked
  quarantined
  retry_scheduled
  retry_exhausted
].freeze

Class Method Summary collapse

Class Method Details

.emit(event, address:, **details) ⇒ Object

Builds the notification line for an event. Unknown events fail closed so a typo cannot silently drop notifications.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ace/hitl/hermes/molecules/hermes_notifications.rb', line 26

def emit(event, address:, **details)
  case event.to_s
  when "question_received"
    "hermes: question #{address} received"
  when "answer_written"
    "hermes: answer #{address} written"
  when "delivered"
    "hermes: #{address} delivered"
  when "acked"
    "hermes: #{address} acked (file deleted)"
  when "quarantined"
    "hermes: #{address} quarantined (#{details[:reason]})"
  when "retry_scheduled"
    "hermes: #{address} retry #{details[:attempt]}/#{details[:max_attempts]} " \
      "(#{details[:policy]})"
  when "retry_exhausted"
    "hermes: #{address} retries exhausted (#{details[:reason]})"
  else
    raise ContractError,
      "unknown hermes notification event #{event.inspect} " \
      "(known: #{EVENTS.join(", ")})"
  end
end