/**
 * ANL-REQUIRE-EXISTENCE — flag `requires:` entries that merely restate what the
 * action signature or CURVED semantics already guarantee (parameter-presence,
 * entity-existence, connection-init) rather than a genuine business
 * precondition. The opus/marrbox over-restatement signature on large specs
 * (opus idle-meta: 94 requires vs sonnet's 14, dominated by "A user id is
 * provided", "MongoDB connection has been initialized", "Referenced Game
 * exists"): prompt-resistant under the #92 additive-only prompt → wants the
 * deterministic verifier. The analog of ANL-EVENT-NONDOMAIN, for `requires`.
 *
 * Treatment is auto-reemit (LLM judgment), NOT a deterministic delete: a
 * borderline precondition might encode a real constraint, so we ask the model
 * to drop the restatement rather than silently removing spec content. The
 * detector is conservative — substantive guards (format/value validity,
 * environment capability, lifecycle state) are not matched (see detectors.ts).
 */
import { isExistenceRestatingRequire, requireRestatementSignals } from '../detectors.js';
export const REQUIRE_EXISTENCE_VERIFIER = {
    id: 'anl-require-existence',
    name: 'Require discipline (additive precondition, not signature/CURVED restatement)',
    enabledByDefault: false,
    contextScope: 'action',
    applies: (ctx) => ctx.actionBodies.size > 0,
    verify: (ctx) => {
        const findings = [];
        for (const [stubPath, body] of ctx.actionBodies) {
            const requires = body.requires ?? [];
            const offending = requires.filter((r) => isExistenceRestatingRequire(r));
            if (offending.length === 0)
                continue;
            const signals = Array.from(new Set(offending.flatMap((r) => requireRestatementSignals(r)))).join(', ');
            const list = offending.map((r) => `"${r}"`).join('; ');
            findings.push({
                code: 'ANL-REQUIRE-EXISTENCE',
                severity: 'warning',
                stubPath,
                message: `${offending.length} require(s) restate signature/CURVED-implicit guarantees (${signals}): ${list}.`,
                correction: `These \`requires\` entries merely restate what the action signature or CURVED semantics already ` +
                    `guarantee — parameter-presence ("X is provided"), entity-existence ("X exists"), or infrastructure ` +
                    `init ("connection initialized"): ${list}. Remove them. Keep only genuine business preconditions a ` +
                    `caller could violate that aren't implied by the inputs or operation kind (e.g. a required lifecycle ` +
                    `state, a value/format constraint, or a cross-entity invariant). If nothing qualifies, omit \`requires\`.`,
            });
        }
        return findings;
    },
};
//# sourceMappingURL=require-existence.js.map