fix(tools): check environment references from a subdirectory #9660

Merged
jotitadev merged 1 commit from upstream-pr/9660 into main 2026-10-23 06:26:23 +00:00
jotitadev commented 2026-10-22 07:04:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T07:04:45Z.


What

tools/check_conventions.py skips the env-reference rule when it runs from a subdirectory, for example cd tools && python3 check_conventions.py or python3 ../tools/check_conventions.py from a build folder. It prints "All conventions checks passed." and gives no warning.

#4368 fixed this for the rest of the checker (ls-tree --full-tree, git grep --full-name … :(top)core/libs/prx). env_reference() came later with #6078, and three of its git calls still take their paths from the current directory:

  • git diff -U0 <base> <head> -- core docs/dev/ENVIRONMENT.md: from tools/ the pathspecs mean tools/core and tools/docs/dev/ENVIRONMENT.md, so the diff is empty. No added read, removed read or removed row is seen.
  • git grep … <head> -- core: same pathspec problem, so the set of names the code still reads is empty.
  • git ls-tree --name-only <base> -- docs/dev/ENVIRONMENT.md: from a subdirectory it does not list the base branch's document, so rows that only the base branch has are not counted as documented.

The pathspecs now use :(top) (the grep also gets --full-name, as in unknown_nids()), and ls-tree gets --full-tree. CI runs from the repository root, where the output does not change.

Tested

