Dispatch recipient selection: first internal building block
Core::DispatchSelection is a read-only internal API. It validates recipient
IDs and optional active Core resource-link reasons supplied by an authorized
caller. It does not create a dispatch, freeze database records, select or assess
destinations, perform product authorization or contact an external service.
It does not depend on Visitor. Other source reason types remain undesigned.
The caller authenticates and authorizes the operation, tenant, every recipient
and every resource, and invokes this API inside the same tenant-scoped
REPEATABLE READ transaction that resolved its input. Core verifies the tenant
context and isolation level, not product permissions. A product-resolved ID or
reason is not proof of authorization. Results must be used within that same
transaction; a returned value is not a reservation or committed snapshot.
TenantContext.with(authorized_tenant_id, isolation: :repeatable_read) do # The product authorizes and resolves these IDs within this transaction. reason = Core::DispatchSelection::Reason.new( recipient_id: recipient_id, resource_id: resource_id, resource_link_id: link_id ) entries = Core::DispatchSelection.call( tenant_id: authorized_tenant_id, recipient_ids: [recipient_id], resource_reasons: [reason] ) # Consume entries here; future dispatch creation is not implemented.endEach entry contains one recipient ID and its Core resource-link reasons. A recipient may have no reasons when selected explicitly; no Visitor location is invented. Multiple distinct active links for a recipient remain distinct, while repeated recipient IDs are collapsed. Duplicate reason link IDs, reasons for unselected recipients, malformed IDs and unsupported isolation are rejected. Every supplied recipient must exist in the tenant, and every supplied link must be active and match the claimed tenant, recipient and resource. Missing, foreign, ended or mismatched records reject the whole result. Resource selection and reason legitimacy remain the product’s responsibility. The API does not infer a reason for a resource with no recipients or preserve a display name.
Limits are 1,000 supplied recipient IDs and 5,000 reasons per call. Exceeding a limit fails, never truncates. Larger selection strategies, explicit selection reason identifiers, other source types and the final dispatch schema are open. The transaction snapshot may precede the selection query: concurrent check-outs or edits committed after it began do not change that snapshot.