[#4253 3/8] refactor(pe): rewire Match onto Select, remove selector abstraction#4284
Draft
stevenvegt wants to merge 1 commit into
Draft
[#4253 3/8] refactor(pe): rewire Match onto Select, remove selector abstraction#4284stevenvegt wants to merge 1 commit into
stevenvegt wants to merge 1 commit into
Conversation
Assisted-by: AI
Contributor
|
Coverage Impact This PR will not change total coverage. 🚦 See full report on Qlty Cloud »🛟 Help
|
This was referenced May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Parent PRD
#4253
Item 3 of 8. Depends on item #1 (#4280) — branched off
4253-1-select-engine, retargeted to the feature branch once #1 merges.Summary
Rewire the public
vcr/pematching API ontoSelectand delete theCredentialSelectorabstraction. The credential_selection path stops constructing a selector and instead passes the selection asSelectinitial bindings. Net effect: less surface, and a single matching engine. Behavior is preserved for every PD that does not reuse anidacross descriptors (i.e. every PD today).Implementation Spec
vcr/pe/presentation_definition.goMatch(vcs []vc.VerifiableCredential, opts ...Option) ([]vc.VerifiableCredential, []InputDescriptorMappingObject, error)— gains variadic options that pass through toSelect. Discovery'spd.Match(creds)keeps compiling unchanged (no opts ⇒FirstMatch, no bindings).MatchWithSelector.matchConstraints,matchBasic, andmatchSubmissionRequirements. Their submission-requirement satisfaction now lives insideSelect(item added baseline funcs from old repo #1, which reuses the unchangedgroups()/apply()/deduplicate()helpers).Matchbecomes a thin wrapper: buildSelectoptions, callSelect(pd, vcs, opts...), then build the[]InputDescriptorMappingObjectdescriptor map (paths + dedup, plus the single-VC JSON-LD vs JWT path fixup) fromResult.vcr/pe/selector.goDelete entirely:
CredentialSelector,FirstMatchSelector,NewFieldSelector,fieldSelection,matchesSelections.Builder (
vcr/pe/presentation_submission.go)credentialSelectorfield andSetCredentialSelector.SetInitialBindings(bindings map[string]string) *PresentationSubmissionBuilder(named to matchSelect'sWithInitialBindings; in remove config reflection #4 the presenter feeds it the merged user-selection + captured-binding map).Buildcallsb.presentationDefinition.Match(walletVCs, WithInitialBindings(b.bindings))with the defaultFirstMatchstrategy. (The config-driven loose/strict strategy is threaded in Moved Nuts-Network to Nuts-Node and implemented RFC004 #5/mixed nil return with ErrNotFound #7; not here.)Presenter (
vcr/holder/presenter.go)credentialSelectionis non-empty,builder.SetInitialBindings(credentialSelection). TheNewFieldSelectorconstruction and its unknown-key error (line 67-70) are removed.Select; typo protection moves toValidateSelectionKeysat the API layer (Add verifiable data registry #6). This realizes the PRD's "NewFieldSelectorbecomes lenient" by deletion.Behavior preservation (the bar)
For any PD without same-
idreuse — every PD deployed today —FirstMatchplus the absence of cross-descriptor bindings meansSelectpicks the same VC per descriptor thatFirstMatchSelector/NewFieldSelectordid, with no backtracking. So:TestMatch, the submission-requirement, andPresentationSubmission.Validatetest scenarios are the characterization safety net for this rewire and pass with no assertion changes.TestPresentationDefinition_MatchWithSelector_SubmissionRequirementsis retargeted to callMatch(with options) sinceMatchWithSelectoris deleted, but its assertions stay the same.selector_test.gois deleted: itsTestNewFieldSelectorscenarios are covered by added baseline funcs from old repo #1's characterization tests (Selectwith bindings), and the strict-unknown-key assertion is dropped (its replacement isValidateSelectionKeysin added nuts-go-test #2).Submission-requirement satisfaction (
apply/groups/deduplicate) is in scope and reused unchanged insideSelect. What stays deferred per the PRD is the binding search cooperating withpick min>=1subset selection: ifSelect's coarse skip yields a combination that apick/minrule rejects, it does not re-search for a different binding-consistent combination to satisfy the floor; it reports the failure. Tie-breakers among multiple valid assignments are also deferred.Testing
vcr/peandvcr/holdersuites green, with only the deletions/updates noted above.Match(vcs, WithInitialBindings(sel))produces the same result the oldNewFieldSelectorpath did for a representative selection (belt-and-suspenders alongside added baseline funcs from old repo #1's characterization tests).Acceptance Criteria
Matchtakes variadicOptions and is a thin wrapper overSelect(builds the descriptor map fromResultvia the shared private helper);MatchWithSelector,matchConstraints,matchBasic, andmatchSubmissionRequirementsremoved.selector.godeleted; no references toCredentialSelector/FirstMatchSelector/NewFieldSelectorremain.SetInitialBindings; presenter wirescredentialSelectionthrough it with no unknown-key error.vcr/peandvcr/holdertests pass (updated only as described);selector_test.goremoved.go build ./...andgo test ./vcr/...pass.