Skip to content

Reconcile bare/rich component identities in ComponentsFound#1760

Open
AMaini503 wants to merge 1 commit intomainfrom
user/aamaini/component-identity-merging-level1
Open

Reconcile bare/rich component identities in ComponentsFound#1760
AMaini503 wants to merge 1 commit intomainfrom
user/aamaini/component-identity-merging-level1

Conversation

@AMaini503
Copy link
Copy Markdown
Contributor

Within a single detector, components registered under bare Ids (no DownloadUrl/SourceUrl) are now merged into their rich counterparts sharing the same BaseId.

Changes:

  • ComponentRecorder.GetDetectedComponents(): group by BaseId, merge bare metadata (licenses, suppliers, containers) into all rich entries
  • DefaultGraphTranslationService.GatherSetOfDetectedComponentsUnmerged(): extend graph lookup to match on BaseId so rich components absorb graph data (roots, ancestors, devDep, scope, file paths) from bare-Id graphs
  • Tests for both reconciliation levels

Addresses work item #2372676.

Copilot AI review requested due to automatic review settings April 2, 2026 22:37
@AMaini503 AMaini503 requested a review from a team as a code owner April 2, 2026 22:37
@AMaini503 AMaini503 requested a review from schmittjoseph April 2, 2026 22:37
@AMaini503 AMaini503 force-pushed the user/aamaini/component-identity-merging-level1 branch from eefbb60 to 0ec6835 Compare April 2, 2026 22:41
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

👋 Hi! It looks like you modified some files in the Detectors folder.
You may need to bump the detector versions if any of the following scenarios apply:

  • The detector detects more or fewer components than before
  • The detector generates different parent/child graph relationships than before
  • The detector generates different devDependencies values than before

If none of the above scenarios apply, feel free to ignore this comment 🙂

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the orchestrator’s component aggregation so that, within a single detector run, components registered under a “bare” identity (no provenance URLs) are reconciled into their corresponding “rich” identities (same BaseId, but with DownloadUrl/SourceUrl). This ensures ComponentsFound reflects a single coherent identity while retaining important metadata and graph-derived fields.

Changes:

  • Reconcile detected components by BaseId, merging bare metadata into rich entries and dropping the bare entries.
  • Extend graph translation to associate graph data with components by either Id or BaseId, so rich components pick up graph info from bare-id graphs.
  • Add unit tests covering reconciliation behavior at both the ComponentRecorder and graph translation layers.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/Microsoft.ComponentDetection.Common/DependencyGraph/ComponentRecorder.cs Groups detected components by BaseId and merges bare metadata into rich components.
src/Microsoft.ComponentDetection.Orchestrator/Services/GraphTranslation/DefaultGraphTranslationService.cs Applies graph roots/ancestors/dev-dep/scope/locations using Id or BaseId matching.
test/Microsoft.ComponentDetection.Common.Tests/ComponentRecorderTests.cs Adds tests validating bare/rich reconciliation behavior for component aggregation.
test/Microsoft.ComponentDetection.Orchestrator.Tests/Services/DefaultGraphTranslationServiceTests.cs Adds tests validating rich components absorb graph data from bare-id graphs.

Within a single detector, components registered under bare Ids (no
DownloadUrl/SourceUrl) are now merged into their rich counterparts
sharing the same BaseId.

Changes:
- ComponentRecorder.GetDetectedComponents(): group by BaseId, merge
  bare metadata (licenses, suppliers, containers) into all rich entries
- DefaultGraphTranslationService.GatherSetOfDetectedComponentsUnmerged():
  extend graph lookup to match on BaseId so rich components absorb
  graph data (roots, ancestors, devDep, scope, file paths) from
  bare-Id graphs
- Tests for both reconciliation levels

Addresses work item #2372676.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@AMaini503 AMaini503 force-pushed the user/aamaini/component-identity-merging-level1 branch from 0ec6835 to f1ee3e5 Compare April 2, 2026 23:03
// Information about each component is relative to all of the graphs it is present in, so we take all graphs containing a given component and apply the graph data.
foreach (var graphKvp in dependencyGraphsByLocation.Where(x => x.Value.Contains(component.Component.Id)))
// Also match on BaseId to pick up graphs that registered this component under a bare Id (before reconciliation promoted it to a rich Id).
foreach (var graphKvp in dependencyGraphsByLocation.Where(x => x.Value.Contains(component.Component.Id) || (component.Component.Id != component.Component.BaseId && x.Value.Contains(component.Component.BaseId))))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this line is a bit difficult to follow, can we make a private utility method that returns true when applicable.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants