fix(tools): reject empty native web build artifacts #12352

Merged
StoneDC merged 1 commit from upstream-pr/12352 into main 2026-10-28 23:13:50 +00:00
StoneDC commented 2026-10-28 10:31:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by StoneDC on 2026-10-28T10:31:21Z.


What

build_web.py --local considered zero-byte relinker_wasm.mjs or .wasm valid and overwrote a previously useful site with an unusable build. Reject either empty native artifact before copying site sources, retaining the existing missing-file checks.

Implementation basis: The local publish path already requires both native files before copy_sources(). A zero-length module cannot supply the required native Web entry point; this adds the minimal nonempty prerequisite at that same preflight boundary.

Reference sources at the starting main: tools/build_web.py.

Tested

Exact PR head: 668fb237cdad6d86fd056d40a58c77e411da819b; refreshed starting main: 5ae16ad52b5ab6be84c135de0eadb97545616c26. This branch contains one independent commit.

Windows: MinGW GCC 15.2, CMake 4.3.1, Python 3.14.3, Node 24.14.1. WSL Ubuntu 26.04: GCC 15.2, CMake 4.2.3, Python 3.14.4, Node 22.22.1. Native builds use Ninja Release, -DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON and cmake --build BUILD --parallel 8. Focused CTest runs use -V --parallel 4 on Windows and -V --parallel 8 on WSL; test-registration and skip-policy audits pass.

Exact-head local validation Windows WSL Linux
Focused tests 2 CTest groups passed; slowest 1.94s; 49 Python cases total, 0 skipped 2 CTest groups passed; slowest 0.64s; 49 Python cases total, 0 skipped

Command: ctest --test-dir BUILD -R '^web_library_assets$|^web_release$' -V --parallel N.

Run the real local CLI with missing/empty permutations and verify existing app.mjs/.nojekyll sentinels remain unchanged. A nonempty fixture succeeds. The earlier argv-acceptance fixture now writes nonempty module bytes instead of touching empty files, preserving that test purpose. The old implementation fails the empty-artifact regression.

Current-main integration: checked each branch's independent three-way merge against 3a40945e62b7e2543031d5da2b8e351ab603bc1a (all clean), then built and tested the actual merge of that main and all ten initial implementation heads at 91a099a5c398b221b4a88a8f0e0f0b1068a2dbb9. On each OS, all 86 selected CTest groups and 30 Node tests passed. Slowest CTest group: 9.77s Windows / 4.26s WSL. This combined run supplements the independent head runs; it does not make another project a prerequisite. Main's newly merged release-note/cache/test-runner changes were preserved. No locally exercised final CTest group exceeded 30s.

A final open-PR refresh examined 68 new/updated heads since screening. The only newly shared files belonged to #12338 (release-note symlink-loop diagnostics, 761fe2785b28082fda8ce5910cb0e7e4451329bf) and #12328 (separate fuzz-seed test registration, 70993dbf30e355257458a9028785ac5a131fe033). Both merge cleanly with the tested current-main combination at 9ca88c064583c44d0707810d2ec2873f2608489d. In that context the release-note suite and registration audits passed on both OSes, with all 70 trace cases and both CSV registrations preserved. These are focused integration checks, not whole external PR builds. Their behavior is distinct and introduces no ordering dependency.

Pre-push review: git diff --check, Python 3.9 grammar parsing of changed Python files, current-main conventions checker with this complete body, and production test registration audit. Official tools/pr_overlap.py --branch BRANCH --jobs 2 completed against all open PRs at its recorded snapshot. Its result was No overlap with open pull requests. No same behavior was identified in the open-PR/history review; no ordering dependency is required in this snapshot.

Known limits: Nonempty bytes do not establish semantic JavaScript/WASM validity or matching artifact versions. Tests use fixture artifacts; supplemental combined Emscripten compilation and complete Web fixture tests are recorded below. macOS and an older Python runtime were not available locally; Python 3.9 syntax parsing is not runtime testing. No full system-library build, PS5 measurement or game run is claimed. Hosted checks are pending publication/maintainer workflow dispatch and are not counted as local passes.

Supplemental Web integration validation after initial publication: the existing archive-root.test.mjs exposed a preexisting fixture path (linux-1234.zip) that no longer satisfied the producer's checksum-addressed naming contract. PR #12351 now updates only that fixture and its archive.test.mjs counterpart at f0e88751b94a5e9533c7fdaf5fe23573b0c53758, without changing production logic or weakening any assertions. The original failed hosted job is superseded only when its replacement completes.

Using the repository CI's Emscripten 6.0.3, both that exact worker head and the current-main combination at e7056168154f9377796ea7c6782494a8d652a0ee were built with emcmake cmake -DANYPS5_BUILD_WASM=ON -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release, then cmake --build BUILD --target relinker_web --parallel 8. The combination consists of the tested main 3a40945e62b7e2543031d5da2b8e351ab603bc1a and all ten published implementation heads, with #12351's fixture follow-up. Both complete python3 tools/test_web.py --build BUILD suites passed under WSL Node 22.22.1 and Windows Node 24.14.1. Windows executes the same WASM/JavaScript binaries compiled in WSL; this is not a Windows-host Emscripten build. Real ZIP-library integration and actual WASM conversion exercise ZIP/folder inputs, Windows/Linux output, modules, original resources, permissions, streamed ZIP and directory output, batch roots and manifest download/rate-limit/error handling. Additional archive-root, Windows archive and reserved-path suites passed independently on both OSes. Network/library data and filesystem endpoints remain controlled fixtures; no PS5 or real game run is claimed.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5048981906 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12352). Originally posted by [StoneDC](https://github.com/StoneDC) on 2026-10-28T10:31:21Z. --- ### What `build_web.py --local` considered zero-byte `relinker_wasm.mjs` or `.wasm` valid and overwrote a previously useful site with an unusable build. Reject either empty native artifact before copying site sources, retaining the existing missing-file checks. Implementation basis: The local publish path already requires both native files before `copy_sources()`. A zero-length module cannot supply the required native Web entry point; this adds the minimal nonempty prerequisite at that same preflight boundary. Reference sources at the starting main: [tools/build_web.py](https://github.com/boykopovar/AnyPS5/blob/5ae16ad52b5ab6be84c135de0eadb97545616c26/tools/build_web.py). ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Exact PR head: `668fb237cdad6d86fd056d40a58c77e411da819b`; refreshed starting main: `5ae16ad52b5ab6be84c135de0eadb97545616c26`. This branch contains one independent commit. Windows: MinGW GCC 15.2, CMake 4.3.1, Python 3.14.3, Node 24.14.1. WSL Ubuntu 26.04: GCC 15.2, CMake 4.2.3, Python 3.14.4, Node 22.22.1. Native builds use Ninja Release, `-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON` and `cmake --build BUILD --parallel 8`. Focused CTest runs use `-V --parallel 4` on Windows and `-V --parallel 8` on WSL; test-registration and skip-policy audits pass. | Exact-head local validation | Windows | WSL Linux | |---|---|---| | Focused tests | 2 CTest groups passed; slowest 1.94s; 49 Python cases total, 0 skipped | 2 CTest groups passed; slowest 0.64s; 49 Python cases total, 0 skipped | Command: `ctest --test-dir BUILD -R '^web_library_assets$|^web_release$' -V --parallel N`. Run the real local CLI with missing/empty permutations and verify existing `app.mjs`/`.nojekyll` sentinels remain unchanged. A nonempty fixture succeeds. The earlier argv-acceptance fixture now writes nonempty module bytes instead of touching empty files, preserving that test purpose. The old implementation fails the empty-artifact regression. Current-main integration: checked each branch's independent three-way merge against `3a40945e62b7e2543031d5da2b8e351ab603bc1a` (all clean), then built and tested the actual merge of that main and all ten initial implementation heads at `91a099a5c398b221b4a88a8f0e0f0b1068a2dbb9`. On each OS, all **86 selected CTest groups and 30 Node tests** passed. Slowest CTest group: **9.77s Windows / 4.26s WSL**. This combined run supplements the independent head runs; it does not make another project a prerequisite. Main's newly merged release-note/cache/test-runner changes were preserved. No locally exercised final CTest group exceeded 30s. A final open-PR refresh examined 68 new/updated heads since screening. The only newly shared files belonged to [#12338](https://github.com/boykopovar/AnyPS5/pull/12338) (release-note symlink-loop diagnostics, `761fe2785b28082fda8ce5910cb0e7e4451329bf`) and [#12328](https://github.com/boykopovar/AnyPS5/pull/12328) (separate fuzz-seed test registration, `70993dbf30e355257458a9028785ac5a131fe033`). Both merge cleanly with the tested current-main combination at `9ca88c064583c44d0707810d2ec2873f2608489d`. In that context the release-note suite and registration audits passed on both OSes, with all 70 trace cases and both CSV registrations preserved. These are focused integration checks, not whole external PR builds. Their behavior is distinct and introduces no ordering dependency. Pre-push review: `git diff --check`, Python 3.9 grammar parsing of changed Python files, current-main conventions checker with this complete body, and production test registration audit. Official `tools/pr_overlap.py --branch BRANCH --jobs 2` completed against all open PRs at its recorded snapshot. Its result was `No overlap with open pull requests.` No same behavior was identified in the open-PR/history review; no ordering dependency is required in this snapshot. **Known limits:** Nonempty bytes do not establish semantic JavaScript/WASM validity or matching artifact versions. Tests use fixture artifacts; supplemental combined Emscripten compilation and complete Web fixture tests are recorded below. macOS and an older Python runtime were not available locally; Python 3.9 syntax parsing is not runtime testing. No full system-library build, PS5 measurement or game run is claimed. Hosted checks are pending publication/maintainer workflow dispatch and are not counted as local passes. Supplemental Web integration validation after initial publication: the existing `archive-root.test.mjs` exposed a preexisting fixture path (`linux-1234.zip`) that no longer satisfied the producer's checksum-addressed naming contract. PR #12351 now updates only that fixture and its `archive.test.mjs` counterpart at `f0e88751b94a5e9533c7fdaf5fe23573b0c53758`, without changing production logic or weakening any assertions. The original failed hosted job is superseded only when its replacement completes. Using the repository CI's **Emscripten 6.0.3**, both that exact worker head and the current-main combination at `e7056168154f9377796ea7c6782494a8d652a0ee` were built with `emcmake cmake -DANYPS5_BUILD_WASM=ON -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release`, then `cmake --build BUILD --target relinker_web --parallel 8`. The combination consists of the tested main `3a40945e62b7e2543031d5da2b8e351ab603bc1a` and all ten published implementation heads, with #12351's fixture follow-up. Both complete `python3 tools/test_web.py --build BUILD` suites passed under **WSL Node 22.22.1** and **Windows Node 24.14.1**. Windows executes the same WASM/JavaScript binaries compiled in WSL; this is not a Windows-host Emscripten build. Real ZIP-library integration and actual WASM conversion exercise ZIP/folder inputs, Windows/Linux output, modules, original resources, permissions, streamed ZIP and directory output, batch roots and manifest download/rate-limit/error handling. Additional archive-root, Windows archive and reserved-path suites passed independently on both OSes. Network/library data and filesystem endpoints remain controlled fixtures; no PS5 or real game run is claimed. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes
rooklz commented 2026-10-28 10:50:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-28T10:50:03Z.

Review: APPROVED


Checked head 668fb237cd on macOS arm64 (Apple clang, CMake + Ninja Release, -DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON, Python 3.13):

  • tools.tests.test_build_web: 17 OK.
  • With tools/build_web.py reverted to main, the new test fails. The two missing=False (empty file) subtests fail with SystemExit not raised, as they should. The two missing=True subtests also fail on main, but only because the empty-file subtest before each one ran copy_sources() and overwrote the shared app.mjs marker. Missing files were already rejected on main, so those two failures come from the earlier subtest. That's fine as a regression signal, but if you want each subtest to fail only for its own case, rewrite the marker at the start of each subtest. Not blocking.
  • Mutants: st_size < 0, a guard that only covers .mjs, a guard that only covers .wasm, st_size <= 8, and dropping {name} from the message. The test catches all 5.
  • Merged onto main 3a40945e62: 270/270 build, ctest 378/378. check_conventions --base upstream/main passes, the merge-tree is clean, and pr_overlap --branch reports no overlap with open pull requests.

Approving.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5681433977 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12352#pullrequestreview-5681433977). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-28T10:50:03Z. **Review:** APPROVED --- Checked head `668fb237cd` on macOS arm64 (Apple clang, CMake + Ninja Release, `-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON`, Python 3.13): - `tools.tests.test_build_web`: 17 OK. - With `tools/build_web.py` reverted to main, the new test fails. The two `missing=False` (empty file) subtests fail with `SystemExit not raised`, as they should. The two `missing=True` subtests also fail on main, but only because the empty-file subtest before each one ran `copy_sources()` and overwrote the shared `app.mjs` marker. Missing files were already rejected on main, so those two failures come from the earlier subtest. That's fine as a regression signal, but if you want each subtest to fail only for its own case, rewrite the marker at the start of each subtest. Not blocking. - Mutants: `st_size < 0`, a guard that only covers `.mjs`, a guard that only covers `.wasm`, `st_size <= 8`, and dropping `{name}` from the message. The test catches all 5. - Merged onto main `3a40945e62`: 270/270 build, ctest 378/378. `check_conventions --base upstream/main` passes, the merge-tree is clean, and `pr_overlap --branch` reports no overlap with open pull requests. Approving.
MarcZX10 commented 2026-10-28 10:53:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T10:53:53Z.

Review: APPROVED


Reviewed the early artifact checks and regression coverage. The exact-head test_build_web.py run passed 17 tests with 1 platform skip; it verifies that empty or missing native artifacts are rejected before copying sources and that prior site output is preserved, while nonempty artifacts still build. Hosted Linux and Windows relinker checks and the refreshed conventions/labels checks pass. macOS relinker jobs remain pending.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5681477707 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12352#pullrequestreview-5681477707). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T10:53:53Z. **Review:** APPROVED --- Reviewed the early artifact checks and regression coverage. The exact-head `test_build_web.py` run passed 17 tests with 1 platform skip; it verifies that empty or missing native artifacts are rejected before copying sources and that prior site output is preserved, while nonempty artifacts still build. Hosted Linux and Windows relinker checks and the refreshed conventions/labels checks pass. macOS relinker jobs remain pending.
THEMANnt commented 2026-10-28 11:54:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-28T11:54:13Z.

Review: APPROVED


Reviewed 668fb237cdad6d86fd056d40a58c77e411da819b — approve. Empty native web artifacts are rejected before copying site sources, preserving an existing site on invalid build input.

Windows/Python 3.11: head test_build_web.py: 16 passed, 1 skipped (17 total); base test_build_web.py: 15 passed, 1 skipped (16 total). The missing/empty artifact cases for both native files execute and fail against old production because it overwrites the existing marker. Nonempty success remains covered. No Emscripten compiler or live site publication is claimed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5682165175 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12352#pullrequestreview-5682165175). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-28T11:54:13Z. **Review:** APPROVED --- Reviewed `668fb237cdad6d86fd056d40a58c77e411da819b` — approve. Empty native web artifacts are rejected before copying site sources, preserving an existing site on invalid build input. Windows/Python 3.11: head test_build_web.py: 16 passed, 1 skipped (17 total); base test_build_web.py: 15 passed, 1 skipped (16 total). The missing/empty artifact cases for both native files execute and fail against old production because it overwrites the existing marker. Nonempty success remains covered. No Emscripten compiler or live site publication is claimed.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!12352
No description provided.