Class: Protege::AgentMailbox
- Inherits:
-
ActionMailbox::Base
- Object
- ActionMailbox::Base
- Protege::AgentMailbox
- Defined in:
- app/mailboxes/protege/agent_mailbox.rb
Overview
Inbound edge of the Gateway: routes every received email toward the inference pipeline.
Action Mailbox delivers parsed mail here, exposing mail and inbound_email as instance
methods and calling #process as the single entry point. The mailbox resolves the target
persona by recipient address, then hands off to Gateway.accept_smtp_message, which enqueues
InferenceJob. The inbound Message-ID is forwarded as the correlation ID so the trace token
survives the async boundary and is restored inside the job.
Recursion guard
Outbound mail carries an X-Protege-Recursion budget header. Any inbound email whose budget has
reached zero (or below) is silently dropped, preventing infinite loops when one persona replies
to another. Unroutable mail (no matching persona) is bounced with an unrouted notice instead.
Access guardrail
Once routed, the sender is checked against the persona's inbound access guardrail (+Gateway::AccessControl+): the committed global ceiling intersected with the persona's runtime rules. A sender that fails any layer is bounced with an access-denied notice and never reaches inference.
Instance Method Summary collapse
-
#process ⇒ void
Route the inbound email: drop on exhausted recursion budget, bounce when unrouted or when the sender fails the access guardrail, else accept.
Instance Method Details
#process ⇒ void
This method returns an undefined value.
Route the inbound email: drop on exhausted recursion budget, bounce when unrouted or when the sender fails the access guardrail, else accept.
28 29 30 31 32 33 34 35 |
# File 'app/mailboxes/protege/agent_mailbox.rb', line 28 def process return handle_recursion_limit if recursion_limit_reached? return bounce_with_unrouted if persona.nil? return bounce_with_access_denied unless sender_permitted? return if Gateway.(inbound_email:, persona:) end |