You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix 10 code review findings from Rust/PyO3 core review
Correctness fixes:
- token.rs: implement distinct truncate_smart strategy (2:1 head/tail
weighting) — was identical to middle strategy
- chunk.rs: always flush on max_tokens overflow; remove min_tokens guard
that silently allowed chunks to exceed the hard cap
- chunk.rs: fix find_table_end CRLF handling — advance by actual
terminator byte count (2 for CRLF, 1 for LF) instead of always +1
- encoding.rs: detect UTF-8 BOM before chardetng so decode uses
utf-8-sig (strips BOM) rather than utf-8 (preserves it)
- normalize.rs: seed strip_headers_footers candidates from all pages,
not just page 0, so cover-page documents strip running headers
Fallback path fixes (_fallback.py):
- detect_encoding: try cp1252 before latin-1 so Windows smart-quote
bytes (0x80-0x9F) decode to printable chars, not C1 control chars
- chunk(): oversized paragraphs now set metadata={oversized: True}
to match the Rust interface contract
- chunk(): use re.split capturing group to track actual separator
lengths; fixes char_start/char_end drift after 3+-newline gaps
- count/truncate/chunk._count: pass allowed_special=all to tiktoken
encode() to match Rust encode_with_special_tokens behaviour
core.py:
- _decode_bytes chain updated to (utf-8, cp1252, latin-1) so text/CSV
files correctly handle Windows-encoded content
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
0 commit comments