-- The prose-quality audit pass: a QC gate that reads a finished
-- story end to end and flags repetition, template tics, self-
-- restatement and continuity drift before it goes to narration.
-- Repetition a silent reader skims is glaring once narrated aloud.

-- Allow 'prose_audit' as a generation_runs.kind.
ALTER TABLE generation_runs DROP CONSTRAINT generation_runs_kind_check;
ALTER TABLE generation_runs ADD CONSTRAINT generation_runs_kind_check
    CHECK (kind = ANY (ARRAY[
        'gen', 'cleanup', 'audit', 'summary', 'embed',
        'narrate_prep', 'rewrite', 'prose_audit'
    ]));

-- 'repetition' is a first-class audit finding area.
ALTER TABLE audit_findings DROP CONSTRAINT audit_findings_area_check;
ALTER TABLE audit_findings ADD CONSTRAINT audit_findings_area_check
    CHECK (area = ANY (ARRAY[
        'character', 'continuity', 'tone', 'fact',
        'timeline', 'repetition', 'other'
    ]));
