packages/AzStackHci.DiagnosticSettings.0.6.8/Private/AzStackHci.ParallelLayer7.Helpers.ps1

# =============================================================================
# Strict Mode v1 (PS 5.1 safe) - surfaces reads of uninitialised variables at runtime.
Set-StrictMode -Version 1.0

# AzStackHci.ParallelLayer7.Helpers.ps1
# =============================================================================
# Private helpers for the Layer-7 endpoint sweep in Test-AzureLocalConnectivity.
#
# Two helpers live here:
# 1. Invoke-Layer7EndpointTest - tests ONE endpoint (mutates the $UrlObject in place,
# may append CRL/OCSP dependency rows to $script:Results
# via Add-CrlDependencyRowToResults). This is the
# extracted body of the main per-URL ForEach loop and
# is byte-identical to the v0.6.6 inline behaviour.
# 2. Invoke-Layer7BucketWorker - runs inside a Start-Job worker process; loops over
# a bucket of $UrlObject rows calling
# Invoke-Layer7EndpointTest, snapshots the module-scope
# classification state ($script:SSLInspectedURLs,
# $script:CRLOfflineURLs, $script:PrivateLink* arrays,
# any newly-appended $script:Results rows) and returns
# a hashtable for the parent process to merge.
#
# The parallel fan-out is opt-in via the new -Parallelism parameter on
# Test-AzureLocalConnectivity (default 1, sequential, byte-identical to v0.6.6).
# =============================================================================


