fix: preserve repeated quoted CSV headers without a final newline

AF
10h ago
+63-3

Summary

The repeated-header restoration added in #4709 misses a complete quoted header when the file has no final newline. For example, a file containing only "name","name" produces name name.1 even though the second label is name.

At the end of a complete peeked line, treat a pending quote as the closing quote of its field. A line without a terminator reaches this check only at EOF: the bounded header peek returns an empty string if its budget is exhausted, rather than returning a truncated prefix. Unclosed quoted fields and multi-line header handling retain their existing guards.

The shared reader fixes CSV and TSV, including escaped quotes within duplicate labels. No read budget, delimiter, field-size limit or data-row behavior changes.

Validation

  • The 27 new cases produce 18 failures and 9 passing controls on the original source.
  • Exercises filename and byte-stream inputs, comma/semicolon/tab separators, duplicate labels, genuine suffixed labels and escaped quotes. Controls cover LF/CRLF endings and incomplete quoted records.
  • 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.
  • The existing CSV suite includes bounded and prefilled header-peek tests, multi-line header controls and the exhaustive single-line splitter comparison with Python's CSV reader.
  • 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.