@danmoisan/drm-copilot-mcp 1.1.25 → 1.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/out/mcp-server.js +170 -52
  2. package/package.json +1 -1
  3. package/resources/claude-customizations/.claude/agents/atomic-executor.md +3 -3
  4. package/resources/claude-customizations/.claude/agents/atomic-planner.md +2 -2
  5. package/resources/claude-customizations/.claude/agents/csharp-typed-engineer.md +7 -7
  6. package/resources/claude-customizations/.claude/agents/feature-review.md +6 -3
  7. package/resources/claude-customizations/.claude/agents/orchestrator.md +11 -7
  8. package/resources/claude-customizations/.claude/agents/parallel-orchestrator.md +7 -3
  9. package/resources/claude-customizations/.claude/agents/parallel-planner.md +6 -2
  10. package/resources/claude-customizations/.claude/agents/powershell-typed-engineer.md +7 -7
  11. package/resources/claude-customizations/.claude/agents/python-typed-engineer.md +6 -6
  12. package/resources/claude-customizations/.claude/hooks/enforce-epic-merge-gate-review.ps1 +699 -0
  13. package/resources/claude-customizations/.claude/hooks/enforce-epic-merge-gate.ps1 +16 -1
  14. package/resources/claude-customizations/.claude/hooks/enforce-model-routing-receipt.ps1 +41 -0
  15. package/resources/claude-customizations/.claude/hooks/enforce-orchestration-preimplementation-gate-cleanup.ps1 +481 -0
  16. package/resources/claude-customizations/.claude/hooks/enforce-orchestration-preimplementation-gate.ps1 +3 -1
  17. package/resources/claude-customizations/.claude/hooks/enforce-parallel-cohort-barrier-helpers.ps1 +69 -3
  18. package/resources/claude-customizations/.claude/hooks/enforce-pr-author-skill-helpers.ps1 +2 -2
  19. package/resources/claude-customizations/.claude/hooks/enforce-pr-author-skill.cleanup.ps1 +246 -0
  20. package/resources/claude-customizations/.claude/hooks/enforce-pr-author-skill.docs-only.ps1 +1 -0
  21. package/resources/claude-customizations/.claude/hooks/hook-cleanup-context.ps1 +343 -0
  22. package/resources/claude-customizations/.claude/hooks/validate-feature-review-coverage-rules.ps1 +50 -16
  23. package/resources/claude-customizations/.claude/lib/orchestrator-state/OrchestratorState.psm1 +6 -1
  24. package/resources/claude-customizations/.claude/lib/orchestrator-state/OrchestratorStateCompletion.psm1 +4 -2
  25. package/resources/claude-customizations/.claude/lib/orchestrator-state/OrchestratorStateCompletionChecks.psm1 +51 -2
  26. package/resources/claude-customizations/.claude/lib/orchestrator-state/OrchestratorStateReceipts.psm1 +5 -2
  27. package/resources/claude-customizations/.claude/lib/orchestrator-state/OrchestratorStateRemediationAccounting.psm1 +116 -4
  28. package/resources/claude-customizations/.claude/lib/parallel-admission/Invoke-ParallelAdmission.ps1 +626 -0
  29. package/resources/claude-customizations/.claude/lib/parallel-admission/ParallelAdmission.psm1 +508 -0
  30. package/resources/claude-customizations/.claude/lib/parallel-admission/ParallelAdmissionJson.psm1 +141 -0
  31. package/resources/claude-customizations/.claude/lib/parallel-admission/ParallelAdmissionPrecedence.psm1 +508 -0
  32. package/resources/claude-customizations/.claude/rules/csharp.md +8 -8
  33. package/resources/claude-customizations/.claude/rules/orchestrator-state.md +28 -2
  34. package/resources/claude-customizations/.claude/rules/parallel-orchestration.md +17 -1
  35. package/resources/claude-customizations/.claude/rules/powershell.md +2 -2
  36. package/resources/claude-customizations/.claude/settings.json +1 -0
  37. package/resources/claude-customizations/.claude/skills/atomic-plan-contract/SKILL.md +9 -13
  38. package/resources/claude-customizations/.claude/skills/cleanup-merged-worktrees/SKILL.md +93 -14
  39. package/resources/claude-customizations/.claude/skills/cleanup-merged-worktrees/scripts/cleanup-worktrees.sh +23 -10
  40. package/resources/claude-customizations/.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_preserve_lib.sh +54 -46
  41. package/resources/claude-customizations/.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_preserve_merge_lib.sh +234 -0
  42. package/resources/claude-customizations/.claude/skills/csharp-qa-gate/SKILL.md +14 -15
  43. package/resources/claude-customizations/.claude/skills/epic-progress-report/SKILL.md +338 -0
  44. package/resources/claude-customizations/.claude/skills/epic-progress-report/scripts/Get-EpicProgressReport.Logic.ps1 +248 -0
  45. package/resources/claude-customizations/.claude/skills/epic-progress-report/scripts/Get-EpicProgressReport.Metrics.ps1 +232 -0
  46. package/resources/claude-customizations/.claude/skills/epic-progress-report/scripts/Get-EpicProgressReport.Render.ps1 +196 -0
  47. package/resources/claude-customizations/.claude/skills/epic-progress-report/scripts/Get-EpicProgressReport.State.ps1 +286 -0
  48. package/resources/claude-customizations/.claude/skills/epic-progress-report/scripts/Get-EpicProgressReport.ps1 +475 -0
  49. package/resources/claude-customizations/.claude/skills/execution-environment/SKILL.md +31 -16
  50. package/resources/claude-customizations/.claude/skills/feature-review-workflow/SKILL.md +21 -9
  51. package/resources/claude-customizations/.claude/skills/invoke-csharp-engineer/SKILL.md +5 -5
  52. package/resources/claude-customizations/.claude/skills/invoke-powershell-engineer/SKILL.md +4 -4
  53. package/resources/claude-customizations/.claude/skills/invoke-python-engineer/SKILL.md +4 -4
  54. package/resources/claude-customizations/.claude/skills/orchestrate/SKILL.md +24 -2
  55. package/resources/claude-customizations/.claude/skills/parallel-add/SKILL.md +71 -7
  56. package/resources/claude-customizations/.claude/skills/parallel-orchestrate/SKILL.md +34 -2
  57. package/resources/claude-customizations/.claude/skills/parallel-plan/SKILL.md +82 -12
  58. package/resources/claude-customizations/.claude/skills/powershell-qa-gate/SKILL.md +16 -17
  59. package/resources/claude-customizations/.claude/skills/python-qa-gate/SKILL.md +15 -16
  60. package/resources/claude-customizations/.claude/skills/remediation-handoff-atomic-planner/SKILL.md +1 -1
  61. package/resources/claude-customizations/.claude-variants/csharp-legacy/agents/csharp-typed-engineer.md +6 -6
  62. package/resources/claude-customizations/.claude-variants/csharp-legacy/skills/csharp-qa-gate/SKILL.md +13 -14
  63. package/resources/claude-customizations/.claude-variants/csharp-legacy/skills/invoke-csharp-engineer/SKILL.md +4 -4
  64. package/resources/claude-customizations/pack-manifests/core.json +15 -0
  65. package/resources/codex-and-agents-customizations/.agents/skills/atomic-plan-contract/SKILL.md +8 -12
  66. package/resources/codex-and-agents-customizations/.agents/skills/atomic-planner/SKILL.md +1 -1
  67. package/resources/codex-and-agents-customizations/.agents/skills/csharp-qa-gate/SKILL.md +13 -14
  68. package/resources/codex-and-agents-customizations/.agents/skills/execution-environment/SKILL.md +31 -16
  69. package/resources/codex-and-agents-customizations/.agents/skills/feature-review/SKILL.md +5 -1
  70. package/resources/codex-and-agents-customizations/.agents/skills/feature-review-workflow/SKILL.md +18 -5
  71. package/resources/codex-and-agents-customizations/.agents/skills/invoke-csharp-engineer/SKILL.md +4 -4
  72. package/resources/codex-and-agents-customizations/.agents/skills/invoke-powershell-engineer/SKILL.md +4 -4
  73. package/resources/codex-and-agents-customizations/.agents/skills/invoke-python-engineer/SKILL.md +4 -4
  74. package/resources/codex-and-agents-customizations/.agents/skills/orchestrate/SKILL.md +24 -2
  75. package/resources/codex-and-agents-customizations/.agents/skills/orchestrator-state/SKILL.md +16 -1
  76. package/resources/codex-and-agents-customizations/.agents/skills/orchestrator-workflow/SKILL.md +3 -3
  77. package/resources/codex-and-agents-customizations/.agents/skills/powershell/SKILL.md +2 -2
  78. package/resources/codex-and-agents-customizations/.agents/skills/powershell-qa-gate/SKILL.md +15 -16
  79. package/resources/codex-and-agents-customizations/.agents/skills/python-qa-gate/SKILL.md +14 -15
  80. package/resources/codex-and-agents-customizations/.agents/skills/repo-automation-adapter/SKILL.md +2 -0
  81. package/resources/codex-and-agents-customizations/.agents-variants/csharp-legacy/skills/csharp-qa-gate/SKILL.md +13 -14
  82. package/resources/codex-and-agents-customizations/.agents-variants/csharp-legacy/skills/invoke-csharp-engineer/SKILL.md +4 -4
  83. package/resources/codex-and-agents-customizations/.codex/agents/atomic-executor-c1.toml +3 -3
  84. package/resources/codex-and-agents-customizations/.codex/agents/atomic-executor-c2.toml +3 -3
  85. package/resources/codex-and-agents-customizations/.codex/agents/atomic-executor-c3-elevated.toml +3 -3
  86. package/resources/codex-and-agents-customizations/.codex/agents/atomic-executor-c3.toml +3 -3
  87. package/resources/codex-and-agents-customizations/.codex/agents/atomic-executor-c4.toml +3 -3
  88. package/resources/codex-and-agents-customizations/.codex/agents/atomic-executor.toml +3 -3
  89. package/resources/codex-and-agents-customizations/.codex/agents/atomic-planner-c1.toml +2 -2
  90. package/resources/codex-and-agents-customizations/.codex/agents/atomic-planner-c2.toml +2 -2
  91. package/resources/codex-and-agents-customizations/.codex/agents/atomic-planner-c3-elevated.toml +2 -2
  92. package/resources/codex-and-agents-customizations/.codex/agents/atomic-planner-c3.toml +2 -2
  93. package/resources/codex-and-agents-customizations/.codex/agents/atomic-planner-c4.toml +2 -2
  94. package/resources/codex-and-agents-customizations/.codex/agents/atomic-planner.toml +2 -2
  95. package/resources/codex-and-agents-customizations/.codex/agents/csharp-atomic-executor.toml +2 -2
  96. package/resources/codex-and-agents-customizations/.codex/agents/csharp-atomic-planning.toml +1 -1
  97. package/resources/codex-and-agents-customizations/.codex/agents/csharp-orchestrator.toml +1 -1
  98. package/resources/codex-and-agents-customizations/.codex/agents/csharp-typed-engineer-c1.toml +6 -6
  99. package/resources/codex-and-agents-customizations/.codex/agents/csharp-typed-engineer-c2.toml +6 -6
  100. package/resources/codex-and-agents-customizations/.codex/agents/csharp-typed-engineer-c3-elevated.toml +6 -6
  101. package/resources/codex-and-agents-customizations/.codex/agents/csharp-typed-engineer-c3.toml +6 -6
  102. package/resources/codex-and-agents-customizations/.codex/agents/csharp-typed-engineer-c4.toml +6 -6
  103. package/resources/codex-and-agents-customizations/.codex/agents/csharp-typed-engineer.toml +6 -6
  104. package/resources/codex-and-agents-customizations/.codex/agents/feature-review.toml +2 -2
  105. package/resources/codex-and-agents-customizations/.codex/agents/powershell-atomic-executor.toml +2 -2
  106. package/resources/codex-and-agents-customizations/.codex/agents/powershell-atomic-planning.toml +1 -1
  107. package/resources/codex-and-agents-customizations/.codex/agents/powershell-di-unit-test-engineer.toml +1 -1
  108. package/resources/codex-and-agents-customizations/.codex/agents/powershell-orchestrator.toml +1 -1
  109. package/resources/codex-and-agents-customizations/.codex/agents/powershell-typed-engineer-c1.toml +7 -7
  110. package/resources/codex-and-agents-customizations/.codex/agents/powershell-typed-engineer-c2.toml +7 -7
  111. package/resources/codex-and-agents-customizations/.codex/agents/powershell-typed-engineer-c3-elevated.toml +7 -7
  112. package/resources/codex-and-agents-customizations/.codex/agents/powershell-typed-engineer-c3.toml +7 -7
  113. package/resources/codex-and-agents-customizations/.codex/agents/powershell-typed-engineer-c4.toml +7 -7
  114. package/resources/codex-and-agents-customizations/.codex/agents/powershell-typed-engineer.toml +7 -7
  115. package/resources/codex-and-agents-customizations/.codex/agents/pytest-unit-test-coding.toml +1 -1
  116. package/resources/codex-and-agents-customizations/.codex/agents/python-atomic-executor.toml +2 -2
  117. package/resources/codex-and-agents-customizations/.codex/agents/python-atomic-planning.toml +1 -1
  118. package/resources/codex-and-agents-customizations/.codex/agents/python-execution-only-typed.toml +1 -1
  119. package/resources/codex-and-agents-customizations/.codex/agents/python-orchestrator.toml +1 -1
  120. package/resources/codex-and-agents-customizations/.codex/agents/python-typed-engineer-c1.toml +6 -6
  121. package/resources/codex-and-agents-customizations/.codex/agents/python-typed-engineer-c2.toml +6 -6
  122. package/resources/codex-and-agents-customizations/.codex/agents/python-typed-engineer-c3-elevated.toml +6 -6
  123. package/resources/codex-and-agents-customizations/.codex/agents/python-typed-engineer-c3.toml +6 -6
  124. package/resources/codex-and-agents-customizations/.codex/agents/python-typed-engineer-c4.toml +6 -6
  125. package/resources/codex-and-agents-customizations/.codex/agents/python-typed-engineer.toml +6 -6
  126. package/resources/codex-and-agents-customizations/.codex/config.toml +1 -1
  127. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-epic-merge-gate-review.ps1 +699 -0
  128. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-epic-merge-gate.ps1 +29 -2
  129. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-orchestration-preimplementation-gate-cleanup.ps1 +481 -0
  130. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-orchestration-preimplementation-gate.ps1 +4 -2
  131. package/resources/codex-and-agents-customizations/.codex/hooks/hook-cleanup-context.ps1 +343 -0
  132. package/resources/codex-and-agents-customizations/.codex/hooks/validate-feature-review-coverage.ps1 +51 -4
  133. package/resources/codex-and-agents-customizations/.codex-variants/csharp-legacy/agents/csharp-typed-engineer.toml +6 -6
  134. package/resources/codex-and-agents-customizations/pack-manifests/core.json +3 -0
  135. package/resources/customizations/.github/agents/5.1-Beast-adjusted.agent.md +1 -1
  136. package/resources/customizations/.github/agents/Powershell DI Unit Test Engineer.agent.md +20 -26
  137. package/resources/customizations/.github/agents/atomic_executor.agent.md +4 -4
  138. package/resources/customizations/.github/agents/atomic_planning.agent.md +4 -4
  139. package/resources/customizations/.github/agents/commentary-remediation.agent.md +1 -1
  140. package/resources/customizations/.github/agents/commit-steward.agent.md +1 -1
  141. package/resources/customizations/.github/agents/csharp-atomic-executor.agent.md +14 -14
  142. package/resources/customizations/.github/agents/csharp-atomic-planning.agent.md +2 -2
  143. package/resources/customizations/.github/agents/csharp-orchestrator.agent.md +4 -4
  144. package/resources/customizations/.github/agents/csharp-typed-engineer.agent.md +19 -22
  145. package/resources/customizations/.github/agents/epic-review.agent.md +1 -1
  146. package/resources/customizations/.github/agents/gpt-5-beast-mode.agent.md +3 -3
  147. package/resources/customizations/.github/agents/orchestrator.agent.md +8 -8
  148. package/resources/customizations/.github/agents/powershell-atomic-executor.agent.md +12 -12
  149. package/resources/customizations/.github/agents/powershell-atomic-planning.agent.md +4 -4
  150. package/resources/customizations/.github/agents/powershell-orchestrator.agent.md +6 -6
  151. package/resources/customizations/.github/agents/powershell-typed-engineer.agent.md +21 -24
  152. package/resources/customizations/.github/agents/pytest-unit-test-coding.agent.md +13 -17
  153. package/resources/customizations/.github/agents/python-atomic-executor.agent.md +11 -11
  154. package/resources/customizations/.github/agents/python-atomic-planning.agent.md +2 -2
  155. package/resources/customizations/.github/agents/python-execution-only-typed.agent.md +14 -17
  156. package/resources/customizations/.github/agents/python-orchestrator.agent.md +7 -7
  157. package/resources/customizations/.github/agents/python-typed-engineer.agent.md +17 -20
  158. package/resources/customizations/.github/agents/staged-review.agent.md +2 -2
  159. package/resources/customizations/.github/agents/tdd-green.agent.md +1 -1
  160. package/resources/customizations/.github/agents/tdd-red.agent.md +3 -3
  161. package/resources/customizations/.github/agents/tdd-refactor.agent.md +2 -2
  162. package/resources/customizations/.github/agents/typescript-engineer.agent.md +3 -3
  163. package/resources/customizations/.github/codex/execute-hard-lock.prompt.md +3 -3
  164. package/resources/customizations/.github/instructions/general-code-change.instructions.md +1 -1
  165. package/resources/customizations/.github/instructions/powershell-unit-test.instructions.md +1 -1
  166. package/resources/customizations/.github/instructions/python-code-change.instructions.md +5 -5
  167. package/resources/customizations/.github/instructions/python-suppressions.instructions.md +3 -3
  168. package/resources/customizations/.github/instructions/python-unit-test.instructions.md +1 -1
  169. package/resources/customizations/.github/prompts/execute-hard-lock.prompt.md +2 -2
  170. package/resources/customizations/.github/prompts/generate-commit-message-repo.prompt.md +2 -2
  171. package/resources/customizations/.github/prompts/remediate-comments.prompt.md +2 -2
  172. package/resources/customizations/.github/prompts/review-feature.prompt.md +1 -1
  173. package/resources/customizations/.github/skills/atomic-plan-contract/SKILL.md +8 -12
  174. package/resources/customizations/.github/skills/execution-environment/SKILL.md +31 -16
  175. package/resources/customizations/.github/skills/feature-review-workflow/SKILL.md +15 -2
  176. package/resources/feature-templates/bug/plan.yyyy-MM-ddTHH-mm.md +4 -4
  177. package/resources/feature-templates/feature/plan.yyyy-MM-ddTHH-mm.md +3 -3
  178. package/resources/feature-templates/refactor/plan.yyyy-MM-ddTHH-mm.md +2 -2
  179. package/resources/powershell/PoshQC/PoshQC.ScanConfig.psm1 +3 -1
  180. package/resources/powershell/PoshQC/PoshQC.Testing.psm1 +14 -12
  181. package/resources/powershell/PoshQC/PoshQC.psm1 +3 -3
  182. package/resources/powershell/PoshQC/README.md +8 -8
  183. package/resources/powershell/PoshQC/settings/pester.runsettings.psd1 +2 -2
  184. package/resources/templates/policy_audit/AGENTS.md +9 -10
  185. package/resources/templates/policy_audit/policy-audit.yyyy-MM-ddTHH-mm.md +19 -20
@@ -0,0 +1,343 @@
1
+ <#
2
+ .SYNOPSIS
3
+ Pure cleanup-context predicates shared by the cleanup legs of the enforcement gates (issue #1026).
4
+
5
+ .DESCRIPTION
6
+ The cleanup-merged-worktrees skill writes no per-feature, epic, or parallel checkpoint, so
7
+ the checkpoint-based gates cannot recognize its writes, commits, delegation, and pull
8
+ request. Its integrity record is the sanctioned-removal manifest. This file holds the pure
9
+ decisions the gates' cleanup legs share:
10
+
11
+ Test-CleanupManifestText - the manifest header (tool, schema_version) and,
12
+ with -UtcNow, its freshness and run_id.
13
+ Test-CleanupConsolidationRelativePath - the allowlist: the repository-relative prefixes
14
+ docs/ and .claude/agent-memory/ (ordinal,
15
+ case-sensitive), plus the pr-author receipt
16
+ artifacts/pr_body_<digits>.receipt.json with
17
+ -AllowReceipt.
18
+ Find-CleanupConsolidationRecord - the consolidation worktree, identified by its
19
+ porcelain branch, never by its path.
20
+ Test-CleanupScratchPath - the scratch rule: an absolute path outside every
21
+ registered worktree and the session root, under a
22
+ temporary root.
23
+ Test-CleanupConsolidationBranchLabel - the delegation label rule of the model-routing leg.
24
+
25
+ Every function fails closed: a malformed or ambiguous input answers $false or $null.
26
+
27
+ The literals below restate values owned elsewhere: the branch equals
28
+ CLEANUP_WT_CONSOLIDATION_BRANCH in
29
+ .claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_actions_lib.sh, and the
30
+ manifest tool, schema version, and freshness bound equal $script:ExpectedManifestTool,
31
+ $script:ExpectedManifestSchemaVersion, and $script:ManifestFreshnessBound in
32
+ .claude/lib/cleanup-manifest/CleanupWorktreeManifest.psm1. The Codex hooks cannot import
33
+ .claude/lib, so the values are restated here and pinned equal by
34
+ tests/scripts/claude-hooks/hook-cleanup-context.Parity.Tests.ps1. The names avoid the
35
+ removal gates' $script:CleanupWorktreeManifestPath.
36
+
37
+ .NOTES
38
+ PowerShell 7+. Functions and literals only: no file, process, network, clock, or
39
+ environment access, no dot-source, and no import. Byte-identical at .claude/hooks,
40
+ .codex/hooks, and both bundle mirrors under extensions/drm-copilot/resources/.
41
+ #>
42
+
43
+ $script:CleanupContextBranch = 'documentationandmemories'
44
+ $script:CleanupContextManifestRelativePath = 'artifacts/orchestration/cleanup-worktrees-manifest.json'
45
+ $script:CleanupContextManifestTool = 'cleanup-merged-worktrees'
46
+ $script:CleanupContextManifestSchemaVersion = 1
47
+ $script:CleanupContextFreshnessHours = 24
48
+
49
+ function Test-CleanupManifestText {
50
+ <#
51
+ .SYNOPSIS
52
+ Return $true when the text is a cleanup manifest with the expected header.
53
+ .DESCRIPTION
54
+ The text must parse as a JSON object whose tool is the string cleanup-merged-worktrees
55
+ (ordinal) and whose schema_version is the integer 1. When -UtcNow is supplied, the
56
+ manifest must also carry a generated_at that parses, is not after UtcNow, and lies
57
+ within the freshness bound, and a run_id that is a non-blank string. The generated_at
58
+ value is read exactly as CleanupWorktreeManifest.psm1 reads it, so the PR and
59
+ delegation legs agree with the removal gates on freshness.
60
+ .PARAMETER Raw
61
+ The manifest text, or $null when no manifest exists.
62
+ .PARAMETER UtcNow
63
+ The current UTC time from the caller's clock seam.
64
+ .OUTPUTS
65
+ System.Boolean
66
+ #>
67
+ [CmdletBinding()]
68
+ [OutputType([bool])]
69
+ param(
70
+ [AllowNull()][AllowEmptyString()][string] $Raw,
71
+ [datetime] $UtcNow
72
+ )
73
+
74
+ if ([string]::IsNullOrWhiteSpace($Raw)) {
75
+ return $false
76
+ }
77
+ try {
78
+ $manifest = $Raw | ConvertFrom-Json -ErrorAction Stop
79
+ }
80
+ catch {
81
+ return $false
82
+ }
83
+ if ($manifest -isnot [System.Management.Automation.PSCustomObject]) {
84
+ return $false
85
+ }
86
+ $names = @($manifest.PSObject.Properties.Name)
87
+ if ($names -notcontains 'tool' -or $names -notcontains 'schema_version') {
88
+ return $false
89
+ }
90
+ if ($manifest.tool -isnot [string] -or $manifest.tool -cne $script:CleanupContextManifestTool) {
91
+ return $false
92
+ }
93
+ $schemaVersion = $manifest.schema_version
94
+ if (($schemaVersion -isnot [int] -and $schemaVersion -isnot [long]) -or [long]$schemaVersion -ne $script:CleanupContextManifestSchemaVersion) {
95
+ return $false
96
+ }
97
+ if (-not $PSBoundParameters.ContainsKey('UtcNow')) {
98
+ return $true
99
+ }
100
+
101
+ if ($names -notcontains 'generated_at' -or $names -notcontains 'run_id') {
102
+ return $false
103
+ }
104
+ $generatedAt = [datetime]::MinValue
105
+ $styles = [System.Globalization.DateTimeStyles]::AdjustToUniversal -bor [System.Globalization.DateTimeStyles]::AssumeUniversal
106
+ if (-not [datetime]::TryParse([string]$manifest.generated_at, [cultureinfo]::InvariantCulture, $styles, [ref] $generatedAt)) {
107
+ return $false
108
+ }
109
+ if ($generatedAt -gt $UtcNow -or ($UtcNow - $generatedAt) -gt [timespan]::FromHours($script:CleanupContextFreshnessHours)) {
110
+ return $false
111
+ }
112
+ return ($manifest.run_id -is [string] -and -not [string]::IsNullOrWhiteSpace($manifest.run_id))
113
+ }
114
+
115
+ function Test-CleanupConsolidationRelativePath {
116
+ <#
117
+ .SYNOPSIS
118
+ Return $true when a repository-relative path is on the consolidation allowlist.
119
+ .DESCRIPTION
120
+ The path must use only the plain characters A-Z a-z 0-9 . _ / -, must not be rooted,
121
+ must carry no '..' segment, and must start with docs/ or .claude/agent-memory/ under
122
+ ordinal, case-sensitive comparison with at least one character after the prefix. Any
123
+ other Markdown path, such as CLAUDE.md or .claude/rules/x.md, is not admitted. With
124
+ -AllowReceipt the pr-author receipt artifacts/pr_body_<digits>.receipt.json is also
125
+ admitted; it never enters the staging allowlist.
126
+ .PARAMETER RelativePath
127
+ The repository-relative path or operand.
128
+ .PARAMETER AllowReceipt
129
+ Admit the pr-author receipt path (Write and Edit leg only).
130
+ .OUTPUTS
131
+ System.Boolean
132
+ #>
133
+ [CmdletBinding()]
134
+ [OutputType([bool])]
135
+ param(
136
+ [AllowNull()][AllowEmptyString()][string] $RelativePath,
137
+ [switch] $AllowReceipt
138
+ )
139
+
140
+ $path = [string]$RelativePath
141
+ if ($path -cnotmatch '^[A-Za-z0-9._/-]+$' -or $path.StartsWith('/')) {
142
+ return $false
143
+ }
144
+ if (@($path -split '/') -contains '..') {
145
+ return $false
146
+ }
147
+ if ($AllowReceipt -and $path -cmatch '^artifacts/pr_body_[0-9]+\.receipt\.json$') {
148
+ return $true
149
+ }
150
+ foreach ($prefix in @('docs/', '.claude/agent-memory/')) {
151
+ if ($path.Length -gt $prefix.Length -and $path.StartsWith($prefix, [System.StringComparison]::Ordinal)) {
152
+ return $true
153
+ }
154
+ }
155
+ return $false
156
+ }
157
+
158
+ function Find-CleanupConsolidationRecord {
159
+ <#
160
+ .SYNOPSIS
161
+ Return the registered consolidation worktree record, or $null.
162
+ .DESCRIPTION
163
+ Takes the records ConvertFrom-HookTargetWorktreePorcelain emits. The first record (the
164
+ main worktree stanza), prunable records, and detached records are skipped. The single
165
+ remaining record whose Branch is ordinal-equal to documentationandmemories is returned;
166
+ none, or more than one, returns $null. The path is never consulted, because the
167
+ consolidation path can be overridden by CLEANUP_WT_CONSOLIDATION_PATH.
168
+ .PARAMETER Record
169
+ The porcelain records, in listing order.
170
+ .OUTPUTS
171
+ System.Management.Automation.PSCustomObject or $null
172
+ #>
173
+ [CmdletBinding()]
174
+ [OutputType([pscustomobject])]
175
+ param(
176
+ [AllowNull()][AllowEmptyCollection()][object[]] $Record
177
+ )
178
+
179
+ $records = @($Record | Where-Object { $null -ne $_ })
180
+ $found = [System.Collections.Generic.List[object]]::new()
181
+ for ($index = 1; $index -lt $records.Count; $index++) {
182
+ $candidate = $records[$index]
183
+ if ([bool]$candidate.Prunable -or $null -eq $candidate.Branch) {
184
+ continue
185
+ }
186
+ if ([string]$candidate.Branch -ceq $script:CleanupContextBranch) {
187
+ $found.Add($candidate)
188
+ }
189
+ }
190
+ if ($found.Count -ne 1) {
191
+ return $null
192
+ }
193
+ return $found[0]
194
+ }
195
+
196
+ function ConvertTo-CleanupContextPath {
197
+ <#
198
+ .SYNOPSIS
199
+ Normalize a path to forward slashes with one trailing slash removed (bare roots kept).
200
+ .OUTPUTS
201
+ System.String
202
+ #>
203
+ [CmdletBinding()]
204
+ [OutputType([string])]
205
+ param(
206
+ [AllowNull()][AllowEmptyString()][string] $Path
207
+ )
208
+
209
+ $normalized = ([string]$Path).Replace('\', '/')
210
+ if ($normalized.Length -gt 1 -and $normalized.EndsWith('/') -and $normalized -notmatch '^[A-Za-z]:/$') {
211
+ $normalized = $normalized.Substring(0, $normalized.Length - 1)
212
+ }
213
+ return $normalized
214
+ }
215
+
216
+ function Test-CleanupContextPathUnder {
217
+ <#
218
+ .SYNOPSIS
219
+ Return $true when a normalized path equals a root or lies beneath it (OrdinalIgnoreCase).
220
+ .OUTPUTS
221
+ System.Boolean
222
+ #>
223
+ [CmdletBinding()]
224
+ [OutputType([bool])]
225
+ param(
226
+ [Parameter(Mandatory)][AllowEmptyString()][string] $Path,
227
+ [AllowNull()][AllowEmptyString()][string] $Root
228
+ )
229
+
230
+ $normalizedRoot = ConvertTo-CleanupContextPath -Path $Root
231
+ if ([string]::IsNullOrEmpty($normalizedRoot)) {
232
+ return $false
233
+ }
234
+ if ([string]::Equals($Path, $normalizedRoot, [System.StringComparison]::OrdinalIgnoreCase)) {
235
+ return $true
236
+ }
237
+ $prefix = if ($normalizedRoot.EndsWith('/')) { $normalizedRoot } else { $normalizedRoot + '/' }
238
+ return $Path.StartsWith($prefix, [System.StringComparison]::OrdinalIgnoreCase)
239
+ }
240
+
241
+ function Test-CleanupScratchPath {
242
+ <#
243
+ .SYNOPSIS
244
+ Return $true when a path is a scratch path under a temporary root and outside every worktree.
245
+ .DESCRIPTION
246
+ The path must be absolute (drive-rooted or slash-rooted, not UNC), carry no '.' or '..'
247
+ segment and no surrounding whitespace, lie outside every registered worktree root and
248
+ outside the session root, and lie under at least one accepted temporary-root spelling.
249
+ Comparisons use forward-slash normalization and OrdinalIgnoreCase. The rule fails
250
+ closed when no registered root or no temporary root is supplied, and when any
251
+ registered worktree root lies under an accepted temporary root, because a path under
252
+ such a worktree could then be spelled so that it matches no registered root.
253
+ .PARAMETER Path
254
+ The Write or Edit file path.
255
+ .PARAMETER RegisteredRoot
256
+ Every registered worktree root from the listing, prunable ones included.
257
+ .PARAMETER SessionRoot
258
+ The session root.
259
+ .PARAMETER TemporaryRoot
260
+ Every accepted spelling of the operating-system temporary root.
261
+ .OUTPUTS
262
+ System.Boolean
263
+ #>
264
+ [CmdletBinding()]
265
+ [OutputType([bool])]
266
+ param(
267
+ [AllowNull()][AllowEmptyString()][string] $Path,
268
+ [AllowNull()][AllowEmptyCollection()][string[]] $RegisteredRoot,
269
+ [AllowNull()][AllowEmptyString()][string] $SessionRoot,
270
+ [AllowNull()][AllowEmptyCollection()][string[]] $TemporaryRoot
271
+ )
272
+
273
+ $raw = [string]$Path
274
+ if ([string]::IsNullOrEmpty($raw) -or $raw.Trim() -cne $raw) {
275
+ return $false
276
+ }
277
+ $normalized = ConvertTo-CleanupContextPath -Path $raw
278
+ if ($normalized -notmatch '^([A-Za-z]:/|/(?!/))') {
279
+ return $false
280
+ }
281
+ $segments = @($normalized -split '/')
282
+ if ($segments -contains '.' -or $segments -contains '..') {
283
+ return $false
284
+ }
285
+ $roots = @($RegisteredRoot | Where-Object { -not [string]::IsNullOrWhiteSpace($_) })
286
+ $temporary = @($TemporaryRoot | Where-Object { -not [string]::IsNullOrWhiteSpace($_) })
287
+ if ($roots.Count -eq 0 -or $temporary.Count -eq 0 -or [string]::IsNullOrWhiteSpace($SessionRoot)) {
288
+ return $false
289
+ }
290
+ foreach ($registeredCandidate in $roots) {
291
+ $normalizedRoot = ConvertTo-CleanupContextPath -Path $registeredCandidate
292
+ foreach ($temporaryCandidate in $temporary) {
293
+ if (Test-CleanupContextPathUnder -Path $normalizedRoot -Root $temporaryCandidate) {
294
+ return $false
295
+ }
296
+ }
297
+ if (Test-CleanupContextPathUnder -Path $normalized -Root $registeredCandidate) {
298
+ return $false
299
+ }
300
+ }
301
+ if (Test-CleanupContextPathUnder -Path $normalized -Root $SessionRoot) {
302
+ return $false
303
+ }
304
+ foreach ($temporaryCandidate in $temporary) {
305
+ $normalizedTemporary = ConvertTo-CleanupContextPath -Path $temporaryCandidate
306
+ if (-not [string]::Equals($normalized, $normalizedTemporary, [System.StringComparison]::OrdinalIgnoreCase) -and
307
+ (Test-CleanupContextPathUnder -Path $normalized -Root $normalizedTemporary)) {
308
+ return $true
309
+ }
310
+ }
311
+ return $false
312
+ }
313
+
314
+ function Test-CleanupConsolidationBranchLabel {
315
+ <#
316
+ .SYNOPSIS
317
+ Return $true when a delegation prompt names the consolidation branch by exactly one label.
318
+ .DESCRIPTION
319
+ The prompt must contain exactly one 'branch:' label (case-insensitive count), on its own
320
+ line in the lowercase form 'branch: <value>', with the value ordinal-equal to
321
+ documentationandmemories, and no --head or --branch token anywhere, so the worktree
322
+ resolvers that read the first branch signal cannot select a different branch.
323
+ .PARAMETER PromptText
324
+ The delegation prompt.
325
+ .OUTPUTS
326
+ System.Boolean
327
+ #>
328
+ [CmdletBinding()]
329
+ [OutputType([bool])]
330
+ param(
331
+ [AllowNull()][AllowEmptyString()][string] $PromptText
332
+ )
333
+
334
+ $text = [string]$PromptText
335
+ if ([regex]::Matches($text, '(?i)\bbranch:').Count -ne 1) {
336
+ return $false
337
+ }
338
+ if ([regex]::IsMatch($text, '(?i)(?<![\w-])--(?:head|branch)(?![\w-])')) {
339
+ return $false
340
+ }
341
+ $label = [regex]::Match($text, '(?m)^[ \t]*branch:[ \t]*(?<value>[^\r\n]*?)[ \t]*\r?$')
342
+ return ($label.Success -and $label.Groups['value'].Value -ceq $script:CleanupContextBranch)
343
+ }
@@ -19,6 +19,10 @@
19
19
  failures:
20
20
  "informational only", "context only", "out of plan scope", "out of scope",
21
21
  "not applicable", "N/A", "UNVERIFIED".
22
+ The record "N/A - no pre-change run" is not narrowing in three positions: after
23
+ "Baseline:" or "baseline coverage artifact:", as the fifth table cell, and as a
24
+ backticked quotation not directly after a colon. "Change: N/A" on a line carrying
25
+ "Baseline: N/A - no pre-change run" is not narrowing either.
22
26
  - If the coverage artifact for a language is present, repo-wide line coverage is
23
27
  parsed and compared against the governing line floor: the line coverage
24
28
  threshold the repository's root CLAUDE.md states, otherwise the 85 percent
@@ -145,6 +149,50 @@ function Get-LanguageRepoCoverage {
145
149
  return $null
146
150
  }
147
151
 
152
+ function Get-CoverageNarrowingLine {
153
+ [CmdletBinding()]
154
+ [OutputType([string])]
155
+ param(
156
+ [Parameter(Mandatory = $true)]
157
+ [AllowEmptyString()]
158
+ [string[]]$Lines,
159
+
160
+ [Parameter(Mandatory = $true)]
161
+ [string]$LabelPattern,
162
+
163
+ [Parameter(Mandatory = $true)]
164
+ [string]$Language
165
+ )
166
+
167
+ # Sanctioned narrowing text is not a scope narrowing by the audit: a line inside a
168
+ # '## Rejected Scope Narrowing' section (caller text recorded verbatim), and a PowerShell
169
+ # line naming branch coverage but not line coverage (Pester measures no branch coverage).
170
+ # The policy-audit template prescribes the no-pre-change-run record in three positions only,
171
+ # so the record is removed there and stays a narrowing form everywhere else.
172
+ $narrowingPattern = '(?i)(informational only|context only|out of plan scope|out of scope|not applicable|\bN/A\b|\bUNVERIFIED\b)'
173
+ $recordPatterns = @(
174
+ '(?<=(?:\bBaseline|\bbaseline coverage artifact):\s*)N/A - no pre-change run'
175
+ '(?<=^\s*\|(?:[^|]*\|){4}\s*)N/A - no pre-change run(?=\s*\|)'
176
+ '(?<!:\s*)`N/A - no pre-change run`'
177
+ )
178
+ $insideRejectedSection = $false
179
+ foreach ($line in $Lines) {
180
+ if ($line -match '^##\s') { $insideRejectedSection = $line -match '^##\s+Rejected Scope Narrowing\b' }
181
+ elseif ($insideRejectedSection) { continue }
182
+ if ($line -notmatch $LabelPattern -or $line -notmatch '(?i)(coverage|lcov|line[s]?\s+hit|pester)') { continue }
183
+ $reducedLine = $line
184
+ foreach ($recordPattern in $recordPatterns) { $reducedLine = [regex]::Replace($reducedLine, $recordPattern, '') }
185
+ # Tested on the original line, because the removals above strip the record it names.
186
+ if ($line.Contains('Baseline: N/A - no pre-change run')) {
187
+ $reducedLine = [regex]::Replace($reducedLine, '(?<![\w/-])Change: N/A', '')
188
+ $reducedLine = $reducedLine.Replace('New/changed-code coverage: N/A - no production file changed', '')
189
+ }
190
+ if ($reducedLine -notmatch $narrowingPattern) { continue }
191
+ if ($Language -eq 'PowerShell' -and $line -match '(?i)\bbranch\b' -and $line -notmatch '(?i)\bline\s+coverage\b') { continue }
192
+ $line
193
+ }
194
+ }
195
+
148
196
  function Test-LanguageCoverageRow {
149
197
  [OutputType([System.Collections.Hashtable])]
150
198
  param(
@@ -158,7 +206,7 @@ function Test-LanguageCoverageRow {
158
206
  'TypeScript' = @('TypeScript', 'typescript')
159
207
  'Python' = @('Python', 'python', 'pytest')
160
208
  'PowerShell' = @('PowerShell', 'powershell', 'pester')
161
- 'CSharp' = @('C#', 'CSharp', 'csharp', '\.NET', 'dotnet')
209
+ 'CSharp' = @('C#', 'CSharp', 'csharp', '.NET', 'dotnet')
162
210
  }
163
211
 
164
212
  $labels = $languageLabelMap[$Language]
@@ -182,9 +230,8 @@ function Test-LanguageCoverageRow {
182
230
  }
183
231
  }
184
232
 
185
- $narrowingPattern = '(?i)(informational only|context only|out of plan scope|out of scope|not applicable|\bN/A\b|\bUNVERIFIED\b)'
186
- $narrowing = $coverageLines | Where-Object { $_ -match $narrowingPattern }
187
- if ($narrowing -and $narrowing.Count -gt 0) {
233
+ $narrowing = @(Get-CoverageNarrowingLine -Lines $lines -LabelPattern $labelPattern -Language $Language)
234
+ if ($narrowing.Count -gt 0) {
188
235
  $first = ($narrowing | Select-Object -First 1).ToString().Trim()
189
236
  return @{
190
237
  Ok = $false
@@ -29,7 +29,7 @@ Migration contract:
29
29
 
30
30
  ---
31
31
  name: csharp-typed-engineer
32
- description: Project-scoped worker that implements and verifies C# changes within typed repository boundaries. Applies the CSharpier -> .NET Analyzers -> Nullable Analysis -> MSTest toolchain, the 1-3 production-file small-path budget, and zero-regression quality gates.
32
+ description: Project-scoped worker that implements and verifies C# changes within typed repository boundaries. Applies the CSharpier -> .NET Analyzers -> Nullable Analysis -> MSTest toolchain, the 1-3 production-file small-path budget, and quality gates read from the single gate run.
33
33
  tools:
34
34
  - Read
35
35
  - Grep
@@ -62,10 +62,10 @@ Follow the phased workflow defined by the preloaded skills:
62
62
 
63
63
  1. **Policy compliance** — apply `policy-compliance-order` to load mandatory repo policies before any change.
64
64
  2. **Routing and scope** — apply `csharp-change-budget-router` to estimate scope, select direct vs orchestrator handoff mode, and enforce the 3 production + 3 test per-batch cap.
65
- 3. **Plan and baseline** — apply `atomic-plan-contract` for Phase 0 baseline capture and atomic plan structure. Delegate plan authoring to `atomic_planner` when no plan is supplied. Plans must include the proposed class and module structure, minimal DI seams, MSTest scenario-level test strategy, and Moq mock strategy.
66
- 4. **Implement in batches** — apply the approved plan. After each batch, run targeted analyzer and nullable builds on touched projects plus targeted MSTest, and confirm per-file coverage.
67
- 5. **Final QA gate** — apply `csharp-qa-gate` to run the full toolchain, enforce zero-regression deltas against the baseline, and produce the required reporting block before declaring completion.
68
- 6. **Evidence and handoff** — store baseline and post-change evidence per `evidence-and-timestamp-conventions`. Trigger remediation via `remediation-handoff-atomic-planner` when deltas fail.
65
+ 3. **Plan and baseline** — apply `atomic-plan-contract` for Phase 0 static baseline capture and atomic plan structure. Delegate plan authoring to `atomic_planner` when no plan is supplied. Plans must include the proposed class and module structure, minimal DI seams, MSTest scenario-level test strategy, and Moq mock strategy.
66
+ 4. **Implement in batches** — apply the approved plan. After each batch, run targeted analyzer and nullable builds on touched projects. Test and coverage results come from the single gate run. A focused run of one test file to debug a specific failure is debugging only.
67
+ 5. **Final QA gate** — apply `csharp-qa-gate` to run the full toolchain, compare static tool results against the static baseline, read test and coverage results from the single gate run, and produce the required reporting block before declaring completion.
68
+ 6. **Evidence and handoff** — store static baseline and final gate evidence per `evidence-and-timestamp-conventions`. Trigger remediation via `remediation-handoff-atomic-planner` when a gate fails.
69
69
 
70
70
  ## Mode Marker Resolution
71
71
 
@@ -84,7 +84,7 @@ Stop implementation and return to the user when:
84
84
 
85
85
  - the scope estimate or an in-flight batch would exceed the 3-production-file cap in direct mode,
86
86
  - a file is above or would exceed the 800-line hard limit of the tiered file-size policy (split it before proceeding; at 500 lines look for a logical split, and at 700 lines split more aggressively),
87
- - any QA gate delta is non-zero after self-correction,
87
+ - any QA gate check fails after self-correction,
88
88
  - the toolchain cannot be executed in the current environment (mark the change **unverified**),
89
89
  - orchestrator handoff mode is requested but the required context package is incomplete,
90
90
  - policy instructions conflict.
@@ -53,10 +53,13 @@
53
53
  ".codex/hooks/enforce-epic-child-worktree-binding.ps1",
54
54
  ".codex/hooks/enforce-epic-merge-gate-command.ps1",
55
55
  ".codex/hooks/enforce-epic-merge-gate.ps1",
56
+ ".codex/hooks/enforce-epic-merge-gate-review.ps1",
56
57
  ".codex/hooks/enforce-epic-planning-only.ps1",
57
58
  ".codex/hooks/enforce-epic-root-invocation.ps1",
58
59
  ".codex/hooks/enforce-epic-wave-barrier.ps1",
59
60
  ".codex/hooks/enforce-epic-worktree-removal-gate.ps1",
61
+ ".codex/hooks/enforce-orchestration-preimplementation-gate-cleanup.ps1",
62
+ ".codex/hooks/hook-cleanup-context.ps1",
60
63
  ".codex/hooks/enforce-orchestration-preimplementation-gate-epic-resolution.ps1",
61
64
  ".codex/hooks/enforce-orchestration-preimplementation-gate-epic-scope.ps1",
62
65
  ".codex/hooks/enforce-orchestration-preimplementation-gate-helpers.ps1",
@@ -76,7 +76,7 @@ You are a highly capable and autonomous agent, and you can definitely solve this
76
76
  5. Develop a clear, step-by-step plan. Break down the fix into manageable, incremental steps. Display those steps in a simple markdown todo list using plain checkboxes.
77
77
  6. Implement the fix incrementally. Make small, testable code changes.
78
78
  7. Debug as needed. Use debugging techniques to isolate and resolve issues.
79
- 8. Test frequently. Run tests after each change to verify correctness.
79
+ 8. Check frequently. Run static checks after each change, and the single gate run when the change is complete. A focused run of one test file to debug a specific failure is debugging only.
80
80
  9. Iterate until the root cause is fixed and all tests pass.
81
81
  10. Reflect and validate comprehensively. After tests pass, think about the original intent, write additional tests to ensure correctness, and remember there are hidden tests that must also pass before the solution is truly complete.
82
82
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: PowerShell Unit Test + DI Refactor Expert (Guardrailed)
3
- description: Plan + implement minimal DI seams and Pester v5 unit tests with correct mocking (esp. external executables), while enforcing strict scope, analyzer cleanliness, and zero-regression gates.
4
- argument-hint: "Provide the exact script/module under test + the failing tests (or desired behaviors). I will baseline → plan → implement in small batches with analyzer/test/coverage gates."
3
+ description: Plan + implement minimal DI seams and Pester v6 unit tests with correct mocking (esp. external executables), while enforcing strict scope, analyzer cleanliness, and the parallel test gates.
4
+ argument-hint: "Provide the exact script/module under test + the failing tests (or desired behaviors). I will capture the static baseline → plan → implement in small batches with analyzer/test/coverage gates."
5
5
  tools:
6
6
  [vscode/runCommand, vscode/vscodeAPI, execute/testFailure, execute/getTerminalOutput, execute/runTask, execute/createAndRunTask, execute/runInTerminal, execute/runTests, read/problems, read/readFile, read/terminalSelection, read/terminalLastCommand, edit/createDirectory, edit/createFile, edit/editFiles, search, web, 'drmcopilotextension/*', todo]
7
7
 
@@ -12,18 +12,18 @@ handoffs:
12
12
  send: false
13
13
  - label: Implement approved plan with strict gates
14
14
  agent: agent
15
- prompt: "Implement ONLY the approved plan. Enforce: zero new PSScriptAnalyzer findings, zero new failing tests, and no coverage regressions for touched files. Run Analyze+targeted tests after each small batch; run full toolchain at the end."
15
+ prompt: "Implement ONLY the approved plan. Enforce: zero new PSScriptAnalyzer findings, zero failures in the single gate run, and touched files at the coverage thresholds. Run Analyze after each small batch; run full toolchain at the end."
16
16
  send: false
17
17
  - label: Post-change QA gate (analyzer + tests + coverage)
18
18
  agent: agent
19
- prompt: "Run the full toolchain and report deltas: analyzer findings, failing tests, and per-file coverage for touched files. If any regression exists, revert/fix before proceeding."
19
+ prompt: "Run the full toolchain and report analyzer deltas, failures in the single gate run, and per-file coverage for touched files. If any check fails, revert/fix before proceeding."
20
20
  send: false
21
21
  ---
22
22
 
23
23
  # Role and objective
24
24
 
25
25
  You are a senior PowerShell engineer specializing in:
26
- - Pester v5 unit tests (fast, deterministic, isolated)
26
+ - Pester v6 unit tests (fast, deterministic, isolated)
27
27
  - Refactoring production code ONLY as needed to introduce minimal dependency-injection (DI) seams
28
28
  - Correct mocking patterns for external executables (`git`, `gh`, `actionlint`, etc.) and PowerShell cmdlets/providers
29
29
 
@@ -31,7 +31,7 @@ Your objective is **testability without regressions**:
31
31
  - Tests pass identically in Terminal and VS Code Test Explorer
32
32
  - No reliance on PATH, profiles, working directory, network, or machine state
33
33
  - No increase in PSScriptAnalyzer findings
34
- - No decrease in coverage for any file you touch
34
+ - A touched file meets the coverage thresholds, read from the single gate run
35
35
 
36
36
  # Absolute guardrails (non-negotiable)
37
37
 
@@ -77,11 +77,11 @@ Introduce the smallest seam that enables reliable mocking. Prefer seams in this
77
77
  - Do NOT introduce new frameworks, generic runners, or broad abstractions.
78
78
  - Do NOT refactor unrelated code “while you’re here.”
79
79
 
80
- ## 4) Zero-regression quality gates (hard stop)
80
+ ## 4) Quality gates (hard stop)
81
81
  Hard stop if any of these occur:
82
- - New PSScriptAnalyzer findings compared to baseline
83
- - New failing tests compared to baseline
84
- - Coverage drop in any touched file (and in overall coverage if the repo enforces an overall gate)
82
+ - New PSScriptAnalyzer findings compared to the static baseline
83
+ - Any failure in the single gate run
84
+ - A touched file below the coverage thresholds
85
85
 
86
86
  If any gate fails:
87
87
  - revert or fix immediately before proceeding
@@ -90,14 +90,13 @@ If any gate fails:
90
90
  ## 5) Toolchain must be executed (no unverified work)
91
91
  You must run the repo toolchain via `#tool:terminal`.
92
92
 
93
- ### Baseline runs (required before edits)
93
+ ### Static baseline runs (required before edits)
94
94
  - Analyzer baseline (repo standard): `mcp__drm-copilot__run_poshqc_analyze`
95
- - Test baseline (targeted): run only the relevant Pester file(s) or tag/filter used by the repo
96
- - Coverage baseline: capture per-file coverage for the touched file(s), and overall if applicable
97
95
 
98
96
  ### Iteration runs (required after each batch)
99
97
  - Analyzer
100
- - Targeted Pester tests for the impacted area
98
+
99
+ A focused run of one test file to debug a specific failure is debugging only.
101
100
 
102
101
  ### Final QA runs (required before declaring completion)
103
102
  - Format → Analyze → Test with coverage, per repo conventions
@@ -109,12 +108,10 @@ If you cannot run tools in the environment:
109
108
 
110
109
  # Required workflow for every request
111
110
 
112
- ## Phase A — Baseline capture (read-only)
111
+ ## Phase A — Static baseline capture (read-only)
113
112
  1) Identify the EXACT files in scope (list them).
114
- 2) Run and record baseline:
115
- - failing tests list (names + error messages)
113
+ 2) Run and record the static baseline:
116
114
  - analyzer findings count (errors/warnings/information per repo settings)
117
- - coverage baseline (per touched file, and overall if used)
118
115
  3) Write root cause in one paragraph.
119
116
 
120
117
  ## Phase B — Plan (no edits)
@@ -130,17 +127,14 @@ Do not proceed to edits until the user explicitly approves (e.g., “Proceed”)
130
127
  - Batch size: one logical change set only (e.g., add wrapper + update call site + update 1–2 tests)
131
128
  - After each batch:
132
129
  - Run analyzer
133
- - Run the relevant subset of tests
134
- - Confirm coverage did not regress for touched files
135
130
  - Keep edits minimal; no stylistic refactors.
136
131
 
137
132
  ## Phase D — Final QA gate
138
133
  - Run full toolchain (format → analyze → test with coverage)
139
- - Report deltas:
134
+ - Report results:
140
135
  - Analyzer delta (must be 0 new findings)
141
- - Test failures delta (must be 0 new failures)
142
- - Per-file coverage delta for touched files (must be >= baseline)
143
- - Overall coverage delta if applicable (must be >= baseline)
136
+ - Failures in the single gate run (must be 0)
137
+ - Per-file coverage for touched files against the thresholds, read from the single gate run
144
138
 
145
139
  # PowerShell-specific rules (to prevent your recent failure modes)
146
140
 
@@ -178,10 +172,10 @@ When the project imports functions via AST-based `Import-ScriptFunction` returni
178
172
 
179
173
  # Reporting requirements (every response)
180
174
  Your response must include:
181
- 1) **Baseline**: analyzer/tests/coverage before changes
175
+ 1) **Baseline**: analyzer findings before changes
182
176
  2) **Plan**: minimal DI seam + mock strategy + exact file list
183
177
  3) If implementation was approved: patch-style diffs or full-file replacements for only the scoped files
184
- 4) **QA Gate Results**: analyzer delta, failing tests delta, per-file coverage delta (and overall if applicable)
178
+ 4) **QA Gate Results**: analyzer delta, failures in the single gate run, and per-file coverage against the thresholds
185
179
 
186
180
  # Prohibited behaviors
187
181
  - Broad refactors across multiple scripts “while you’re here”
@@ -86,7 +86,7 @@ During preflight (before [P0-T1]), resolve work mode from feature `issue.md` mar
86
86
 
87
87
  If the marker is missing or malformed, fail closed to `full-feature`.
88
88
 
89
- When selected mode is `minor-audit`, preflight MUST reject plans that do not include explicit baseline evidence tasks, targeted verification evidence tasks, and end-state evidence tasks. In these cases return:
89
+ When selected mode is `minor-audit`, preflight MUST reject plans that do not include explicit static baseline evidence tasks, targeted verification evidence tasks read from the gate run, and end-state evidence tasks. In these cases return:
90
90
 
91
91
  `PREFLIGHT: REVISIONS REQUIRED`
92
92
 
@@ -148,8 +148,8 @@ Confirm all of the following; otherwise stop and request a corrected plan:
148
148
  - Phase numbers in IDs match the phase heading.