function Invoke-Layer7EndpointTest {
    <#
    .SYNOPSIS
    Runs DNS + TCP + Layer-7 connectivity tests for a single endpoint row, mutating
    the row in place. Body extracted verbatim from the main ForEach loop in
    Test-AzureLocalConnectivity to enable parallel fan-out via Start-Job.
 
    .DESCRIPTION
    Sequential default behaviour: identical to the pre-extraction inline ForEach body.
    Mutates $UrlObject fields (TCPStatus, Layer7Status, Layer7Response, certificate
    columns, IPAddress, Note). May call Add-CrlDependencyRowToResults which appends
    new rows to $script:Results. May also append to module-scope classification state
    ($script:SSLInspectedURLs, $script:CRLOfflineURLs, $script:PrivateLink* arrays,
    $script:SSLInspectionDetected) via the call into Test-Layer7Connectivity ->
    Get-Layer7CertificateDetails / Get-DnsRecord.
 
    .PARAMETER UrlObject
    The PSCustomObject row from $script:Results to test. Mutated in place.
 
    .PARAMETER SkipUrls
    The list of URLs that the parent loop has decided to skip (the manually-curated
    "skip" list — pre-2026 hardcoded entries like wustat.windows.com).
 
    .PARAMETER ArcGatewayDeployment
    Whether -ArcGatewayDeployment was specified on the public Test-AzureLocalConnectivity.
 
    .PARAMETER NTPTimeServer
    Optional user-supplied NTP server URL (replaces time.windows.com for that one row).
 
    .PARAMETER IncludeTCPConnectivityTests
    Whether -IncludeTCPConnectivityTests was specified on the public function.
 
    .PARAMETER RequestMethod
    'Get' / 'Head' / 'Auto' — plumbed through to Test-Layer7Connectivity.
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [object]$UrlObject,

        [Parameter(Mandatory)]
        [array]$SkipUrls,

        [Parameter(Mandatory=$false)]
        [bool]$ArcGatewayDeployment = $false,

        [Parameter(Mandatory=$false)]
        [string]$NTPTimeServer,

        [Parameter(Mandatory=$false)]
        [bool]$IncludeTCPConnectivityTests = $false,

        [Parameter(Mandatory=$false)]
        [ValidateSet('Get','Head','Auto')]
        [string]$RequestMethod = 'Auto'
    )

    # Local alias preserves the old loop variable name so the extracted body remains
    # diff-readable against the v0.6.6 ForEach body it came from.
    $urlObj = $UrlObject

    # Per-iteration DNSCheck reset (matches original "Remove-Variable DNSCheck" inside the loop).
    $DNSCheck = $null

    Write-Debug "Arc Gateway boolean for url '$($urlObj.url)' from source $($urlObj.Source) = $($urlObj.ArcGateway)"

    # If the ArcGatewayDeployment switch is used, only test URLs that do not support Arc Gateway
    if ($ArcGatewayDeployment) {
        # Skip URLs with ArcGateway -eq $True
        if ($urlObj.ArcGateway) {
            # Skip URLs that support Arc Gateway
            Write-HostAzS "Skipped URL: '$($urlObj.URL)' as supported by Arc Gateway" -ForegroundColor Yellow
            Set-UrlObjectSkipFields -UrlObject $urlObj -TCPStatus "Skipped" -Layer7Status "Skipped"
            $urlObj.Note = "Skipped, URL is supported by Arc Gateway - $($urlObj.Note)"
            Write-HostAzS ""
            return
        }
    }

    # Process URLs that require special handling
    if (($urlObj.URL -like ("*.gw.arc.azure.com") -or $urlObj.URL -like ("*.gw.arc.azure.net"))) {
        if ($ArcGatewayDeployment) {
            # Replace the URL with the user-defined Arc Gateway URL, if specified
            $urlObj.URL = (Get-DomainFromURL -url $script:UpdatedArcGatewayURL).Domain
            # Run DNS + TCP + Layer 7 connectivity tests using shared helper
            # Forward -RequestMethod down through Invoke-EndpointConnectivityTest into Test-Layer7Connectivity (parity with the non-wildcard branch).
            $testResult = Invoke-EndpointConnectivityTest -Url $urlObj.URL -Port $urlObj.Port -IncludeTCPConnectivityTests:$IncludeTCPConnectivityTests -RequestMethod $RequestMethod
            Copy-ConnectivityResultsToUrlObject -UrlObject $urlObj -TestResult $testResult
        } else {
            # Not using Arc Gateway, skip the URL
            Write-HostAzS "Skipping URL, (not using Arc Gateway): $($urlObj.URL)" -ForegroundColor Green
            Set-UrlObjectSkipFields -UrlObject $urlObj -TCPStatus "Skipped" -Layer7Status "Skipped"
            $urlObj.Note = "Skipped, not using Arc Gateway, as '-ArcGatewayDeployment' switch not present - $($urlObj.Note)"
        }

    } elseif ($urlObj.URL -eq "time.windows.com") {
        # Replace the URL with the user-defined NTP Time Server, if specified
        if ([string]::IsNullOrWhiteSpace($NTPTimeServer)) {
            # Use default NTP Time Server
            Write-HostAzS "Using default NTP Time Server: 'time.windows.com' for NTP connectivity test on UDP port 123, as the '`$NTPTimeServer' parameter was not specified" -ForegroundColor Yellow
            $DNSCheck = Get-DnsRecord -url (Get-DomainFromURL -url $urlObj.URL).Domain
        } else {
            Write-HostAzS "Replacing default NTP Time Server 'time.windows.com' with user-defined NTP server: '$NTPTimeServer'" -ForegroundColor Green
            [string]$urlObj.URL = (Get-DomainFromURL -url $NTPTimeServer).Domain
            $urlObj.Source = "User-defined NTP server"
            # //// Ignore RFC1918 check during DNS check for user-defined NTP server ////
            $DNSCheck = Get-DnsRecord -url (Get-DomainFromURL -url $NTPTimeServer).Domain -SkipRfc1918Check
        }
        # If using a Proxy, DNS resolution from the local host may not be required
        if (($DNSCheck.DNSExists) -or ($script:Proxy.Enabled)) {
            $StopWatch = [Diagnostics.Stopwatch]::StartNew()
            $urlObj.TCPStatus, $urlObj.IPAddress = Test-NTPConnectivity -ntpServer $urlObj.URL
            if ($urlObj.TCPStatus -eq "Success") {
                $urlObj.Layer7Status = "Success"
            } else {
                $urlObj.Layer7Status = "Failed"
            }
            if ([string]::IsNullOrWhiteSpace($urlObj.IPAddress)) {
                $urlObj.IPAddress = $DNSCheck.IpAddress
            }
            $urlObj.Layer7Response = "UDP port 123"
            $urlObj.Layer7ResponseTime = [math]::round($StopWatch.Elapsed.TotalMilliseconds/1000, 3)
            $StopWatch.Stop()
            # NTP does not use SSL certificates
            $urlObj.CertificateIssuer = "N/A"
            $urlObj.CertificateSubject = "N/A"
            $urlObj.CertificateThumbprint = "N/A"
            $urlObj.IntermediateCertificateIssuer = "N/A"
            $urlObj.IntermediateCertificateSubject = "N/A"
            $urlObj.IntermediateCertificateThumbprint = "N/A"
            $urlObj.RootCertificateIssuer = "N/A"
            $urlObj.RootCertificateSubject = "N/A"
            $urlObj.RootCertificateThumbprint = "N/A"
        } else {
            Set-UrlObjectSkipFields -UrlObject $urlObj -TCPStatus "Failed" -Layer7Status "Failed" -IPAddress $DNSCheck.IpAddress
        }

    # //// Skipped URLs ////
    } elseif ($SkipUrls.URL.Contains($urlObj.URL)) {
        Write-HostAzS "Skipped URL: $($urlObj.URL)" -ForegroundColor Green
        Set-UrlObjectSkipFields -UrlObject $urlObj -TCPStatus "Skipped" -Layer7Status "Skipped"
        $urlObj.Note = "Skipped URL - $($urlObj.Note)"

    # //// Wildcard URLs ////
    } elseif ($urlObj.IsWildcard) {
        Write-HostAzS "Wildcard URLs are processed later..." -ForegroundColor Yellow
        Set-UrlObjectSkipFields -UrlObject $urlObj -TCPStatus "Skipped" -Layer7Status "Skipped"
        $urlObj.Note = "$($urlObj.Note)"

    # //// Non-wildcard URLs ////
    } else {
        # Placeholder KeyVault URL: show Warning status instead of running tests against a URL that will always fail DNS
        if ($urlObj.URL -like "yourhcikeyvaultname.vault.*") {
            Write-HostAzS "WARNING: Default KeyVault endpoint '$($urlObj.URL)' is being used." -ForegroundColor Yellow
            Write-HostAzS "INFO: Specify your KeyVault endpoint using the '-KeyVaultURL' parameter to validate your actual KeyVault connectivity." -ForegroundColor Yellow
            Set-UrlObjectSkipFields -UrlObject $urlObj -TCPStatus "Failed" -Layer7Status "Failed"
            $urlObj.Note = "PARAMETER `"-KeyVaultURL https://<yourKeyVault>.vault.azure.net`" WAS NOT USED - THIS IS REQUIRED TO SPECIFY YOUR UNIQUE KEY VAULT NAME - Key vault for deployment secrets."
            # Sleep for 3 seconds to allow the user to read the warning, if present.
            Start-Sleep -Seconds 3
            # NOTE: original 'Continue' here SKIPS the trailing Write-HostAzS "" — replicate by returning early.
            return
        }
        # Run DNS + TCP + Layer 7 connectivity tests using shared helper
        # Forward -RequestMethod down through Invoke-EndpointConnectivityTest into Test-Layer7Connectivity.
        $testResult = Invoke-EndpointConnectivityTest -Url $urlObj.URL -Port $urlObj.Port -IncludeTCPConnectivityTests:$IncludeTCPConnectivityTests -RequestMethod $RequestMethod
        Copy-ConnectivityResultsToUrlObject -UrlObject $urlObj -TestResult $testResult
    }
    # Add line return after each URL (matches the original loop trailing Write-HostAzS "").
    Write-HostAzS ""
}


function Invoke-Layer7BucketWorker {
    <#
    .SYNOPSIS
    Worker scriptblock body — runs inside a Start-Job child process, loops over a
    bucket of endpoint rows calling Invoke-Layer7EndpointTest, and returns a snapshot
    of all module-scope classification state for the parent process to merge.
 
    .DESCRIPTION
    Each Start-Job worker is its own process, so $script:* variables are isolated.
    The worker imports the module (so Invoke-Layer7EndpointTest, Test-Layer7Connectivity,
    Get-DnsRecord, Add-CrlDependencyRowToResults etc. are all available), seeds the
    module-scope state from the parent's snapshot, runs the bucket sequentially, then
    returns a hashtable that the parent merges.
 
    Returned hashtable keys:
      - Rows : the mutated $UrlObject rows from this bucket (RowID-tagged)
      - NewCrlRows : any rows appended to $script:Results by
                                     Add-CrlDependencyRowToResults inside the bucket
      - RedirectedResults : URLs the worker discovered via HTTP 301/302 redirect
                                     responses ($script:RedirectedResults snapshot — Phase 4
                                     of Test-AzureLocalConnectivity iterates the parent's
                                     copy of this list, so workers MUST plumb it back or
                                     redirected URLs are silently dropped from the output)
      - SSLInspectedURLs : list of URLs flagged for SSL Inspection
      - CRLOfflineURLs : list of URLs whose CRL/OCSP check was offline
      - SSLInspectionDetected : bool — true if any row in the bucket triggered SSL inspection
      - PrivateLinkDetected : bool — true if any URL in the bucket resolved to RFC1918
                                     (the parent uses this scalar flag to decide whether to
                                     print the customer-facing 'PRIVATE LINK DETECTED' warning)
      - PrivateLinkDetectedArray : list of URLs flagged for Private Link
      - PrivateLinkCriticalArray : list of URLs flagged for Private Link (RFC1918, critical)
      - PrivateLinkProxyBypassArray: list of URLs flagged for Private Link (RFC1918, proxy bypass)
      - BucketIndex : the worker's bucket index (for deterministic merge order)
      - BucketWallClockSec : wall-clock duration of this worker's bucket
 
    Diagnostic console output produced during testing is interleaved across workers — that
    is the documented behaviour of the parallel mode. The transcript still captures every
    line; the JSON output is RowID-sorted so customer-facing output ordering is identical
    to sequential mode.
 
    .PARAMETER Bucket
    Array of $UrlObject rows for this worker to test (round-robin partition from parent).
 
    .PARAMETER ParameterBag
    Hashtable carrying SkipUrls / ArcGatewayDeployment / NTPTimeServer /
    IncludeTCPConnectivityTests / RequestMethod / Proxy / UpdatedArcGatewayURL.
 
    .PARAMETER BucketIndex
    Index of this bucket (0..N-1).
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [array]$Bucket,

        [Parameter(Mandatory)]
        [hashtable]$ParameterBag,

        [Parameter(Mandatory=$false)]
        [int]$BucketIndex = 0
    )

    $bucketSw = [System.Diagnostics.Stopwatch]::StartNew()

    # Tag every Write-HostAzS line emitted from inside this worker with [bucket-N]
    # so the interleaved transcript is greppable per bucket. Cleared in the finally
    # so the parent process never inherits a stale prefix.
    $script:WorkerLogPrefix = "[bucket-$BucketIndex] "

    # Wrap the bucket body in try/finally so the [bucket-N] prefix is ALWAYS cleared
    # (and the stopwatch always stopped) even if a terminating error escapes the
    # per-row try/catch below. Body indentation is intentionally unchanged to keep
    # this diff minimal and reviewable.
    try {

    # Seed module-scope state from the parent's snapshot — Invoke-Layer7EndpointTest reads
    # $script:Proxy and $script:UpdatedArcGatewayURL. Constants.ps1's Initialize-ModuleState
    # has already created the empty ArrayLists / arrays for the classification state, so
    # we can rely on those being initialised but empty in this worker process.
    if ($ParameterBag.ContainsKey('Proxy')) {
        $script:Proxy = $ParameterBag.Proxy
    }
    if ($ParameterBag.ContainsKey('UpdatedArcGatewayURL')) {
        $script:UpdatedArcGatewayURL = $ParameterBag.UpdatedArcGatewayURL
    }

    # Snapshot the row count BEFORE running the bucket so we can isolate any new
    # CRL/OCSP rows that Add-CrlDependencyRowToResults appends during testing.
    # The worker's $script:Results starts as a (cloned) copy of the bucket so that
    # Add-CrlDependencyRowToResults's host-level dedupe still works correctly within
    # the bucket's scope.
    [System.Collections.ArrayList]$script:Results = @($Bucket)
    $initialRowCount = $script:Results.Count

    foreach ($row in $Bucket) {
        try {
            Invoke-Layer7EndpointTest `
                -UrlObject $row `
                -SkipUrls $ParameterBag.SkipUrls `
                -ArcGatewayDeployment ([bool]$ParameterBag.ArcGatewayDeployment) `
                -NTPTimeServer $ParameterBag.NTPTimeServer `
                -IncludeTCPConnectivityTests ([bool]$ParameterBag.IncludeTCPConnectivityTests) `
                -RequestMethod $ParameterBag.RequestMethod
        } catch {
            # Mark the row as Failed but never abort the bucket — bucket-level isolation matters.
            try {
                $row.Layer7Status = 'Failed'
                $row.Layer7Response = "Worker exception: $($_.Exception.Message)"
            } catch {}
        }
    }

    # Identify any new CRL/OCSP dependency rows the bucket appended during testing.
    $newCrlRows = @()
    if ($script:Results.Count -gt $initialRowCount) {
        $newCrlRows = @($script:Results | Select-Object -Skip $initialRowCount)
    }

    }
    finally {
        $bucketSw.Stop()

        # Clear the bucket prefix so a direct (non-Start-Job) caller doesn't leak it.
        # In the Start-Job process this is moot — the process is torn down — but
        # Pester tests that invoke Invoke-Layer7BucketWorker in-proc would otherwise
        # see subsequent Write-HostAzS calls still tagged.
        $script:WorkerLogPrefix = ''
    }

    return @{
        Rows                         = @($Bucket)
        NewCrlRows                   = $newCrlRows
        RedirectedResults            = @($script:RedirectedResults)
        SSLInspectedURLs             = @($script:SSLInspectedURLs)
        CRLOfflineURLs               = @($script:CRLOfflineURLs)
        SSLInspectionDetected        = [bool]$script:SSLInspectionDetected
        PrivateLinkDetected          = [bool]$script:PrivateLinkDetected
        PrivateLinkDetectedArray     = @($script:PrivateLinkDetectedArray)
        PrivateLinkCriticalArray     = @($script:PrivateLinkCriticalArray)
        PrivateLinkProxyBypassArray  = @($script:PrivateLinkProxyBypassArray)
        BucketIndex                  = $BucketIndex
        BucketWallClockSec           = [math]::Round($bucketSw.Elapsed.TotalSeconds, 3)
    }
}


