Skip to content

tooling: extend the patch manifest loader (nesting refusal, shader kind, load_data) - #3119

Merged
pigalot merged 15 commits into
R0Y00:mainfrom
JohnConnorNPC:patches/loader-extend
Nov 28, 2026
Merged

pigalot merged 15 commits into
R0Y00:mainfrom
JohnConnorNPC:patches/loader-extend

Conversation

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Refs #3037 (follows #3056; no applier yet).

What changes

tools/patch_manifest.py keeps its format, its strictness (lowercase hex, integer rva, parse-time span and overlap checks) and its CLI (patch manifest: <reason>, exit status 1). It gains three behaviors:

  • Deep nesting: tomllib recurses once per nested array or inline table, so a manifest nested past the recursion limit raised RecursionError, and the CLI printed a traceback. It is now refused as manifest is nested too deeply to parse.
  • kind = "shader": the translation files of one shader cache key, for the shader-cache translation override named in patch manifests: hash-gated memory and data patches for source-translated builds #3037. It is checked for shape only.
    • key is 16 lowercase hex digits and pipeline is graphics, compute or mesh86.
    • revision must have the form of that pipeline's key revision: x2w-startup-shader-<n>, x2w-startup-shader-<n>cs or x2w-startup-mesh-86-<n>. The loader does not check that <n> is the runtime's current number, because the runtime bumps it often; a later consumer that serves the files must compare it with the runtime (none exists yet).
    • files is a non-empty array of { ext, file, sha256 } tables using the pipeline's extensions, each listed once, with the required ones present. file is a bare file name, for a later consumer to resolve in the manifest's directory.
    • A key may have only one patch, and shader patches take no part in the memory overlap check. Other kinds are still refused as not supported.
  • load_data(manifest, data): load for a caller that has already read the input. It hashes data, so the bytes that pass the gate are the bytes the caller then patches or translates, even if the file changes in between. load is unchanged and shares the target comparison.

docs/experiments/patch-manifests.md gains the shader format, its pipeline table, the new cases and the mutations.

Fixture

tests/patch_manifest_check.py keeps its three tests and adds five, all on the same synthetic PE32+ (build_pe32_plus). Registration is unchanged (tests/checks/python-linux/patch_manifest.txt, CTest patch_manifest_controls).

  • Deep nesting: with the recursion limit set to 1000 inside the test, a 2000-deep array is refused by parse and through the CLI (status 1, empty stdout, no traceback). Shape control: a 50-deep array gets past tomllib and is refused only for its unknown key.
  • Shader patches: one per pipeline loads beside a memory patch, and the CLI lists every id. There are 28 refusals, one per rule. They include another pipeline's revision, a revision without its number or with a leading zero, and six file values that are not bare names.
  • Pinned to the runtime:
    • Each pipeline's extensions are the ones its loader in the runtime reads for a key (cache_path(..., L"", key, ext) and mesh86's load_stage). mesh86's .ps.cso is the only optional one.
    • The runtime's current revision of each pipeline fits the loader's form. The fixture uses revisions that are not the current ones, so a routine bump keeps the check green.
  • load_data: the image's bytes give the same result as load, and the flipped image is refused. After the input file is replaced by the flipped image, load_data on the original bytes still loads and load on the file is refused.

Mutations, each run once on the final tree with the file restored by hash:

Change Result
RecursionError no longer caught test_deep_nesting_is_refused errors
Revision form check removed test_shader_patches (5 failures)
Required-file check removed test_shader_patches (2 failures)
Same-key check removed test_shader_patches (1 failure)
Bare-name check on file removed test_shader_patches (6 failures)
d3d12_draw.inl reads .vx.cso instead of .vs.cso test_shader_files_match_the_runtime fails
The runtime's graphics revision gets a suffix (-29b) test_shader_revision_forms_match_the_runtime fails
The runtime's graphics revision is bumped (-29 to -30) Control: green
load_data compares the target with itself test_load_data_gates_the_bytes_given fails

Tested

Commit 13269fb5 on main ca659396, Linux (Debian 13), Python 3.13.5, pefile 2024.8.26:

python -B tests/patch_manifest_check.py      # Ran 8 tests ... OK
python -B tools/run_checks_parallel.py -j 1 --from-dir tests/checks/python-linux <the python-linux job's list>
                                             # all 235 checks passed
python -B tests/docs_links_check.py          # Checked 79 Markdown files and 586 links.
python -B tests/bidi_controls_check.py       # no bidirectional controls

Not run on Windows; the CTest registration is unchanged and was not exercised.

This PR was AI-assisted.

@thepatrickworld

Copy link
Copy Markdown
Contributor

Independent audit of the fixture's coverage on 13269fb5: 16 of 24 mutations killed, eight survive, and the memory kind's multi-patch geometry is not pinned

Not a code change; measurements only.

Environment

  • Ubuntu 26.04.1 LTS, Linux 7.0.0-38-generic x86_64, Python 3.11.16, pefile 2024.8.26 on PYTHONPATH.
  • Worktree at 13269fb5, git status --porcelain --untracked-files=no empty. Diff against origin/main (63a30dc1): 3 files, +290/−5.
  • sha256: tools/patch_manifest.py ec0c1fb0dad12cdb5a845457c830208a01ee2cb84fb06dd0ba159743e907db35, tests/patch_manifest_check.py 17ccc58ca44c9fb39027a5727f6c6ba3f8eacc4033422bea7754fbc0a90a9565, docs/experiments/patch-manifests.md f269c786524f3e1427333c665904a1091b05a5b73f5f99767ec34c55db6d8ad3.
  • Baseline: Ran 8 tests in 0.321s … OK, rc=0. No Windows, no GPU needed: the fixture is pure Python.
  • One datum for the doc's last paragraph: the eight tests also pass on Python 3.11.16, so the deep-nesting case holds on an interpreter older than the 3.12 of the CI job and the 3.13.5 recorded there.

Commands

cd <worktree at 13269fb5>
PYTHONPATH=<dir with pefile> python3 -B tests/patch_manifest_check.py     # baseline, and after each restore

Each mutation below is applied alone, as a single str.replace whose count(old) is asserted to be 1 first, then the fixture is run, then git checkout -- tools/patch_manifest.py. The file's sha256 is printed before the matrix and after every restore, and is ec0c1fb0… in all 24 cases, so no mutant leaks into the next run.

Observed — 24 mutations, 16 killed

Mutation Result First failure
if not isinstance(entry["bytes"], str) or not HEX.fullmatch(entry["bytes"]): → if False: (positive control) killed bytes must be
except RecursionError: → except ZeroDivisionError: killed ERROR test_deep_nesting_is_refused
"[1-9][0-9]*" → "[0-9]+" (<n> accepts a leading zero) killed revision 'x2w-startup-shader-012cs'
REVISIONS[pipeline].fullmatch(revision) → .match(revision) killed s002 revision 'x2w-startup-shader-12cs' is not a graphics key revision
KEY.fullmatch(key) → KEY.match(key) survived —
SHA256.fullmatch(value) → SHA256.match(value) survived —
for c in "/\\:" → for c in "/\\" (drive letter allowed) killed file 'C:s001.txt' must be a bare file name
or name in (".", "..") → or False killed file '..' must be a bare file name (+1)
duplicate-key block → if False: killed patches s001 and s002 override the same key
if ext in files: → if False: killed s001 lists .txt twice
if missing := [...] → if False: killed compute override is missing: .cs.cso (+1)
or not entry["files"] removed killed files must be a non-empty array
if start < end: → if start <= end: survived —
not 0 <= rva < 1 << 32 → not 0 < rva < 1 << 32 survived —
type(rva) is not int → not isinstance(rva, int) killed rva must be
if not value.strip(): → if not value: killed remove_when must be a non-empty
mesh86 required tuple gains .ps.cso killed test_shader_files_match_the_runtime
hashlib.sha256(data).hexdigest() → hash of the manifest's file name killed ERROR test_load_data_gates_the_bytes_given
"files": list(files.values()) → [::-1] killed test_shader_patches
shader patches.append(patch) + continue → continue removed killed ERROR KeyError: 'rva'
except (ValueError, OSError) → except ValueError survived —
spans.sort() → pass survived —
HEX = re.compile(r"(?:[0-9a-f]{2})+") → * survived —
memory patch "why": _text(...) removed survived —

The mutation table in docs/experiments/patch-manifests.md is accurate for every row I re-ran in another form: RecursionError no longer caught, revision form check, bare-name check, required-file check and same-key check all killed the mutant here too. It covers "Overlap check removed" but not the neighbouring off-by-one, while it does cover "Span check off by one (>=)" for the RVA bound.

The eight survivors, each with its witness

