Skip to content

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

Merged
adriadam10 merged 2 commits into
boykopovar:mainfrom
milescoviello:feat/uds-trophy-progress
Oct 25, 2026
Merged

adriadam10 merged 2 commits into
boykopovar:mainfrom
milescoviello:feat/uds-trophy-progress

Conversation

@milescoviello

@milescoviello milescoviello commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

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 2e22b67. 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 4777cac as eb60099724, with no conflicts; git range-diff shows the commit unchanged. The only trophy-side change on main since the previous base is feat: PS4 NpTrophy, save data v1, NpWebApi offline and Limbo's other imports #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 dce41a8 (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

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 3786 docs/user/USAGE.md
PR 5021 docs/user/USAGE.md
PR 5925 docs/user/USAGE.md
PR 6171 docs/user/USAGE.md
PR 6924 docs/user/USAGE.md
PR 7642 docs/user/USAGE.md
PR 9345 docs/user/USAGE.md
PR 9508 docs/user/USAGE.md
PR 10193 docs/user/USAGE.md

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
milescoviello force-pushed the feat/uds-trophy-progress branch from 259922d to b21f0b7 Compare October 22, 2026 04:12
@milescoviello

Copy link
Copy Markdown
Contributor Author

@MarcZX10 rebased onto main dce41a8, 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

Copy link
Copy Markdown
Contributor

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 dce41a8), 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 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prior current-main/test blocker is resolved on b21f0b7, and the targeted evidence is detailed. One current blocker remains: upstream main is 4777cac, while this branch is 1 ahead/92 behind (merge base dce41a8). 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
milescoviello force-pushed the feat/uds-trophy-progress branch from b21f0b7 to eb60099 Compare October 22, 2026 11:32
@milescoviello

Copy link
Copy Markdown
Contributor Author

@MarcZX10 rebased onto current main 4777cac 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)

@milescoviello
milescoviello force-pushed the feat/uds-trophy-progress branch from eb60099 to 905d880 Compare October 25, 2026 00:24
@milescoviello

Copy link
Copy Markdown
Contributor Author

@MarcZX10 rebased onto current main cf528e7 as you asked; head 905d880156, one commit, no conflicts. Linux (Ubuntu 26.04.1, GCC 15.2, Release): the 8 trophy and UDS tests (guest_np_trophy, 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. tools/check_conventions.py passes.

AI-assisted: yes (Claude Code)

@Dextroid17

Copy link
Copy Markdown
Contributor

@MarcZX10, your review (5613362874, on b21f0b7e88) noted the Linux results were author-reported because you could not run the tests locally. This repeats milescoviello's Linux run (comment 6391396790) independently, on a different distro and compiler, and adds a negative control.

Setup: CachyOS x86_64, GCC 16.2.1, Release, configured with the CI Linux flags without ccache (-G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DANYPS5_ENABLE_SPIRV_TOOLS=ON). Two trees: the head 905d880156 (parent cf528e78c6), and the head merged with today's main 2e22b67032 (15 commits newer, none touching the trophy/UDS libraries; clean merge, a645c2dbd1).

Tests (ctest): the seven trophy/UDS tests the PR lists plus guest_np_trophy, the same 8 as the author's latest comment (guest_np_trophy, guest_nptrophy2, np_trophy2_store, np_trophy2_package, np_uds_events, guest_np_trophy_unlocks, guest_np_trophy_data, guest_np_trophy_stats) pass 8/8, 3 of 3 runs, on both trees.

Negative control (head tree): each row is one change, rebuilt, run 3 times, and failed the same way all 3 times.

change                                          fails                                  message
Event.cpp from cf528e78c6                       guest_np_trophy_stats                  trophy progress was not recorded for its own trophy
TitleTrophies.cpp: drop the rule.filter check   np_trophy2_package,                    a filtered rule did not take its trophy's progress, or another trophy's rule did
                                                guest_np_trophy_stats                  trophy progress was not recorded for its own trophy
TitleTrophies.cpp: drop the Max/Raise branch    np_trophy2_package,                    a max stat went down
                                                guest_np_trophy_stats                  lower trophy progress replaced higher progress

With the first change, the old trophy progress is not recorded log line comes back; this row repeats the red check in the PR body. With all files restored (git status clean), the 8 tests pass again.

Not covered: Windows and macOS, and a real title such as Borderlands 4.

AI-assisted: yes

@milescoviello

Copy link
Copy Markdown
Contributor Author

@Dextroid17 thank you, especially for the three negative controls: they pin each part of the change, not just the end result. I've added your run to Tested.

AI-assisted: yes (Claude Code)

@adriadam10 adriadam10 self-assigned this Oct 25, 2026
milescoviello and others added 2 commits October 25, 2026 17:24
… trophies through _UpdateTrophyProgress

Titles report a progressive trophy's progress with _UpdateTrophyProgress
events. Their udsNN.ucp rules feed $._trophy_progress into an int32
statistic with the max aggregation, filtered on $._trophy_id, and the
trophy's unlockCondition names that statistic. Those statistics and
rules were skipped and the events were dropped, so such trophies never
reported progress or unlocked (21 of Borderlands 4's 64).

- Read max statistics (largest value posted, from initialValue) and
  int32 statistics (0 to 2147483647).
- Read a rule condition with one == property equal to an unsigned
  integer, and apply the rule only to events whose property matches.
- Post _UpdateTrophyProgress through the statistic rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adriadam10
adriadam10 force-pushed the feat/uds-trophy-progress branch from 905d880 to 6ce060e Compare October 25, 2026 16:27
@adriadam10
adriadam10 dismissed MarcZX10’s stale review October 25, 2026 16:29

Dismissing a stale review: the requested changes were addressed after it (new head) and the merge queue blocks on it. Please request changes again if anything is still open.

@adriadam10
adriadam10 merged commit 58c9977 into boykopovar:main Oct 25, 2026
10 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the max/int32 statistics, the == property filter, StatStore::Raise (compare and store under the lock), the int32 bounds and the new tests (they need the new types and the guest case aborts on main). Added one commit: docs/user/USAGE.md still said only latest uint32/uint64 statistics are applied, now it lists max, int32 and the property filter. Merged.

@milescoviello

Copy link
Copy Markdown
Contributor Author

Thanks for the USAGE.md commit and for merging, @adriadam10.

AI-assisted: yes (Claude Code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants