Repository navigation
hashdict: a string longer than 201 characters is not cut into fragments - #1121
Conversation
The harvest pattern ended a match after 201 characters and the next match started in the middle of the same run, so a truncated prefix and a fragment were added as names and the path component across the cut was lost. The whole run is matched now and split into its parts as before; a run or a part longer than 201 characters is not added as a name, which keeps the longest entry the dictionary could ever hold. Parts are found one at a time, so a very long run does not build a list of all of them. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Tested 9f95b08 on Linux (WSL2 Ubuntu), Python 3.12, CPU only: pass
|
|
The red |
lucastayaralvarenga-ui
left a comment
There was a problem hiding this comment.
Reviewed at 9f95b08. Windows / CPython 3.14: all 25 hashdict tests passed. The boundary regression preserves the path component crossing the old 201-byte cut, and the existing delimiter and minimum-length cases still pass. Long runs are matched as a whole before the per-name length cap is applied.
AI-assisted review. No game data.
Claimed in the coordination issue as: #1006 (comment) (new BUILD item)
What and why
tools/hashdict.pyharvests names with[A-Za-z_][A-Za-z0-9_./:\-]{2,200}. A run longer than 201 characters ends the match there, and the next match starts in the middle of the same run. Soharvestadded a truncated 201-character prefix and a fragment as if they were names, and the path component across the cut was never added.Example (synthetic): a 230-character
platform:/levels/.../props_lev_des_building_name.ytd. Before,props_lev_des_building_namewas missing andops_lev_des_building_name,ops_lev_des_building_name.ytdand a prefix ending in/prwere in the dictionary. The dictionary keeps the alphabetically first name on a hash collision, so such fragments can also displace a real name.Now the whole run is matched and split into its parts as before. A run, or a part, longer than 201 characters (
MAX_NAME_LEN) is not added as a name; the old pattern could never produce a longer entry, so the dictionary's ceiling is the same. A long path contributes all its components; a long token with no separator contributes nothing. The parts are found one at a time, so a run of megabytes does not build a list of all of them.For input with no run over 201 characters the harvested set is identical to before.
Tested
CPU only, synthetic data, no game files, no GPU. Windows 11, Python 3.14; also Python 3.11 and Linux (WSL, Python 3.10).
python -I tests/test_hashdict.py: 25 tests pass (3 new: the 230-character path, a separator-free token over the cap, a run of exactly the cap).main's pattern the first two fail: the path test with'props_lev_des_building_name' not found, the token test because fragments are added. The third passes on both; it pins the boundary.harveston random blobs with no run over 201 characters (noise, embedded names of 199, 200 and 201 characters,--minfrom -1 to 8): identical sets over 1,200 harvests; a second, independent run of 30,000 inputs also matched.abc/abc/...peaks at 21 MB undertracemalloc, which is the run itself.python -m compileall -q make_game.py tools testsis clean. Not run on a real carve folder.AI-assisted (Claude Code).
Checklist
docs/design.md, with how it was confirmed. (not a translator change)🤖 Generated with Claude Code