WITH latest_scores AS (
SELECT
s.*,
ROW_NUMBER() OVER (
PARTITION BY s.entity_type, s.entity_id
ORDER BY s.created_at DESC, s.id DESC
) AS rn
FROM artifact_signals s
WHERE s.kind = 'falsification_score'
AND s.dimension = 'strength'
)
SELECT (a.artifact_type || ':' || a.id::text) AS ref, a.title
FROM artifacts a
JOIN latest_scores fs
ON fs.entity_type = a.artifact_type
AND fs.entity_id = a.id::text
AND fs.rn = 1
WHERE a.epistemic_tier IN ('T3', 'T4', 'T5')
AND a.is_latest = 1
AND fs.value >= 0.7
AND fs.created_at < NOW() - INTERVAL '7 days'
AND NOT EXISTS (
SELECT 1
FROM artifact_signals rebuttal_target
WHERE rebuttal_target.entity_type = a.artifact_type
AND rebuttal_target.entity_id = a.id::text
AND rebuttal_target.kind = 'falsification_rebutted'
)
AND NOT EXISTS (
SELECT 1
FROM artifact_signals rebuttal_attempt
WHERE rebuttal_attempt.entity_type = 'falsification_attempt'
AND rebuttal_attempt.entity_id = fs.metadata->>'attempt_id'
AND rebuttal_attempt.kind = 'falsification_rebutted'
)