Repository navigation
build(deps): pin NLTK 3.10.4 for the nltk tokenizer - #625
gloryfromca wants to merge 2 commits into
Conversation
NLTK 3.9.4's PorterStemmer.stem() can be driven into a slow path by a
crafted word (PYSEC-2026-3738, fixed in 3.10.3), and the nltk tokenizer
stems every token of ingested text. The extra and the dev group now pin
3.10.4.
The pin was exact because tokens change across NLTK releases. Measured
on 83,484 LoCoMo and LongMemEval texts, the two releases differ only on
a word right after an opening quote ('cause), which 3.9.4 dropped (449
texts); turn-level BM25 over the 1,977 LoCoMo questions with evidence
is unchanged. A new test pins that case. Stores indexed with the nltk
tokenizer should run everos cascade rebuild.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gloryfromca
left a comment
There was a problem hiding this comment.
Blocking: update the NLTK-data setup for 3.10.4's private-directory requirement.
One introduced compatibility regression is marked inline.
Validation performed:
uv lock --checkpassed, and the lock installed NLTK 3.10.4 with its newdefusedxmldependency.- With an owner-private corpus directory, the focused tokenizer suite passed (14/14) and the full unit suite passed (4,185 passed, 4 skipped).
- With the repository's existing
.venv/nltk_datasetup in this mode-775 worktree, 3.10.4 refused the corpus and 11 focused tests failed; 3.9.4 reads the same corpus. - Ruff check/format, all 14 import contracts, asset/file-size/name/contributor-doc/datetime/singleton/OpenAPI/CJK gates passed when invoked directly (
makeis unavailable in this environment).
I covered CLAUDE.md and the applicable .claude/rules, the refreshed origin/main...HEAD diff, tokenizer factory/callers and dependency history, backward compatibility, test changes (none were weakened), and architecture/import constraints.
On POSIX, NLTK 3.10 skips data another account could write (a group or world write bit, or a foreign owner), so such data reads as missing and the tokenizer asked for a download that changes nothing. A data directory left group-writable by an earlier install (umask 002) keeps its mode when the downloader runs again. The error now names the directory and the chmod that fixes it, install-deps makes .venv/nltk_data private after downloading, and the docs and the upgrade note say why. Windows is unaffected: NLTK checks ownership on POSIX only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gloryfromca
left a comment
There was a problem hiding this comment.
No blockers; this can merge as far as I am concerned.
The prior NLTK-data permission blocker is fixed and its thread is resolved. Validation on this revision:
- reproduced the old failure with a group-writable corpus (11 tokenizer failures), then verified the new
chmod -R go-wremediation (26/26 tokenizer tests passed); - verified the normal-process
CapabilityErrornames the refused directory and remediation; uv lock --check, diff whitespace, Ruff check/format, all 14 import contracts, documentation, asset/file-size/name/contributor-doc/datetime/singleton/OpenAPI/CJK gates passed. (makeis unavailable in this environment, so its constituent gates were invoked directly.)
I covered the full refreshed diff and fix delta, applicable repository rules, tokenizer callers and dependency history, backward compatibility, test integrity, and architecture/import constraints. No tests were weakened. GitHub lint, links, package, title, and commit-message checks are also green; longer unit/integration jobs are still running.
Summary
The
[nltk]extra and the dev group pinned NLTK 3.9.4. In that release,PorterStemmer.stem()can be driven into a slow path by a crafted word (PYSEC-2026-3738, fixed in 3.10.3), and thenltktokenizer stems every token of ingested text. Both pins are now 3.10.4.The pin is exact because tokens change across NLTK releases, and stored tokens must match query tokens. Measured on real text, the only difference between the two releases is a word right after an opening quote (
'cause): 3.9.4 dropped it, 3.10.4 keeps it. Keyword retrieval quality does not change:40 of the 1,977 questions change rank: 31 move up slightly and 9 move down slightly.
uv.lock: onlynltkchanges.'causeis kept.Securityentry, plus anUpgradenote that a store indexed with[tokenizer] name = "nltk"should runeveros cascade rebuild. The defaultjiebatokenizer is unaffected.Area
Verification
Checklist
main..envfiles, dependency folders, or generated output.Notes for Reviewers
nltktokenizer can now differ slightly from the harness's, through those quote-prefixed words.By submitting this pull request, I agree that my contribution is licensed under
the Apache License 2.0.
🤖 Generated with Claude Code