fix(libSceNpTrophy2): keep stat rules labelled with their stat's name #18642

Merged
JJenkx merged 1 commit from upstream-pr/18642 into main 2026-11-13 01:06:12 +00:00
JJenkx commented 2026-11-11 23:28:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-11T23:28:47Z.


What

Since 47101d6e4b (#15951), ParseStatRules skips a statistics rule whose output has any member other than statId. The rules that titles ship in sce_sys/uds/udsNN.ucp label nearly every output with the stat's statName, and most also with its sourceId:

{"condition":{"eventName":"UDSUpdateTrophyProgress","property":{"path":"$.trophy_id","comparator":"==","value":"28"}},
 "action":{"input":"$.trophy_progress","output":{"statId":23,"statName":"CheckingOutCompetitionStat"}}}

These rules are now dropped with a [trophy] ... has unsupported output member "statName" line. In 21 of the titles below, this includes rules that feed a trophy's udsStatId, so those trophies no longer show progress or unlock through their statistic.

This keeps a rule whose output has statName or sourceId when each one is the string of the same name in the definition of the rule's statId. A label that names something else, or is not a string, still skips the rule with a [trophy] line. Output members other than these two are still skipped, as #15951 intended.

Evidence

Survey of the udsNN.ucp files of the 116 extracted titles here that have one:

  • 5648 rule outputs have only statId, statName and sourceId. In every one, statName and sourceId equal the members of the same name in that stat's stats_definition.json entry. No output has a label that differs.
  • 386 of those rules are otherwise supported (a latest/max stat of a supported type, a $.name input and a supported condition). 334 of them write a stat that a trophy names in udsStatId, in 21 titles.
  • Records written before #15951 show these rules in use. Astro Bot (PPSA21564) posts ResetAllCounters at start-up, and its record from 2 November holds stats 132 to 139, 143 and 269 to 273, all written by statName-labelled rules.

Tested

Current-main refresh, 2026-11-12: head 6bd7fa6b6d0655b225d37e22b824cf496fe2cfa8 rebases the approved change onto main a9e688d0a07659a45b55ae609ca22dd5a819aea2 without merge commits. Production/test changed lines are identical to c3d3d6a64a. The only conflict was adjacent debt text: retained this PR's extraction-label paragraph and main's merged #18640 greater-than condition paragraph.

Matched Linux CPU checks, with the same new TrophyPackage.cpp fixture on both arms, three full repetitions of ctest -R 'trophy|uds|universal' -V:

  • Main: 36 passes and 3 expected failures, all three in np_trophy2_package at the stat-label regression. The other 12 fixtures pass each time.
  • Refreshed branch: 39/39 passes, zero skips.
  • Actual provider/test hashes remain unchanged within each arm. Conventions and whitespace checks pass. A subsequent merge preview against main 673c517827f7 is clean; that newer preview tree was not executed.

Exact source pins, preservation/resolution proof, builds, verbose logs and JUnit, SHA-256 7d3ac37699fbe9e8802db7cac3c9f85838713c25c9b86cd2fd2eb78318fa8924; archive and all 26 members downloaded and hash-verified. This is a CPU refresh; the prior Astro Bot runs below keep their original pins. No new native, Windows, GPU, console or performance result is claimed.

  • np_trophy2_package_tests: the new testStatLabels keeps rules whose statName and sourceId match their stat's definition, skips a rule labelled with another stat's name or source or with a null label, and checks that only the kept rules copy their input. It fails on main at the first check and passes with this change.
  • All 13 trophy and UDS tests (ctest -R 'trophy|uds|universal') pass on this head (c3d3d6a64a), Linux, GCC 16, Release.
  • Astro Bot (PPSA21564), 125 s, record removed before each run, alternating main 9c9b19dd6e and this change on it (d735d4bb0d), two runs each: main writes no record and logs 86 statName skips per run; this change logs none and writes stats 132 to 139, 143 and 269 to 273 (all 0 after the title's ResetAllCounters), as its record from before #15951 holds. Linux 7.2.14, RX 6650 XT, RADV Mesa 26.2.6, Release. Details: https://github.com/boykopovar/AnyPS5/pull/18642#issuecomment-6812568741

#18640 has merged into main. This refresh retains its greater-than rule-condition support and its debt explanation alongside this PR’s output-label behavior. No open dependency is introduced.

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:5268389041 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18642). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-11-11T23:28:47Z. --- ### What Since 47101d6e4b (#15951), `ParseStatRules` skips a statistics rule whose `output` has any member other than `statId`. The rules that titles ship in `sce_sys/uds/udsNN.ucp` label nearly every output with the stat's `statName`, and most also with its `sourceId`: ```json {"condition":{"eventName":"UDSUpdateTrophyProgress","property":{"path":"$.trophy_id","comparator":"==","value":"28"}}, "action":{"input":"$.trophy_progress","output":{"statId":23,"statName":"CheckingOutCompetitionStat"}}} ``` These rules are now dropped with a `[trophy] ... has unsupported output member "statName"` line. In 21 of the titles below, this includes rules that feed a trophy's `udsStatId`, so those trophies no longer show progress or unlock through their statistic. This keeps a rule whose output has `statName` or `sourceId` when each one is the string of the same name in the definition of the rule's `statId`. A label that names something else, or is not a string, still skips the rule with a `[trophy]` line. Output members other than these two are still skipped, as #15951 intended. ### Evidence Survey of the `udsNN.ucp` files of the 116 extracted titles here that have one: - 5648 rule outputs have only `statId`, `statName` and `sourceId`. In every one, `statName` and `sourceId` equal the members of the same name in that stat's `stats_definition.json` entry. No output has a label that differs. - 386 of those rules are otherwise supported (a `latest`/`max` stat of a supported type, a `$.name` input and a supported condition). 334 of them write a stat that a trophy names in `udsStatId`, in 21 titles. - Records written before #15951 show these rules in use. Astro Bot (PPSA21564) posts `ResetAllCounters` at start-up, and its record from 2 November holds stats 132 to 139, 143 and 269 to 273, all written by `statName`-labelled rules. ### Tested <!-- codex-pr18642-refresh-20261112 --> **Current-main refresh, 2026-11-12:** head `6bd7fa6b6d0655b225d37e22b824cf496fe2cfa8` rebases the approved change onto main `a9e688d0a07659a45b55ae609ca22dd5a819aea2` without merge commits. Production/test changed lines are identical to `c3d3d6a64a`. The only conflict was adjacent debt text: retained this PR's extraction-label paragraph and main's merged #18640 greater-than condition paragraph. Matched Linux CPU checks, with the same new `TrophyPackage.cpp` fixture on both arms, three full repetitions of `ctest -R 'trophy|uds|universal' -V`: - Main: **36 passes and 3 expected failures**, all three in `np_trophy2_package` at the stat-label regression. The other 12 fixtures pass each time. - Refreshed branch: **39/39 passes**, zero skips. - Actual provider/test hashes remain unchanged within each arm. Conventions and whitespace checks pass. A subsequent merge preview against main `673c517827f7` is clean; that newer preview tree was not executed. [Exact source pins, preservation/resolution proof, builds, verbose logs and JUnit](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/pr18642-6bd7-main-a9e688-trophy-linux-20261112.tar.gz), SHA-256 `7d3ac37699fbe9e8802db7cac3c9f85838713c25c9b86cd2fd2eb78318fa8924`; archive and all 26 members downloaded and hash-verified. This is a CPU refresh; the prior Astro Bot runs below keep their original pins. No new native, Windows, GPU, console or performance result is claimed. - `np_trophy2_package_tests`: the new `testStatLabels` keeps rules whose `statName` and `sourceId` match their stat's definition, skips a rule labelled with another stat's name or source or with a null label, and checks that only the kept rules copy their input. It fails on main at the first check and passes with this change. - All 13 trophy and UDS tests (`ctest -R 'trophy|uds|universal'`) pass on this head (`c3d3d6a64a`), Linux, GCC 16, Release. - Astro Bot (PPSA21564), 125 s, record removed before each run, alternating `main` `9c9b19dd6e` and this change on it (`d735d4bb0d`), two runs each: `main` writes no record and logs 86 `statName` skips per run; this change logs none and writes stats 132 to 139, 143 and 269 to 273 (all 0 after the title's `ResetAllCounters`), as its record from before #15951 holds. Linux 7.2.14, RX 6650 XT, RADV Mesa 26.2.6, Release. Details: https://github.com/boykopovar/AnyPS5/pull/18642#issuecomment-6812568741 ### Related #18640 has merged into main. This refresh retains its greater-than rule-condition support and its debt explanation alongside this PR’s output-label behavior. No open dependency is introduced. ### 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
PrivacyOnion commented 2026-11-12 06:11:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-12T06:11:52Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against c3d3d6a64a:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: np_trophy2_package_tests built cleanly.
  • CTest (np_trophy2_package):
    1/1 Test #3897: np_trophy2_package ...............   Passed    1.69 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNpTrophy2/src/TrophyPackage.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #3897: np_trophy2_package ...............Subprocess aborted***Exception:   1.94 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • TrophyPackage.cpp readRule: Verified labels.at(*statId) pointer lookup safety; *statId is guaranteed to exist in labels because line 486 validates rules.stats.contains(*statId), which is populated exclusively in ParseStatRules where labels.try_emplace(*statId, &stats.items[index]) also records the definition pointer.
    • TrophyPackage.cpp readRule: Verified null and type checks for label and definition across keys 'statName' and 'sourceId': non-string labels, absent definition keys (definition == nullptr), mismatched values, and non-string definition fields safely append to rules.skipped and return early without null dereferences.
    • TrophyPackage.cpp ParseStatRules: Verified lifetime of StatLabels mapping std::uint64_t to const Json*: pointers to stats.items[index] remain valid across the scope of definitions in ParseStatRules, and no pointers escape into the returned StatRules object.
    • TrophyPackage.cpp readRule: Verified output member validation loop properly accepts 'statId', 'statName', and 'sourceId' while continuing to diagnose and skip any extraneous or unsupported action/output member.
    • tests/TrophyPackage.cpp testStatLabels: Verified test coverage exercises matching single/dual labels, mismatched labels, missing definition members, null labels, and stat application via ApplyStatRules, with all test artifacts cleaned up in the temporary directory.
    • docs/dev/debt/libSceNpTrophy2.md and AGENTS.md rules: Verified zero comments were added to code, conventional commit format is preserved, and the debt file accurately documents the behavior gap for mismatched output labels.
  • Minor: please drop the Generated with footer from the description; the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5869920513 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18642#pullrequestreview-5869920513). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-12T06:11:52Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `c3d3d6a64a`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `np_trophy2_package_tests` built cleanly. - **CTest** (`np_trophy2_package`): ``` 1/1 Test #3897: np_trophy2_package ............... Passed 1.69 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNpTrophy2/src/TrophyPackage.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/1 Test #3897: np_trophy2_package ...............Subprocess aborted***Exception: 1.94 sec 0% tests passed, 1 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - TrophyPackage.cpp readRule: Verified labels.at(*statId) pointer lookup safety; *statId is guaranteed to exist in labels because line 486 validates rules.stats.contains(*statId), which is populated exclusively in ParseStatRules where labels.try_emplace(*statId, &stats.items[index]) also records the definition pointer. - TrophyPackage.cpp readRule: Verified null and type checks for label and definition across keys 'statName' and 'sourceId': non-string labels, absent definition keys (definition == nullptr), mismatched values, and non-string definition fields safely append to rules.skipped and return early without null dereferences. - TrophyPackage.cpp ParseStatRules: Verified lifetime of StatLabels mapping std::uint64_t to const Json*: pointers to stats.items[index] remain valid across the scope of definitions in ParseStatRules, and no pointers escape into the returned StatRules object. - TrophyPackage.cpp readRule: Verified output member validation loop properly accepts 'statId', 'statName', and 'sourceId' while continuing to diagnose and skip any extraneous or unsupported action/output member. - tests/TrophyPackage.cpp testStatLabels: Verified test coverage exercises matching single/dual labels, mismatched labels, missing definition members, null labels, and stat application via ApplyStatRules, with all test artifacts cleaned up in the temporary directory. - docs/dev/debt/libSceNpTrophy2.md and AGENTS.md rules: Verified zero comments were added to code, conventional commit format is preserved, and the debt file accurately documents the behavior gap for mismatched output labels. - Minor: please drop the `Generated with` footer from the description; the AI-assisted checkbox can stay. Looks Good To Me
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!18642
No description provided.