Repository navigation
feat(tools): validate complete patch catalogs offline - #12263
Conversation
|
A Windows run, since the description lists none. Head
AI-assisted: yes (Claude Code). |
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
MarcZX10
left a comment
There was a problem hiding this comment.
The validator reuses the advisor’s catalog and entry validation, then checks every entry independent of local title files, verifies patch format/target coverage, confines paths, and reports duplicate IDs only when entries could match the same title/version. The tests cover malformed entries, escaping and Windows-drive target paths, duplicate IDs, mutually exclusive hashes, and valid empty catalogs. I checked the PR head’s validate_entry return shape and metadata validation; the validator uses them consistently. The reported Python 3.14 tests and current cross-platform relinker/ASan, Windows, conventions and eligibility checks pass. No blocking issue found.
|
Thanks for the thorough review, Marc. I appreciate you checking the current head, the duplicate-ID behavior, and the cross-platform checks. |
THEMANnt
left a comment
There was a problem hiding this comment.
Reviewed 1d7bdd81caac641370b5404feb45c26362e30359 — request changes.
[P2] Report decoder-depth failures as invalid catalogs — tools/validate_patch_catalog.py:52–55. The new command documents exit 2 for invalid catalogs, but a valid JSON index whose entries contains 2,500 nested arrays escapes as RecursionError, prints a traceback and exits 1. The same CLI returns the intended exit 2 for entries: [null] and exit 0 for an empty catalog. A generated or malformed deep index therefore bypasses the validator's controlled failure contract. Catch the decoder-depth failure at the catalog boundary and add a real CLI regression that checks exit 2, no traceback and input preservation.
Windows/Python 3.11: all 11 supplied validator tests passed; the existing advisor suite passed 33 cases with 2 symlink-privilege skips (35 total). The independent probe uses the exact submitted CLI and preserves each input. This is a new command, so missing old helper APIs are not behavioral regression proof. No game files or relinker-applicability claim is involved.
|
Reviewed Reproduction (macOS arm64, head file run directly):
On this host, 2,500 levels decodes on every version (each entry is reported as invalid). 200,000 levels escapes on all four. The script's floor is 3.11 ( Suggested fix (source): Tests (two added to def test_deeply_nested_index_is_reported_as_invalid(self):
depth = 200000
(self.catalog / "index.json").write_text('{"format": 1, "entries": ' + "[" * depth + "]" * depth + "}")
output, errors = io.StringIO(), io.StringIO()
with contextlib.redirect_stdout(output), contextlib.redirect_stderr(errors):
result = validate_patch_catalog.main(["--catalog", str(self.catalog)])
self.assertEqual(result, 2)
self.assertIn("Catalog validation: index.json is nested too deeply", errors.getvalue())
def test_catalog_symlink_loop_is_reported_as_invalid(self):
loop = self.root / "loop"
loop.symlink_to(loop)
output, errors = io.StringIO(), io.StringIO()
with contextlib.redirect_stdout(output), contextlib.redirect_stderr(errors):
result = validate_patch_catalog.main(["--catalog", str(loop)])
self.assertEqual(result, 2)
self.assertIn("Catalog validation:", errors.getvalue())Verified:
The 200,000 depth is deliberate: 20,000 decodes fine on 3.14+, so a smaller fixture would not test the new arm there. AI-assisted: yes (Claude Code). |
|
@THEMANnt Thanks for the P2 report. Fixed on the current head, I also handled looping On this head, the validator and advisor suites pass all 50 tests on Python 3.11 and 3.14. The synthetic real-relinker integration, conventions, test registration, and diff check also pass. Please re-review when convenient. |
THEMANnt
left a comment
There was a problem hiding this comment.
Re-reviewed c6c35d1a538929fdbcf11b428daa979af3dee1f7 — approve. My decoder-depth change request is addressed: deeply nested index JSON and patch TOML now exit 2 without a traceback. Duplicate JSON keys and looping catalog paths are also rejected without modifying the input files. The default advisor path remains compatible.
Windows/Python 3.11: the validator/advisor suites run 50 tests, with 47 passed and 3 symlink-privilege skips; the baseline advisor runs 35, with 33 passed and 2 skips. Independent CLI controls cover the original 2,500-level index, a 200,000-array index, nested patch TOML, duplicate top-level and entry keys, and an actual Windows junction loop, plus valid controls. All fixed-head invalid cases return 2 without a traceback and preserve every fixture file. The previously reviewed head still crashes on the depth/loop cases and silently accepts the duplicate-key controls.
A fresh Windows/GCC 15.3 Release relinker build passes the synthetic real-relinker advisor integration, and the registered validator CTest passes (14 passed, 1 symlink skip internally). Conventions, script registration and whitespace checks pass. The current Windows/Ubuntu relinker and ASan CI jobs pass; the macOS matrix remains pending. This approval closes the reviewed code defect; no console/title or game-file validation is claimed.
What
Add
tools/validate_patch_catalog.py --catalog DIRto check every format-1 catalog entry offline before sharing it or running a catalog CI job. It reuses the advisor's index and entry validation, checks relative target paths, duplicate JSON keys and patch-file format, and reports all invalid entries with their catalog numbers. It also rejects duplicate IDs that could match one title build while allowing the same ID for mutually exclusive target hashes or another content version.The command needs no game files or relinker and does not download or apply patches. It performs structural checks; the relinker's stricter TOML parser and
--verify-patchesremain necessary to establish applicability. The advisor's recommendation behavior is unchanged. This follows #8900, #10719 and #11489 and supports the external catalog proposal in #8893.Malformed deeply nested
index.jsondata, deeply nested patch TOML, and a looping--catalogsymlink are reported as catalog errors with exit code2, without a traceback.Tested
python3 -m unittest tools.tests.test_validate_patch_catalog tools.tests.test_suggest_patchesand the same command with/usr/bin/python3.11(50 passed on each version). The CLI regressions check exit code2, no traceback, and preserved input for deeply nested JSON/TOML, looping catalog paths, and duplicate JSON keys.python3 core/relinker/relinker/tests/test_patch_advisor.py <relinker>passed with the real relinker.python3 tools/check_conventions.py --base origin/main,python3 tools/check_test_registration.py --scripts, andgit diff --check origin/main...HEADpassed.python3 tools/validate_patch_catalog.py --helppassed. No game files were used.tomllibrequirement. Python 3.9/3.10 was not available for a local CMake run.python3 tools/pr_overlap.py --branch feat/patch-catalog-validatorcompleted. I reviewed the sharedCMakeLists.txtandUSAGE.mdhunks it could not compare automatically; they concern other features.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file (n/a: Python tool only).mdfiles or images added to the repository (attach them to this PR)