docs(hw-oracle): build the oracle under XDG_CACHE_HOME when it is set #12719

Merged
XairRrR merged 1 commit from upstream-pr/12719 into main 2026-10-29 10:54:06 +00:00
XairRrR commented 2026-10-29 04:53:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T04:53:51Z.


What

docs/dev/HW_ORACLE.md says the first run builds oracle.c into ~/.cache/anyps5-hw-oracle/. That is wrong whenever XDG_CACHE_HOME is set. tools/hw-oracle/hw_oracle.py uses HW_ORACLE_CACHE if it is set. Otherwise it uses $XDG_CACHE_HOME/anyps5-hw-oracle, and falls back to ~/.cache/anyps5-hw-oracle only when XDG_CACHE_HOME is unset or empty. For example, with XDG_CACHE_HOME=/tmp/xdg the binary is built under /tmp/xdg/anyps5-hw-oracle/, and a reader who looks in ~/.cache to find or clear the build finds nothing. The document now names XDG_CACHE_HOME, the ~/.cache fallback, and HW_ORACLE_CACHE as the override of both. Only the document changes.

Tested

Arch Linux 7.2.11-zen, GCC 16.2.1, Ninja, Release, Intel Core i9-14900KF. Documentation only, so no build was needed.

  • Printed hw_oracle.CACHE under four environments. XDG_CACHE_HOME=/tmp/xdg gives /tmp/xdg/anyps5-hw-oracle. XDG_CACHE_HOME unset or empty with HOME=/tmp/h gives /tmp/h/.cache/anyps5-hw-oracle. HW_ORACLE_CACHE=/tmp/o with XDG_CACHE_HOME=/tmp/xdg gives /tmp/o.
  • python3 tools/hw-oracle/test_hw_oracle.py: 48 tests, OK (1 skipped).
  • python3 tools/check_conventions.py --base origin/main: all conventions checks passed. git diff --check origin/main: clean.
  • python3 tools/pr_overlap.py --branch auto/docs-hw-oracle-xdg-cache: no overlap with open pull requests. #11454 and #12348 also edit this file, in other paragraphs, and both merge cleanly with this branch.

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:5062434275 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12719). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-10-29T04:53:51Z. --- ### What `docs/dev/HW_ORACLE.md` says the first run builds `oracle.c` into `~/.cache/anyps5-hw-oracle/`. That is wrong whenever `XDG_CACHE_HOME` is set. `tools/hw-oracle/hw_oracle.py` uses `HW_ORACLE_CACHE` if it is set. Otherwise it uses `$XDG_CACHE_HOME/anyps5-hw-oracle`, and falls back to `~/.cache/anyps5-hw-oracle` only when `XDG_CACHE_HOME` is unset or empty. For example, with `XDG_CACHE_HOME=/tmp/xdg` the binary is built under `/tmp/xdg/anyps5-hw-oracle/`, and a reader who looks in `~/.cache` to find or clear the build finds nothing. The document now names `XDG_CACHE_HOME`, the `~/.cache` fallback, and `HW_ORACLE_CACHE` as the override of both. Only the document changes. ### Tested Arch Linux 7.2.11-zen, GCC 16.2.1, Ninja, Release, Intel Core i9-14900KF. Documentation only, so no build was needed. - Printed `hw_oracle.CACHE` under four environments. `XDG_CACHE_HOME=/tmp/xdg` gives `/tmp/xdg/anyps5-hw-oracle`. `XDG_CACHE_HOME` unset or empty with `HOME=/tmp/h` gives `/tmp/h/.cache/anyps5-hw-oracle`. `HW_ORACLE_CACHE=/tmp/o` with `XDG_CACHE_HOME=/tmp/xdg` gives `/tmp/o`. - `python3 tools/hw-oracle/test_hw_oracle.py`: 48 tests, OK (1 skipped). - `python3 tools/check_conventions.py --base origin/main`: all conventions checks passed. `git diff --check origin/main`: clean. - `python3 tools/pr_overlap.py --branch auto/docs-hw-oracle-xdg-cache`: no overlap with open pull requests. #11454 and #12348 also edit this file, in other paragraphs, and both merge cleanly with this branch. ### 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: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
rooklz commented 2026-10-29 05:21:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-29T05:21:44Z.

Review: APPROVED


Checked on macOS 26 arm64 at 664a5c93e8, against main 52c09d567d.

The new sentence matches the code. tools/hw-oracle/hw_oracle.py L17 on main is CACHE = Path(HW_ORACLE_CACHE or Path(XDG_CACHE_HOME or ~/.cache) / "anyps5-hw-oracle"), and build() (L68) is the only reader. Because it uses or, an empty variable counts as unset, which is what "unset or empty" says. I printed hw_oracle.CACHE from a git archive of the PR head with HOME=/tmp/h and both variables cleared first. Python 3.9.6, 3.13 and 3.14 gave the same result for all 7 environments:

