Skip to content

[release/v7.6] Split TPN manifest and Component Governance manifest#26978

Merged
daxian-dbw merged 1 commit intoPowerShell:release/v7.6from
daxian-dbw:backport/release/v7.6/26891-6e2b4c784
Mar 10, 2026
Merged

[release/v7.6] Split TPN manifest and Component Governance manifest#26978
daxian-dbw merged 1 commit intoPowerShell:release/v7.6from
daxian-dbw:backport/release/v7.6/26891-6e2b4c784

Conversation

@daxian-dbw
Copy link
Copy Markdown
Member

Backport of #26891 to release/v7.6

Triggered by @daxian-dbw on behalf of @TravisEz13

Original CL Label: CL-BuildPackaging

/cc @PowerShell/powershell-maintainers

Impact

REQUIRED: Choose either Tooling Impact or Customer Impact (or both). At least one checkbox must be selected.

Tooling Impact

  • Required tooling change
  • Optional tooling change (include reasoning)

Enhances ClearlyDefined compliance tooling with improved cache management, package version handling, and updated manifest file paths. Introduces cache persistence functions and new script for finding harvested NuGet package versions.

Customer Impact

  • Customer reported
  • Found internally

Regression

REQUIRED: Check exactly one box.

  • Yes
  • No

This is not a regression.

Testing