function Merge-Layer7WorkerResult {
    <#
    .SYNOPSIS
    Merges one worker's returned hashtable into the parent module-scope state.
 
    .DESCRIPTION
    - Replaces parent rows by RowID with the worker's mutated copies.
    - Appends new CRL/OCSP dependency rows to $script:Results (idempotent: skips
      URLs already present at the parent level).
    - Unions the SSL-inspection / CRL-offline / Private-Link arrays.
    - ORs the SSLInspectionDetected flag.
 
    .PARAMETER WorkerResult
    The hashtable returned by Invoke-Layer7BucketWorker.
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [hashtable]$WorkerResult
    )

    # The worker mutated the original PSCustomObject references in $Bucket. Because
    # Start-Job serialises objects across the process boundary, the deserialised rows
    # returned in WorkerResult.Rows are NOT the same instances as the parent's
    # $script:Results entries. Merge by RowID match.
    foreach ($workerRow in $WorkerResult.Rows) {
        $match = $script:Results | Where-Object { $_.RowID -eq $workerRow.RowID } | Select-Object -First 1
        if ($null -ne $match) {
            # Copy back every mutated field. This is intentionally explicit (not
            # ForEach-Object Get-Member) to avoid accidentally overwriting RowID/URL/Port etc.
            foreach ($field in @(
                'TCPStatus','IPAddress','Layer7Status','Layer7Response','Layer7ResponseTime',
                'CertificateIssuer','CertificateSubject','CertificateThumbprint',
                'IntermediateCertificateIssuer','IntermediateCertificateSubject','IntermediateCertificateThumbprint',
                'RootCertificateIssuer','RootCertificateSubject','RootCertificateThumbprint',
                'Note','URL','Source'
            )) {
                if (($workerRow.PSObject.Properties.Name -contains $field) -and ($match.PSObject.Properties.Name -contains $field)) {
                    $match.$field = $workerRow.$field
                }
            }
        }
    }

    # Append any new CRL/OCSP dependency rows the worker generated. When the same
    # dependency URL is discovered in another bucket the row is NOT re-added — instead
    # we extend the existing row's Source field so customer-facing output preserves
    # all parent-domain attributions. This mirrors the Tier-1 dedupe semantics inside
    # Add-CrlDependencyRowToResults (Private/AzStackHci.Connectivity.Helpers.ps1) for
    # the cross-bucket case, where each worker's local dedupe cannot see other buckets.
    foreach ($newRow in $WorkerResult.NewCrlRows) {
        # Defence-in-depth: skip any $null row (mirrors the RedirectedResults loop guard
        # below) so a malformed worker payload can never throw on $newRow.URL.
        if ($null -eq $newRow) { continue }
        $existing = $script:Results | Where-Object { ($_.URL -eq $newRow.URL) -and ($_.Port -eq $newRow.Port) } | Select-Object -First 1
        if ($null -eq $existing) {
            $script:Results.Add($newRow) | Out-Null
        } elseif ($newRow.PSObject.Properties.Name -contains 'Source' -and -not [string]::IsNullOrWhiteSpace($newRow.Source)) {
            # Extract the parent-domain hint(s) from the worker's Source string and append
            # any not already present on the parent row's Source. The Source field uses
            # '; '-separated parent-domain tokens so a simple substring check is reliable.
            $existingSrc = if ([string]::IsNullOrWhiteSpace($existing.Source)) { '' } else { $existing.Source }
            foreach ($token in ($newRow.Source -split ';\s*')) {
                $t = $token.Trim()
                if ($t -and ($existingSrc -notmatch [regex]::Escape($t))) {
                    $existing.Source = if ([string]::IsNullOrWhiteSpace($existing.Source)) { $t } else { "$($existing.Source); $t" }
                    $existingSrc = $existing.Source
                }
            }
        }
    }

    # Plumb back any URLs the worker discovered as HTTP 301/302 redirect targets so
    # Phase 4 of Test-AzureLocalConnectivity (the redirected-URLs loop) can test them.
    # Without this merge step those rows would be silently dropped from the JSON / HTML
    # / CSV output in -Parallelism > 1 runs. Dedupe by url + Port matches the existing
    # New-RedirectedResultEntry semantics in Private/AzStackHci.Connectivity.Helpers.ps1.
    if ($WorkerResult.RedirectedResults) {
        foreach ($redirRow in $WorkerResult.RedirectedResults) {
            if ($null -eq $redirRow) { continue }
            $existsInRedirected = $script:RedirectedResults | Where-Object { ($_.url -eq $redirRow.url) -and ($_.Port -eq $redirRow.Port) } | Select-Object -First 1
            $existsInResults    = $script:Results          | Where-Object { ($_.URL -eq $redirRow.url) -and ($_.Port -eq $redirRow.Port) } | Select-Object -First 1
            if ((-not $existsInRedirected) -and (-not $existsInResults)) {
                $script:RedirectedResults.Add($redirRow) | Out-Null
            }
        }
    }

    foreach ($u in $WorkerResult.SSLInspectedURLs) {
        if (-not ($script:SSLInspectedURLs -contains $u)) { $script:SSLInspectedURLs.Add($u) | Out-Null }
    }
    foreach ($u in $WorkerResult.CRLOfflineURLs) {
        if (-not ($script:CRLOfflineURLs -contains $u)) { $script:CRLOfflineURLs.Add($u) | Out-Null }
    }
    if ($WorkerResult.SSLInspectionDetected) { $script:SSLInspectionDetected = $true }
    # OR-merge the scalar PrivateLinkDetected flag — the parent uses this boolean (NOT
    # the array) at the end of Test-AzureLocalConnectivity to decide whether to print
    # the customer-facing 'PRIVATE LINK DETECTED' warning block.
    if ($WorkerResult.PrivateLinkDetected) { $script:PrivateLinkDetected = $true }
    foreach ($u in $WorkerResult.PrivateLinkDetectedArray) {
        if (-not ($script:PrivateLinkDetectedArray -contains $u)) { $script:PrivateLinkDetectedArray += $u }
    }
    foreach ($u in $WorkerResult.PrivateLinkCriticalArray) {
        if (-not ($script:PrivateLinkCriticalArray -contains $u)) { $script:PrivateLinkCriticalArray += $u }
    }
    foreach ($u in $WorkerResult.PrivateLinkProxyBypassArray) {
        if (-not ($script:PrivateLinkProxyBypassArray -contains $u)) { $script:PrivateLinkProxyBypassArray += $u }
    }
}


