Private/AzStackHci.PolicyDocuments.Helpers.ps1

function New-OsConfigPolicyDocumentsRecord {
    param([string]$Node, [string]$Status = 'Unavailable', [string]$Message = '')
    [pscustomobject][ordered]@{
        SchemaVersion = '1.0'; Node = $Node; Result = 'INFO'
        StartedAtUtc = $null; CompletedAtUtc = $null; StorageVersion = $null
        CollectionStatus = $Status; EvidenceComplete = $false; EnumerationComplete = $false
        Documents = @(); Errors = @()
        Message = $Message
    }
}

function Read-OsConfigPolicyDocuments {
    [CmdletBinding()]
    param([string]$ModulePath)
    $ErrorActionPreference = 'Stop'
    $result = New-OsConfigPolicyDocumentsRecord -Node ([Environment]::MachineName) -Message 'Stored document inventory, not effective policy precedence, compliance or proof of enforcement.'
    $result.StartedAtUtc = [datetime]::UtcNow.ToString('o')
    try {
        if (-not $ModulePath) {
            $modules = @(Get-Module OsConfiguration -ListAvailable -ErrorAction Stop)
            if ($modules.Count -ne 1) { throw "No unique installed OsConfiguration module (found $($modules.Count)); no installation or version selection attempted." }
            $ModulePath = $modules[0].Path
        }
        $loaded = @(Import-Module $ModulePath -PassThru -Scope Local -ErrorAction Stop | Where-Object Name -eq 'OsConfiguration')
        if ($loaded.Count -ne 1) { throw 'Import did not return one OsConfiguration module.' }
        $result.StorageVersion = [string]$loaded[0].Version
        $documents = @(OsConfiguration\Get-OsConfiguration -ErrorAction Stop |
            OsConfiguration\Get-OsConfigurationDocument -ErrorAction Stop)
        if ($documents.Count -gt 1024) { throw 'Document inventory exceeds the 1024-document safety limit; inventory was not accepted.' }
        $result.EnumerationComplete = $true
        $seen = @{}
        $contentBytes = 0L
        foreach ($document in $documents) {
            $entry = [pscustomobject][ordered]@{
                SourceId = [string]$document.SourceId; Authority = [string]$document.FriendlyName
                Id = [string]$document.Id; Type = [string]$document.Type; State = [string]$document.State
                Version = [string]$document.Version; ResultChecksum = [string]$document.ResultChecksum
                ResultTimestamp = [string]$document.ResultTimestamp
                Content = $null; Scenarios = @(); ContentCollected = $false; Error = $null
            }
            $key = "$($entry.SourceId)/$($entry.Id)"
            if (-not $entry.SourceId -or -not $entry.Id -or $seen.ContainsKey($key)) {
                throw 'Document enumeration returned an empty or duplicate source/document identity.'
            }
            $seen[$key] = $true
            if ($entry.Type -eq 'DocumentTypeConfiguration') {
                try {
                    $content = OsConfiguration\Get-OsConfigurationDocumentContent `
                        -SourceId $entry.SourceId -Id $entry.Id -ErrorAction Stop
                    if ($content -isnot [string] -or [string]::IsNullOrWhiteSpace($content)) { throw 'Expected nonempty document JSON.' }
                    $size = [Text.Encoding]::UTF8.GetByteCount($content)
                    if ($size -gt 2MB -or ($contentBytes + $size) -gt 16MB) {
                        throw 'Configuration content exceeds the 2 MiB per-document / 16 MiB per-node safety limit; content was not retained.'
                    }
                    $contentBytes += $size
                    $entry.Content = $content
                    $parsed = ConvertFrom-Json -InputObject $content -ErrorAction Stop
                    $scenarios = @($parsed.OsConfiguration.Scenarios)
                    if (-not $scenarios.Count -or $null -eq $scenarios[0]) { throw 'No scenarios in configuration document.' }
                    foreach ($scenario in $scenarios) {
                        $name = [string]$scenario.Name
                        if (-not $name) { throw 'Scenario name is missing.' }
                        $payload = $scenario.PSObject.Properties[$name]
                        if ($null -eq $payload -or $payload.Value -isnot [pscustomobject]) {
                            throw "No settings object for scenario '$name'; raw content retained."
                        }
                        $entry.Scenarios += [pscustomobject]@{
                            Name = $name; Action = [string]$scenario.Action
                            Settings = @(
                                foreach ($property in $payload.Value.PSObject.Properties) {
                                    [pscustomobject]@{ Name = $property.Name; Value = $property.Value }
                                }
                            )
                        }
                    }
                    $entry.ContentCollected = $true
                } catch {
                    $entry.Error = $_.Exception.Message
                    $result.Errors += "${key}: $($entry.Error)"
                }
            }
            $result.Documents += $entry
        }
    } catch { $result.Errors += $_.Exception.Message }
    $result.EvidenceComplete = $result.EnumerationComplete -and $result.Errors.Count -eq 0
    $result.CollectionStatus = if ($result.EvidenceComplete) { 'Collected' } elseif ($result.Documents.Count -or $result.EnumerationComplete) { 'Partial' } else { 'Unavailable' }
    $result.CompletedAtUtc = [datetime]::UtcNow.ToString('o')
    $result
}

function Get-OsConfigPolicyDocumentsEvidence {
    [CmdletBinding()]
    param([string]$Node, [string]$OutputPath, [ValidateRange(1, 120)][int]$TimeoutSeconds = 30)
    $record = New-OsConfigPolicyDocumentsRecord -Node $Node -Message 'Policy document collection unavailable; no policy absence or enforcement conclusion.'
    $record.StartedAtUtc = [datetime]::UtcNow.ToString('o')
    $job = $null
    try {
        $loaded = @(Get-Module OsConfiguration -All)
        if ($loaded.Count -gt 1) { throw 'Multiple loaded OsConfiguration modules; source version is ambiguous.' }
        $modulePath = if ($loaded.Count -eq 1) { $loaded[0].Path } else { $null }
        $definitions = @('New-OsConfigPolicyDocumentsRecord', 'Read-OsConfigPolicyDocuments') | ForEach-Object {
            "function $_ { $((Get-Command $_ -CommandType Function -ErrorAction Stop).Definition) }"
        }
        $job = Start-Job -ArgumentList ($definitions -join "`n"), $modulePath -ScriptBlock {
            param($Definitions, $ModulePath)
            $ErrorActionPreference = 'Stop'
            $process = [Diagnostics.Process]::GetCurrentProcess()
            try { [pscustomobject]@{ ProcessId = $PID; StartTimeUtcTicks = $process.StartTime.ToUniversalTime().Ticks } }
            finally { $process.Dispose() }
            if ($PSVersionTable.PSVersion.Major -ne 5 -or $PSVersionTable.PSVersion.Minor -ne 1) { throw 'Policy document collection requires Windows PowerShell 5.1.' }
            . ([scriptblock]::Create($Definitions))
            Read-OsConfigPolicyDocuments -ModulePath $ModulePath
        } -ErrorAction Stop
        if ($null -eq (Wait-Job -Job $job -Timeout $TimeoutSeconds -ErrorAction Stop)) { throw "Policy document worker timed out after $TimeoutSeconds seconds." }
        $output = @(Receive-Job -Job $job -Keep -ErrorAction Stop)
        if ($job.State -ne 'Completed' -or $output.Count -ne 2 -or $output[1].Node -ine $Node) {
            throw 'Policy document worker did not return one node-matched observation.'
        }
        $record = $output[1]
    } catch { $record.Errors += $_.Exception.Message }
    finally {
        if ($null -ne $job) {
            if ($job.State -notin @('Completed', 'Failed', 'Stopped')) {
                $identity = @(Receive-Job -Job $job -Keep -ErrorAction SilentlyContinue) | Select-Object -First 1
                $process = $null
                try {
                    if ($null -eq $identity -or -not $identity.ProcessId) { throw 'Worker process identity was not returned.' }
                    $process = [Diagnostics.Process]::GetProcessById([int]$identity.ProcessId)
                    if ($process.Id -eq $PID -or $process.StartTime.ToUniversalTime().Ticks -ne [long]$identity.StartTimeUtcTicks) { throw 'Worker process identity did not match.' }
                    $process.Kill()
                    if (-not $process.WaitForExit(5000)) { throw 'Worker did not exit after termination.' }
                } catch {
                    $record.Errors += "Worker cleanup: $($_.Exception.Message)"
                    Write-Warning "Unable to terminate owned policy document worker: $($_.Exception.Message)" -WarningAction Continue
                } finally { if ($null -ne $process) { $process.Dispose() } }
            }
            try { Remove-Job -Job $job -Force -ErrorAction Stop }
            catch {
                $record.Errors += "Job cleanup: $($_.Exception.Message)"
                Write-Warning "Unable to remove owned policy document job: $($_.Exception.Message)" -WarningAction Continue
            }
        }
    }
    $record.EvidenceComplete = $record.EnumerationComplete -and $record.Errors.Count -eq 0
    $record.CollectionStatus = if ($record.EvidenceComplete) { 'Collected' } elseif ($record.Documents.Count -or $record.EnumerationComplete) { 'Partial' } else { 'Unavailable' }
    if (-not $record.CompletedAtUtc) { $record.CompletedAtUtc = [datetime]::UtcNow.ToString('o') }
    if ($OutputPath) {
        $path = Join-Path (Join-Path $OutputPath $Node) "$Node-PolicyDocuments.json"
        $record | ConvertTo-Json -Depth 100 | Out-File -LiteralPath $path -Encoding utf8 -Force -ErrorAction Stop
    }
    $record
}

function Assert-OsConfigPolicyDocumentsArtifact {
    param($Evidence, [string]$Node)
    if ($null -eq $Evidence -or $Evidence.Node -ine $Node -or $Evidence.SchemaVersion -cne '1.0' -or
        $Evidence.Result -cne 'INFO' -or $Evidence.CollectionStatus -cnotin @('Collected', 'Partial', 'Unavailable') -or
        $Evidence.EvidenceComplete -isnot [bool] -or $Evidence.EnumerationComplete -isnot [bool] -or
        $Evidence.Documents -isnot [System.Collections.IList] -or $Evidence.Errors -isnot [System.Collections.IList] -or
        $Evidence.Documents.Count -gt 1024 -or
        $Evidence.EvidenceComplete -ne ($Evidence.EnumerationComplete -and $Evidence.Errors.Count -eq 0)) {
        throw 'Invalid policy document inventory envelope.'
    }
    $status = if ($Evidence.EvidenceComplete) { 'Collected' } elseif ($Evidence.Documents.Count -or $Evidence.EnumerationComplete) { 'Partial' } else { 'Unavailable' }
    if ($Evidence.CollectionStatus -cne $status) { throw 'Policy document collection status disagrees with coverage.' }
    foreach ($errorMessage in $Evidence.Errors) {
        if ($errorMessage -isnot [string] -or [string]::IsNullOrWhiteSpace($errorMessage)) { throw 'Invalid policy document collection error.' }
    }
    if (-not $Evidence.EvidenceComplete -and -not $Evidence.Errors.Count) { throw 'Incomplete policy inventory has no error.' }
    $seen = @{}
    foreach ($document in $Evidence.Documents) {
        $key = "$($document.SourceId)/$($document.Id)"
        if ([string]::IsNullOrWhiteSpace($document.SourceId) -or [string]::IsNullOrWhiteSpace($document.Id) -or $seen.ContainsKey($key) -or
            $document.ContentCollected -isnot [bool] -or $document.Scenarios -isnot [System.Collections.IList]) { throw 'Invalid policy document identity or shape.' }
        $seen[$key] = $true
        if ($document.Type -eq 'DocumentTypeConfiguration') {
            if ($document.ContentCollected -and ($document.Error -or -not $document.Scenarios.Count -or $document.Content -isnot [string])) { throw 'Invalid collected configuration document.' }
            if (-not $document.ContentCollected -and (-not $document.Error -or -not $Evidence.Errors.Count)) { throw 'Unread configuration document lacks an error.' }
            if ($document.ContentCollected) {
                $parsed = ConvertFrom-Json -InputObject $document.Content -ErrorAction Stop
                $originalScenarios = @($parsed.OsConfiguration.Scenarios)
                if ($originalScenarios.Count -ne $document.Scenarios.Count) { throw 'Scenario inventory disagrees with stored content.' }
                for ($i = 0; $i -lt $originalScenarios.Count; $i++) {
                    $original = $originalScenarios[$i]
                    $scenario = $document.Scenarios[$i]
                    if ($scenario.Name -cne $original.Name -or $scenario.Action -cne [string]$original.Action) { throw 'Scenario identity/action disagrees with stored content.' }
                    $payload = $original.PSObject.Properties[[string]$original.Name]
                    if ($null -eq $payload -or $payload.Value -isnot [pscustomobject]) { throw 'Stored scenario has no settings object.' }
                    $properties = @($payload.Value.PSObject.Properties)
                    if ($properties.Count -ne $scenario.Settings.Count) { throw 'Requested setting inventory disagrees with stored content.' }
                    for ($j = 0; $j -lt $properties.Count; $j++) {
                        $value = $properties[$j].Value
                        $capturedValue = $scenario.Settings[$j].Value
                        if ($properties[$j].Name -cne $scenario.Settings[$j].Name -or
                            (ConvertTo-Json -InputObject $value -Depth 100 -Compress) -cne (ConvertTo-Json -InputObject $capturedValue -Depth 100 -Compress)) {
                            throw 'Requested setting value disagrees with stored content.'
                        }
                    }
                }
            }
        } elseif ($document.ContentCollected -or $null -ne $document.Content -or $document.Scenarios.Count) {
            throw 'Non-configuration document was presented as configuration evidence.'
        }
        foreach ($scenario in $document.Scenarios) {
            if ([string]::IsNullOrWhiteSpace($scenario.Name) -or $scenario.Settings -isnot [System.Collections.IList]) { throw 'Invalid policy scenario.' }
            foreach ($setting in $scenario.Settings) {
                if ([string]::IsNullOrWhiteSpace($setting.Name) -or -not $setting.PSObject.Properties['Value']) { throw 'Invalid requested setting.' }
            }
        }
    }
}

function Get-OsConfigPolicyDocumentsSummary {
    param([string]$ExportPath, [string[]]$Nodes, [System.Collections.IDictionary]$DocumentSnapshot)
    $details = @(
        foreach ($node in $Nodes) {
            $path = Join-Path (Join-Path $ExportPath $node) "$node-PolicyDocuments.json"
            if ($null -ne $DocumentSnapshot -and $DocumentSnapshot.Contains($path)) {
                $DocumentSnapshot[$path]
                continue
            }
            $record = New-OsConfigPolicyDocumentsRecord -Node $node -Status 'NotCollected' -Message 'No policy document artifact was captured; no live query or reassessment performed.'
            if (Test-Path -LiteralPath $path) {
                try {
                    if ((Get-Item -LiteralPath $path -ErrorAction Stop).Length -gt 128MB) { throw 'Policy document artifact exceeds the replay size limit.' }
                    $captured = Get-Content -LiteralPath $path -Raw -ErrorAction Stop | ConvertFrom-Json -ErrorAction Stop
                    Assert-OsConfigPolicyDocumentsArtifact -Evidence $captured -Node $node
                    $record = $captured
                } catch {
                    $record.CollectionStatus = 'Unavailable'
                    $record.Errors = @("Invalid policy document artifact: $($_.Exception.Message)")
                    $record.Message = 'Captured policy document inventory could not be used; no fallback or live query performed.'
                }
            }
            if ($null -ne $DocumentSnapshot) { $DocumentSnapshot[$path] = $record }
            $record
        }
    )
    $complete = @($details | Where-Object EvidenceComplete)
    $differs = $null
    if ($complete.Count -ge 2) {
        $signatures = @(
            foreach ($detail in $complete) {
                $identities = @($detail.Documents | Where-Object Type -eq 'DocumentTypeConfiguration' |
                    ForEach-Object { [pscustomobject]@{ Authority = $_.Authority; Id = $_.Id } } |
                    Sort-Object Authority, Id)
                ConvertTo-Json -InputObject $identities -Compress -Depth 3
            }
        )
        $differs = @($signatures | Where-Object { $_ -cne $signatures[0] }).Count -gt 0
    }
    [pscustomobject]@{
        CheckId = 'PolicyDocuments'; Severity = 'Low'; Result = 'INFO'
        EvidenceComplete = ($Nodes.Count -gt 0 -and $complete.Count -eq $Nodes.Count)
        EvaluatedNodes = @($complete | ForEach-Object Node)
        MissingNodes = @($details | Where-Object { -not $_.EvidenceComplete } | ForEach-Object Node)
        ConfigurationInventoryDiffers = $differs
        Message = 'Informational stored intent. Inventory differences compare authority labels/document IDs on complete nodes only, not setting values, applicability or enforcement. Completed does not mean compliant.'
        Details = $details
    }
}

function New-OsConfigPolicySettingIndex {
    [CmdletBinding()]
    param($Inventory)
    $lookup = [System.Collections.Hashtable]::new([StringComparer]::InvariantCulture)
    if ($null -eq $Inventory) { return $lookup }
    foreach ($document in $Inventory.Documents) {
        if ($document.Type -cne 'DocumentTypeConfiguration' -or -not $document.ContentCollected) { continue }
        for ($index = 0; $index -lt $document.Scenarios.Count; $index++) {
            $scenario = $document.Scenarios[$index]
            if ($scenario.Action -cne 'set' -or $scenario.Name -cnotin @('SecurityBaselineALMemberServer', 'SecurityBaselineAzureStackHCI24H2MemberServer')) { continue }
            foreach ($value in $scenario.Settings) {
                $name = [string]$value.Name
                if (-not $lookup.ContainsKey($name)) { $lookup[$name] = New-Object 'System.Collections.Generic.List[object]' }
                $lookup[$name].Add([pscustomobject]@{ Document=$document; Scenario=$scenario; ScenarioIndex=$index; Setting=$value })
            }
        }
    }
    return $lookup
}

function Get-OsConfigPolicySettingEvidence {
    [CmdletBinding()]
    param($Setting, $Inventory, [string]$Node, [System.Collections.IDictionary]$SettingIndex)
    $result = [pscustomobject][ordered]@{
        MappingVersion = '1.0'; Result = 'INFO'; State = 'NotCollected'
        Node = $Node; InventoryComplete = $false; CollectionStatus = 'NotCollected'
        InventoryStartedAtUtc = $null; InventoryCompletedAtUtc = $null
        ConflictingValues = $null; Observations = @(); Errors = @()
        Message = 'No captured policy inventory linked to this setting; no live query or effective-policy conclusion.'
    }
    if ($null -eq $Inventory) { return $result }
    $result.State = 'Unavailable'
    $result.Errors = @($Inventory.Errors)
    if ($Inventory.Node -ine $Node) {
        $result.Errors += 'Policy inventory node does not match the assessed node.'
        return $result
    }
    $result.InventoryComplete = $Inventory.EvidenceComplete
    $result.CollectionStatus = $Inventory.CollectionStatus
    $result.InventoryStartedAtUtc = $Inventory.StartedAtUtc
    $result.InventoryCompletedAtUtc = $Inventory.CompletedAtUtc
    $name = if ($Setting.PSObject.Properties['Name']) { [string]$Setting.Name } else { [string]$Setting.CheckId }
    if ($null -eq $SettingIndex) { $SettingIndex = New-OsConfigPolicySettingIndex -Inventory $Inventory }
    $entries = @(if ($SettingIndex.Contains($name)) { $SettingIndex[$name].ToArray() })
    foreach ($entry in $entries) {
        $document = $entry.Document
        $scenario = $entry.Scenario
        $value = $entry.Setting
        $matches = $null
        $comparison = 'NotEvaluated'
        if ($Inventory.EvidenceComplete) {
            $matches = Get-OsConfigCustomizationValueMatch -Setting $Setting -Target $value.Value
            $comparison = if ($null -eq $matches) { 'NotComparable' } elseif ($matches) { 'MatchesObserved' } else { 'DiffersFromObserved' }
        }
        $result.Observations += [pscustomobject][ordered]@{
            SourceId = $document.SourceId; Authority = $document.Authority
            DocumentId = $document.Id; DocumentVersion = $document.Version; DocumentState = $document.State
            DocumentResultTimestamp = $document.ResultTimestamp
            Scenario = $scenario.Name; ScenarioIndex = $entry.ScenarioIndex; Action = $scenario.Action
            SettingName = $value.Name; RequestedValue = $value.Value
            Comparison = $comparison; ValueMatches = $matches
        }
    }
    $numeric = @('Byte','SByte','Int16','UInt16','Int32','UInt32','Int64','UInt64')
    $scalars = @($result.Observations | Where-Object {
        $_.RequestedValue -is [string] -or ($null -ne $_.RequestedValue -and $_.RequestedValue.GetType().Name -in $numeric)
    })
    if ($scalars.Count) {
        $values = @($scalars | ForEach-Object { ConvertTo-Json -InputObject $_.RequestedValue -Compress })
        if (@($values | Where-Object { $_ -cne $values[0] }).Count) { $result.ConflictingValues = $true }
        elseif ($Inventory.EvidenceComplete -and $scalars.Count -eq $result.Observations.Count) { $result.ConflictingValues = $false }
    }
    $result.State = if ($result.ConflictingValues -eq $true) { 'ConflictingRecordedValues' }
        elseif (-not $Inventory.EvidenceComplete) { 'Unavailable' }
        elseif (-not $result.Observations.Count) { 'NoMatchingDocument' }
        else { 'RecordedValues' }
    $result.Message = 'Exact baseline-scenario/setting identity links only. Every captured authority is retained; no winner or effective target is selected. Scalar comparisons reuse the recorded-customization comparator and do not change published results, customization assessments or runtime enforcement claims.'
    if (-not $Inventory.EvidenceComplete) { $result.Message += ' Inventory coverage is incomplete; observations are retained but actual-value comparisons are withheld.' }
    if (-not $result.Observations.Count) { $result.Message += ' No matching readable set action in the two qualified baseline scenarios; other scenarios and policy mechanisms are not excluded.' }
    $result
}

function Get-OsConfigValidatedPolicySettingEvidence {
    param($Captured, $Setting, $Inventory, [string]$Node, [System.Collections.IDictionary]$SettingIndex)
    if ($null -eq $Captured) { return $null }
    try {
        if ($Captured.MappingVersion -cne '1.0') { throw 'Unsupported per-setting policy mapping version.' }
        if ($null -ne $Inventory -and $Inventory.CollectionStatus -eq 'NotCollected') { $Inventory = $null }
        if ($Inventory.Errors -and @($Inventory.Errors | Where-Object { $_ -like 'Invalid policy document artifact:*' }).Count) {
            throw 'Linked policy inventory is invalid.'
        }
        $expected = Get-OsConfigPolicySettingEvidence -Setting $Setting -Inventory $Inventory -Node $Node -SettingIndex $SettingIndex
        foreach ($field in @('Result','State','Node','InventoryComplete','CollectionStatus','InventoryStartedAtUtc','InventoryCompletedAtUtc','ConflictingValues','Observations','Errors')) {
            if (-not $Captured.PSObject.Properties[$field] -or
                (ConvertTo-Json -InputObject $Captured.$field -Depth 100 -Compress) -cne (ConvertTo-Json -InputObject $expected.$field -Depth 100 -Compress)) {
                throw "Per-setting policy evidence disagrees with captured inventory/actual values: $field."
            }
        }
        return $Captured
    } catch {
        $unavailable = Get-OsConfigPolicySettingEvidence -Setting $Setting -Node $Node
        $unavailable.State = 'Unavailable'; $unavailable.CollectionStatus = 'Unavailable'
        $unavailable.Errors = @($_.Exception.Message)
        $unavailable.Message = 'Captured per-setting policy evidence could not be validated. Primary baseline results remain unchanged; no live query or replacement assessment was performed.'
        return $unavailable
    }
}

function Add-OsConfigPolicySettingEvidence {
    [CmdletBinding()]
    param($Assessment, $Inventory, [string]$OutputPath, [switch]$DeferExport)
    if ($null -eq $Assessment) { throw 'Baseline assessment is required to attach policy evidence.' }
    if ($null -ne $Inventory) { Assert-OsConfigPolicyDocumentsArtifact -Evidence $Inventory -Node $Assessment.Node }
    $settingIndex = New-OsConfigPolicySettingIndex -Inventory $Inventory
    $updates = New-Object 'System.Collections.Generic.List[object]'
    foreach ($setting in $Assessment.Settings) {
        $context = Get-OsConfigPolicySettingEvidence -Setting $setting -Inventory $Inventory -Node $Assessment.Node -SettingIndex $settingIndex
        $updates.Add([pscustomobject]@{ Setting=$setting; Context=$context; Original=$setting.PSObject.Properties['PolicyDocumentEvidence'] })
    }
    try {
        foreach ($update in $updates) {
            $update.Setting | Add-Member -NotePropertyName PolicyDocumentEvidence -NotePropertyValue $update.Context -Force -ErrorAction Stop
        }
    } catch {
        # Leave a complete baseline-only (or previously enriched) assessment for the caller's final export.
        foreach ($update in $updates) {
            $update.Setting.PSObject.Properties.Remove('PolicyDocumentEvidence')
            if ($null -ne $update.Original) { $update.Setting.PSObject.Properties.Add($update.Original) }
        }
        throw
    }
    if (-not $DeferExport) { Export-OsConfigBaselineAssessment -Assessment $Assessment -OutputPath $OutputPath }
}

function ConvertTo-OsConfigPolicyDocumentsHtml {
    param($Detail)
    $html = [Text.StringBuilder]::new()
    [void]$html.Append('<div class="policy-documents-section"><details class="policy-documents"><summary style="font-weight:600;white-space:normal;overflow-wrap:anywhere;">Policy Documents (' + $Detail.Documents.Count + ')<span style="display:block;font-weight:400;">Collection: ' + (ConvertTo-HtmlSafe $Detail.CollectionStatus) + '</span></summary><p>Stored configuration intent, not effective precedence or proof of enforcement. Query documents are inventory only; different scenario versions are not inherently unhealthy.</p>')
    [void]$html.Append('<p>Collection: ' + (ConvertTo-HtmlSafe $Detail.CollectionStatus) + '. ' + (ConvertTo-HtmlSafe $Detail.Message) + '</p>')
    [void]$html.Append('<div class="table-wrapper"><table><tr><th>Authority / Source ID</th><th>Document / Type</th><th>State</th><th>Scenario / Action</th><th>Requested settings</th></tr>')
    foreach ($document in $Detail.Documents) {
        $scenarios = @($document.Scenarios | ForEach-Object { "$($_.Name) / $($_.Action) ($(@($_.Settings).Count) settings)" }) -join '; '
        $settingsHtml = [Text.StringBuilder]::new()
        foreach ($scenario in $document.Scenarios) {
            foreach ($setting in $scenario.Settings) {
                $value = if ($null -eq $setting.Value) { 'null' } else { ConvertTo-Json -InputObject $setting.Value -Depth 100 -Compress }
                [void]$settingsHtml.Append('<div>' + (ConvertTo-HtmlSafe "$($scenario.Name)/$($setting.Name)") + ': ' + (ConvertTo-HtmlSafe $value) + '</div>')
            }
        }
        $contentHtml = if ($document.Type -eq 'DocumentTypeConfiguration') {
            '<details><summary>Requested values / read errors</summary>' + $settingsHtml.ToString() + (ConvertTo-HtmlSafe $document.Error) + '</details>'
        } else { 'Not read (inventory only)' }
        [void]$html.Append('<tr><td>' + (ConvertTo-HtmlSafe "$($document.Authority) / $($document.SourceId)") + '</td><td>' + (ConvertTo-HtmlSafe "$($document.Id) / $($document.Type)") + '</td><td>' + (ConvertTo-HtmlSafe $document.State) + '</td><td>' + (ConvertTo-HtmlSafe $scenarios) + '</td><td>' + $contentHtml + '</td></tr>')
    }
    [void]$html.Append('</table></div>')
    if (-not $Detail.Documents.Count) { [void]$html.Append('<p>No document rows captured. This does not establish that no policy applies.</p>') }
    [void]$html.Append('</details>')
    foreach ($errorMessage in $Detail.Errors) { [void]$html.Append('<p class="badge badge-na">Policy Documents collection: ' + (ConvertTo-HtmlSafe $errorMessage) + '</p>') }
    [void]$html.Append('</div>')
    $html.ToString()
}

# SIG # Begin signature block
# MIInKAYJKoZIhvcNAQcCoIInGTCCJxUCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCDk10NbJd2WtLeG
# zv97mMp5h/+pkhFGGcJ/wGYfWwibBqCCDLowggX1MIID3aADAgECAhMzAAACHU0Z
# yE7XD1dIAAAAAAIdMA0GCSqGSIb3DQEBCwUAMFcxCzAJBgNVBAYTAlVTMR4wHAYD
# VQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xKDAmBgNVBAMTH01pY3Jvc29mdCBD
# b2RlIFNpZ25pbmcgUENBIDIwMjQwHhcNMjYwNDE2MTg1OTQzWhcNMjcwNDE1MTg1
# OTQzWjB0MQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UE
# BxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMR4wHAYD
# VQQDExVNaWNyb3NvZnQgQ29ycG9yYXRpb24wggEiMA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