149
149
  - Task numbers are sequential within each phase.
150
150
  - Phase 0 exists and contains the repo-policy reading tasks in the required order.
151
- - For plans that change code or tests: Phase 0 also includes baseline capture tasks for the **language-specific toolchains** applicable to the files being changed (per the table in Section 0).
152
- - Phase 0 baseline capture tasks specify artifacts stored in the canonical baseline location defined in `atomic-plan-contract`, and include `Timestamp`, `Command`, and `EXIT_CODE` fields.
151
+ - For plans that change code or tests: Phase 0 also includes static baseline capture tasks for the **language-specific toolchains** applicable to the files being changed (per the table in Section 0).
152
+ - Phase 0 static baseline capture tasks specify artifacts stored in the canonical baseline location defined in `atomic-plan-contract`, and include `Timestamp`, `Command`, and `EXIT_CODE` fields.
153
153
  - For plans that change code or tests: a final QA phase exists that runs the full toolchain loop **for each applicable language** and reports results.
154
154
  - Any **TDD Red** regression-test task (i.e., a test task whose acceptance criteria expects `pytest` to fail) is tagged with the exact flag `[expect-fail]` in the task title text (after the task ID).
155
155
  - No task is a “bucket task” (e.g., “Refactor module”, “Write tests”) that cannot be completed as a single binary outcome.
@@ -252,7 +252,7 @@ If the user says “resume”, “continue”, or “try again”:
252
252
  - When completing a task or a plan, report the toolchain status explicitly:
253
253
  - For python, this is Black, Ruff, Pyright, Pytest, and coverage.
254
254
  - For bash, this is shell QC and bats testing.
255
- - For powershell, this is `mcp__drm-copilot__run_poshqc_format`, `mcp__drm-copilot__run_poshqc_analyze`, and `mcp_drmcopilotext_run_poshqc_test`.
255
+ - For powershell, this is `mcp__drm-copilot__run_poshqc_format`, `mcp__drm-copilot__run_poshqc_analyze`, and one `Invoke-PoshQCParallelTest` run.
256
256
  - For json, this is json formatting and json linting.
257
257
  - Always end with the updated checklist so the user can see progress.
258
258