function Split-Layer7BucketsRoundRobin {
    <#
    .SYNOPSIS
    Cost-aware bin-packs a row array into N buckets, with plain round-robin fallback.
 
    .DESCRIPTION
    Endpoint timing is heterogeneous: rows that trigger CRL/OCSP chain validation
    or that are flagged as Critical/Wildcard typically take 2-3x longer than a
    plain HEAD probe. A pure `i % Buckets` round-robin can leave one worker with
    most of the slow rows.
 
    Algorithm (cost-aware mode, default):
      1. Estimate a per-row cost (Get-Layer7RowCost — CRL/OCSP/Critical = 3,
         Wildcard = 2, Redirected = 2, all others = 1).
      2. Sort rows DESC by cost. (Output ordering is preserved at MERGE time via
         RowID-sort — see Merge-Layer7WorkerResult — so the bucket-internal order
         does not affect customer-visible results.)
      3. Greedy bin-pack: for each row, place it in the bucket with the lowest
         current cumulative cost. Ties broken by lowest bucket index.
 
    Algorithm (legacy round-robin, opt-in via -RoundRobin):
      Plain `i % Buckets` — preserved for benchmarking / regression comparison.
 
    .PARAMETER Rows
    The full ordered array of rows to partition.
 
    .PARAMETER Buckets
    Number of buckets (= -Parallelism). Range 1-64.
 
    .PARAMETER RoundRobin
    Switch to force the legacy `i % Buckets` distribution. Default behaviour
    (switch absent) is cost-aware bin-packing.
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [array]$Rows,

        [Parameter(Mandatory)]
        [ValidateRange(1, 64)]
        [int]$Buckets,

        [switch]$RoundRobin
    )

    # Initialise N empty bucket arrays. The leading comma on `,@()` is required —
    # `for` would otherwise unwrap a 0-element array, leaving fewer than N buckets.
    $result = @(for ($i = 0; $i -lt $Buckets; $i++) { ,@() })

    if ($RoundRobin -or $Buckets -eq 1 -or $Rows.Count -le $Buckets) {
        # Legacy / trivial cases: bin-packing has no benefit.
        for ($i = 0; $i -lt $Rows.Count; $i++) {
            $b = $i % $Buckets
            $result[$b] += $Rows[$i]
        }
        return ,$result
    }

    # Cost-aware greedy bin-pack.
    $costs = @{}
    foreach ($row in $Rows) {
        $costs[$row] = Get-Layer7RowCost -Row $row
    }
    # Sort DESC by cost. Stable for ties (PowerShell's Sort-Object is NOT stable;
    # use a secondary key by original index to make ordering deterministic for tests).
    $indexed = for ($i = 0; $i -lt $Rows.Count; $i++) {
        [pscustomobject]@{ Row = $Rows[$i]; Cost = $costs[$Rows[$i]]; Index = $i }
    }
    $sorted = @($indexed | Sort-Object -Property @{Expression='Cost';Descending=$true}, @{Expression='Index';Descending=$false})

    $bucketCost = New-Object 'int[]' $Buckets
    foreach ($entry in $sorted) {
        # Find bucket with minimum cumulative cost (ties → lowest index).
        $minIdx = 0
        for ($b = 1; $b -lt $Buckets; $b++) {
            if ($bucketCost[$b] -lt $bucketCost[$minIdx]) { $minIdx = $b }
        }
        $result[$minIdx] += $entry.Row
        $bucketCost[$minIdx] += $entry.Cost
    }
    return ,$result
}

