Class: MnemeEnrichmentJob

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

Overview

Second stage of the drain pipeline: runs Mneme’s recall loop so any older memory she judges useful lands in the mailbox as background PendingMessages, then hands off to the drain loop via Events::StartProcessing.

Triggered by Events::Subscribers::MnemeKickoff in response to Events::StartMneme, which MeleteEnrichmentJob only emits when goals changed during the preceding Melete run. Runs the phantom Mneme::RecallRunner loop — the event is only the entry/exit plumbing.

Mneme recall is enrichment — it adds recalled memories as background phantom pairs but is never required for the primary pipeline to make progress. If recall raises (bad FTS5 input, SQL glitch, …) the handoff to the drain loop must still happen, otherwise the session’s user message is stranded in the mailbox with no retry trigger. Exceptions are logged loudly so failures stay visible — they just don’t gate the drain.

Instance Method Summary collapse

Instance Method Details

#perform(session_id, pending_message_id: nil) ⇒ Object

Parameters:

  • session_id (Integer)
  • pending_message_id (Integer, nil) (defaults to: nil)

    the PM that kicked off the chain



26
27
28
29
30
31
32
33
34
35
# File 'app/jobs/mneme_enrichment_job.rb', line 26

def perform(session_id, pending_message_id: nil)
  session = Session.find(session_id)

  run_recall(session)

  Events::Bus.emit(Events::StartProcessing.new(
    session_id: session_id,
    pending_message_id: pending_message_id
  ))
end