fix(libSceNpEntitlementAccess): make abort and delete request idempotent #11941

Merged
akkadbakkad89 merged 2 commits from upstream-pr/11941 into main 2026-10-30 01:03:58 +00:00
akkadbakkad89 commented 2026-10-27 13:15:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-10-27T13:15:20Z.


What

sceNpEntitlementAccessAbortRequest and sceNpEntitlementAccessDeleteRequest threw not implemented. Both now ignore the request ID and return 0.

Every request-creating call in the library fails SCE_NP_ERROR_SIGNED_OUT before minting an ID, so no request can ever exist and the library keeps no request table. Aborting or deleting therefore has nothing to act on; the remaining question was the result code, and there are two sources:

  • sharpemu NpEntitlementAccessExports.cs implements both as unconditional ORBIS_GEN2_OK for Gen4 and Gen5, asserted by its EntitlementRequestLifecycle_AbortAndDeleteSucceedWithNoRequestsOutstanding test (abort of ID 1, delete called twice, all return 0). The library's debt file already cites sharpemu for sceNpEntitlementAccessGetGameTrialsFlag/sceNpEntitlementAccessGetPftFlag.
  • A RAGE title's rlNpSetEntitlementCountWorkItem calls AbortRequest only on the SCE_NP_ENTITLEMENT_ACCESS_ERROR_ABORTED poll path and DeleteRequest unconditionally at cleanup; ret < SCE_OK from either is logged and the work item continues, so an error result is tolerated but success is the intended answer.

SCE_NP_ENTITLEMENT_ACCESS_ERROR_NOT_FOUND (0x80558007) was considered and rejected: sharpemu's contract returns OK for an ID that was never created, and titles call delete unconditionally on cleanup of IDs that were never successfully requested.

The debt entry now records the contract, the source and the remaining unknown (aborting or deleting an ID a signed-in console's table would still hold is unmeasured).

Same-file adjacency, no functional overlap: #8646 implements the consumable request/poll trio (different exports, currently conflicting with base), #11909 adds signed-out/parameter coverage to the same test file (text-level conflict only), #11529 rewrites the neighbouring GetEntitlementKey debt bullet.

Tested

Windows 11, WinLibs MinGW-w64 GCC, Ninja Release, BUILD_TESTING=ON, bundled dependencies. guest_entitlements extended: abort and delete each return 0 for request IDs 0, 1, -7 and INT64_MAX, delete twice in a row returns 0. ctest -R '^guest_entitlements' -V: 2/2 passed. python tools/check_conventions.py --base origin/main passes. tools/pr_overlap.py --branch run; shared-file PRs listed above. No title or console was run.

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: #11529 and #11909 — this PR lands last: #11529 (approved, debt file) and #11909 (test file) merge first in either order; this branch is then rebased onto the result before merge
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5034522028 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11941). Originally posted by [akkadbakkad89](https://github.com/akkadbakkad89) on 2026-10-27T13:15:20Z. --- ### What `sceNpEntitlementAccessAbortRequest` and `sceNpEntitlementAccessDeleteRequest` threw `not implemented`. Both now ignore the request ID and return 0. Every request-creating call in the library fails `SCE_NP_ERROR_SIGNED_OUT` before minting an ID, so no request can ever exist and the library keeps no request table. Aborting or deleting therefore has nothing to act on; the remaining question was the result code, and there are two sources: - [sharpemu `NpEntitlementAccessExports.cs`](https://github.com/sharpemu/sharpemu-mac/blob/main/src/SharpEmu.Libs/Np/NpEntitlementAccessExports.cs) implements both as unconditional `ORBIS_GEN2_OK` for Gen4 and Gen5, asserted by its `EntitlementRequestLifecycle_AbortAndDeleteSucceedWithNoRequestsOutstanding` test (abort of ID 1, delete called twice, all return 0). The library's debt file already cites sharpemu for `sceNpEntitlementAccessGetGameTrialsFlag`/`sceNpEntitlementAccessGetPftFlag`. - A RAGE title's `rlNpSetEntitlementCountWorkItem` calls `AbortRequest` only on the `SCE_NP_ENTITLEMENT_ACCESS_ERROR_ABORTED` poll path and `DeleteRequest` unconditionally at cleanup; `ret < SCE_OK` from either is logged and the work item continues, so an error result is tolerated but success is the intended answer. `SCE_NP_ENTITLEMENT_ACCESS_ERROR_NOT_FOUND` (`0x80558007`) was considered and rejected: sharpemu's contract returns OK for an ID that was never created, and titles call delete unconditionally on cleanup of IDs that were never successfully requested. The debt entry now records the contract, the source and the remaining unknown (aborting or deleting an ID a signed-in console's table would still hold is unmeasured). Same-file adjacency, no functional overlap: #8646 implements the consumable request/poll trio (different exports, currently conflicting with base), #11909 adds signed-out/parameter coverage to the same test file (text-level conflict only), #11529 rewrites the neighbouring `GetEntitlementKey` debt bullet. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11, WinLibs MinGW-w64 GCC, Ninja Release, `BUILD_TESTING=ON`, bundled dependencies. `guest_entitlements` extended: abort and delete each return 0 for request IDs 0, 1, -7 and `INT64_MAX`, delete twice in a row returns 0. `ctest -R '^guest_entitlements' -V`: 2/2 passed. `python tools/check_conventions.py --base origin/main` passes. `tools/pr_overlap.py --branch` run; shared-file PRs listed above. No title or console was run. ### 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: #11529 and #11909 — this PR lands last: #11529 (approved, debt file) and #11909 (test file) merge first in either order; this branch is then rebased onto the result before merge - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-27 13:30:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T13:30:45Z.

Review: CHANGES_REQUESTED


Reviewed exact head 96812a0ae732e8d351872973cafce723b553cee1. The two exports ignore the ID and return success; the test covers zero, positive, negative and maximum IDs plus repeated delete. The signed-out request functions in this library do not mint IDs, and the debt entry preserves the unmeasured signed-in/table-held case. Hosted Windows build and policy checks pass; the PR reports guest_entitlements passing 2/2 on Windows. I found no additional implementation issue in this narrow change.

There is a merge-order blocker in the overlap checklist. I compared exact current heads with git merge-tree: #11941 conflicts in core/libs/tests/GuestEntitlements.cpp with open #11909, and in docs/dev/debt/libSceNpEntitlementAccess.md with open #11529. The description notes those shared files but does not say which PR lands first, while the checklist says Depends on: none. Please agree and record the order on the checklist (Depends on: #N for the first PR this needs, otherwise explicitly say which lands second and rebase it after the first lands). The #8646 branch separately conflicts with current main; that is a stale conflict in #8646's GuestOfflineImports.cpp, not a file changed by #11941.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5667831109 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11941#pullrequestreview-5667831109). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-27T13:30:45Z. **Review:** CHANGES_REQUESTED --- Reviewed exact head `96812a0ae732e8d351872973cafce723b553cee1`. The two exports ignore the ID and return success; the test covers zero, positive, negative and maximum IDs plus repeated delete. The signed-out request functions in this library do not mint IDs, and the debt entry preserves the unmeasured signed-in/table-held case. Hosted Windows build and policy checks pass; the PR reports `guest_entitlements` passing 2/2 on Windows. I found no additional implementation issue in this narrow change. There is a merge-order blocker in the overlap checklist. I compared exact current heads with `git merge-tree`: #11941 conflicts in `core/libs/tests/GuestEntitlements.cpp` with open #11909, and in `docs/dev/debt/libSceNpEntitlementAccess.md` with open #11529. The description notes those shared files but does not say which PR lands first, while the checklist says `Depends on: none`. Please agree and record the order on the checklist (`Depends on: #N` for the first PR this needs, otherwise explicitly say which lands second and rebase it after the first lands). The #8646 branch separately conflicts with current `main`; that is a stale conflict in #8646's `GuestOfflineImports.cpp`, not a file changed by #11941.
MarcZX10 commented 2026-10-27 13:36:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T13:36:42Z.

Review: CHANGES_REQUESTED


Re-reviewed new exact head 8328c0a2f1153c86a3584fbf484bd498da693892. The latest checklist now mentions the shared-file order, but exact git merge-tree comparisons still conflict with both open #11909 (GuestEntitlements.cpp) and #11529 (libSceNpEntitlementAccess.md). “This PR lands second and will be rebased onto whichever of them merges first” does not identify which PR this one depends on; after one lands, the other still overlaps and the order/rebase plan remains unsettled.

Please agree with the affected contributors on a specific sequence and record the actual first dependency in Depends on (and what happens to the other PR) before approval. The current-main merge is clean. This remains a coordination request only; the implementation review found no additional code issue. The Windows build check for this new head is still in progress.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5667912166 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11941#pullrequestreview-5667912166). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-27T13:36:42Z. **Review:** CHANGES_REQUESTED --- Re-reviewed new exact head `8328c0a2f1153c86a3584fbf484bd498da693892`. The latest checklist now mentions the shared-file order, but exact `git merge-tree` comparisons still conflict with both open #11909 (`GuestEntitlements.cpp`) and #11529 (`libSceNpEntitlementAccess.md`). “This PR lands second and will be rebased onto whichever of them merges first” does not identify which PR this one depends on; after one lands, the other still overlaps and the order/rebase plan remains unsettled. Please agree with the affected contributors on a specific sequence and record the actual first dependency in `Depends on` (and what happens to the other PR) before approval. The current-main merge is clean. This remains a coordination request only; the implementation review found no additional code issue. The Windows build check for this new head is still in progress.
MarcZX10 commented 2026-10-29 00:14:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T00:14:12Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The agreed #11529 → #11909 → #11941 sequence and the exact-head Windows control address the earlier blockers, but the branch still needs to be refreshed onto current main.

What I ran

Reviewed head ffc8b7c45ff032324687636973f5a9f56a2386e7; its merge base with current main is 319621ba2e578bd053b0baba2877fe70520e0737. The preview merge onto current main 3a2b91981651569163768854a1fcdc7193b6667b is clean, and no paths changed on both sides since that merge base. Environment: Linux x86-64, Git and GitHub CLI. I did not build or run the tests locally.

git fetch https://github.com/boykopovar/AnyPS5.git main:refs/review/main-20261029 refs/pull/11941/head:refs/review/pr-11941-20261029
git merge-base refs/review/main-20261029 refs/review/pr-11941-20261029
git merge-tree --write-tree refs/review/main-20261029 refs/review/pr-11941-20261029
base=$(git merge-base refs/review/main-20261029 refs/review/pr-11941-20261029)
comm -12 <(git diff --name-only "$base" refs/review/main-20261029 | sort) <(git diff --name-only "$base" refs/review/pr-11941-20261029 | sort)

Results

Check Result
Current-main merge preview Clean
Touched paths changed on current main since merge base None
Focused Windows tests Author reports guest_entitlements and guest_entitlements_missing pass 3/3 on this head
Hosted Windows Pass
Product Linux and specialized jobs Skipped
Local build/tests Not run
Command output
head=ffc8b7c45ff032324687636973f5a9f56a2386e7
merge-base=319621ba2e578bd053b0baba2877fe70520e0737
current-main-merge-preview=c706eb769e78011f14eb1ad6635d1f6fd8fc6a80
touched paths changed on both sides:
#11529: merged
#11909: open

Negative control

Assertion Change to code under test Outcome
The new abort implementation distinguishes the base from the PR The author reports substituting main's Export.cpp while keeping the PR test guest_entitlements failed with sceNpEntitlementAccessAbortRequest not implemented; this control is author-reported and was not rerun here

Findings

Blocking

  • The branch is based on 319621ba2e, not current main 3a2b91981651. The clean preview and lack of changed-path overlap reduce conflict risk, but the contribution rules require keeping the branch current. Please rebase and rerun the focused tests on that tree.

Non-blocking

  • The previously requested overlap sequence is now explicit: #11529 and #11909 precede #11941; #11529 is already merged and #11909 remains open. The current checklist records both.

Sources

Not verified

  • I did not rerun Windows or Linux tests locally and did not test on a console. The detailed Windows results and negative control are author/reviewer-provided; hosted product Linux is skipped.

To get this to a good state

Rebase onto current main and rerun guest_entitlements and guest_entitlements_missing on the new head. Keep the #11529/#11909 sequence documented and record the exact base and head. I will re-check the refreshed diff and rerun the focused tests available here.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5691332455 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11941#pullrequestreview-5691332455). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T00:14:12Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The agreed #11529 → #11909 → #11941 sequence and the exact-head Windows control address the earlier blockers, but the branch still needs to be refreshed onto current `main`. ## What I ran Reviewed head `ffc8b7c45ff032324687636973f5a9f56a2386e7`; its merge base with current `main` is `319621ba2e578bd053b0baba2877fe70520e0737`. The preview merge onto current `main` `3a2b91981651569163768854a1fcdc7193b6667b` is clean, and no paths changed on both sides since that merge base. Environment: Linux x86-64, Git and GitHub CLI. I did not build or run the tests locally. ```sh git fetch https://github.com/boykopovar/AnyPS5.git main:refs/review/main-20261029 refs/pull/11941/head:refs/review/pr-11941-20261029 git merge-base refs/review/main-20261029 refs/review/pr-11941-20261029 git merge-tree --write-tree refs/review/main-20261029 refs/review/pr-11941-20261029 base=$(git merge-base refs/review/main-20261029 refs/review/pr-11941-20261029) comm -12 <(git diff --name-only "$base" refs/review/main-20261029 | sort) <(git diff --name-only "$base" refs/review/pr-11941-20261029 | sort) ``` ## Results | Check | Result | |---|---| | Current-main merge preview | Clean | | Touched paths changed on current main since merge base | None | | Focused Windows tests | Author reports `guest_entitlements` and `guest_entitlements_missing` pass 3/3 on this head | | Hosted Windows | Pass | | Product Linux and specialized jobs | Skipped | | Local build/tests | Not run | <details> <summary>Command output</summary> ```text head=ffc8b7c45ff032324687636973f5a9f56a2386e7 merge-base=319621ba2e578bd053b0baba2877fe70520e0737 current-main-merge-preview=c706eb769e78011f14eb1ad6635d1f6fd8fc6a80 touched paths changed on both sides: #11529: merged #11909: open ``` </details> ## Negative control | Assertion | Change to code under test | Outcome | |---|---|---| | The new abort implementation distinguishes the base from the PR | The author reports substituting `main`'s `Export.cpp` while keeping the PR test | `guest_entitlements` failed with `sceNpEntitlementAccessAbortRequest not implemented`; this control is author-reported and was not rerun here | ## Findings ### Blocking - The branch is based on `319621ba2e`, not current `main` `3a2b91981651`. The clean preview and lack of changed-path overlap reduce conflict risk, but the contribution rules require keeping the branch current. Please rebase and rerun the focused tests on that tree. ### Non-blocking - The previously requested overlap sequence is now explicit: #11529 and #11909 precede #11941; #11529 is already merged and #11909 remains open. The current checklist records both. ## Sources - [Contribution rules for current bases and overlap order](https://github.com/boykopovar/AnyPS5/blob/3a2b91981651569163768854a1fcdc7193b6667b/CONTRIBUTING.md#L57-L67) - [Implementation at the reviewed head](https://github.com/boykopovar/AnyPS5/tree/ffc8b7c45ff032324687636973f5a9f56a2386e7/core/libs/prx/libSceNpEntitlementAccess) - [Exact-head tests](https://github.com/boykopovar/AnyPS5/blob/ffc8b7c45ff032324687636973f5a9f56a2386e7/core/libs/tests/GuestEntitlements.cpp) ## Not verified - I did not rerun Windows or Linux tests locally and did not test on a console. The detailed Windows results and negative control are author/reviewer-provided; hosted product Linux is skipped. ## To get this to a good state Rebase onto current `main` and rerun `guest_entitlements` and `guest_entitlements_missing` on the new head. Keep the #11529/#11909 sequence documented and record the exact base and head. I will re-check the refreshed diff and rerun the focused tests available here.
MarcZX10 commented 2026-10-29 05:19:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T05:19:51Z.

Review: APPROVED


Re-checked — looks good

The author’s refresh preserves the reviewed two-commit diff, the agreed #11529 → #11909 → #11941 order is recorded, and the reported entitlement tests cover both exports and the negative control; I found no blocker in the current-head preview.

What I ran

  • Reviewed head 24f5853925950ce81ad9dd5faac19274ebe4410e against current main 52c09d567d2fa453494dd720fcf53a98149468e4.
  • Ran git merge-tree --write-tree and compared paths changed on main since the PR merge base.
  • Checked the author’s rebase note, current hosted checks, dependency status, and the earlier exact-head Windows test/control report.

Results

Check Result
Current-main preview Clean; tree 06eb182f50...
Main changes since merge base Two commits; no overlapping paths with this PR
Focused tests Author/reviewer report: guest_entitlements and guest_entitlements_missing pass 3/3 on the pre-refresh head; author says the current rebase preserves the exact diff and the focused tests remain applicable
Negative control Reported control replacing the changed exports with main versions fails as expected
Current hosted checks Eligibility and conventions pass; merge state is clean
Declared sequence #11529 is merged; #11909 remains open and is correctly listed as a prerequisite before this PR lands
Raw output
$ git merge-tree --write-tree refs/review/main-20261029b refs/review/pr-11941-20261029
06eb182f50...
exit=0
merge-base: 4004c9711450ed83a076dd88823232293ff4930d
current main: 52c09d567d2fa453494dd720fcf53a98149468e4
changed-path intersection: none

Negative control

The exact-head Windows report describes reverting the implementation to main; both focused tests then fail in the intended checks. I did not rerun this control locally.

Findings

Blocking

  • None found in the current diff or current-main merge preview.

Non-blocking

  • Keep the declared order: rebase this branch onto #11909 after that prerequisite merges, then rerun the two focused entitlement tests and conventions on the final stack tip before merge.

Sources

Not verified

  • I did not rerun the Windows tests or negative control locally. The test output is author/reviewer-reported; #11909 has not yet merged, so the final stacked tip still needs its post-merge run.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5693202310 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11941#pullrequestreview-5693202310). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T05:19:51Z. **Review:** APPROVED --- # Re-checked — looks good The author’s refresh preserves the reviewed two-commit diff, the agreed #11529 → #11909 → #11941 order is recorded, and the reported entitlement tests cover both exports and the negative control; I found no blocker in the current-head preview. ## What I ran - Reviewed head `24f5853925950ce81ad9dd5faac19274ebe4410e` against current `main` `52c09d567d2fa453494dd720fcf53a98149468e4`. - Ran `git merge-tree --write-tree` and compared paths changed on `main` since the PR merge base. - Checked the author’s rebase note, current hosted checks, dependency status, and the earlier exact-head Windows test/control report. ## Results | Check | Result | |---|---| | Current-main preview | Clean; tree `06eb182f50...` | | Main changes since merge base | Two commits; no overlapping paths with this PR | | Focused tests | Author/reviewer report: `guest_entitlements` and `guest_entitlements_missing` pass 3/3 on the pre-refresh head; author says the current rebase preserves the exact diff and the focused tests remain applicable | | Negative control | Reported control replacing the changed exports with `main` versions fails as expected | | Current hosted checks | Eligibility and conventions pass; merge state is clean | | Declared sequence | #11529 is merged; #11909 remains open and is correctly listed as a prerequisite before this PR lands | <details> <summary>Raw output</summary> ```text $ git merge-tree --write-tree refs/review/main-20261029b refs/review/pr-11941-20261029 06eb182f50... exit=0 merge-base: 4004c9711450ed83a076dd88823232293ff4930d current main: 52c09d567d2fa453494dd720fcf53a98149468e4 changed-path intersection: none ``` </details> ## Negative control The exact-head Windows report describes reverting the implementation to `main`; both focused tests then fail in the intended checks. I did not rerun this control locally. ## Findings ### Blocking - None found in the current diff or current-main merge preview. ### Non-blocking - Keep the declared order: rebase this branch onto #11909 after that prerequisite merges, then rerun the two focused entitlement tests and conventions on the final stack tip before merge. ## Sources - [Implementation and tests at reviewed head](https://github.com/boykopovar/AnyPS5/tree/24f5853925950ce81ad9dd5faac19274ebe4410e/core/libs) - [Contribution rules at current main](https://github.com/boykopovar/AnyPS5/blob/52c09d567d2fa453494dd720fcf53a98149468e4/CONTRIBUTING.md#L57-L66) - [PR checklist/dependency order](https://github.com/boykopovar/AnyPS5/pull/11941) ## Not verified - I did not rerun the Windows tests or negative control locally. The test output is author/reviewer-reported; #11909 has not yet merged, so the final stacked tip still needs its post-merge run.
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!11941
No description provided.