fix: reject lossy metadata column collisions in Prodigy CSV export

AF
9h ago
+84-3

Summary

Prodigy CSV export lowercases metadata keys after validation. This creates collisions that the existing case-sensitive id check does not catch:

  • ID becomes a second id column, and the metadata value is replaced with the element ID.
  • Text collides with the element text and raises an incidental TypeError.
  • Tag and tag in one record collapse to one field, silently discarding a value.

Validate each record's normalized CSV column names before constructing its row. Raise a descriptive ValueError with the metadata index for reserved names, and reject two keys that normalize to the same name. Matching column names in different records remain valid. The JSON export path remains case-sensitive.

Validation

  • The 12 new cases produce 9 failures and 3 passing controls on the original source.
  • Covers reserved names in several cases, duplicate normalized keys in either order, unchanged input metadata, shared column names across records, JSON metadata and metadata-free CSV export.
  • A combined fork validation branch runs both changes' regressions against the pinned original source: 27 failures, 12 passing controls. With the final source restored, the regressions plus the existing Prodigy, CSV and TSV suites report 192 passed on Python 3.12.
  • Repository-configured Ruff check, format check and source-integrity checks pass.
  • Validation run, exact commands and JUnit artifacts.

Checklist

  • User-facing conventional-commit title.
  • Maintainer: please apply the bug category label.