/**
 * ANL-STEP-CODE — flag `steps` that read as transcribed code rather than
 * business intent. The residual the input-format fix (TODO #22) can't fully
 * reach: sonnet on the gnarliest messy sources still transcribes
 * (`[call] res.status(401)`, `db.select(...).limit(1)`). The deterministic
 * backstop the proposal calls for.
 */
import { isProgrammingStep, programmingSignals } from '../detectors.js';
export const STEP_TRANSCRIPTION_VERIFIER = {
    id: 'anl-step-code',
    name: 'Step transcription (business intent, not code)',
    enabledByDefault: false,
    contextScope: 'action',
    applies: (ctx) => ctx.actionBodies.size > 0,
    verify: (ctx) => {
        const findings = [];
        for (const [stubPath, body] of ctx.actionBodies) {
            const steps = body.steps ?? [];
            const offending = [];
            for (let i = 0; i < steps.length; i++) {
                const step = steps[i];
                if (isProgrammingStep(step)) {
                    offending.push({ index: i + 1, step, signals: programmingSignals(step) });
                }
            }
            if (offending.length === 0)
                continue;
            const stepNums = offending.map((o) => o.index).join(', ');
            const sigs = Array.from(new Set(offending.flatMap((o) => o.signals))).join(', ');
            findings.push({
                code: 'ANL-STEP-CODE',
                severity: 'warning',
                stubPath,
                message: `${offending.length} of ${steps.length} step(s) read as transcribed code (step(s) ${stepNums}; signals: ${sigs}).`,
                correction: `Step(s) ${stepNums} read as transcribed code (signals: ${sigs}). ` +
                    `Rewrite them as business intent a domain expert would say — describe WHAT the action accomplishes, ` +
                    `not HOW. No function calls, HTTP status codes, \`[kind]\` markers, or code variables/member-access; ` +
                    `the realize stack derives the implementation. Keep the other steps as-is.`,
            });
        }
        return findings;
    },
};
//# sourceMappingURL=step-transcription.js.map