Class: Protege::ConsoleInferenceJob

Inherits:
ApplicationJob show all
Defined in:
app/jobs/protege/console_inference_job.rb

Overview

Runs a dashboard-originated message through the inference pipeline.

The console counterpart to InferenceJob: enqueued by Gateway.accept_console_message when a developer sends a message from the HQ console. Because console messages bypass SMTP entirely, this job operates on a Message that has already been persisted, rather than on an ActionMailbox::InboundEmail it must ingest first. The remainder of the flow — correlation-ID restoration, running the Orchestrator's Harness, and recording the outcome — mirrors InferenceJob.

Lifecycle

  1. Restore the correlation ID for event tracing.
  2. Find the Message and Persona from their IDs.
  3. Transition the message to processing.
  4. Run the inference loop (+Harness+).
  5. Mark the message processed on success, failed on error.

Instance Method Summary collapse

Instance Method Details

#perform(message_id:, persona_id:, correlation_id:) ⇒ void

This method returns an undefined value.

Process one pre-persisted console message end to end.

Parameters:

  • message_id (Integer)

    primary key of the pre-persisted Message record

  • persona_id (Integer)

    primary key of the Persona; STI loads the correct subclass

  • correlation_id (String)

    trace token forwarded from the console request

Raises:

  • (StandardError)

    re-raised after being recorded on the message, to trigger retries



30
31
32
33
34
35
36
37
38
39
40
# File 'app/jobs/protege/console_inference_job.rb', line 30

def perform(message_id:, persona_id:, correlation_id:)
  restore_correlation_id(correlation_id)

  message = Message.find(message_id)
  persona = Persona.find(persona_id)

  process(message:, persona:)
rescue StandardError => e
  message&.mark_failed!(e)
  raise
end