/**
 * Pure builders for the webhook event envelope (D0045: zero I/O, in the kernel).
 * `projectReport` denormalizes the routing-friendly slice of a Report;
 * `buildWebhookEnvelope` wraps it with delivery metadata. The caller stamps
 * `deliveredAt` (passed in for deterministic tests) and supplies the events.
 */
export function projectReport(report, link) {
    return {
        reportId: report.id,
        ...(report.tag ? { publishTag: report.tag } : {}),
        source: report.provenance.source.name,
        areas: report.provenance.areas,
        belowCritical: report.summary.belowCritical,
        regressed: report.comparison?.regressed ?? [],
        degraded: report.degraded !== undefined,
        ...(link ? { link } : {}),
    };
}
export function buildWebhookEnvelope(input) {
    return {
        schemaVersion: 1,
        deliveredAt: input.deliveredAt,
        surface: input.surface,
        events: input.events,
        report: input.report,
        ...(input.jobId ? { jobId: input.jobId } : {}),
        ...(input.summary !== undefined ? { summary: input.summary } : {}),
    };
}