Run on the same manifest, head versus mutant in place.

KEY and input_sha256 accept trailing text (lines 90 and 74). KEY.fullmatch → match; key "00c0ffee0badf00dzz": head ValueError: patch s001 key must be 16 lowercase hex digits, mutant parse ACCEPTED 1 patch carrying that 18-character key. Same for input_sha256 = 64 hex digits + "garbage": head ValueError: input_sha256 must be 64 lowercase hex digits, mutant accepts, and the hash gate then refuses with manifest is for another input: manifest input_sha256 aaaa…garbage, input sha256 8573… — a message that sends the author to the input file when the malformed field is in the manifest. Note the revision check is not in this class: .match there is killed, because a graphics form matches the compute revision x2w-startup-shader-12cs (the cross-pipeline case does double duty).

Patch adjacency and ordering (lines 165–167). if start < end: → <=: patches [0x1010, 0x1012) and [0x1012, 0x1014) — head parse ACCEPTED 2 patches, mutant ValueError: patches p001 and p002 overlap. Without spans.sort(), the same two disjoint patches listed in descending RVA (p002 at 0x1020 first, p001 at 0x1010) are accepted head and refused patches p002 and p001 overlap under the mutant. Both are refusals of a valid manifest, and the fixture cannot see them: its only accepted manifest with more than one patch is p001 plus four shader patches (tests/patch_manifest_check.py:153), and its only overlap case duplicates the same span (:110, ok + second). So no accepted manifest in the fixture carries two memory patches at all — neither adjacency, nor order, nor two disjoint patches are pinned.

bytes is claimed non-empty, not pinned. HEX + → *: bytes = "" is refused head (bytes must be a non-empty, even number of lowercase hex digits) and accepted by the mutant as a patch whose bytes has length 0. The fixture's only bytes refusal is the odd-length "90c" (:111).

rva bottom edge (line 147). 0 <= rva → 0 < rva: a patch at rva = 0x0 is accepted head and refused by the mutant. Decorative in practice — a patch at RVA 0 has no meaning in a PE32+ — but it is the lower end of the range the message documents, and only the upper end (0xffffffff plus one byte accepted, plus two refused, :124-126) is pinned.

The memory patch's output field is unpinned. Removing "why": _text(entry["why"], f"{where} why") from the memory dict (line 159) survives: head returns keys ['bytes', 'expect_sha256', 'id', 'kind', 'remove_when', 'rva', 'why'], the mutant six of them. The fixture asserts id, rva and bytes for the memory kind, so a field can be dropped from the caller's view in silence.

The CLI's OSError branch (line 202). except (ValueError, OSError) → except ValueError, with a manifest path that does not exist: head prints patch manifest: [Errno 2] No such file or directory: '<path>', rc=1; the mutant ends in a traceback (FileNotFoundError: [Errno 2] …), rc=1. The exit status is unchanged, so this is a diagnostic contract, not behaviour — and the class is partly pinned already, since the deep-nesting case asserts rc=1 with no traceback. What is not pinned is ENOENT/EACCES on the manifest itself.

What this does not say

  • One machine, Linux only, no Windows run, one commit. The fixture is registered in tests/checks/python-linux/patch_manifest.txt and the python-linux job (.github/workflows/windows.yml:182, no if:) runs it on every pull request, so this is the gate the change lands behind; the Windows ctest --preset pr regex does not select patch_manifest_controls.
  • A survivor means "no test in this fixture separates the mutant from head", not "the rule is wrong". Three of the eight are refusals of valid input (adjacency, ordering, rva = 0); two are shape checks that accept trailing text, and one of those then produces a misleading message from the gate; one accepts a zero-length bytes; one drops an output field; one is stderr only.
  • Mutants run against the imported module, one fresh interpreter per run, and no tools/__pycache__ was present at any point. Worth knowing for anyone repeating this: python3 -B stops Python from writing bytecode, not from reading an existing .pyc, so a stale cache would make a survivor fake.
  • Only the loader and its fixture are mutated; the runtime-side rows of the doc's table (d3d12_draw.inl, mesh86_cache.inl) were read, not re-run.

AI-assisted.

…e CLI's OSError

Four memory patches in descending RVA, three adjacent and one at RVA 0, load; a one-byte overlap is refused in either order. A hash or key with trailing text and an empty bytes are refused, the bound patch is compared field by field, and a missing input file reaches the CLI as a diagnostic. Each kills one of the eight mutations that survived the fixture.
@JohnConnorNPC

Copy link
Copy Markdown
Collaborator Author

Thank you for the audit, @thepatrickworld. I re-ran your 24 mutations at 13269fb5 and got the same result: 16 killed, the same 8 survive, none of them an equivalent mutant. Seven of the eight sit in the memory code from #3056 (the KEY one is ours).

I pushed two commits to this branch:

  • tests: a 17-digit key, input_sha256 and expect_sha256 with trailing text, empty bytes, a full-dict check of p001, a missing input file through the CLI (status 1, no traceback), and a side-by-side test of two memory patches (descending order, adjacent, one at RVA 0, and a one-byte overlap refused in both orders).
  • docs: eight new rows in the mutation table; the measured line now says 9 tests.

With them, all 24 mutations are killed. patch_manifest_check runs 9 tests OK, docs_links and bidi pass. Thanks also for the Python 3.11.16 datum: the deep-nesting case holds there too.

This comment was AI-assisted.

@thepatrickworld

Copy link
Copy Markdown
Contributor

Independent re-run on 4968e124: the 24 mutants are killed, and one more survives
Not a code change; measurements only

What was measured

The 24 mutations from the audit at 13269fb5, plus four aimed at the assertions you added, applied one at a
time to tools/patch_manifest.py with the fixture re-run after each, then restored with
git checkout -- tools/patch_manifest.py and its sha256 compared before the next mutant (a mismatch would
have aborted the run; final sha256 ec0c1fb0dad12cdb5a845457c830208a01ee2cb84fb06dd0ba159743e907db35).

tools/patch_manifest.py is byte-identical between 13269fb5 and 4968e124, so every kill below comes from
the new tests, not from a change in the loader. Fixture measured: 27af1a89897561fc9797da6f5c6f68fc5cf93f689f6fa27cf17c87e001cbb882.

Environment

  • Linux: Ubuntu 26.04.1, Python 3.11.16, pefile 2024.8.26
  • Windows: 11 Pro 10.0.26200.9974, Python 3.15.2, pefile 2024.8.26
  • Same tool and fixture sha256 on both.

Commands

# fixture, 9 tests, from the checkout root
python -B tests/patch_manifest_check.py -v

# each mutant: edit the loader, re-run the fixture above, restore with
#   git checkout -- tools/patch_manifest.py

The Windows run used a directory holding a copy of tools/, tests/patch_manifest_check.py,
tests/call_evidence_check.py and src/startup_stubs/, because the fixture resolves ROOT from its own
path; the tool and fixture sha256 above are the ones it ran.

Observed: the eight that survived at 13269fb5

Each is now killed, by the case that targets it:

  • KEY.fullmatch -> match: test_shader_patches, patch s001 key must be 16 lowercase hex digits (17 digits).
  • SHA256.fullmatch -> match: test_malformed_manifests_are_refused, both input_sha256 must be 64 lowercase hex digits and p001 expect_sha256 must be 64 (trailing text).
  • start < end -> start <= end: test_memory_patches_side_by_side, which raises on the four adjacent patches.
  • spans.sort() removed: test_memory_patches_side_by_side, which raises on the descending order.
  • bytes pattern + -> *: test_malformed_manifests_are_refused, p001 bytes must be a non-empty.
  • why dropped from a memory patch: test_bound_input_loads, on the full-dict comparison.
  • 0 <= rva -> 0 < rva: test_memory_patches_side_by_side, which raises on the patch at RVA 0.
  • except (ValueError, OSError) -> except ValueError: test_wrong_input_is_refused, on the missing input (traceback instead of patch manifest: [Errno).

Three further probes of the new assertions are killed too: spans.sort(reverse=True), remove_when dropped
from a memory patch, and the overlap guard removed.

The nine tests on Windows

Ran 9 tests in 0.648s then OK at 4968e124, which closes the "Not yet run on Windows" line in
docs/experiments/patch-manifests.md. The same 28 mutants give the same verdict there, so the kills do not
depend on the 3.13 interpreter. It is not the CI path: the python-linux job runs 3.12.

One survivor

spans.sort() -> spans.sort(key=lambda s: s[2]) passes all nine tests on both machines. It is material,
not equivalent: a manifest that lists four memory patches with ids that do not follow the addresses
(p000 at SECTION_RVA + 4, p001 at + 2, p002 at SECTION_RVA, p003 at 0, same two-byte
replacement) is accepted at 4968e124 and refused as patches p000 and p001 overlap under the mutant. Your
accept case pairs ids that ascend as the addresses descend (p003 at + 4 ... p000 at 0), which is the
order an id sort happens to produce.

One-line remedy, verified: decorrelate the ids in that case,
(("p000", SECTION_RVA + 4), ("p001", SECTION_RVA + 2), ("p002", SECTION_RVA), ("p003", 0)) with the
expected list below it. With that edit the head stays green and the mutant fails on
test_memory_patches_side_by_side.

Limits

  • A mutation matrix, not a coverage proof: 28 mutants of one file, one fixture, one format version.
  • The kills are assertion failures and uncaught refusals on these inputs, not a statement about the manifest
    format beyond them.
  • The Windows run is a one-off on a copy tree, not the CI.

AI-assisted.

…sses

A sort of the spans by id instead of by address passed the fixture, because
the accept case listed ids that followed the addresses. Use ids that follow
neither the addresses nor their reverse, and list the mutation.

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean extension of the patch manifest loader. Deep nesting protection via RecursionError catch prevents tracebacks, shader patch support adds proper shape validation (key format, pipeline enum, revision regex, bare-name file check), and load_data() correctly gates on caller-provided bytes rather than re-reading from disk. The 28 refusal cases covering every rule plus the mutation audit provide thorough verification. Approved.

@pigalot pigalot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed 4968e124 merged over current main 9e7eab5b. The merge is clean (tree cf564d9e) and git diff --cached --check is clean.

What I ran on Windows. After cmake --preset <dev|release>:

ctest --test-dir out/build/<preset> --no-tests=error -R '^(patch_manifest_controls|docs_links|call_evidence_check)$'

3/3 pass in both presets. out\pe-env\Scripts\python.exe -B tests/patch_manifest_check.py -v runs 9 tests, OK. So the CTest registration is now exercised; the body says it wasn't.

What I traced against the runtime.

  • Revisions: PIPELINES matches the runtime at 9e7eab5b. d3d12_draw.inl uses x2w-startup-shader-29 and -29cs, and mesh86_cache.inl uses x2w-startup-mesh-86-1.
  • Extensions: graphics reads .txt, .vs.cso and .ps.cso and returns if either .cso is missing. Compute reads .txt and .cs.cso. mesh86 reads .mesh86.txt and .ms.cso, and .ps.cso only when the request has a pixel stage.
  • mesh57: leaving it out is right. request_slot57_mesh (x2w-startup-mesh-57-3) only publishes req_ files, and nothing reads a slot-57 translation back yet.

Mutants on top of the 28 already in the thread, each run against tests/patch_manifest_check.py:

Mutant Result
: dropped from the file check killed
\ dropped from the file check killed
. allowed as a name killed
.. allowed as a name killed
revision [1-9][0-9]* → [0-9]+ killed
empty files array allowed killed
mesh86 .ps.cso made required killed
duplicate ext check removed killed
load_data re-reads the input file killed
spans.sort() → spans.sort(key=lambda s: s[2]) survives on Windows too (thepatrickworld's survivor; the code is from #3056)

Blocking: file accepts names that aren't files in the manifest's directory on Windows. _file_name says the value is "for a later consumer to resolve in the manifest's directory". On this branch, parse accepts these as a shader patch's file:

  • NUL, CON.txt and Com1: device names. Opening <dir>\NUL opens the null device, not a file in the directory.
  • s001.txt. and s001.txt : Windows strips a trailing dot or space, so these name s001.txt.
  • a*b, a?b, a<b, a|b, a"b and a<TAB>b: names Windows can't create.

The runtime that would serve these files only runs on Windows. A check run once at load time is the place to refuse them, before any consumer exists. A version I tried:

RESERVED = re.compile(r"(?i)(?:con|prn|aux|nul|com[0-9]|lpt[0-9])")
...
    if (any(c in name for c in '<>:"/\\|?*') or any(ord(c) < 32 for c in name) or name in (".", "..")
            or name[-1] in ". " or RESERVED.fullmatch(name.split(".")[0])):
        raise ValueError(f"{where} {name!r} must be a bare Windows file name, without a directory, drive or '..'")

With it, the fixture stays at 9 tests OK. All twelve names above are refused, and s001.txt, s001.cs.cso, console.txt, nulls.cso and a b.txt are still accepted. Two or three of those names next to the six existing bare-name refusals would pin it.

Non-blocking.

  1. The sort-key survivor: thepatrickworld's remedy (ids that don't follow the addresses in the side-by-side accept case) is still unapplied at 4968e124.
  2. Scope: the nesting refusal is a fix to the existing loader and stands apart from the shader kind and load_data, which both serve #3037. I'm not asking for a split; a maintainer may prefer one.

Verdict: changes requested on 4968e124, for the file name rule only.

Environment: Windows 11 25H2 build 26200.9974; Python 3.12.10; pefile from requirements-dev.txt.

This reply was AI-assisted.

@KelboLive

Copy link
Copy Markdown
Contributor

I agree with pigalot's CHANGES_REQUESTED review — the _file_name check needs to be tightened for Windows reserved names and invalid characters. The current check (any(c in name for c in "/\\:") or name in (".", "..")) misses:

  • Reserved device names: NUL, CON, PRN, AUX, COM1-9, LPT1-9 (case-insensitive)
  • Trailing dots/spaces (Windows strips them, so s001.txt. opens as s001.txt)
  • Invalid characters: < > " | ? * and control chars (< 32)

pigalot's suggested fix looks correct. Please add a couple of the reserved names to the fixture refusals (e.g., file = "NUL", file = "CON.txt", file = "s001.txt ") to pin it.

Non-blocking observations:

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator Author

Thank you for the review, @pigalot. You're right: file accepted names that don't name a file in the manifest's directory on Windows.

I pushed two commits (the first is the earlier sort-key test fix). The loader now refuses, with three separate messages and the bare-name message unchanged: any of <>"|?* or a control character (including a tab), a trailing dot or space (s001.txt., s001.txt ), and reserved device names (CON PRN AUX NUL COM0-9 LPT0-9, plus CONIN$/CONOUT$ and the superscript COM/LPT forms), case-insensitive, with or without an extension. NUL, CON.txt and Com1 are among the 17 refused names pinned next to the bare-name refusals. Six near-miss names still load (console.txt, nulls.cso, a b.txt, com10.txt, conin.txt, .s001.txt).

Twelve new mutations each fail a test, and the 24 audit mutants are still killed. The sort-key mutant that survived is killed by the earlier commit; sorting by span end remains equivalent. patch_manifest_check runs 9 tests OK, docs_links and bidi pass. I ran these on Linux only, not Windows.

This comment was AI-assisted.

@pigalot pigalot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-reviewed 0d733d9a on Windows. On its own it passes, but merged over current main (fdba6e15) one of its pins fails. The merge itself is clean, and git diff --cached --check reports no problems.

My earlier request is fixed. _file_name now refuses the twelve names I listed, plus CONIN$, CONOUT$, and COM or LPT followed by a superscript digit. console.txt, nulls.cso, com10.txt, conin.txt, a b.txt and .s001.txt are still accepted.

On 0d733d9a alone, out\pe-env\Scripts\python.exe -B tests/patch_manifest_check.py -v runs 9 tests, all OK, so the first Windows run of these cases passes. I also ran nine of the mutations from your table on Windows, and each fails the check:

Mutant Result
<>"|?* check removed killed (9 failures)
control-character check removed killed (3)
trailing dot/space check removed killed (3)
trailing dot only killed (2)
device check removed killed (9)
match instead of fullmatch killed (1 failure, 4 errors)
device matched against the whole name killed (5)
rstrip(" ") dropped killed (2)
device names case-sensitive killed (6)

The sort-key survivor from the earlier round is fixed too. The side-by-side ids no longer follow the addresses.

Blocking: merged with current main, test_shader_files_match_the_runtime [compute] fails.

AssertionError: Items in the first set but not the second:
'.cs.hlsl'

patch_manifest_controls fails the same way in dev and release (ctest --test-dir out/build/<preset> --no-tests=error -R '^(patch_manifest.*|docs_links|call_evidence_check|bidi_controls)$': 3 of 4 pass). This branch's base is ca659396. Since then, #3006 (7364e6a9) added this check to src/startup_stubs/d3d12_compute_dispatch.inl:

if (output == x2w::NativeComputeOutput::unmarked) {
    const DWORD attributes = cache_path(path, L"", tr.key, L".cs.hlsl") ? GetFileAttributesW(path) : INVALID_FILE_ATTRIBUTES;
    if (attributes == INVALID_FILE_ATTRIBUTES || (attributes & FILE_ATTRIBUTE_DIRECTORY)) { ...
        return "native translation without a revision; rebuild it"; }
}

So for a compute key, the runtime now looks for <key>.cs.hlsl too. It only checks that the file exists, and only when the .txt manifest carries no native compiler revision. Without that file, a patch that ships only .txt and .cs.cso with an unmarked manifest is treated as stale. The pin is doing its job here; the loader's table is behind the runtime.

A fix that matches how mesh86's .ps.cso is handled: after merging main, add .cs.hlsl to compute's extensions as an optional file. Note in the doc that the runtime needs it only for an unmarked manifest, and pin that condition the way the load_stage(L".ps.cso", ...) line is pinned. Making it required would also satisfy the set pin, but then a patch with a natively marked manifest would have to carry a file the runtime never reads.

Non-blocking: device names on current Windows. On Windows 11 build 26200, creating nul.txt, nul .txt or aux.cso in a temporary directory makes an ordinary file of that name. Only bare NUL opens the device. Older Windows versions still open these names as devices, and Microsoft's page still lists them, so refusing them is the safe rule. The doc's wording, "a name Windows would not open as a file of that name", is accurate for those versions. You might say "on some Windows versions" for the names with an extension.

Verdict: changes requested on 0d733d9a, for the .cs.hlsl pin failure after merging main only. The file-name rule is done.

Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; pefile from requirements-dev.txt.

This reply was AI-assisted.

Since R0Y00#3006 the runtime's compute loader also looks for <key>.cs.hlsl when the
key's .txt has no native line, and refuses the translation without it. List it
as a compute translation file, optional like mesh86's .ps.cso, since the loader
does not read the .txt. Pin it beside the runtime's unmarked-manifest check.
@JohnConnorNPC

Copy link
Copy Markdown
Collaborator Author

CI on 0d733d9 failed in patch_manifest_check because main's #3006 made the compute loader look for a .cs.hlsl file, which our drift test (test_shader_files_match_the_runtime [compute]) did not know about. It is not a Python-version or OS difference; the same failure reproduces locally on the PR merged into main.

I pushed a fix: the compute manifest now accepts .cs.hlsl as an optional file (the required set stays .txt + .cs.cso), with a new accept case and a pin on the runtime condition under which it looks for the file (a .txt with no native line). Three new mutations (.cs.hlsl dropped, made required, runtime condition forced true) are each killed. On the merge with current main patch_manifest_check runs 9 tests OK, and docs_links and bidi pass.

Because the fix needs #3006's lookup, I then merged current main into the branch (d3013cf), so the branch is green on its own; the results above are re-measured on that merge.

This comment was AI-assisted.

@pigalot pigalot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-reviewed d3013cf1 on Windows. The pin failure I asked about is fixed, so I'm approving.

Fixed. compute now lists .cs.hlsl among the files the runtime reads, and leaves it out of the required ones (.txt, .cs.cso). The doc table and the new paragraph say when the runtime looks for it: only for a .txt without a native line. test_shader_files_match_the_runtime pins that condition (if (output == x2w::NativeComputeOutput::unmarked) {) the same way it pins mesh86's .ps.cso. The new accept case (s005, compute with .txt, .cs.cso and .cs.hlsl) loads, and the CLI lists its id.

Testing. I trial-merged this head over current main (c3204a9c); the merge is clean. On that tree, out\pe-env\Scripts\python.exe -B tests/patch_manifest_check.py -v runs 9 tests, all OK, including test_shader_files_match_the_runtime, which failed on 0d733d9a after merging main. bidi_controls_check.py passes. CI is green on d3013cf1.

Mutants (on Windows, each run through tests/patch_manifest_check.py):

Mutant Result
.cs.hlsl dropped from compute's files killed (2 failures, 1 error)
.cs.hlsl made required killed (2 failures)
runtime condition replaced by if (true) { killed (2 failures)
runtime looks for .cs.dxil instead of .cs.hlsl killed (3 failures)

The first three are yours; the fourth checks that the set pin follows the extension the runtime actually reads.

The device-name note from my last review was non-blocking and still stands as a wording suggestion only.

Verdict: approve at d3013cf1.

Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; pefile from requirements-dev.txt.

This reply was AI-assisted.

@pigalot
pigalot merged commit e46cd28 into R0Y00:main Nov 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants