feat(iit): harden QC pipeline consistency and release artifacts

Implement IIT quality workflow hardening across eQuery deduplication, guard metadata validation, timeline/readability improvements, and chat evidence fallbacks, then synchronize release and development documentation for deployment handoff.

Includes migration/scripts for open eQuery dedupe guards, orchestration/status semantics, report/tool readability fixes, and updated module status plus deployment checklist.

Made-with: Cursor
This commit is contained in:
2026-03-08 21:54:35 +08:00
parent ac724266c1
commit a666649fd4
57 changed files with 28637 additions and 316 deletions

View File

@@ -0,0 +1,48 @@
-- 1) 先收敛历史 open 重复,避免唯一索引创建失败
WITH ranked AS (
SELECT
id,
ROW_NUMBER() OVER (
PARTITION BY
project_id,
record_id,
COALESCE(event_id, ''),
COALESCE(category, '')
ORDER BY
CASE status
WHEN 'reviewing' THEN 4
WHEN 'responded' THEN 3
WHEN 'reopened' THEN 2
WHEN 'pending' THEN 1
ELSE 0
END DESC,
updated_at DESC NULLS LAST,
created_at DESC NULLS LAST,
id DESC
) AS rn
FROM iit_schema.equery
WHERE status IN ('pending', 'responded', 'reviewing', 'reopened')
)
UPDATE iit_schema.equery e
SET
status = 'auto_closed',
closed_at = COALESCE(e.closed_at, NOW()),
closed_by = COALESCE(e.closed_by, 'system_dedupe_migration'),
resolution = COALESCE(
NULLIF(e.resolution, ''),
'自动去重收敛:同一受试者/事件/规则已存在未关闭 eQuery'
),
updated_at = NOW()
FROM ranked r
WHERE e.id = r.id
AND r.rn > 1;
-- 2) 为 open 集合建立唯一去重键,防止未来重复写入
CREATE UNIQUE INDEX IF NOT EXISTS uq_iit_equery_open_dedupe_key
ON iit_schema.equery (
project_id,
record_id,
(COALESCE(event_id, '')),
(COALESCE(category, ''))
)
WHERE status IN ('pending', 'responded', 'reviewing', 'reopened');