feat(libSceNpTrophy2,libSceNpUniversalDataSystem): unlock progressive trophies through _UpdateTrophyProgress #9562

Merged
milescoviello merged 2 commits from upstream-pr/9562 into main 2026-10-25 18:45:49 +00:00
milescoviello commented 2026-10-22 02:25:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-22T02:25:10Z.


What

Progressive trophies never unlock and always report 0 progress. Titles report a progressive trophy's progress with _UpdateTrophyProgress. main dropped that event ("trophy progress is not recorded"), and also skipped the statistic and rule a title's udsNN.ucp ships to carry it. Borderlands 4 (PPSA01494) ships this shape for 21 of its 64 trophies, and Forspoken (PPSA03984) for 23. In Borderlands 4:

  • The trophy: trophy00.ucp gives trophy 5 "unlockCondition":{"udsStatId":"116","comparator":"ge","targetValue":"60","progressive":true}.
  • The statistic: stats_definition.json defines stat 116 as "dataType":"int32","aggregation":"max","minValue":"0","initialValue":"0".
  • The rule: stats_extraction.json has "condition":{"eventName":"_UpdateTrophyProgress","property":{"path":"$._trophy_id","comparator":"==","value":"5"}}, with "action":{"input":"$._trophy_progress","output":{"statId":116}}.

On main the boot log lists all three as unsupported: stat 116 has aggregation "max"; only "latest" is supported, ... filters _UpdateTrophyProgress by more than its eventName; only eventName conditions are supported.

The changes:

  • max statistics keep the largest value posted. They start from initialValue, or from minValue without one. StatStore::Raise does the compare and store under the store's lock, so two posts can't lose the larger value.
  • int32 statistics take values from 0 to 2147483647. A negative minValue still refuses, with its own text.
  • A rule condition may be an eventName plus one property whose path is a $.name path, whose comparator is == and whose value is an unsigned integer. The rule then applies only to events whose property holds that integer. Any other comparator, a value that isn't an unsigned integer, or more condition members still skip the rule, with a message that says what is supported.
  • _UpdateTrophyProgress now goes through the title's statistic rules like any other event. The trophy store's existing stat path then reports the progress and unlocks the trophy at its target, and the platinum with it.
  • _UnlockTrophy is unchanged: it still unlocks directly, not through its count statistic.
  • Other aggregations (sum, count, collection, eachLatest) are still skipped.
  • The debt entries say max, int32 and the property filter follow the rules titles ship, not a console measurement.

