@danmoisan/drm-copilot-mcp 1.1.11 → 1.1.12
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.
- package/out/mcp-server.js +366 -159
- package/package.json +1 -1
- package/resources/claude-customizations/.claude/agents/epic-orchestrator.md +1 -1
- package/resources/claude-customizations/.claude/agents/epic-planner.md +4 -1
- package/resources/claude-customizations/.claude/agents/pr-author.md +15 -0
- package/resources/claude-customizations/.claude/hooks/enforce-epic-merge-gate-authorization.ps1 +443 -0
- package/resources/claude-customizations/.claude/hooks/enforce-epic-merge-gate.ps1 +33 -37
- package/resources/claude-customizations/.claude/hooks/enforce-model-routing-receipt.ps1 +120 -5
- package/resources/claude-customizations/.claude/hooks/enforce-orchestration-preimplementation-gate-epic-scope.ps1 +127 -0
- package/resources/claude-customizations/.claude/hooks/enforce-orchestration-preimplementation-gate-helpers.ps1 +163 -15
- package/resources/claude-customizations/.claude/hooks/enforce-orchestration-preimplementation-gate.ps1 +14 -27
- package/resources/claude-customizations/.claude/hooks/enforce-parallel-worktree-removal-gate.ps1 +66 -5
- package/resources/claude-customizations/.claude/hooks/enforce-pr-author-skill-helpers.ps1 +134 -10
- package/resources/claude-customizations/.claude/hooks/enforce-pr-author-skill.epic-base-branch.ps1 +37 -8
- package/resources/claude-customizations/.claude/hooks/enforce-pr-author-skill.ps1 +3 -1
- package/resources/claude-customizations/.claude/hooks/enforce-prd-feature-before-planner-helpers.ps1 +332 -0
- package/resources/claude-customizations/.claude/hooks/enforce-prd-feature-before-planner.ps1 +211 -182
- package/resources/claude-customizations/.claude/lib/codex-routing/CodexDeployment.psm1 +1 -0
- package/resources/claude-customizations/.claude/lib/worktree-resolution/EpicScopeReadiness.psm1 +176 -0
- package/resources/claude-customizations/.claude/lib/worktree-resolution/EpicScopeResolution.psm1 +369 -0
- package/resources/claude-customizations/.claude/lib/worktree-resolution/WorktreeItemResolution.psm1 +392 -0
- package/resources/claude-customizations/.claude/lib/worktree-resolution/WorktreeResolution.psm1 +500 -0
- package/resources/claude-customizations/.claude/lib/worktree-resolution/WorktreeTargetResolution.psm1 +347 -0
- package/resources/claude-customizations/.claude/rules/orchestrator-state.md +27 -0
- package/resources/claude-customizations/.claude/skills/cleanup-merged-worktrees/SKILL.md +12 -0
- package/resources/claude-customizations/.claude/skills/epic-orchestrate/SKILL.md +14 -1
- package/resources/claude-customizations/.claude/skills/epic-plan/SKILL.md +4 -0
- package/resources/claude-customizations/.claude/skills/orchestrate/SKILL.md +4 -1
- package/resources/claude-customizations/.claude/skills/parallel-orchestrate/SKILL.md +39 -6
- package/resources/claude-customizations/.claude/skills/pr-author/SKILL.md +15 -0
- package/resources/claude-customizations/.claude/skills/quota-throttling/SKILL.md +221 -0
- package/resources/claude-customizations/pack-manifests/core.json +9 -0
- package/resources/codex-and-agents-customizations/.agents/skills/codex-model-routing/SKILL.md +13 -14
- package/resources/codex-and-agents-customizations/.codex/config.toml +1 -1
- package/resources/codex-and-agents-customizations/.codex/hooks/enforce-epic-merge-gate.ps1 +193 -0
- package/resources/codex-and-agents-customizations/.codex/hooks/enforce-epic-planning-only.ps1 +15 -5
- package/resources/codex-and-agents-customizations/.codex/hooks/enforce-orchestration-preimplementation-gate-helpers.ps1 +163 -15
- package/resources/codex-and-agents-customizations/.codex/scripts/Resolve-CodexDeployment.ps1 +87 -0
- package/resources/codex-and-agents-customizations/.codex/scripts/Resolve-CodexTopology.ps1 +96 -0
- package/resources/codex-and-agents-customizations/.codex/scripts/codex-routing-cli-common.ps1 +370 -0
- package/resources/codex-and-agents-customizations/.codex/scripts/epic-child-launch-contract.ps1 +475 -0
- package/resources/codex-and-agents-customizations/.codex/scripts/epic-child-launch-runtime.ps1 +445 -0
- package/resources/codex-and-agents-customizations/.codex/scripts/epic-child-persistence-runtime.ps1 +118 -0
- package/resources/codex-and-agents-customizations/.codex/scripts/epic-child-sandbox-preflight.ps1 +69 -0
- package/resources/codex-and-agents-customizations/.codex/scripts/launch-epic-child-wave.ps1 +471 -0
- package/resources/codex-and-agents-customizations/.codex/scripts/post-codex-worktree-session.ps1 +280 -0
- package/resources/codex-and-agents-customizations/.codex/scripts/resume-epic-child.ps1 +263 -0
- package/resources/codex-and-agents-customizations/.codex-variants/csharp-legacy/agents/csharp-typed-engineer.toml +2 -1
- package/resources/codex-and-agents-customizations/pack-manifests/core.json +18 -1
- package/resources/lib/codex-routing/CodexDeployment.psm1 +315 -0
- package/resources/lib/codex-routing/CodexTopology.psm1 +394 -0
- package/resources/powershell/PoshQC/settings/pester.runsettings.psd1 +26 -0
package/resources/claude-customizations/.claude/hooks/enforce-parallel-worktree-removal-gate.ps1
CHANGED
|
@@ -41,6 +41,12 @@ Import-Module (Join-Path $PSScriptRoot '../lib/cleanup-manifest/CleanupWorktreeM
|
|
|
41
41
|
. (Join-Path $PSScriptRoot 'hook-command-invocation.ps1')
|
|
42
42
|
$script:ParallelCheckpointPath = 'artifacts/orchestration/parallel-orchestrator-state.json'
|
|
43
43
|
$script:AllowedMergeStatuses = @('merged', 'worktree_removed')
|
|
44
|
+
# Epic checkpoint location (issue #688). An epic run records per-child state in
|
|
45
|
+
# features[] and never writes the parallel checkpoint, so without this read every
|
|
46
|
+
# merged epic child worktree reached the deny below even though
|
|
47
|
+
# enforce-epic-worktree-removal-gate.ps1 authorized the same call. Both gates run on
|
|
48
|
+
# the same Bash call, so that deny won and epic worktrees could never be removed.
|
|
49
|
+
$script:EpicCheckpointPath = 'artifacts/orchestration/epic-orchestrator-state.json'
|
|
44
50
|
# Sanctioned-removal manifest location. Recorded here beside the checkpoint path so
|
|
45
51
|
# every hook-read document this gate consults is named in one place; the module owns
|
|
46
52
|
# the read itself.
|
|
@@ -64,6 +70,28 @@ function Get-ParallelWorktreeRemovalGateCheckpointContent {
|
|
|
64
70
|
return (Get-Content -LiteralPath $script:ParallelCheckpointPath -Raw)
|
|
65
71
|
}
|
|
66
72
|
|
|
73
|
+
function Get-ParallelWorktreeRemovalGateEpicCheckpointContent {
|
|
74
|
+
<#
|
|
75
|
+
.SYNOPSIS
|
|
76
|
+
Read the raw JSON text of the epic checkpoint. Tests mock this function
|
|
77
|
+
(read seam, issue #688).
|
|
78
|
+
.DESCRIPTION
|
|
79
|
+
A separate seam from the parallel checkpoint reader so a test can drive the
|
|
80
|
+
two documents independently: the epic branch must be exercised with the
|
|
81
|
+
parallel checkpoint absent, present-but-not-covering, and covering.
|
|
82
|
+
.OUTPUTS
|
|
83
|
+
System.String or $null
|
|
84
|
+
#>
|
|
85
|
+
[CmdletBinding()]
|
|
86
|
+
[OutputType([string])]
|
|
87
|
+
param()
|
|
88
|
+
|
|
89
|
+
if (-not (Test-Path -LiteralPath $script:EpicCheckpointPath -PathType Leaf)) {
|
|
90
|
+
return $null
|
|
91
|
+
}
|
|
92
|
+
return (Get-Content -LiteralPath $script:EpicCheckpointPath -Raw)
|
|
93
|
+
}
|
|
94
|
+
|
|
67
95
|
function Get-ParallelWorktreeRemovalCommandPath {
|
|
68
96
|
<#
|
|
69
97
|
.SYNOPSIS
|
|
@@ -113,11 +141,16 @@ function Get-ParallelWorktreeRemovalCommandPath {
|
|
|
113
141
|
function Find-ParallelWorktreeItemRecord {
|
|
114
142
|
<#
|
|
115
143
|
.SYNOPSIS
|
|
116
|
-
Locate the
|
|
144
|
+
Locate the record whose worktree_path matches the target path.
|
|
117
145
|
.PARAMETER Checkpoint
|
|
118
|
-
Parsed
|
|
146
|
+
Parsed checkpoint, or $null when absent/unreadable.
|
|
119
147
|
.PARAMETER WorktreePath
|
|
120
148
|
The target worktree path extracted from the command text.
|
|
149
|
+
.PARAMETER RecordArrayName
|
|
150
|
+
Name of the record array to scan. Defaults to 'items', the parallel
|
|
151
|
+
checkpoint's array, so every existing caller is unchanged; the epic branch
|
|
152
|
+
added for issue #688 passes 'features'. Parameterized rather than duplicated
|
|
153
|
+
so both topologies share one path-normalization implementation.
|
|
121
154
|
.OUTPUTS
|
|
122
155
|
System.Object or $null
|
|
123
156
|
#>
|
|
@@ -127,14 +160,17 @@ function Find-ParallelWorktreeItemRecord {
|
|
|
127
160
|
$Checkpoint,
|
|
128
161
|
|
|
129
162
|
[AllowNull()]
|
|
130
|
-
[string] $WorktreePath
|
|
163
|
+
[string] $WorktreePath,
|
|
164
|
+
|
|
165
|
+
[ValidateNotNullOrEmpty()]
|
|
166
|
+
[string] $RecordArrayName = 'items'
|
|
131
167
|
)
|
|
132
168
|
|
|
133
169
|
if ($null -eq $Checkpoint -or [string]::IsNullOrWhiteSpace($WorktreePath)) {
|
|
134
170
|
return $null
|
|
135
171
|
}
|
|
136
172
|
$checkpointProps = @($Checkpoint.PSObject.Properties.Name)
|
|
137
|
-
if ($checkpointProps -notcontains
|
|
173
|
+
if ($checkpointProps -notcontains $RecordArrayName) {
|
|
138
174
|
return $null
|
|
139
175
|
}
|
|
140
176
|
|
|
@@ -142,7 +178,7 @@ function Find-ParallelWorktreeItemRecord {
|
|
|
142
178
|
|
|
143
179
|
# Scan every recorded item for a worktree_path that matches the removal target;
|
|
144
180
|
# path separators are normalized so Windows- and POSIX-style paths compare equal.
|
|
145
|
-
foreach ($item in @($Checkpoint
|
|
181
|
+
foreach ($item in @($Checkpoint.$RecordArrayName)) {
|
|
146
182
|
$itemProps = @($item.PSObject.Properties.Name)
|
|
147
183
|
if ($itemProps -notcontains 'worktree_path') {
|
|
148
184
|
continue
|
|
@@ -264,6 +300,31 @@ function Invoke-ParallelWorktreeRemovalGateDecision {
|
|
|
264
300
|
return Get-ParallelWorktreeGateAllowDecision
|
|
265
301
|
}
|
|
266
302
|
|
|
303
|
+
# Epic-authorization branch (issue #688). It runs after the parallel allow above and
|
|
304
|
+
# before the manifest branch below, so neither of those decisions changes. An epic run
|
|
305
|
+
# records per-child state in the epic checkpoint's features[] array and never writes the
|
|
306
|
+
# parallel checkpoint, so before this branch every merged epic child worktree fell
|
|
307
|
+
# through to the deny even though enforce-epic-worktree-removal-gate.ps1 authorized the
|
|
308
|
+
# same call from that same record. The merge_status predicate is the one already used
|
|
309
|
+
# for parallel items, so the two topologies cannot drift apart on what counts as safe.
|
|
310
|
+
#
|
|
311
|
+
# Fail-closed is preserved: an absent, unreadable, or malformed epic checkpoint parses to
|
|
312
|
+
# $null, which yields no record, which is not allowed.
|
|
313
|
+
$epicCheckpointRaw = Get-ParallelWorktreeRemovalGateEpicCheckpointContent
|
|
314
|
+
$epicCheckpoint = $null
|
|
315
|
+
if (-not [string]::IsNullOrWhiteSpace($epicCheckpointRaw)) {
|
|
316
|
+
try {
|
|
317
|
+
$epicCheckpoint = $epicCheckpointRaw | ConvertFrom-Json -ErrorAction Stop
|
|
318
|
+
} catch {
|
|
319
|
+
$epicCheckpoint = $null
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
$featureRecord = Find-ParallelWorktreeItemRecord -Checkpoint $epicCheckpoint -WorktreePath $worktreePath -RecordArrayName 'features'
|
|
324
|
+
if (Test-ParallelWorktreeRemovalAllowed -ItemRecord $featureRecord) {
|
|
325
|
+
return Get-ParallelWorktreeGateAllowDecision
|
|
326
|
+
}
|
|
327
|
+
|
|
267
328
|
# Sanctioned-removal manifest branch (issue #635). It runs last, so a
|
|
268
329
|
# checkpoint-authorized removal still allows at the same decision point it does
|
|
269
330
|
# today and no transcript attribution changes.
|
|
@@ -15,10 +15,13 @@
|
|
|
15
15
|
payload-reader migration (issue #501) added the module import, the envelope-anomaly
|
|
16
16
|
mapping, and the entry-point seam. The split is a pure move with no behaviour change.
|
|
17
17
|
|
|
18
|
-
Both helpers read the script-scoped configuration
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
Both helpers read the script-scoped configuration the parent hook declares and call the
|
|
19
|
+
parent hook's injectable read seams, so this file is only ever dot-sourced from that hook
|
|
20
|
+
and never invoked on its own. $script:PrContextArtifactPath is a process-directory-relative
|
|
21
|
+
artifact path and stays one. $script:OrchestratorStateCheckpointPath is different after
|
|
22
|
+
issue #673: the parent declares it null, and Get-PrAuthorBypassReason assigns it the
|
|
23
|
+
absolute checkpoint path of the worktree identity resolution selected, so every later
|
|
24
|
+
reader receives one resolved path rather than deriving its own.
|
|
22
25
|
|
|
23
26
|
.NOTES
|
|
24
27
|
Compatible with PowerShell 7+. No external module dependencies.
|
|
@@ -30,6 +33,92 @@ param()
|
|
|
30
33
|
# so this file keeps working when a test dot-sources it directly.
|
|
31
34
|
. (Join-Path $PSScriptRoot 'hook-command-scanner.ps1')
|
|
32
35
|
. (Join-Path $PSScriptRoot 'hook-command-invocation.ps1')
|
|
36
|
+
# Worktree target resolution (issue #687). The checkpoint this gate validates must belong to
|
|
37
|
+
# the item the call is about. Reading a session-root-relative path made that the item whose
|
|
38
|
+
# worktree happened to occupy the session root, so in a parallel or epic topology the gate
|
|
39
|
+
# could return allow on the strength of a sibling item's state -- a false green, which is
|
|
40
|
+
# worse than a false denial because it reports success for a lifecycle it never checked.
|
|
41
|
+
Import-Module (Join-Path $PSScriptRoot '../lib/worktree-resolution/WorktreeResolution.psm1') -Force -ErrorAction Stop
|
|
42
|
+
Import-Module (Join-Path $PSScriptRoot '../lib/worktree-resolution/WorktreeTargetResolution.psm1') -Force -ErrorAction Stop
|
|
43
|
+
# Portable-identity resolution (issue #673). A path signal cannot select a worktree: a merged
|
|
44
|
+
# feature folder exists in every checkout branched from main, so it places a call in many at
|
|
45
|
+
# once. The item is identified by its canonical issue number and its branch instead.
|
|
46
|
+
Import-Module (Join-Path $PSScriptRoot '../lib/worktree-resolution/WorktreeItemResolution.psm1') -Force -ErrorAction Stop
|
|
47
|
+
# Epic scope (issue #663): the epic integration pull request is gated against the epic checkpoint.
|
|
48
|
+
Import-Module (Join-Path $PSScriptRoot '../lib/worktree-resolution/EpicScopeResolution.psm1') -Force -ErrorAction Stop
|
|
49
|
+
Import-Module (Join-Path $PSScriptRoot '../lib/worktree-resolution/EpicScopeReadiness.psm1') -Force -ErrorAction Stop
|
|
50
|
+
|
|
51
|
+
function Resolve-PrAuthorWorktreeTarget {
|
|
52
|
+
<#
|
|
53
|
+
.SYNOPSIS
|
|
54
|
+
Resolve the call's target worktree. Tests mock this function (resolution seam).
|
|
55
|
+
.DESCRIPTION
|
|
56
|
+
A seam rather than a direct call because the resolver reads real git state: the
|
|
57
|
+
worktree list, each registration's branch, and the filesystem. A test that drove it
|
|
58
|
+
directly would depend on the machine's live worktrees and would pass or fail
|
|
59
|
+
according to what other sessions happen to have checked out, which the repository's
|
|
60
|
+
determinism policy forbids. Mocking here lets a test state the resolution outcome it
|
|
61
|
+
is exercising and nothing else.
|
|
62
|
+
.OUTPUTS
|
|
63
|
+
The target result object from Resolve-WorktreeItemTarget.
|
|
64
|
+
#>
|
|
65
|
+
[CmdletBinding()]
|
|
66
|
+
param(
|
|
67
|
+
[Parameter(Mandatory)]
|
|
68
|
+
[string] $CommandText
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
return (Resolve-WorktreeItemTarget -Text $CommandText -SessionRoot (Get-Location).Path)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function Get-PrAuthorTargetCheckpointResolution {
|
|
75
|
+
<#
|
|
76
|
+
.SYNOPSIS
|
|
77
|
+
Resolve the checkpoint path this call must be validated against.
|
|
78
|
+
.DESCRIPTION
|
|
79
|
+
Resolves the target worktree from the command text by portable identity and maps the
|
|
80
|
+
four resolution states onto a checkpoint path or a deny reason:
|
|
81
|
+
|
|
82
|
+
SessionRoot -> that worktree's own checkpoint, composed absolutely.
|
|
83
|
+
OtherWorktree -> that worktree's own checkpoint, composed the same way.
|
|
84
|
+
NoTarget -> deny, carrying the code Get-WorktreeResolutionNoTargetReasonCode
|
|
85
|
+
returns. pr-author passes --head on every gh pr create, so a call
|
|
86
|
+
reaching here omitted the explicit target; the remedy is to supply
|
|
87
|
+
it, never to fall back to whichever checkpoint occupies the
|
|
88
|
+
session root.
|
|
89
|
+
Ambiguous -> deny, carrying the code
|
|
90
|
+
Get-WorktreeResolutionAmbiguityReasonCode returns.
|
|
91
|
+
|
|
92
|
+
The two resolved states share one branch because the path is now composed the same
|
|
93
|
+
way for both: identity selects the worktree, and the checkpoint is read beneath it.
|
|
94
|
+
A session-root result is not a special case, it is the case where identity happened
|
|
95
|
+
to select the worktree the process is already running in.
|
|
96
|
+
|
|
97
|
+
Returning a deny for the two unresolved states is what keeps the gate honest: it
|
|
98
|
+
refuses to answer rather than answering from unrelated state. Neither reason-code
|
|
99
|
+
literal appears in this file; both come from the accessors named above.
|
|
100
|
+
.OUTPUTS
|
|
101
|
+
System.Collections.Specialized.OrderedDictionary with CheckpointPath and Reason.
|
|
102
|
+
#>
|
|
103
|
+
[CmdletBinding()]
|
|
104
|
+
[OutputType([System.Collections.Specialized.OrderedDictionary])]
|
|
105
|
+
param(
|
|
106
|
+
[Parameter(Mandatory)]
|
|
107
|
+
[string] $CommandText
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
$target = Resolve-PrAuthorWorktreeTarget -CommandText $CommandText
|
|
111
|
+
|
|
112
|
+
switch ($target.Status) {
|
|
113
|
+
{ $_ -in @('SessionRoot', 'OtherWorktree') } {
|
|
114
|
+
return [ordered]@{ CheckpointPath = (Get-WorktreeItemCheckpointPath -WorktreeRoot $target.WorktreeRoot); Reason = $null }
|
|
115
|
+
}
|
|
116
|
+
default {
|
|
117
|
+
$reason = "$($target.ReasonCode): $($target.Detail) The pr-author gate will not validate this call against the session root's checkpoint, because that checkpoint may belong to a different item. Pass --head <branch> on the gh pr create command so the call names its own target."
|
|
118
|
+
return [ordered]@{ CheckpointPath = $null; Reason = $reason }
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
33
122
|
|
|
34
123
|
function Test-PrAuthorReceiptVerification {
|
|
35
124
|
<#
|
|
@@ -55,6 +144,12 @@ function Test-PrAuthorReceiptVerification {
|
|
|
55
144
|
with Write access to artifacts/ can replace the body file and the receipt together.
|
|
56
145
|
.PARAMETER CommandText
|
|
57
146
|
The Bash command text containing the --body-file argument.
|
|
147
|
+
.PARAMETER CheckpointPath
|
|
148
|
+
The absolute checkpoint path identity resolution selected, passed through to check 6
|
|
149
|
+
so that check reads the resolved worktree's checkpoint rather than deriving its own.
|
|
150
|
+
.PARAMETER EpicScope
|
|
151
|
+
Optional. The epic-scope result Get-PrAuthorBypassReason resolved (issue #663), passed
|
|
152
|
+
through to check 6 so the call is resolved once; $null outside epic scope.
|
|
58
153
|
.OUTPUTS
|
|
59
154
|
System.String or $null
|
|
60
155
|
#>
|
|
@@ -62,7 +157,13 @@ function Test-PrAuthorReceiptVerification {
|
|
|
62
157
|
[OutputType([string])]
|
|
63
158
|
param(
|
|
64
159
|
[Parameter(Mandatory)]
|
|
65
|
-
[string] $CommandText
|
|
160
|
+
[string] $CommandText,
|
|
161
|
+
|
|
162
|
+
[Parameter(Mandatory)]
|
|
163
|
+
[string] $CheckpointPath,
|
|
164
|
+
|
|
165
|
+
[AllowNull()]
|
|
166
|
+
[object] $EpicScope
|
|
66
167
|
)
|
|
67
168
|
|
|
68
169
|
# Check 1: the --body-file argument must match the canonical artifacts/pr_body_<N>.md pattern.
|
|
@@ -133,7 +234,7 @@ function Test-PrAuthorReceiptVerification {
|
|
|
133
234
|
}
|
|
134
235
|
|
|
135
236
|
# Check 6: under epic_mode, gh pr create must carry a matching --base override.
|
|
136
|
-
$epicBaseBranchReason = Test-EpicBaseBranchOverride -CommandText $CommandText
|
|
237
|
+
$epicBaseBranchReason = Test-EpicBaseBranchOverride -CommandText $CommandText -CheckpointPath $CheckpointPath -EpicScope $EpicScope
|
|
137
238
|
if ($epicBaseBranchReason) {
|
|
138
239
|
return $epicBaseBranchReason
|
|
139
240
|
}
|
|
@@ -234,13 +335,36 @@ function Get-PrAuthorBypassReason {
|
|
|
234
335
|
return "PR_CONTEXT_MISSING: ``$script:PrContextArtifactPath`` is absent. Run ``mcp__drm-copilot__collect_pr_context`` before creating or editing the PR body."
|
|
235
336
|
}
|
|
236
337
|
|
|
338
|
+
# Epic scope (issue #663): when the call's --head equals the epic checkpoint's
|
|
339
|
+
# integration_branch, the integration pull request is gated by the epic PR-creation
|
|
340
|
+
# readiness predicate on artifacts/orchestration/epic-orchestrator-state.json, and no
|
|
341
|
+
# per-feature checkpoint is resolved or read. Resolved once; check 6 reuses the result.
|
|
342
|
+
$epicScope = $null
|
|
343
|
+
if ($hasBodyFile -and $ContextExists) {
|
|
344
|
+
$epicScope = Resolve-EpicScopeCheckpoint -Text $CommandText -SessionRoot (Get-Location).Path
|
|
345
|
+
}
|
|
346
|
+
|
|
237
347
|
# Orchestrator-state preflight: runs inside this same PreToolUse hook (so it cannot be
|
|
238
348
|
# bypassed by invoking gh pr create/edit directly) before receipt verification.
|
|
239
|
-
if ($
|
|
240
|
-
$
|
|
349
|
+
if ($null -ne $epicScope -and $epicScope.IsEpicScope) {
|
|
350
|
+
$failure = Get-EpicPrCreationReadinessFailure -Checkpoint $epicScope.Checkpoint -HeadBranch $epicScope.Branch
|
|
351
|
+
if ($failure) {
|
|
352
|
+
return "ORCHESTRATOR_STATE_PREFLIGHT_FAILED: this epic-scope pull request was evaluated against $($epicScope.CheckpointPath), and the failed readiness predicate is '$failure'."
|
|
353
|
+
}
|
|
354
|
+
$script:OrchestratorStateCheckpointPath = $epicScope.CheckpointPath
|
|
355
|
+
} elseif ($hasBodyFile -and $ContextExists) {
|
|
356
|
+
$resolution = Get-PrAuthorTargetCheckpointResolution -CommandText $CommandText
|
|
357
|
+
if ($resolution.Reason) {
|
|
358
|
+
return $resolution.Reason
|
|
359
|
+
}
|
|
360
|
+
# Assigned once here and read by every later consumer, so the preflight, the receipt
|
|
361
|
+
# verifier, and the epic base-branch check cannot disagree about which item is gated.
|
|
362
|
+
$script:OrchestratorStateCheckpointPath = $resolution.CheckpointPath
|
|
363
|
+
$checkpointPath = $script:OrchestratorStateCheckpointPath
|
|
364
|
+
$preflightResult = Invoke-OrchestratorStatePreflight -CheckpointPath $checkpointPath
|
|
241
365
|
if ($preflightResult.HasErrors) {
|
|
242
366
|
$preflightSummary = if ([string]::IsNullOrWhiteSpace($preflightResult.ErrorText)) {
|
|
243
|
-
"checkpoint missing at $
|
|
367
|
+
"checkpoint missing at $checkpointPath"
|
|
244
368
|
} else {
|
|
245
369
|
$preflightResult.ErrorText
|
|
246
370
|
}
|
|
@@ -250,7 +374,7 @@ function Get-PrAuthorBypassReason {
|
|
|
250
374
|
|
|
251
375
|
# Receipt verification: extends, and does not replace, the previously-allowed path.
|
|
252
376
|
if ($hasBodyFile -and $ContextExists) {
|
|
253
|
-
$receiptReason = Test-PrAuthorReceiptVerification -CommandText $CommandText
|
|
377
|
+
$receiptReason = Test-PrAuthorReceiptVerification -CommandText $CommandText -CheckpointPath $script:OrchestratorStateCheckpointPath -EpicScope $epicScope
|
|
254
378
|
if ($receiptReason) {
|
|
255
379
|
return $receiptReason
|
|
256
380
|
}
|
package/resources/claude-customizations/.claude/hooks/enforce-pr-author-skill.epic-base-branch.ps1
CHANGED
|
@@ -20,19 +20,24 @@ function Get-PrAuthorCheckpointContent {
|
|
|
20
20
|
Read the raw JSON text of the per-feature orchestrator checkpoint. Tests mock this
|
|
21
21
|
function (read seam) for the epic-mode base-branch override check.
|
|
22
22
|
.DESCRIPTION
|
|
23
|
-
Returns the raw text content of
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
Returns the raw text content of the checkpoint at the supplied path, or $null when the
|
|
24
|
+
file is absent. This is the injectable boundary for checkpoint content used by
|
|
25
|
+
Test-EpicBaseBranchOverride; no test writes the checkpoint file to disk.
|
|
26
|
+
|
|
27
|
+
The path is mandatory and carries no default (issue #673). A relative default was the
|
|
28
|
+
second of this feature's three bindings: it made check 6 read whichever checkpoint
|
|
29
|
+
occupied the process directory even when target resolution had already selected a
|
|
30
|
+
different worktree, so the epic verdict could come from an unrelated item.
|
|
26
31
|
.PARAMETER CheckpointPath
|
|
27
|
-
The
|
|
32
|
+
The absolute path of the checkpoint belonging to the resolved worktree.
|
|
28
33
|
.OUTPUTS
|
|
29
34
|
System.String or $null
|
|
30
35
|
#>
|
|
31
36
|
[CmdletBinding()]
|
|
32
37
|
[OutputType([string])]
|
|
33
38
|
param(
|
|
34
|
-
[Parameter(Mandatory
|
|
35
|
-
[string] $CheckpointPath
|
|
39
|
+
[Parameter(Mandatory)]
|
|
40
|
+
[string] $CheckpointPath
|
|
36
41
|
)
|
|
37
42
|
|
|
38
43
|
if (-not (Test-Path -LiteralPath $CheckpointPath)) {
|
|
@@ -57,6 +62,13 @@ function Test-EpicBaseBranchOverride {
|
|
|
57
62
|
unchanged.
|
|
58
63
|
.PARAMETER CommandText
|
|
59
64
|
The Bash command text under evaluation.
|
|
65
|
+
.PARAMETER CheckpointPath
|
|
66
|
+
The absolute checkpoint path identity resolution selected, passed straight through to
|
|
67
|
+
the read seam so this check and the orchestrator-state preflight read one file.
|
|
68
|
+
.PARAMETER EpicScope
|
|
69
|
+
Optional. The epic-scope result gate 1 resolved (issue #663). When it reports epic
|
|
70
|
+
scope, the integration pull request must pass --base main and the per-feature
|
|
71
|
+
checkpoint seam is not read; $null keeps the per-feature epic_mode rule unchanged.
|
|
60
72
|
.OUTPUTS
|
|
61
73
|
System.String or $null
|
|
62
74
|
#>
|
|
@@ -64,7 +76,13 @@ function Test-EpicBaseBranchOverride {
|
|
|
64
76
|
[OutputType([string])]
|
|
65
77
|
param(
|
|
66
78
|
[Parameter(Mandatory)]
|
|
67
|
-
[string] $CommandText
|
|
79
|
+
[string] $CommandText,
|
|
80
|
+
|
|
81
|
+
[Parameter(Mandatory)]
|
|
82
|
+
[string] $CheckpointPath,
|
|
83
|
+
|
|
84
|
+
[AllowNull()]
|
|
85
|
+
[object] $EpicScope
|
|
68
86
|
)
|
|
69
87
|
|
|
70
88
|
# The epic-mode base-branch override only constrains gh pr create; gh pr edit does not
|
|
@@ -75,7 +93,18 @@ function Test-EpicBaseBranchOverride {
|
|
|
75
93
|
return $null
|
|
76
94
|
}
|
|
77
95
|
|
|
78
|
-
|
|
96
|
+
# Epic scope (issue #663): the epic's own integration pull request targets main. The
|
|
97
|
+
# scope object comes from gate 1, so the epic checkpoint is not read a second time and
|
|
98
|
+
# the per-feature checkpoint is not consulted.
|
|
99
|
+
if ($null -ne $EpicScope -and $EpicScope.IsEpicScope) {
|
|
100
|
+
$epicBaseValue = Get-CommandLineFlagValue -CommandText $CommandText -CommandWord 'gh' -SubcommandPath @('pr', 'create') -FlagName '--base'
|
|
101
|
+
if ($null -eq $epicBaseValue -or $epicBaseValue -cne 'main') {
|
|
102
|
+
return "EPIC_BASE_BRANCH_MISMATCH: this epic-scope gh pr create was evaluated against $($EpicScope.CheckpointPath); the integration pull request must pass --base main."
|
|
103
|
+
}
|
|
104
|
+
return $null
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
$checkpointRaw = Get-PrAuthorCheckpointContent -CheckpointPath $CheckpointPath
|
|
79
108
|
if ([string]::IsNullOrWhiteSpace($checkpointRaw)) {
|
|
80
109
|
return $null
|
|
81
110
|
}
|
|
@@ -46,7 +46,9 @@ param()
|
|
|
46
46
|
|
|
47
47
|
Import-Module (Join-Path $PSScriptRoot '../lib/hook-payload/HookPayload.psm1') -Force
|
|
48
48
|
$script:PrContextArtifactPath = 'artifacts/pr_context.summary.txt'
|
|
49
|
-
|
|
49
|
+
# Null until the resolution step assigns the absolute path of the resolved worktree's
|
|
50
|
+
# checkpoint (issue #673); a relative default here was the process-directory binding.
|
|
51
|
+
$script:OrchestratorStateCheckpointPath = $null
|
|
50
52
|
|
|
51
53
|
Import-Module (Join-Path $PSScriptRoot '../lib/orchestrator-state/OrchestratorState.psm1') -Force
|
|
52
54
|
|