# LATAM monitor fan-out dispatcher

Handler: `dispatcher_function.lambda_handler`

## Responsibility

This function only:

1. selects LATAM active and previous-day new-signup tenants from the DevOps DB;
2. serializes one tenant per message;
3. sends messages to the monitor SQS queue in batches of 10.

It does not enrich tenants, call Billing/Clinic/Qwen, inspect clusters, write to
the LATAM target database, or score tenants.

## Default selection

Active candidates must be active external LATAM tenants and must not use the
`free_trial`, `new_user`, or `closing` plan.

Previous-day new signups use `country_region = 'LATAM'`. Their plans are not
filtered because `new_user` and `free_trial` are expected in this flow.

## Configuration

Required environment variables:

- `DEVOPS_DB_HOST`
- `DEVOPS_DB_USER`
- `DEVOPS_DB_PASSWORD`
- `DEVOPS_DB_NAME`
- `MONITOR_QUEUE_URL`

Optional environment variables:

- `DEVOPS_DB_PORT` (default `3306`)

The IAM role only needs CloudWatch Logs permissions and `sqs:SendMessage` for
the monitor queue. The template configures a 120-second timeout and 256 MB of
memory for this selection-and-fan-out responsibility.

## Manual invocation controls

The event can contain:

- `include_active` (default `true`)
- `include_new_signup` (default `true`)
- `limit` (default unlimited, applied independently to each source)
- `run_id` (default current UTC timestamp)
