4. CQ-002 Compliance Patch

Purpose: Detect and fix challenges missing "you/your" engagement language as required by CQ-002 content rule.

Prerequisites:

  • Supabase credentials
  • AI model API key (for patching non-compliant challenges)

Cost / Duration: Detection is free (regex) | AI patch costs ~$0.003/challenge

Prompt

Detect and fix CQ-002 violations (challenges missing "you/your" language).

Step 1 — Detection query (find non-compliant challenges):

```sql
SELECT f.id, f.title, c.challenge_style, c.challenge_text
FROM fact_records f
JOIN fact_challenge_content c ON c.fact_record_id = f.id
WHERE f.status = 'validated'
  AND c.challenge_text IS NOT NULL
  AND c.challenge_text !~ '\\b(you|your|you''re|you''ve|you''d|yourself)\\b'
LIMIT 100;
```

Step 2 — Report the count and sample of violations.

Step 3 — For each violation, use the challenge content generation pipeline
to regenerate the challenge text with proper CQ-002 compliance.

The `CQ002_REGEX` from `packages/ai/src/challenge-content-rules.ts` defines
the exact pattern. After patching, verify every challenge passes:

```ts
import { CQ002_REGEX } from './packages/ai/src/challenge-content-rules'
// CQ002_REGEX.test(challengeText) must return true
```

Step 4 — Re-run the detection query to confirm zero remaining violations.

Verification

  • Detection query returns violation count
  • All violations patched with regenerated challenge text
  • Every patched challenge passes CQ002_REGEX.test()
  • Re-run detection query returns 0 violations
  • Patched challenges maintain factual accuracy and correct style

Back to index