Class: Protege::Orchestrator::Context
- Inherits:
-
Object
- Object
- Protege::Orchestrator::Context
- Defined in:
- lib/protege/orchestrator/context.rb
Overview
Base context shared by both kinds of run. Carries the per-run runtime data every tool and
resolver needs — persona, a frozen config snapshot, logger, correlation id — plus the
#deliver affordance for sending mail through the Gateway, without exposing mutable framework
state. Frozen after construction so one instance is safely shared across every tool/resolver
invocation in a run.
The thing that drove the run differs by kind, so it is exposed through two accessors that both
default to nil here and are each overridden by exactly one subclass: ReplyContext sets
#message (reactive, an inbound email) and ResponsibilityContext sets #responsibility
(proactive, a scheduled Loop run). Tools and resolvers branch on whichever is present.
Direct Known Subclasses
Instance Attribute Summary collapse
- #config ⇒ Protege::Persona, ... readonly
- #correlation_id ⇒ Protege::Persona, ... readonly
- #logger ⇒ Protege::Persona, ... readonly
- #persona ⇒ Protege::Persona, ... readonly
Instance Method Summary collapse
-
#deliver(mail:, attachments: []) ⇒ Object
Deliver an outbound mail via the Gateway, handling transport, thread resolution, and message persistence under the current persona.
-
#initialize(persona:) ⇒ void
constructor
Capture the shared runtime data and freeze.
-
#message ⇒ Object?
The inbound message that drove this run, or nil when none did (overridden by
ReplyContext). -
#responsibility ⇒ Protege::Responsibility?
The responsibility that drove this run, or nil when none did (overridden by
ResponsibilityContext).
Constructor Details
#initialize(persona:) ⇒ void
Capture the shared runtime data and freeze. Subclasses set their own subject ivar before
calling super, since this constructor freezes the instance.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/protege/orchestrator/context.rb', line 27 def initialize(persona:) @persona = persona @logger = Protege.configuration.logger # Snapshot a frozen *copy* so the context is immutable without freezing the process-wide # configuration (which boot-time code and tests still mutate). @config = Protege.configuration.dup.freeze @correlation_id = Protege::Current.correlation_id freeze end |
Instance Attribute Details
#config ⇒ Protege::Persona, ... (readonly)
20 21 22 |
# File 'lib/protege/orchestrator/context.rb', line 20 def config @config end |
#correlation_id ⇒ Protege::Persona, ... (readonly)
20 21 22 |
# File 'lib/protege/orchestrator/context.rb', line 20 def correlation_id @correlation_id end |
#logger ⇒ Protege::Persona, ... (readonly)
20 21 22 |
# File 'lib/protege/orchestrator/context.rb', line 20 def logger @logger end |
#persona ⇒ Protege::Persona, ... (readonly)
20 21 22 |
# File 'lib/protege/orchestrator/context.rb', line 20 def persona @persona end |
Instance Method Details
#deliver(mail:, attachments: []) ⇒ Object
Deliver an outbound mail via the Gateway, handling transport, thread resolution, and message
persistence under the current persona. Any attachments (blobs already in storage) are attached
to the persisted outbound message by reference, so a file is never re-uploaded on send.
60 61 62 |
# File 'lib/protege/orchestrator/context.rb', line 60 def deliver(mail:, attachments: []) Gateway.deliver(mail:, persona:, attachments:) end |
#message ⇒ Object?
The inbound message that drove this run, or nil when none did (overridden by ReplyContext).
41 42 43 |
# File 'lib/protege/orchestrator/context.rb', line 41 def nil end |
#responsibility ⇒ Protege::Responsibility?
The responsibility that drove this run, or nil when none did (overridden by
ResponsibilityContext).
49 50 51 |
# File 'lib/protege/orchestrator/context.rb', line 49 def responsibility nil end |