function Get-Layer7RowCost {
    <#
    .SYNOPSIS
    Estimate the relative cost of testing a Layer-7 row, used by Split-Layer7BucketsRoundRobin.
 
    .DESCRIPTION
    Returns 3 for CRL/OCSP / Critical rows (slowest — chain validation, often
    blocked endpoints with full timeout), 2 for Wildcard / Redirected rows
    (medium — extra DNS + sometimes a second HEAD), and 1 for everything else.
    The exact numbers are not load-bearing; they only need to reflect the
    relative wall-clock weight so the greedy bin-pack balances correctly.
    #>

    [CmdletBinding()]
    [OutputType([int])]
    param(
        [Parameter(Mandatory)]
        [object]$Row
    )

    $isCrl   = ($Row.PSObject.Properties['Source']     -and ($Row.Source -match 'CRL|OCSP|crl\.|ocsp\.'))
    $isCrit  = ($Row.PSObject.Properties['Source']     -and ($Row.Source -match 'Critical'))
    $isWild  = ($Row.PSObject.Properties['IsWildcard'] -and $Row.IsWildcard)
    $isRedir = ($Row.PSObject.Properties['Source']     -and ($Row.Source -match 'Redirect'))

    if ($isCrl -or $isCrit) { return 3 }
    if ($isWild -or $isRedir) { return 2 }
    return 1
}

# SIG # Begin signature block
# MIInRAYJKoZIhvcNAQcCoIInNTCCJzECAQExDzANBglghkgBZQMEA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