Successfully backported and merged to v7.4 (#26955) and v7.5 (#26967). Verified through CI pipeline runs. Changes focus on compliance tooling cache management and manifest file organization.

Risk

REQUIRED: Check exactly one box.

  • High
  • Medium
  • Low

Medium risk as it modifies ClearlyDefined compliance tooling and updates manifest file paths across multiple build and CI scripts. However, changes are well-tested through successful backports to v7.4 and v7.5. Focused on build-time operations with no runtime impact.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@daxian-dbw daxian-dbw requested review from a team and jshigetomi as code owners March 10, 2026 18:37
Copilot AI review requested due to automatic review settings March 10, 2026 18:37
@daxian-dbw daxian-dbw added the CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log label Mar 10, 2026
@@ -0,0 +1,755 @@
{
"Registrations": [
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should not be back ported or needs to be regenerated for the branch.

Copy link
Copy Markdown
Member Author

@daxian-dbw daxian-dbw Mar 10, 2026

Choose a reason for hiding this comment

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

Can we backport this change and then regenerate for this branch? Or do we have to remove this file from this PR?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I will run ".\tools\findMissingNotices.ps1 -ForceHarvestedOnly -fix" after merging this PR, to update this file.

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

Backport to release/v7.6 that reorganizes Component Governance manifests (split main vs TPN) and updates the ClearlyDefined compliance tooling to support cache persistence and harvested-version discovery.

Changes:

  • Split cgmanifest.json into tools/cgmanifest/main/cgmanifest.json and tools/cgmanifest/tpn/cgmanifest.json, updating pipeline/script references.
  • Extend ClearlyDefined tooling with cache import/export, search/version helpers, and revised caching TTL behavior.
  • Enhance findMissingNotices.ps1 with an option to generate a harvested-only TPN manifest and revert non-harvested packages.

Reviewed changes

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

Show a summary per file
File Description
tools/packaging/packaging.psm1 Updates CG manifest path used during global tool packaging.
tools/findMissingNotices.ps1 Adds harvested-only TPN generation flow; updates manifest paths.
tools/clearlyDefined/src/ClearlyDefined/ClearlyDefined.psm1 Adds cache/search helpers and changes harvest/caching behavior.
tools/clearlyDefined/Find-LastHarvestedVersion.ps1 Adds helper for finding last harvested NuGet version (fallback to NuGet).
tools/clearlyDefined/ClearlyDefined.ps1 Updates manifest path consumed by ClearlyDefined tooling.
tools/cgmanifest/main/cgmanifest.json New location for main CG manifest content.
tools/cgmanifest/tpn/cgmanifest.json New location for TPN-focused CG manifest content.
.vsts-ci/windows-arm64.yml Updates PR path filters for new cgmanifest folder layout.
.vsts-ci/psresourceget-acr.yml Updates PR path filters for new cgmanifest folder layout.
.vsts-ci/mac.yml Updates PR path filters for new cgmanifest folder layout.
.vsts-ci/linux-internal.yml Updates PR path filters for new cgmanifest folder layout.
.pipelines/templates/compliance/generateNotice.yml Narrows component detection scan path to the TPN manifest directory.

Comment on lines +33 to +35
Start-job -ScriptBlock {
Invoke-WebRequest -Method Post -Uri 'https://api.clearlydefined.io/harvest' -Body $using:body -ContentType 'application/json' -MaximumRetryCount $using:maxRetryCount -RetryIntervalSec $using:retryIntervalSec
}
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

Start-ClearlyDefinedHarvest now uses Start-Job to invoke the harvest request, but the job is never waited/received/removed. In non-interactive runs (CI pwsh -File), the PowerShell process can exit before jobs run, so harvest requests may never be sent; additionally this can create many orphaned jobs. Consider invoking the request synchronously, or explicitly Wait-Job/Receive-Job/Remove-Job (optionally with throttling) to ensure completion and avoid job buildup.

Copilot uses AI. Check for mistakes.
Comment on lines +48 to +68
# Parse the current version
try {
[System.Management.Automation.SemanticVersion]$currentSemVer = $CurrentVersion
} catch {
[Version]$currentSemVer = $CurrentVersion
}

# First try the ClearlyDefined search API (more efficient)
try {
Write-Verbose "Searching ClearlyDefined API for versions of $Name (sorted by release date)..."
# Get versions sorted by release date descending (newest first) for efficiency
$versions = Get-ClearlyDefinedPackageVersions -PackageName $Name

if ($versions -and $versions.Count -gt 0) {
# Results are already sorted by release date newest first
# Filter to versions <= current version
foreach ($versionInfo in $versions) {
try {
$versionObj = [System.Management.Automation.SemanticVersion]$versionInfo.Version
if ($versionObj -le $currentSemVer) {
# Check harvest status
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

Version parsing/comparison can break when $CurrentVersion isn't parseable as SemanticVersion (e.g., 4-part versions): $currentSemVer becomes a [Version], but later code compares it to a [SemanticVersion], which throws and is swallowed—causing the search loop to skip all candidates and return $null. Consider normalizing both sides to the same version type (or using the same fallback logic for both current and candidate versions) so non-semver package versions can still be handled reliably.

Copilot uses AI. Check for mistakes.
# Build a lookup table of harvest status by package name + version
$harvestStatus = @{}
foreach ($item in $fullList) {
$key = "$($item.Name)|$($item.PackageVersion)"
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

The objects returned by Get-ClearlyDefinedData don't include .Name / .PackageVersion (they carry package identity under .coordinates.name and .coordinates.revision). As written, $key will be empty/incorrect for every item, so the harvest-status lookup will be wrong and all packages may be treated as non-harvested.

Suggested change
$key = "$($item.Name)|$($item.PackageVersion)"
$name = $item.coordinates.name
$version = $item.coordinates.revision
if (-not $name -or -not $version) {
continue
}
$key = "$name|$version"

Copilot uses AI. Check for mistakes.
Comment on lines +506 to +510
foreach ($item in $finalHarvestData) {
$matchingNewRegistration = $newRegistrations | Where-Object {
$_.Component.Nuget.Name -eq $item.Name -and
$_.Component.Nuget.Version -eq $item.PackageVersion
}
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

$finalHarvestData elements (from Get-ClearlyDefinedData) don't have .Name / .PackageVersion, so this match will never succeed and the TPN manifest update logic won't include any registrations. Use the package identity from .coordinates (or carry the name/version alongside the request) when correlating results back to $newRegistrations.

Copilot uses AI. Check for mistakes.
@daxian-dbw daxian-dbw merged commit dcdb0a5 into PowerShell:release/v7.6 Mar 10, 2026
42 checks passed
@daxian-dbw daxian-dbw deleted the backport/release/v7.6/26891-6e2b4c784 branch March 10, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants