Skip to content

refactor(mobile): enforce result model invariants#1932

Open
szijpeter wants to merge 7 commits into
mainfrom
chore/mobile-result-model-invariants
Open

refactor(mobile): enforce result model invariants#1932
szijpeter wants to merge 7 commits into
mainfrom
chore/mobile-result-model-invariants

Conversation

@szijpeter

@szijpeter szijpeter commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Tightens the Kotlin and Swift mobile wallet output models so callers cannot construct contradictory or incomplete result states.

This builds on the presentation-result hierarchy merged in walt-id/waltid-identity#1892 and keeps its ready and invalid preview states correctly separated.

What Changed

Event Results

  • Replaces open event value objects with closed Kotlin and Swift enums covering every wallet-core issuance and presentation event, including prepared presentation responses.
  • Maps the core Kotlin enum exhaustively into the mobile enum and the SKIE-generated enum exhaustively into the Swift facade, so additions require an explicit mapping on both surfaces.
  • Keeps stable event names and derives phase and status from the selected case instead of accepting contradictory constructor arguments.

Presentation Preview Results

  • Makes client_id and nonce required, non-blank fields of a successfully prepared presentation preview.
  • Gives invalid previews a separate partial request context with a required, non-blank client_id and an optional nonce, whose absence may itself be the validation error.
  • Rejects empty credential requirements, empty alternatives, and blank query references.
  • Applies the same non-blank reference invariant to returned credential options and transaction data.
  • Rejects disclosures marked selectable unless they are both selectively disclosable and optional.
  • Keeps the Kotlin, Swift, Compose demo, and native iOS demo models aligned.

Architecture Notes

  • Events use enums rather than a sealed hierarchy because the domain is finite and the cases carry no case-specific payload.
  • Ready previews expose validated MobileWalletPresentationRequestInfo / PresentationRequestInfo values with required client IDs and nonces. Invalid previews expose MobileWalletPresentationRequestContext / PresentationRequestContext, which retain the required client ID while allowing the nonce to be absent.
  • Public result constructors remain available so integrators can build representative SDK values in tests and previews; constructor validation protects those public construction paths.
  • The mobile facade enforces only invariants required for internally consistent return values. Protocol-level DCQL grammar and aggregate request validation remain outside this PR.

Caveats and Follow-Ups

  • Mobile wallet configuration types and protocol-level DCQL validation are intentionally outside this result-model cleanup.

Breaking Changes

MobileWalletEvent and Swift WalletEvent are now closed enums. Callers constructing event fixtures must select a declared event case; Swift callers that parse a stable name can use the failable WalletEvent(name:) initializer.

MobileWalletPresentationRequestInfo.clientId / Swift PresentationRequestInfo.clientID and nonce are now non-optional and must be non-blank.

Invalid preview results now expose the separate partial MobileWalletPresentationRequestContext / PresentationRequestContext type. Its client ID is required and non-blank, while its nonce remains optional so missing-nonce validation errors can be represented.

Constructing internally inconsistent presentation output fixtures now fails immediately.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 406aa20d-d80c-4727-a8ea-3f195f47d360

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@szijpeter szijpeter self-assigned this Jul 20, 2026
@szijpeter szijpeter added the ci:mobile Run mobile related CI workflows for this PR label Jul 20, 2026
@szijpeter
szijpeter force-pushed the chore/mobile-result-model-invariants branch from cf2f0af to 8a7e288 Compare July 20, 2026 22:42
@szijpeter
szijpeter marked this pull request as ready for review July 21, 2026 06:45
@szijpeter
szijpeter force-pushed the chore/mobile-result-model-invariants branch from 8a7e288 to 314eabe Compare July 21, 2026 10:12
@szijpeter
szijpeter changed the base branch from main to chore/credentials-reproducible-install July 21, 2026 10:34
Base automatically changed from chore/credentials-reproducible-install to main July 21, 2026 13:01
@szijpeter
szijpeter enabled auto-merge July 21, 2026 13:41
@szijpeter
szijpeter force-pushed the chore/mobile-result-model-invariants branch from 314eabe to b562c18 Compare July 21, 2026 15:53
Add KDoc comments for all five properties in MobileWalletPresentationRequestContext
to satisfy Dokka's failOnWarning requirement. Documentation explains each property's
role in the OpenID4VP invalid-request flow, clarifying when values are present or
nullable.
…ters

Add parameter documentation for PresentationRequestContext init to satisfy
Swift-DocC's coverage requirements. Each parameter now explains its role in
the OpenID4VP invalid-request context, matching the Kotlin documentation.
@szijpeter
szijpeter force-pushed the chore/mobile-result-model-invariants branch from cfd40c5 to 79251dc Compare July 22, 2026 11:58
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

ci:mobile Run mobile related CI workflows for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant