Commit Graph

20 Commits

Author SHA1 Message Date
6265b337a8 save_keys: guard --out with same_report_path and refuse directories before resolving (SAVE-KEYS-OUT-GUARD) 2026-11-24 17:37:58 -05:00
bb72c1cc23 Merge pull request #4385 from SebSilent
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:14:15 -05:00
c2315d58b3 save_keys: check the walk guard on platforms where chmod cannot lock a folder
The regression test self-skips on Windows and as root, and CI runs this file
only on windows-latest, so the guard was never exercised in CI. Force
os.scandir to raise for one folder instead, in-process, which reproduces the
same PermissionError on every platform.

AI-assisted.
2026-11-22 23:55:42 -03:00
2bccd96bfb save_keys: fail on an unlistable sub-folder instead of silently skipping its saves 2026-11-22 22:10:20 -03:00
5948c690b8 tests: skip the hard-link cases where hard links are unavailable
Guard the remaining unguarded os.link() calls in test_awc_names.py, test_gamedata_graph.py, test_navmesh_decode.py, test_restofworld_index.py, test_rtti_scan.py, test_save_keys.py, test_swizzle_search.py, and test_tex_headers_report_paths.py with try/except (OSError, NotImplementedError) so only the hard-link subtest/check is skipped when hard links are unavailable and the rest of each test still runs.
2026-11-23 01:01:33 +01:00
6fde257c9e Merge pull request #2434 from Ayinaki 2026-11-22 13:15:17 -05:00
ca0f03bf58 save_keys: break --compose vocabulary ties by the word, not hash order
compose() built its Counter by iterating a set of harvested strings and then took most_common(N),
so words with equal counts were chosen in hash iteration order: twenty words counted once and
--compose 6 picked a different six per run, and a key only that vocabulary could compose resolved
in some runs and not others. Rank by (count, word) instead, and cover the order-independence, the
tie rule and five repeated CLI runs.
2026-11-22 17:02:36 +00:00
2bcaacf51b save_keys: a missing input or --dict file is one error line, not a traceback
`collect nope.jsav`, `resolve nope.jsav --dict d.txt` and `resolve save.json --dict nope.txt` ended in a
FileNotFoundError traceback. Both commands now print `error: <path>: <reason>` and return 1, as `resolve`
already does for an --out it cannot write.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016ABh36DZ2sZNq3ChN6EZJs
2026-11-22 19:00:21 +03:00
7ed1cf1e60 tests: reuse the save key resolve CLI fixture 2026-11-22 11:40:59 -03:00
7ee2879342 test: use a valid dictionary for compose validation 2026-11-22 11:25:14 -03:00
85f6c01bb7 save_keys: reject negative compose counts 2026-11-22 11:24:51 -03:00
b2d7c367b0 Merge pull request #1387 from undeadhuman37 2026-11-22 06:08:09 -05:00
de0366d619 save_keys: resolve refuses an --out that is one of its inputs
`resolve --out names.txt --dict names.txt` replaced the user's local
dictionary with the JSON report (exit 0, no warning); a save, a file found
in an input folder, or a hard link to either was replaced the same way.
An --out in a missing folder ended in a FileNotFoundError traceback after
the whole resolve (and --compose) had run.

resolve now checks --out before reading anything: it refuses a path that
is the same file (os.path.samefile) as any input file or --dict path, and
a missing folder, each as one error line with exit 1. A write that still
fails is reported the same way. input_files() lists the files iter_inputs
reads, so the check and the reader agree on folder inputs.

Tests: tests/test_save_keys.py 19/19 (2 new, synthetic names and saves);
the new cases fail on main (5 subtest failures). No game files, no GPU.

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:51:14 +03:00
82575ab46e save_keys: harvest a long identifier whole instead of cutting it after 81 characters
IDENT had its length bound inside the pattern ({1,80}), so a longer run of identifier characters was cut after 81
and the search went on in what was left: one 89-character name became an 81-character prefix and a tail that
nobody wrote, and the real name was never hashed against the save keys. The pattern now takes the whole run, and
a run past 255 characters (an encoded blob, not a name) is left out whole. hashdict.py already reads names this
way.

tests/test_save_keys.py: four tests, all fail on the old code. Synthetic inputs only.
2026-11-22 10:05:21 +00:00
1d649a8bde Merge pull request #872 from ray3242
# Conflicts:
#	tools/save_keys.py
2026-11-21 23:15:54 -05:00
145672a28d BUILD: name the offending file in save_keys JSAV warnings 2026-11-21 22:02:44 -06:00
e74d7f54c3 save_keys: directory scans read .jsav and .asav saves (#844)
iter_inputs only took .json, .bin and extensionless files from a folder, so collect and resolve silently skipped
the JSAV/ASAV saves they document as their input. Extensions now match case-insensitively.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 22:55:41 -05:00
28b3191eeb BUILD: include .jsav files in save_keys directory scans 2026-11-21 21:53:32 -06:00
3895b9d86b BUILD: skip a malformed JSAV table with a warning instead of a traceback 2026-11-21 20:49:52 -06:00
df696e4c3b saves: key hashes are case-sensitive joaat; add tools/save_keys.py
The $0x... keys in JSAV blocks and ASAV settings are the case-sensitive joaat
(seed 0, no lower-casing) of engine/script names, the same rule as the member
hashes in docs/world_names.md. Found from structure: the group keys hash names
derived from the clear-text JSON wrappers.

tools/save_keys.py collects the distinct keys from saves or extract folders and
resolves them against strings harvested from any local files (raw bytes and
zlib streams), reporting per hash family how many keys resolve and how many
are expected by chance; --compose N adds one/two-word names. On the sample set
278 of 1,059 keys resolve with joaat over the game's own data archives; every
other family stays at chance level. Only counts are documented; names stay local.

Synthetic tests only (tests/test_save_keys.py).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:21:17 +00:00