bcquality/tools/Resolve-SkillWorklist.ps1
Stefano Demiliani 4287233f80
Strengthen review contracts and add AL reliability guidance (#196)
* Strengthen review contracts and HTTP guidance

- add outbound HttpClient transport and HTTP status review rules with paired fixtures`n- resolve layered action-skill overrides deterministically across enabled layers`n- validate findings reports and enforce measurable changed-fixture coverage

* Add data handling and test isolation guidance

- add SCM guidance for deriving base quantities through line unit-of-measure validation`n- add security guidance for parameterizing SetFilter with external text`n- add test isolation guidance for resetting per-test state before initialization guards`n- add web-service guidance for JSON null handling and invariant standard format 9`n- route and cover all five rules with paired evaluation fixtures

* Fix findings report rollup validation

* Validate findings report rollups

* Enforce merged finding identity

* Fix locationless finding deduplication

* Reject conflicting merged corrections

* Detect conflicting leaf corrections

* Route HTTP error checks to canonical web-services knowledge

Let the Error Handling leaf conditionally retrieve the existing HTTP owner articles, preserving applicability and exact-path provenance. Add deterministic source-contract and retrieval regressions without duplicating knowledge rules.

Copilot-Session-Id: a92a7788-103e-4651-9b84-19e34caffb94

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: wenjiefan <wenjiefan@microsoft.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jesper Schulz-Wedde <jesper.schulzwedde@microsoft.com>
2026-09-29 13:03:39 +02:00

92 lines
No EOL
3 KiB
PowerShell

<#
.SYNOPSIS
Resolves a super-skill's ordered leaf worklist across enabled layers.
#>
[CmdletBinding()]
param(
[string] $BCQualityRoot,
[string] $IndexPath,
[Parameter(Mandatory)]
[string] $SuperSkillPath,
[string[]] $EnabledLayers = @('microsoft', 'community', 'custom'),
[string[]] $DisabledSkills = @()
)
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
if (-not $BCQualityRoot) {
$BCQualityRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
}
$BCQualityRoot = (Resolve-Path -LiteralPath $BCQualityRoot).Path
if (-not $IndexPath) {
$IndexPath = Join-Path $BCQualityRoot 'skill-index.json'
}
if (-not (Test-Path -LiteralPath $IndexPath -PathType Leaf)) {
& (Join-Path $PSScriptRoot 'Build-SkillIndex.ps1') -BCQualityRoot $BCQualityRoot -IndexPath $IndexPath | Out-Null
}
$knownLayers = @('microsoft', 'community', 'custom')
$unknownLayers = @($EnabledLayers | Where-Object { $_ -cnotin $knownLayers })
if ($unknownLayers.Count) {
throw "Unknown enabled layers: $($unknownLayers -join ', ')"
}
$index = Get-Content -LiteralPath $IndexPath -Raw | ConvertFrom-Json
$skills = @($index.skills)
$superSkills = @($skills | Where-Object path -CEQ $SuperSkillPath)
if ($superSkills.Count -ne 1) {
throw "Expected one indexed super-skill at '$SuperSkillPath', found $($superSkills.Count)."
}
$superSkill = $superSkills[0]
if (-not @($superSkill.subSkills).Count) {
throw "Action skill '$SuperSkillPath' is not a super-skill."
}
$precedence = @{ microsoft = 0; community = 1; custom = 2 }
$resolved = [Collections.Generic.List[object]]::new()
$skipped = [Collections.Generic.List[object]]::new()
foreach ($declaredPath in @($superSkill.subSkills)) {
$declared = @($skills | Where-Object path -CEQ $declaredPath)
if ($declared.Count -ne 1) {
throw "Declared sub-skill '$declaredPath' is not uniquely indexed."
}
$candidates = @(
$skills |
Where-Object {
$_.id -CEQ $declared[0].id -and
$_.layer -cin $EnabledLayers -and
$_.path -cnotin $DisabledSkills -and
-not @($_.subSkills).Count
} |
Sort-Object @{ Expression = { $precedence[$_.layer] }; Descending = $true }, path
)
if (-not $candidates.Count) {
$skipped.Add([pscustomobject][ordered]@{
id = $declared[0].id
declaredPath = $declaredPath
reason = 'configuration'
}) | Out-Null
continue
}
$winner = $candidates[0]
$resolved.Add([pscustomobject][ordered]@{
id = $winner.id
path = $winner.path
version = $winner.version
layer = $winner.layer
declaredPath = $declaredPath
}) | Out-Null
}
return [pscustomobject][ordered]@{
superSkill = [pscustomobject][ordered]@{
id = $superSkill.id
path = $superSkill.path
version = $superSkill.version
}
subSkills = @($resolved)
skipped = @($skipped)
}