fix(oracle): publish cached executable only after successful build #1542

Merged
ska2704 merged 2 commits from upstream-pr/1542 into main 2026-10-09 09:42:52 +00:00
ska2704 commented 2026-10-08 11:47:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ska2704 on 2026-10-08T11:47:01Z.


What

The hardware oracle compiles directly into its shared cached executable. If a compiler writes output and then fails, the next call accepts the fresh partial file and can fail with Exec format error. An overlapping build can expose the same unfinished output.

Compile in a private temporary directory inside the cache, then atomically replace oracle only after the compiler succeeds. Failed rebuilds preserve the previous executable and clean unpublished output. Add regression coverage for failed builds, retries, cache reuse and overlapping builds, and register the CPU oracle tests with CTest. This fixes cache publication in the tool introduced by #871.

Tested

macOS, Python 3.14, CPU only:

  • python3 tools/hw-oracle/test_hw_oracle.py: 7 tests passed. The added cases produced 3 assertion failures on unchanged upstream (cold failure, failed rebuild and overlapping build).
  • A real subprocess reproducer using a failing fake compiler confirmed partial-cache reuse and Exec format error before the fix; after the fix, retry produced a runnable executable and a failed rebuild preserved the old cache.
  • python3 -m unittest discover -s tools/tests -v: passed.
  • A focused CMake harness executed the repository's test registration block: both CTests passed with BUILD_TESTING=ON; neither was registered with it OFF.
  • Repository conventions and git diff --check: passed.

The unchanged upstream Build workflow also passed on the fork at this PR's exact head 466ebde2, including the main build, patched-library build and CTest with --repeat until-fail:3:

  • Linux: 431 passed, 22 GPU capability skips, 453 registered; Vulkan required with lavapipe.
  • Windows: 272 passed, 173 GPU/device skips, 445 registered.
  • The new hardware_oracle CTest passed all three repetitions on both platforms.

The full product build and ROCm/AMD GPU execution were not run locally; this change does not alter instruction semantics.

After updating the branch with main (f1451396), commit 567b1f92 retains progress_report, import_audit and hardware_oracle in the relocated Python test block before the relinker-only early return. On macOS with Python 3.14 and AppleClang 21:

  • The documented relinker-only CMake configuration and test-registration check passed.
  • All three Python CTests passed all three repetitions; the oracle suite's 7 tests and the tools suite's 14 tests also passed directly.
  • Conventions and diff checks passed; independent review of the conflict resolution found no actionable issues.

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 in TechnicalDebt (no guest exports changed)
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (no dependencies added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes, Codex for investigation, implementation, testing and independent agent review
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4786276074 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1542). Originally posted by [ska2704](https://github.com/ska2704) on 2026-10-08T11:47:01Z. --- ### What The hardware oracle compiles directly into its shared cached executable. If a compiler writes output and then fails, the next call accepts the fresh partial file and can fail with `Exec format error`. An overlapping build can expose the same unfinished output. Compile in a private temporary directory inside the cache, then atomically replace `oracle` only after the compiler succeeds. Failed rebuilds preserve the previous executable and clean unpublished output. Add regression coverage for failed builds, retries, cache reuse and overlapping builds, and register the CPU oracle tests with CTest. This fixes cache publication in the tool introduced by #871. ### Tested macOS, Python 3.14, CPU only: - `python3 tools/hw-oracle/test_hw_oracle.py`: 7 tests passed. The added cases produced 3 assertion failures on unchanged upstream (cold failure, failed rebuild and overlapping build). - A real subprocess reproducer using a failing fake compiler confirmed partial-cache reuse and `Exec format error` before the fix; after the fix, retry produced a runnable executable and a failed rebuild preserved the old cache. - `python3 -m unittest discover -s tools/tests -v`: passed. - A focused CMake harness executed the repository's test registration block: both CTests passed with `BUILD_TESTING=ON`; neither was registered with it OFF. - Repository conventions and `git diff --check`: passed. The unchanged upstream Build workflow also passed on [the fork at this PR's exact head `466ebde2`](https://github.com/ska2704/AnyPS5/actions/runs/37774029040), including the main build, patched-library build and CTest with `--repeat until-fail:3`: - Linux: 431 passed, 22 GPU capability skips, 453 registered; Vulkan required with lavapipe. - Windows: 272 passed, 173 GPU/device skips, 445 registered. - The new `hardware_oracle` CTest passed all three repetitions on both platforms. The full product build and ROCm/AMD GPU execution were not run locally; this change does not alter instruction semantics. After updating the branch with `main` (`f1451396`), commit `567b1f92` retains `progress_report`, `import_audit` and `hardware_oracle` in the relocated Python test block before the relinker-only early return. On macOS with Python 3.14 and AppleClang 21: - The documented relinker-only CMake configuration and test-registration check passed. - All three Python CTests passed all three repetitions; the oracle suite's 7 tests and the tools suite's 14 tests also passed directly. - Conventions and diff checks passed; independent review of the conflict resolution found no actionable issues. ### Checklist - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) (no guest exports changed) - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (no dependencies added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes, Codex for investigation, implementation, testing and independent agent review
ska2704 commented 2026-10-08 12:33:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ska2704 on 2026-10-08T12:33:38Z.


The listed overlaps are mechanical CMake conflicts, with no implementation dependency:

  • #1432 and #1456 relocate the root Python test block. The hardware_oracle registration from this PR needs to be retained inside that relocated block.
  • #1461 and #1462 add import_audit immediately after progress_report, at the same insertion point as hardware_oracle. Both test registrations need to be retained.

None duplicates the oracle cache fix or is required by it, so Depends on: none remains accurate. A test merge of this PR's head 466ebde2 with current main (0b3cc73e) succeeds without conflicts. No source change is needed against current main; the resolutions above apply if the overlapping PRs merge first.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6059958052 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1542#issuecomment-6059958052). Originally posted by [ska2704](https://github.com/ska2704) on 2026-10-08T12:33:38Z. --- The listed overlaps are mechanical CMake conflicts, with no implementation dependency: - #1432 and #1456 relocate the root Python test block. The `hardware_oracle` registration from this PR needs to be retained inside that relocated block. - #1461 and #1462 add `import_audit` immediately after `progress_report`, at the same insertion point as `hardware_oracle`. Both test registrations need to be retained. None duplicates the oracle cache fix or is required by it, so `Depends on: none` remains accurate. A test merge of this PR's head `466ebde2` with current `main` (`0b3cc73e`) succeeds without conflicts. No source change is needed against current `main`; the resolutions above apply if the overlapping PRs merge first.
ska2704 commented 2026-10-09 02:27:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ska2704 on 2026-10-09T02:27:17Z.


Updated with current main and resolved the CMake conflict in 567b1f92. All three Python tests (progress_report, import_audit, hardware_oracle) are retained before the relinker-only early return.

On macOS, the relinker-only configuration and test-registration check passed, and each Python CTest passed three repetitions. The oracle suite's 7 tests, tools suite's 14 tests and conventions checks also passed. The PR is mergeable again; upstream CI for the updated revision is awaiting workflow approval.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6073014347 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1542#issuecomment-6073014347). Originally posted by [ska2704](https://github.com/ska2704) on 2026-10-09T02:27:17Z. --- Updated with current `main` and resolved the CMake conflict in [567b1f92](https://github.com/boykopovar/AnyPS5/pull/1542/commits/567b1f923f67477c4655525f6729927d7ef323ef). All three Python tests (`progress_report`, `import_audit`, `hardware_oracle`) are retained before the relinker-only early return. On macOS, the relinker-only configuration and test-registration check passed, and each Python CTest passed three repetitions. The oracle suite's 7 tests, tools suite's 14 tests and conventions checks also passed. The PR is mergeable again; upstream CI for the updated revision is awaiting workflow approval.
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!1542
No description provided.