macOS 27.2 arm64 (M2 Max), git 2.55, /usr/bin/python3 3.9.6 and Python 3.14.7, main 6ef5a1c4c, then rebased onto d6eafa54d with the new tests and check_conventions.py run again:

  • New test_a_check_from_a_subdirectory_reports_the_same_findings in test_check_conventions_env_reference.py. One branch adds an undocumented read, adds a read whose row only the base branch has, drops one of two reads of a documented name, and removes the row of a name nothing reads. It expects the same single finding from the root, core, core/libs/prx/libSceExample and docs/dev. With main's checker the three subdirectory runs report nothing. Putting back any one of the three old git calls fails the test again. The whole file passes on 3.9 and 3.14 (13 tests).
  • Repository check: a commit that adds std::getenv("ANYPS5_TOOLS_PROBE") to a library gets one env-reference error from the root. From tools/, main's checker passes it. With this change it reports the same error from the root, tools/, core/ and docs/.
  • Replay of 40 commits of main (--base <c>^1 --head <c>: the last 25 that add a getenv("A… read under core/ and the last 15 that touch docs/dev/ENVIRONMENT.md):
    • From the root, the output of this change matches main's checker for all 40.
    • From tools/, this change matches the root for all 40.
    • From tools/, main's checker misses the root's env-reference error on 3 of them: a07ad3057 (APS5_NO_HW_F32_PRESERVE), a55dc4c53 (APS5_NO_WGI) and b8607f4ce (APS5_VIDEOOUT_TELEMETRY_DIR).
  • The other 13 test_check_conventions_*.py files and test_env_reference.py pass on 3.9.
  • Merges cleanly with #8777 and #8995, the open PRs on check_conventions.py and env_reference.py. With both merged on top, test_check_conventions_env_reference.py, test_check_conventions_comments.py and test_env_reference.py pass on 3.9.
  • python3 tools/check_conventions.py --base origin/main passes. python3 tools/pr_overlap.py --branch fix/conventions-env-reference-from-subdirectory: no overlap.

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 (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4963472907 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9660). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-22T07:04:45Z. --- ### What `tools/check_conventions.py` skips the `env-reference` rule when it runs from a subdirectory, for example `cd tools && python3 check_conventions.py` or `python3 ../tools/check_conventions.py` from a build folder. It prints "All conventions checks passed." and gives no warning. #4368 fixed this for the rest of the checker (`ls-tree --full-tree`, `git grep --full-name … :(top)core/libs/prx`). `env_reference()` came later with #6078, and three of its git calls still take their paths from the current directory: - `git diff -U0 <base> <head> -- core docs/dev/ENVIRONMENT.md`: from `tools/` the pathspecs mean `tools/core` and `tools/docs/dev/ENVIRONMENT.md`, so the diff is empty. No added read, removed read or removed row is seen. - `git grep … <head> -- core`: same pathspec problem, so the set of names the code still reads is empty. - `git ls-tree --name-only <base> -- docs/dev/ENVIRONMENT.md`: from a subdirectory it does not list the base branch's document, so rows that only the base branch has are not counted as documented. The pathspecs now use `:(top)` (the grep also gets `--full-name`, as in `unknown_nids()`), and `ls-tree` gets `--full-tree`. CI runs from the repository root, where the output does not change. ### Tested macOS 27.2 arm64 (M2 Max), git 2.55, `/usr/bin/python3` 3.9.6 and Python 3.14.7, main 6ef5a1c4c, then rebased onto d6eafa54d with the new tests and `check_conventions.py` run again: - New `test_a_check_from_a_subdirectory_reports_the_same_findings` in `test_check_conventions_env_reference.py`. One branch adds an undocumented read, adds a read whose row only the base branch has, drops one of two reads of a documented name, and removes the row of a name nothing reads. It expects the same single finding from the root, `core`, `core/libs/prx/libSceExample` and `docs/dev`. With main's checker the three subdirectory runs report nothing. Putting back any one of the three old git calls fails the test again. The whole file passes on 3.9 and 3.14 (13 tests). - Repository check: a commit that adds `std::getenv("ANYPS5_TOOLS_PROBE")` to a library gets one `env-reference` error from the root. From `tools/`, main's checker passes it. With this change it reports the same error from the root, `tools/`, `core/` and `docs/`. - Replay of 40 commits of main (`--base <c>^1 --head <c>`: the last 25 that add a `getenv("A…` read under `core/` and the last 15 that touch `docs/dev/ENVIRONMENT.md`): - From the root, the output of this change matches main's checker for all 40. - From `tools/`, this change matches the root for all 40. - From `tools/`, main's checker misses the root's `env-reference` error on 3 of them: a07ad3057 (`APS5_NO_HW_F32_PRESERVE`), a55dc4c53 (`APS5_NO_WGI`) and b8607f4ce (`APS5_VIDEOOUT_TELEMETRY_DIR`). - The other 13 `test_check_conventions_*.py` files and `test_env_reference.py` pass on 3.9. - Merges cleanly with #8777 and #8995, the open PRs on `check_conventions.py` and `env_reference.py`. With both merged on top, `test_check_conventions_env_reference.py`, `test_check_conventions_comments.py` and `test_env_reference.py` pass on 3.9. - `python3 tools/check_conventions.py --base origin/main` passes. `python3 tools/pr_overlap.py --branch fix/conventions-env-reference-from-subdirectory`: no overlap. ### 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 (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fogydes commented 2026-10-22 08:43:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fogydes on 2026-10-22T08:43:30Z.


Reviewed; verified the diff and (via the tool's own test suite) both the fix and its failure mode. The three switched calls are exactly the ones env_reference() makes that were cwd-dependent: the diff pathspec now pinned with :(top)core/:(top)docs/..., the git grep with --full-name + :(top)core, and the ls-tree with --full-tree. The other git diff calls in the checker (--name-status etc.) print root-relative paths regardless of cwd, so no other rule needed the same treatment — I checked for that rather than assuming. The new test reports sibling results identical from root, core, core/libs/prx/libSceExample and docs/dev, and the same test run against main's checker fails with empty subdirectory findings, reproducing the claim. Deterministic output preserved; the pre-existing (unused) base/head params on findings_of remain untouched, correctly outside topic scope.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6336592431 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9660#issuecomment-6336592431). Originally posted by [fogydes](https://github.com/fogydes) on 2026-10-22T08:43:30Z. --- Reviewed; verified the diff and (via the tool's own test suite) both the fix and its failure mode. The three switched calls are exactly the ones `env_reference()` makes that were cwd-dependent: the diff pathspec now pinned with `:(top)core`/`:(top)docs/...`, the `git grep` with `--full-name` + `:(top)core`, and the `ls-tree` with `--full-tree`. The other `git diff` calls in the checker (`--name-status` etc.) print root-relative paths regardless of cwd, so no other rule needed the same treatment — I checked for that rather than assuming. The new test reports sibling results identical from root, `core`, `core/libs/prx/libSceExample` and `docs/dev`, and the same test run against main's checker fails with empty subdirectory findings, reproducing the claim. Deterministic output preserved; the pre-existing (unused) `base`/`head` params on `findings_of` remain untouched, correctly outside topic scope.
MarcZX10 commented 2026-10-22 09:10:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T09:10:47Z.

Review: CHANGES_REQUESTED


The root-relative path fixes are targeted and preserve root-run behavior. I ran the exact-head checker suites locally: all test_check_conventions_*.py tests pass (146/146), and test_env_reference.py passes (8/8). Exact-head diff-check and conventions pass; hosted conventions, eligibility, intake, labels and relinker Linux/Windows/macOS + ASan jobs pass. The new test verifies identical findings from the root and three nested directories. The body identifies #8777 and #8995 as related open tool changes and reports a clean combined test run.

I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5611813464 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9660#pullrequestreview-5611813464). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T09:10:47Z. **Review:** CHANGES_REQUESTED --- The root-relative path fixes are targeted and preserve root-run behavior. I ran the exact-head checker suites locally: all `test_check_conventions_*.py` tests pass (146/146), and `test_env_reference.py` passes (8/8). Exact-head diff-check and conventions pass; hosted conventions, eligibility, intake, labels and relinker Linux/Windows/macOS + ASan jobs pass. The new test verifies identical findings from the root and three nested directories. The body identifies #8777 and #8995 as related open tool changes and reports a clean combined test run. I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.
jotitadev commented 2026-10-22 09:27:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T09:27:43Z.


Thanks for the review. Marked as draft to hold it under #5239 until the open queue is below 700 or a title needs it; I'll mark it ready then.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6337429658 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9660#issuecomment-6337429658). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-22T09:27:43Z. --- Thanks for the review. Marked as draft to hold it under #5239 until the open queue is below 700 or a title needs it; I'll mark it ready then.
MarcZX10 commented 2026-10-22 14:31:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T14:31:03Z.

Review: APPROVED


Correction: my earlier changes-requested review was based only on a mistaken queue hold tied to #5239. My review found no code blocker; PRs may continue to be submitted and will be handled in due course.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5615878358 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9660#pullrequestreview-5615878358). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T14:31:03Z. **Review:** APPROVED --- Correction: my earlier changes-requested review was based only on a mistaken queue hold tied to #5239. My review found no code blocker; PRs may continue to be submitted and will be handled in due course.
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!9660
No description provided.