/**
 * ANL-EVENT-NONDOMAIN — flag `publishes` entries whose name denotes a query /
 * read / render / helper rather than a domain state-change. The marrbox event
 * over-emission signature (`JobCardRead`, `GameListFetched`,
 * `CookieConsentDismissed`, `RoleNotificationCardRendered`): prompt-resistant
 * (ticks UP under the additive prompt) → wants the deterministic verifier.
 *
 * Treatment is auto-reemit (LLM judgment), NOT a deterministic delete: the
 * discriminator is the event KIND in its name, but an event we don't recognise
 * the subscriber for may still be consumed externally — so we ask the model to
 * drop it rather than silently deleting spec content.
 */
import { isNonDomainEvent } from '../detectors.js';
export const EVENT_DISCIPLINE_VERIFIER = {
    id: 'anl-event-non-domain',
    name: 'Event discipline (domain state-change, not query/render)',
    enabledByDefault: false,
    contextScope: 'action',
    applies: (ctx) => ctx.actionBodies.size > 0,
    verify: (ctx) => {
        const findings = [];
        for (const [stubPath, body] of ctx.actionBodies) {
            const publishes = body.publishes ?? [];
            const offending = publishes.filter((e) => isNonDomainEvent(e));
            if (offending.length === 0)
                continue;
            const list = offending.map((e) => `\`${e}\``).join(', ');
            findings.push({
                code: 'ANL-EVENT-NONDOMAIN',
                severity: 'warning',
                stubPath,
                message: `${offending.length} published event(s) read as query/read/render, not domain state-change: ${offending.join(', ')}.`,
                correction: `The published event(s) ${list} read as a query/read/render/helper, not a domain state-change event. ` +
                    `Remove them from \`publishes\` — only emit events for genuine domain state changes (something a ` +
                    `subscriber would react to). Reads, list-fetches, renders, and normalizations are not domain events.`,
            });
        }
        return findings;
    },
};
//# sourceMappingURL=event-discipline.js.map