Keep Pulsar safe in long-lived workers
Pulsar workflow constructors hold dependencies while execute receives runtime data. That convention avoids retaining request, actor, tenant, payload state in objects reused by Octane/queue workers; scoped bindings reset with Laravel lifecycle but do not provide security.
Octane singleton request
Laravel Octane boots the application once and reuses it. Constructors therefore hold only stable dependencies. A workflow must not retain a Request, actor, tenant, correlation value, payload, live Model, mutable configuration, or captured container in an instance property. Controller and route method Request injection remains a Laravel delivery boundary.
| Object or state | Binding or use | Reset and limit |
|---|---|---|
| Pure stateless Adapter/value service | Regular, or deliberate singleton with no mutable/request/config/container capture. | Shared only while stateless; application tests choose the singleton. |
| Actor, tenant, or request context | Scoped Contract/implementation or explicit execute()/handler argument. | Laravel flushes Octane request and queue-job scope; callers still reconstruct, authorize, and tenant-scope. |
| UseCase, Action, Operation, Query | Constructor dependencies; runtime data in execute(). | Do not retain caller context as a property. |
| Job, Command, queued Listener | Durable IDs, DTOs, and Value Objects. | Reconstruct, authorize, scope, and keep the same idempotency key. |
| Static cache or mutable global | No actor/tenant accumulation. | Only application-owned bounded cache/invalidation; package tests prove no memory safety or isolation. |
Pass runtime values at the method boundary
Context: runtime boundary — stable dependencies enter the constructor; request-specific data enters the workflow call.
final class ChargeInvoice
{
public function __construct(private PaymentGateway $gateway) {}
public function execute(InvoiceId $invoiceId, ActorId $actorId): void {}
}Scoped lifetime is not authorization, tenant isolation, idempotency, or exactly-once delivery. This documentation neither creates a Context API nor configures Octane, workers, middleware, caches, or tenant infrastructure.
Continue with Contracts and Adapters for bindings, Tenancy for independent isolation, and Anti-patterns for the prohibited shapes.