package com.cameleer.server.core.alerting;

import java.time.Instant;
import java.util.Map;

/**
 * Specification for alerting-specific execution counting.
 * Distinct from {@code SearchRequest}: no text-in-body subqueries, no cursor, no {@code FINAL}.
 * All fields except {@code tenantId}, {@code environment}, {@code from}, and {@code to} are nullable filters.
 */
public record AlertMatchSpec(
        String tenantId,
        String environment,
        String applicationId,           // nullable — omit to match all apps
        String routeId,                 // nullable — omit to match all routes
        String status,                  // "FAILED" / "COMPLETED" / null for any
        Map<String, String> attributes, // exact match on execution attribute key=value; empty = no filter
        Instant from,
        Instant to,
        Instant after                   // nullable; used by PER_EXCHANGE mode to advance cursor past last seen
) {
    public AlertMatchSpec {
        attributes = attributes == null ? Map.of() : Map.copyOf(attributes);
    }
}
