patch manifests: hash-gated memory and data patches for source-translated builds #3037
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#3037
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@JohnConnorNPC on GitHub · 2026-11-27 09:30 UTC · original
Refs discussion #3026. Target branch
main(cpp-migrationhas been merged into it).Goal
Add a declarative patch manifest so input-specific adjustments can be applied to a source-translated build without modifying the original binary or data on disk, and without putting any input content in the repository.
Scope of this issue (main only)
id,kind,whyandremove_when. Fixture: a synthetic PE, with a negative control for a wrong input hash.memorypatches (runtime). After image load, write replacement bytes at an RVA only if the original bytes matchexpect_sha256(verified, never stored). Negative control: wrong bytes fail loudly.datapatches (file layer). Serve a replacement file or byte range for a path, leaving the original untouched. Needs the file-API shim to be the single read path; the first step is checking what exists insrc/.Out of scope here
hook, function replace/skip/return-constant/branch-force) as a separate PR. The base-branch question is settled:cpp-migrationwas merged intomain(#3039), so everything here targetsmain. The manifest should be consumed by the existing translators rather than a parallel tool: the CPU converter (exe_aot) and, for GPU programs, the shader-cache translation override. One manifest and one planner, several consumers.game-files/patches/, which is gitignored.Acceptance
docs/experiments.mdgain the manifest format and the reproduction command.This issue was AI-assisted.
@Not-Saii on GitHub · 2026-11-27 12:31 UTC · original
Claiming item 1 (schema, loader and hash gate). Items 2-4 stay open; I can follow with item 2 once this lands.
Environment: Windows 11 build 26300, Python 3.14 (CI: Python 3.12 on Linux). Pure Python, no GPU or game files needed.
Part I will test:
tools/patch_manifest.py, a TOML manifest read with the standard library'stomllib.[target] input_sha256plus[[patch]]entries, each withid,kind,whyandremove_when. The whole manifest is validated and the input's SHA-256 compared before anything is returned, so nothing applies partially. Unknown or missing keys are refused at every level. Onlykind = "memory"is defined (rva,expect_sha256,bytes), checked for shape only, with no applier.hookanddataare refused as not supported until their stages define them. The loader returnsmanifest_sha256and the patch ids for item 4.Fixture:
tests/patch_manifest_check.pywith a synthetic PE32+ built at run time frombuild_pe32_plusintests/call_evidence_check.py. Negative controls: a wrong-input hash through the CLI (exit 1), plus misspelled keys, unsupported kind, duplicate id, overlapping patches and malformed values. Registered intests/checks/python-linux/andtests/cmake/; note indocs/experiments/patch-manifests.md.Shared interface: the manifest format. Stages 2-4 and the
exe_aotand shader-cache consumers would build on it, so please flag any objection to TOML or to the strict-key rule now. PR will targetmain.@JohnConnorNPC on GitHub · 2026-11-27 14:06 UTC · original
@Not-Saii Thanks for #3056. I had a schema, loader and hash gate built to nearly the same design (TOML, same keys, same SHA-256 gate) and had not posted it before yours merged, so I'm dropping mine and building on yours. I also have the next stages built and reviewed locally on my own loader copy and will rebase them onto yours: the memory applier in the debugger launcher (item 2), a consumer in the CPU converter (
exe_aot --patches, translating a patched copy) and a per-key shader-cache override. So to avoid overlap I'm taking item 2 and will open it one PR at a time. First a small PR totools/patch_manifest.py: a refusal for deeply nested input (the CLI currently ends in a RecursionError traceback), akind = "shader"shape, and a gate on bytes the caller already read. Item 3 (datapatches, the file layer) is not started; please take it if you'd like it.This comment was AI-assisted.