environment CACHE
(none) /tmp/h/.cache/anyps5-hw-oracle
XDG_CACHE_HOME= /tmp/h/.cache/anyps5-hw-oracle
XDG_CACHE_HOME=/tmp/xdg /tmp/xdg/anyps5-hw-oracle
HW_ORACLE_CACHE=/tmp/o XDG_CACHE_HOME=/tmp/xdg /tmp/o
HW_ORACLE_CACHE= XDG_CACHE_HOME=/tmp/xdg /tmp/xdg/anyps5-hw-oracle
HW_ORACLE_CACHE= XDG_CACHE_HOME= /tmp/h/.cache/anyps5-hw-oracle
XDG_CACHE_HOME=rel rel/anyps5-hw-oracle

An empty HW_ORACLE_CACHE also falls through instead of overriding, so "overrides both" holds only for a non-empty value. That is the usual reading, so I don't think it needs a word. oracle_hip.py never reads CACHE, so the paragraph is right to stay under ### Linux.

Optional, and not this PR: a relative XDG_CACHE_HOME (row rel) is used as-is, relative to the cwd. The XDG spec says relative values should be ignored. That would be a code change in a separate PR, if anyone wants it.

Gates: test_hw_oracle.py passes on Python 3.13 (OK, 3 skipped, no GPU). check_conventions.py --base upstream/main --head passes, git diff --check is clean, and merge-tree against main is clean. pr_overlap.py --branch reports "No overlap with open pull requests."

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5693216531 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12719#pullrequestreview-5693216531). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-29T05:21:44Z. **Review:** APPROVED --- Checked on macOS 26 arm64 at 664a5c93e8, against main 52c09d567d. **The new sentence matches the code.** `tools/hw-oracle/hw_oracle.py` L17 on main is `CACHE = Path(HW_ORACLE_CACHE or Path(XDG_CACHE_HOME or ~/.cache) / "anyps5-hw-oracle")`, and `build()` (L68) is the only reader. Because it uses `or`, an empty variable counts as unset, which is what "unset or empty" says. I printed `hw_oracle.CACHE` from a `git archive` of the PR head with `HOME=/tmp/h` and both variables cleared first. Python 3.9.6, 3.13 and 3.14 gave the same result for all 7 environments: | environment | CACHE | |---|---| | (none) | /tmp/h/.cache/anyps5-hw-oracle | | `XDG_CACHE_HOME=` | /tmp/h/.cache/anyps5-hw-oracle | | `XDG_CACHE_HOME=/tmp/xdg` | /tmp/xdg/anyps5-hw-oracle | | `HW_ORACLE_CACHE=/tmp/o XDG_CACHE_HOME=/tmp/xdg` | /tmp/o | | `HW_ORACLE_CACHE= XDG_CACHE_HOME=/tmp/xdg` | /tmp/xdg/anyps5-hw-oracle | | `HW_ORACLE_CACHE= XDG_CACHE_HOME=` | /tmp/h/.cache/anyps5-hw-oracle | | `XDG_CACHE_HOME=rel` | rel/anyps5-hw-oracle | An empty `HW_ORACLE_CACHE` also falls through instead of overriding, so "overrides both" holds only for a non-empty value. That is the usual reading, so I don't think it needs a word. `oracle_hip.py` never reads `CACHE`, so the paragraph is right to stay under `### Linux`. Optional, and not this PR: a relative `XDG_CACHE_HOME` (row `rel`) is used as-is, relative to the cwd. The XDG spec says relative values should be ignored. That would be a code change in a separate PR, if anyone wants it. Gates: `test_hw_oracle.py` passes on Python 3.13 (OK, 3 skipped, no GPU). `check_conventions.py --base upstream/main --head` passes, `git diff --check` is clean, and `merge-tree` against main is clean. `pr_overlap.py --branch` reports "No overlap with open pull requests."
THEMANnt commented 2026-10-29 07:08:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-29T07:08:07Z.

Review: APPROVED


Reviewed 664a5c93e8e9288e4ffacdf1495c6f4f6aa16fa5 against 52c09d567d2fa453494dd720fcf53a98149468e4. The pinned oracle runner selects HW_ORACLE_CACHE first, then nonempty XDG_CACHE_HOME/anyps5-hw-oracle, then ~/.cache/anyps5-hw-oracle. The revised fallback and override wording matches that expression. No actionable finding in the documentation change.

Validation: inspected the changed wording and relevant pinned source; relative source links and git diff --check pass. Documentation-only validation: no runtime behavior changed. Author-reported title inventories, console/emulator observations and macOS/physical-GPU measurements were not independently reproduced; this review does not certify those measurements.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5694040344 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12719#pullrequestreview-5694040344). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-29T07:08:07Z. **Review:** APPROVED --- Reviewed `664a5c93e8e9288e4ffacdf1495c6f4f6aa16fa5` against `52c09d567d2fa453494dd720fcf53a98149468e4`. The pinned oracle runner selects HW_ORACLE_CACHE first, then nonempty XDG_CACHE_HOME/anyps5-hw-oracle, then ~/.cache/anyps5-hw-oracle. The revised fallback and override wording matches that expression. No actionable finding in the documentation change. Validation: inspected the changed wording and relevant pinned source; relative source links and git diff --check pass. Documentation-only validation: no runtime behavior changed. Author-reported title inventories, console/emulator observations and macOS/physical-GPU measurements were not independently reproduced; this review does not certify those measurements.
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!12719
No description provided.