feat(tools): emit patch advisor decisions as JSON #12769
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12769"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by StoneDC on 2026-10-29T08:40:08Z.
What
Add optional
suggest_patches.py --jsonwith final decision status, per-entry verification output/summary, targets, validated metadata and the recommended entry number. Preserve text output and verification policy. Reject non-finite input numbers before they enter reports, and serialize withallow_nan=False.Integrate current main now that #12340 and #12787 are merged. Keep both RecursionError handlers, path/symlink error handling, current metadata validation and the complete JSON/native integration regressions. Remove the obsolete open prerequisite from the checklist; the merged #12787 head remains an ancestor. Schema-version/conversion-option additions are outside this change.
Tested
Exact tested head:
fa07033d2427f9a69174d0864a5edbf39fbfebfc, including mainac94ac850371e12cde7048c3db59135e19a869c3.Windows 11 / MinGW GCC 15.2 / CMake 4.3.1 / Python 3.14.3 and 3.12.14; WSL Ubuntu 26.04 / GCC 15.2 / CMake 4.2.3 / Python 3.14.4 and 3.12.16. Real CMake/Ninja Release configurations use
ANYPS5_RELINKER_ONLY=ON,BUILD_TESTING=ONand each selected interpreter.ctest --test-dir BUILD -R '^(patch_advisor.*|validate_patch_catalog|test_script_registration)$' -V --output-on-failure --no-tests=error: all 6 registered groups pass in each of the four configurations; 62 unittest methods per configuration. Slowest selected group: 1.43 s. No CTest group is skipped.allow_nan=False, both RecursionError catches and main path validation are retained.No full system-library build, new ARM64 runtime, local macOS runtime, PS5/title run or GPU validation is claimed. Hosted results for the new head are reported separately after publication; earlier-head checks are not substituted.
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.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-29T11:25:44Z.
Review: COMMENTED
Checked on macOS arm64 at
a0e63ff042(merge-tree against mainba5b5330b3is clean; conventions andgit diff --checkpass).test_patch_advisor_json2/2 andtest_suggest_patchesOK on Homebrew Python 3.12, 3.13 and 3.15. Both new tests fail against main'ssuggest_patches.pybecause main has no--json, as expected.patch_advisor_json_integrationpasses in 0.20 s against a real macOS relinker, so the integration fixture also works on a third host.Test gap. I made 15 single-line mutants of the JSON reporting in
main(). Only 3 are caught by the unit test (list status, entrynumber, default record status), and the integration test addsexit_code. These 11 pass both tests:reasondropped (hash mismatch / validate_entry error / timeout), duplicate-id demotion leaving the recordverified, norecommended_entry,no_match→rejected, relinker-error status →rejected, top-levelerrordropped,verification.stdout/stderremptied,metadatadropped,patch→None.The test below pins every record kind with one 6-entry catalog (verified, stale hash, invalid metadata, two duplicate ids, timeout) and adds the three failure statuses. It kills all 15 mutants, passes on this head with 3.12, 3.13 and 3.15, and fails on main. Each run takes a few ms:
Non-blocking.
rejectedwith noreason. Readers have to parseverificationto tell these apart from the other rejections.reasonvalues are also mixed:verification_timeoutis a code, while every other reason is free text. Picking one style now would keep the JSON contract simple.--catalog) still exit 2 with no JSON on stdout. That is probably fine, but the help text could say so.exceptin the same block. Whichever lands second needs to addRecursionErrornext to the newfinish(2, "error", error).(AI-assisted review)
Imported from boykopovar/AnyPS5. Originally posted by WhiteAssassins on 2026-10-29T13:55:06Z.
Review: APPROVED
Reviewed head
ec81a3562b. The optional JSON path preserves text behavior and exit statuses, records per-entry verification decisions, and has unit and native relinker integration coverage. Hosted relinker checks pass. The schema-version and conversion-argument suggestion can be handled in a follow-up.Imported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-10-29T14:19:43Z.
Review: DISMISSED
Blocking JSON-validity edge on exact head
ec81a3562b.Python's json.loads accepts NaN/Infinity by default. A matching catalog entry whose raw
patchfield isNaNreaches the per-entry rejection path, but the report record capturesentry.get("patch")before validation;json.dumpsthen emits that raw float as the non-standard tokenNaN.Repro: use a catalog index entry with titleId
TEST00001, contentVersion01.000.000,patch: NaN, and a syntactically validtargetsobject; provide valid param/input/relinker files and run with--json. The tool exits 1 with stdout equivalent to:{"entries":[{"number":1,"patch":NaN,"reason":"invalid relative path: nan","status":"rejected"}],"status":"rejected"}Python's permissive parser accepts that output, but a strict JSON parser rejects
NaN, so a malformed catalog can make the machine-readable mode stop being JSON while the tool reports a handled rejection. I reproduced the same behavior on stacked #12911.Please reject non-finite constants on JSON input (for example via
parse_constantraisingValueError) or otherwise ensure only validated/JSON-safe values are reflected, and add a strict-output regression. The ordinary valid-JSON paths and text behavior otherwise look unaffected.Imported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-10-30T00:57:42Z.
Review: DISMISSED
Re-reviewed exact head
be1fa52be7. The strict-JSON blocker from my previous review is fixed: the focused JSON suite passes on Windows Python 3.12 and WSL Python 3.12.3, non-finite catalog/parameter numbers are rejected before verification, and allow_nan=False protects serialization. I found no remaining defect in that fix itself. The remaining blocker is integration order with the older approved #12340 through this PR's prerequisite #12787. Exact current-head merge checks: #12787 + #12769 is clean; #12340 + #12787 conflicts in tools/suggest_patches.py; #12340 + #12769 also conflicts in tools/suggest_patches.py. #12787's body already acknowledges the #12340 conflict, but there is no resolved landing order yet. Please coordinate and record the stack order before merge; the lowest-risk sequence is #12340 first, then rebase/resolve #12787 keeping both symlink-loop and RecursionError handling, then rebase #12769 onto that integrated result (and #12911 after it). Once the overlap is resolved/restacked, I can re-check the exact integrated head; the JSON-validity issue itself is resolved.Imported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-11-12T15:38:25Z.
Review: APPROVED
Re-reviewed exact head
fa07033d24after the prerequisite stack was resolved. #12340 and #12787 are both merged, current main is integrated, and this PR is now CLEAN with the prerequisite overlap removed from the diff while retaining the strict-number, RecursionError, and path/symlink handling. Local Windows Python 3.12 validation passed test_patch_advisor_json.py (6/6) and test_suggest_patches.py (40 tests, 4 existing filesystem skips); git diff --check is clean. Hosted checks have no failures. Approved.