Tested

  • Independent run by @Dextroid17 (comment): CachyOS, GCC 16.2.1, Release with SPIRV-Tools on. The same 8 trophy/UDS tests pass 3 of 3 on 905d880156 and on it merged with main 2e22b67032. Three negative controls each fail 3 of 3: the old Event.cpp, dropping the rule.filter check, and dropping the Max/Raise branch.

  • Rebased onto main 4777caca34 as eb60099724, with no conflicts; git range-diff shows the commit unchanged. The only trophy-side change on main since the previous base is #9433's new PS4 libSceNpTrophy library, which uses none of the shared code this PR changes. On eb60099724 the seven tests pass 3 of 3 on Linux (Ubuntu 26.04.1, GCC 15.2, Release). The earlier rebase onto main dce41a8947 (head b21f0b7e88) passed the same 3 of 3. The results below are from the pre-rebase head.

  • Linux (Ubuntu 26.04.1, GCC 15.2, Release), head 259922dc10 on a6dcea9279: the seven trophy and UDS tests (guest_nptrophy2, np_trophy2_store, np_trophy2_package, np_uds_events, guest_np_trophy_unlocks, guest_np_trophy_data, guest_np_trophy_stats) pass 3 of 3.

  • Windows 11 VM (WinLibs GCC 15.2.0, Release): the same seven pass 3 of 3 on this head and 3 of 3 on its merge base.

  • New tests:

    • np_trophy2_package (testStatRules, testProgressRules): max statistics, from their initialValue and never going down, int32 bounds, == property filters (a matching id updates, another id or a missing or negative id doesn't), the refusal texts, and StatStore::Raise across a restart.
    • guest_np_trophy_stats (RecordTrophyProgress): Borderlands 4's shape end to end through sceNpUniversalDataSystemPostEvent. Progress 4 then 2 reports 4, the other trophy stays at 0, 3 of 3 unlocks the second trophy, 12 of 10 unlocks the first and the platinum, and the stats file keeps 112 12 and 113 3.
    • Red check: with main's sources and this branch's GuestNpTrophyStats.cpp (keeping main's sum message, so the run reaches the new case), guest_np_trophy_stats aborts with trophy progress was not recorded for its own trophy, after main logs [trophy] ignored _UpdateTrophyProgress {"_trophy_id":1,"_trophy_progress":4} posted to context 6: trophy progress is not recorded. With this branch's sources restored it passes again. np_trophy2_package doesn't build against main, since it uses StatAggregation, StatFilter and StatStore::Raise.
  • Real title data: I compiled TrophyPackage.cpp from main and from this head into a small host program and parsed the titles' own trophy00.ucp and uds00.ucp. It counts the progressive trophies whose udsStatId a rule feeds:

    title main this PR
    Borderlands 4 (PPSA01494) 0 stats, 0 rules; 0 of 21 progressive trophies fed 21 stats, 21 rules for _UpdateTrophyProgress; 21 of 21
    Forspoken (PPSA03984) 0 stats, 0 rules; 0 of 23 31 stats, 31 rules for 9 events; 23 of 23
    ASTRO BOT (PPSA21564) 8 of 8 (latest statistics) 8 of 8

    The other six titles I have (Ghost of Tsushima, Metal Gear Solid 4, Crimson Desert, MXGP 26, Super Meat Boy 3D, Call of Duty Black Ops 2) have no progressive trophies.

  • Not tested: a title posting _UpdateTrophyProgress during play. None of my runs got far enough to post one, and none of 658 earlier run logs contains a posted progress event. macOS.

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:4961157092 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9562). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-22T02:25:10Z. --- ### What Progressive trophies never unlock and always report 0 progress. Titles report a progressive trophy's progress with `_UpdateTrophyProgress`. `main` dropped that event ("trophy progress is not recorded"), and also skipped the statistic and rule a title's `udsNN.ucp` ships to carry it. Borderlands 4 (PPSA01494) ships this shape for 21 of its 64 trophies, and Forspoken (PPSA03984) for 23. In Borderlands 4: - **The trophy:** `trophy00.ucp` gives trophy 5 `"unlockCondition":{"udsStatId":"116","comparator":"ge","targetValue":"60","progressive":true}`. - **The statistic:** `stats_definition.json` defines stat 116 as `"dataType":"int32","aggregation":"max","minValue":"0","initialValue":"0"`. - **The rule:** `stats_extraction.json` has `"condition":{"eventName":"_UpdateTrophyProgress","property":{"path":"$._trophy_id","comparator":"==","value":"5"}}`, with `"action":{"input":"$._trophy_progress","output":{"statId":116}}`. On `main` the boot log lists all three as unsupported: `stat 116 has aggregation "max"; only "latest" is supported`, `... filters _UpdateTrophyProgress by more than its eventName; only eventName conditions are supported`. **The changes:** - **`max` statistics** keep the largest value posted. They start from `initialValue`, or from `minValue` without one. `StatStore::Raise` does the compare and store under the store's lock, so two posts can't lose the larger value. - **`int32` statistics** take values from 0 to 2147483647. A negative `minValue` still refuses, with its own text. - **A rule condition** may be an `eventName` plus one `property` whose `path` is a `$.name` path, whose `comparator` is `==` and whose `value` is an unsigned integer. The rule then applies only to events whose property holds that integer. Any other comparator, a value that isn't an unsigned integer, or more condition members still skip the rule, with a message that says what is supported. - **`_UpdateTrophyProgress`** now goes through the title's statistic rules like any other event. The trophy store's existing stat path then reports the progress and unlocks the trophy at its target, and the platinum with it. - `_UnlockTrophy` is unchanged: it still unlocks directly, not through its `count` statistic. - Other aggregations (`sum`, `count`, `collection`, `eachLatest`) are still skipped. - The debt entries say `max`, `int32` and the property filter follow the rules titles ship, not a console measurement. ### Tested - **Independent run** by @Dextroid17 ([comment](https://github.com/boykopovar/AnyPS5/pull/9562#issuecomment-6391796840)): CachyOS, GCC 16.2.1, Release with SPIRV-Tools on. The same 8 trophy/UDS tests pass 3 of 3 on `905d880156` and on it merged with `main` 2e22b67032. Three negative controls each fail 3 of 3: the old `Event.cpp`, dropping the `rule.filter` check, and dropping the Max/Raise branch. - **Rebased** onto `main` 4777caca34 as `eb60099724`, with no conflicts; `git range-diff` shows the commit unchanged. The only trophy-side change on `main` since the previous base is #9433's new PS4 `libSceNpTrophy` library, which uses none of the shared code this PR changes. On `eb60099724` the seven tests pass 3 of 3 on Linux (Ubuntu 26.04.1, GCC 15.2, Release). The earlier rebase onto `main` dce41a8947 (head `b21f0b7e88`) passed the same 3 of 3. The results below are from the pre-rebase head. - **Linux** (Ubuntu 26.04.1, GCC 15.2, Release), head `259922dc10` on `a6dcea9279`: the seven trophy and UDS tests (`guest_nptrophy2`, `np_trophy2_store`, `np_trophy2_package`, `np_uds_events`, `guest_np_trophy_unlocks`, `guest_np_trophy_data`, `guest_np_trophy_stats`) pass 3 of 3. - **Windows 11 VM** (WinLibs GCC 15.2.0, Release): the same seven pass 3 of 3 on this head and 3 of 3 on its merge base. - **New tests:** - `np_trophy2_package` (`testStatRules`, `testProgressRules`): `max` statistics, from their `initialValue` and never going down, `int32` bounds, `==` property filters (a matching id updates, another id or a missing or negative id doesn't), the refusal texts, and `StatStore::Raise` across a restart. - `guest_np_trophy_stats` (`RecordTrophyProgress`): Borderlands 4's shape end to end through `sceNpUniversalDataSystemPostEvent`. Progress 4 then 2 reports 4, the other trophy stays at 0, 3 of 3 unlocks the second trophy, 12 of 10 unlocks the first and the platinum, and the stats file keeps `112 12` and `113 3`. - Red check: with `main`'s sources and this branch's `GuestNpTrophyStats.cpp` (keeping `main`'s `sum` message, so the run reaches the new case), `guest_np_trophy_stats` aborts with `trophy progress was not recorded for its own trophy`, after `main` logs `[trophy] ignored _UpdateTrophyProgress {"_trophy_id":1,"_trophy_progress":4} posted to context 6: trophy progress is not recorded`. With this branch's sources restored it passes again. `np_trophy2_package` doesn't build against `main`, since it uses `StatAggregation`, `StatFilter` and `StatStore::Raise`. - **Real title data:** I compiled `TrophyPackage.cpp` from `main` and from this head into a small host program and parsed the titles' own `trophy00.ucp` and `uds00.ucp`. It counts the progressive trophies whose `udsStatId` a rule feeds: | title | `main` | this PR | |---|---|---| | Borderlands 4 (PPSA01494) | 0 stats, 0 rules; 0 of 21 progressive trophies fed | 21 stats, 21 rules for `_UpdateTrophyProgress`; 21 of 21 | | Forspoken (PPSA03984) | 0 stats, 0 rules; 0 of 23 | 31 stats, 31 rules for 9 events; 23 of 23 | | ASTRO BOT (PPSA21564) | 8 of 8 (`latest` statistics) | 8 of 8 | The other six titles I have (Ghost of Tsushima, Metal Gear Solid 4, Crimson Desert, MXGP 26, Super Meat Boy 3D, Call of Duty Black Ops 2) have no progressive trophies. - **Not tested:** a title posting `_UpdateTrophyProgress` during play. None of my runs got far enough to post one, and none of 658 earlier run logs contains a posted progress event. macOS. ### 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 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)
MarcZX10 commented 2026-10-22 04:02:03 +00:00 (Migrated from github.com)

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

Review: CHANGES_REQUESTED


The parser/store changes are backed by targeted tests for max, int32, initial values, property filters, restart persistence and the Borderlands 4 trophy-progress path. The reported red/green and Linux/Windows runs are author-reported; hosted conventions, eligibility, intake, labels and report checks pass, while hosted product/relinker jobs are skipped. I did not run tests locally.

One repository rule remains before approval: this branch is based on 6ef5a1c4, while current upstream main is d9c99c9 (after #8204). The intervening main change appears unrelated, but CONTRIBUTING requires the branch to stay current. Please rebase/merge current main and rerun the focused seven trophy/UDS tests on the resulting head; update the Tested section to identify that head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5609105939 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9562#pullrequestreview-5609105939). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T04:02:03Z. **Review:** CHANGES_REQUESTED --- The parser/store changes are backed by targeted tests for `max`, `int32`, initial values, property filters, restart persistence and the Borderlands 4 trophy-progress path. The reported red/green and Linux/Windows runs are author-reported; hosted conventions, eligibility, intake, labels and report checks pass, while hosted product/relinker jobs are skipped. I did not run tests locally. One repository rule remains before approval: this branch is based on `6ef5a1c4`, while current upstream `main` is `d9c99c9` (after #8204). The intervening main change appears unrelated, but CONTRIBUTING requires the branch to stay current. Please rebase/merge current `main` and rerun the focused seven trophy/UDS tests on the resulting head; update the Tested section to identify that head.
milescoviello commented 2026-10-22 04:12:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-22T04:12:59Z.


@MarcZX10 rebased onto main dce41a8947, with no conflicts, as head b21f0b7e88. The seven trophy and UDS tests pass 3 of 3 on it (Linux, Release), and the Tested section now names that head.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6332510874 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9562#issuecomment-6332510874). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-22T04:12:59Z. --- @MarcZX10 rebased onto `main` dce41a8947, with no conflicts, as head `b21f0b7e88`. The seven trophy and UDS tests pass 3 of 3 on it (Linux, Release), and the Tested section now names that head. AI-assisted: yes (Claude Code)
MarcZX10 commented 2026-10-22 11:21:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T11:21:23Z.


Thanks for rebasing and rerunning the seven focused tests. The specific blocker in my earlier review is resolved: you report those tests passing 3/3 on the rebased head, and hosted eligibility, labels, report, and conventions checks succeed (the product and relinker jobs are skipped). I also checked the intervening upstream changes: they do touch the same TrophyPackage/TrophyStore/TitleTrophies code, but the three-way merge is clean and there are no later main commits on these paths. The remaining repository-rule issue is freshness: this head is 1 commit ahead and 92 behind current upstream/main (merge base dce41a894), so please update to current main and rerun the focused trophy/UDS suite before merge. I did not run the C++ tests locally; the available filesystem has no free space, so I’m treating the posted test results as author-reported. The PR’s checklist and Tested section otherwise give the title data, supported JSON shapes, negative control, and untested real-title posting limitation needed to assess the scope.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6339501715 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9562#issuecomment-6339501715). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T11:21:23Z. --- Thanks for rebasing and rerunning the seven focused tests. The specific blocker in my earlier review is resolved: you report those tests passing 3/3 on the rebased head, and hosted eligibility, labels, report, and conventions checks succeed (the product and relinker jobs are skipped). I also checked the intervening upstream changes: they do touch the same TrophyPackage/TrophyStore/TitleTrophies code, but the three-way merge is clean and there are no later main commits on these paths. The remaining repository-rule issue is freshness: this head is 1 commit ahead and 92 behind current upstream/main (merge base dce41a894), so please update to current main and rerun the focused trophy/UDS suite before merge. I did not run the C++ tests locally; the available filesystem has no free space, so I’m treating the posted test results as author-reported. The PR’s checklist and Tested section otherwise give the title data, supported JSON shapes, negative control, and untested real-title posting limitation needed to assess the scope.
MarcZX10 commented 2026-10-22 11:21:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T11:21:25Z.

Review: DISMISSED


The prior current-main/test blocker is resolved on b21f0b7e88, and the targeted evidence is detailed. One current blocker remains: upstream main is 4777caca34, while this branch is 1 ahead/92 behind (merge base dce41a894). CONTRIBUTING requires the branch to stay current; please update it and rerun the focused seven trophy/UDS tests before merge. I did not run the tests locally because this environment's filesystem is full, so the Linux results are author-reported. Hosted eligibility, labels, report, and conventions succeed; product and relinker jobs are skipped.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5613362874 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9562#pullrequestreview-5613362874). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T11:21:25Z. **Review:** DISMISSED --- The prior current-main/test blocker is resolved on b21f0b7e88, and the targeted evidence is detailed. One current blocker remains: upstream main is 4777caca34, while this branch is 1 ahead/92 behind (merge base dce41a894). CONTRIBUTING requires the branch to stay current; please update it and rerun the focused seven trophy/UDS tests before merge. I did not run the tests locally because this environment's filesystem is full, so the Linux results are author-reported. Hosted eligibility, labels, report, and conventions succeed; product and relinker jobs are skipped.
milescoviello commented 2026-10-22 11:33:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-22T11:33:22Z.


@MarcZX10 rebased onto current main 4777caca34 as eb60099724, with no conflicts. git range-diff shows the commit unchanged.

The only trophy-side change on main since the last base is #9433's new PS4 libSceNpTrophy, which doesn't use the shared package, store or title-trophy code this PR changes. On the new head the seven trophy/UDS tests pass 3 of 3 on Linux. Tested names the head.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6339718188 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9562#issuecomment-6339718188). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-22T11:33:22Z. --- @MarcZX10 rebased onto current `main` 4777caca34 as `eb60099724`, with no conflicts. `git range-diff` shows the commit unchanged. The only trophy-side change on `main` since the last base is #9433's new PS4 `libSceNpTrophy`, which doesn't use the shared package, store or title-trophy code this PR changes. On the new head the seven trophy/UDS tests pass 3 of 3 on Linux. Tested names the head. AI-assisted: yes (Claude Code)
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!9562
No description provided.