sdtk-spec-kit 0.3.15 → 0.3.16

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.
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "0.3.15",
3
- "sourceCommit": "65285e05045a652553cc1f1c209340ea7f5d08d3",
2
+ "version": "0.3.16",
3
+ "sourceCommit": "b974bd438f786bf2cf7ff71a03d159df8b93ae70",
4
4
  "fileCount": 94,
5
5
  "files": [
6
6
  {
@@ -30,13 +30,13 @@
30
30
  },
31
31
  {
32
32
  "path": "toolkit/scripts/agents/run-claude-task.ps1",
33
- "sha256": "3ed4e1d5c951aa309a64c5940e9f1e69e6748e07c650258017deebb9287c0f2d",
34
- "size": 4706
33
+ "sha256": "8616291be4aaa4fb5cb0f1f4c738c108ab79090bf767ee2b4403d6d582c150c7",
34
+ "size": 19239
35
35
  },
36
36
  {
37
37
  "path": "toolkit/scripts/agents/run-codex-task.ps1",
38
- "sha256": "7821318d618a0b82c9027844e260acfda36bed075ddbebc3619c4ddf3682317f",
39
- "size": 4304
38
+ "sha256": "5d5ddf37b902fbc8857c64f4b201da9129942c66fa54e9b53984008263862080",
39
+ "size": 29058
40
40
  },
41
41
  {
42
42
  "path": "toolkit/scripts/agents/validate-mailbox-formal-artifact.py",
@@ -155,8 +155,8 @@
155
155
  },
156
156
  {
157
157
  "path": "toolkit/skills/sdtk-mailbox-dispatch/SKILL.md",
158
- "sha256": "738a48be4a0d6adf5d7f0033b053ca999e00e0e9103702e1bea60d5ecfd7b328",
159
- "size": 4807
158
+ "sha256": "926840764de83772c12d8e7c0d07a1be28472488dd00f2ec28dc97ba77788a49",
159
+ "size": 5836
160
160
  },
161
161
  {
162
162
  "path": "toolkit/skills/sdtk-orchestrator/SKILL.md",
@@ -260,8 +260,8 @@
260
260
  },
261
261
  {
262
262
  "path": "toolkit/skills-claude/mailbox-dispatch/SKILL.md",
263
- "sha256": "0e45fb26e1a17e0f75a59acf59fe6a4cd8b74a17c32a9eded08c7d6b8b37bf8a",
264
- "size": 4802
263
+ "sha256": "4895d9a56ba67ff69038c7d11c582307a2b40a7d12d2cc3ddc3463403ca453dc",
264
+ "size": 5831
265
265
  },
266
266
  {
267
267
  "path": "toolkit/skills-claude/orchestrator/SKILL.md",
@@ -450,13 +450,13 @@
450
450
  },
451
451
  {
452
452
  "path": "toolkit/templates/mailbox/AGENT_REPORT_TEMPLATE.md",
453
- "sha256": "d36ae9af62e0f403e588b3ce6608cea335ab1d9af693021bdce2731ff8cb5bc3",
454
- "size": 1390
453
+ "sha256": "b67ae168d02764bf189306d58a7971d93a8a9538bcbec0ea8b5ff5ccc891e481",
454
+ "size": 1844
455
455
  },
456
456
  {
457
457
  "path": "toolkit/templates/mailbox/AGENT_TASK_TEMPLATE.md",
458
- "sha256": "18a80588e43dde5b720b7e30821bad9308cf9e8b7ba168598ba16b937d9d1486",
459
- "size": 2229
458
+ "sha256": "3fd748061615802c8cd5a4978396a782f59404662339ee18f732352cb79b4f84",
459
+ "size": 2821
460
460
  },
461
461
  {
462
462
  "path": "toolkit/templates/QUALITY_CHECKLIST.md",
@@ -3,8 +3,8 @@ f75e0a81845d4f841ed2c03d6a3837f345daf799d5cef18db3366517e8716861 toolkit/AGENTS
3
3
  1cb0643111e385a1ba606458998a977dc0c066cfdefc4e7069dd485ab2843c4e toolkit/README.md
4
4
  2a037fede7b749841db61aeb06473b9f19a5ac49520b533cb496c375d6054f32 toolkit/runtimes/claude/CLAUDE_TEMPLATE.md
5
5
  4453f452a6ac99f123d734f66d608e0c3d931262f3b51ea32307ef327911e938 toolkit/runtimes/codex/CODEX_TEMPLATE.md
6
- 3ed4e1d5c951aa309a64c5940e9f1e69e6748e07c650258017deebb9287c0f2d toolkit/scripts/agents/run-claude-task.ps1
7
- 7821318d618a0b82c9027844e260acfda36bed075ddbebc3619c4ddf3682317f toolkit/scripts/agents/run-codex-task.ps1
6
+ 8616291be4aaa4fb5cb0f1f4c738c108ab79090bf767ee2b4403d6d582c150c7 toolkit/scripts/agents/run-claude-task.ps1
7
+ 5d5ddf37b902fbc8857c64f4b201da9129942c66fa54e9b53984008263862080 toolkit/scripts/agents/run-codex-task.ps1
8
8
  f726aac97132a74d64cfac238a4ad736391a67291219221bb1abb20ecf81940a toolkit/scripts/agents/validate-mailbox-formal-artifact.py
9
9
  48bc3d8b1942e1e3499d8933a97e1c8f9bcb201e7c4d801afa3f04159113bdee toolkit/scripts/generate-code-handoff.ps1
10
10
  2b456e0e9ebeb948db9bdd1a905195285a8ae44839b09b5f0bbefac597cfd67a toolkit/scripts/init-feature.ps1
@@ -28,7 +28,7 @@ ce5af79e5c4902b9c8ceb7e8dae848a6a5a26d5b845eee94ee8aafff88990256 toolkit/skills
28
28
  1f10d2c1405d0ef80caa0b741197f2fde80659bab4e66291560780413e633313 toolkit/skills/sdtk-dev/SKILL.md
29
29
  099024d3b31b63a20e6a041d4a3f0062bfd4fa5b3960926112fa44a7a20972b5 toolkit/skills/sdtk-dev-backend/SKILL.md
30
30
  419def53f37a10006a54392e642f2e86ac2bfa44c8ed826159ce309f2a9a3d6a toolkit/skills/sdtk-dev-frontend/SKILL.md
31
- 738a48be4a0d6adf5d7f0033b053ca999e00e0e9103702e1bea60d5ecfd7b328 toolkit/skills/sdtk-mailbox-dispatch/SKILL.md
31
+ 926840764de83772c12d8e7c0d07a1be28472488dd00f2ec28dc97ba77788a49 toolkit/skills/sdtk-mailbox-dispatch/SKILL.md
32
32
  8597f99d53547b1cf30ffc54bbf19a6c3a502a5560e549d4ec5b9630f5d5b7c1 toolkit/skills/sdtk-orchestrator/SKILL.md
33
33
  90d3c9d8bb2bb3b28e81bc10c6b1799236250dfcb2ebed43eb161c78ff00a084 toolkit/skills/sdtk-pm/SKILL.md
34
34
  9e41a944a73c6960c8aa24d8930e64c1ed699ed8b410a587b042186e2d450e6e toolkit/skills/sdtk-qa/SKILL.md
@@ -49,7 +49,7 @@ c17bb4faff318032ee99ead56e5fa182811c7bcaa176e463d0377cefde213ac1 toolkit/skills
49
49
  7806428b02784daa03785f55c16414f9c40fb5f36481c4bd3973c7be38fdba10 toolkit/skills-claude/dev/SKILL.md
50
50
  b4de86bc4730c4fcfe4f1bde8f9f64f03fd517825bb699e911199825cc3d4249 toolkit/skills-claude/dev-backend/SKILL.md
51
51
  37b3ae11db18bc3f64a76b22bca95cea778d6cfbb8b038d46851bd44ff8ff8f1 toolkit/skills-claude/dev-frontend/SKILL.md
52
- 0e45fb26e1a17e0f75a59acf59fe6a4cd8b74a17c32a9eded08c7d6b8b37bf8a toolkit/skills-claude/mailbox-dispatch/SKILL.md
52
+ 4895d9a56ba67ff69038c7d11c582307a2b40a7d12d2cc3ddc3463403ca453dc toolkit/skills-claude/mailbox-dispatch/SKILL.md
53
53
  3dafddf5d218c794c2d2cffce09c982cfc1115bb5221b7315497afca5ff42bdd toolkit/skills-claude/orchestrator/SKILL.md
54
54
  e9e346ff0e1fc66236ceabf64a043c9a28926e7ff06296b26dd5836cf045802a toolkit/skills-claude/pm/SKILL.md
55
55
  a94b06194dd120f959082e3bcded91573e8c7b2ee350ab5bbad63a9c3cc331ab toolkit/skills-claude/qa/SKILL.md
@@ -87,8 +87,8 @@ e65192c4e72d86d27452c89f7be2d3bfe1118af550f71e3eee9db92e20f96cea toolkit/templa
87
87
  5d1aec41dd9c51c1dac67ab344dd8acecb9be79717ddadf91d358013eecdcb26 toolkit/templates/handoffs/DEV_TO_SDTK_CODE.md
88
88
  f70bd655f2865adb2231976e9861054522e45afd3e13613430b5ebe9176ac80d toolkit/templates/handoffs/PM_TO_BA.md
89
89
  6ee91d4307ec0fc6dbdee281f2a3f99efa552de55b535ff46cf498689572f9f7 toolkit/templates/handoffs/QA_RELEASE_DECISION.md
90
- d36ae9af62e0f403e588b3ce6608cea335ab1d9af693021bdce2731ff8cb5bc3 toolkit/templates/mailbox/AGENT_REPORT_TEMPLATE.md
91
- 18a80588e43dde5b720b7e30821bad9308cf9e8b7ba168598ba16b937d9d1486 toolkit/templates/mailbox/AGENT_TASK_TEMPLATE.md
90
+ b67ae168d02764bf189306d58a7971d93a8a9538bcbec0ea8b5ff5ccc891e481 toolkit/templates/mailbox/AGENT_REPORT_TEMPLATE.md
91
+ 3fd748061615802c8cd5a4978396a782f59404662339ee18f732352cb79b4f84 toolkit/templates/mailbox/AGENT_TASK_TEMPLATE.md
92
92
  205dafaed01e5841d3c6870a093d08ba4ce58a9bbfc716a506f0951149e2dcf9 toolkit/templates/QUALITY_CHECKLIST.md
93
93
  2ba15299f149dca87d182ca65d8dccc3b27335c6ac31e01cc42afd02476d5dad toolkit/templates/README.md
94
94
  b756c866fe7e76d1f4003871d80abe491d0283e0c95205121e6f91fbd8b02471 toolkit/templates/SHARED_PLANNING.md
@@ -1,111 +1,332 @@
1
- param(
2
- [Parameter(Mandatory = $true)] [string] $RepoRoot,
3
- [Parameter(Mandatory = $true)] [string] $TaskFile,
4
- [Parameter(Mandatory = $true)] [string] $ReportFile,
5
- [string] $LogFile = '',
6
- [string] $SessionName = '',
7
- [string] $Model = '',
8
- [ValidateSet('default','dontAsk','acceptEdits','auto','bypassPermissions','plan')] [string] $PermissionMode = 'dontAsk',
9
- [ValidateSet('low','medium','high','max')] [string] $Effort = 'medium',
10
- [switch] $DryRun
11
- )
12
-
13
- $ErrorActionPreference = 'Stop'
14
- $Utf8NoBom = [System.Text.UTF8Encoding]::new($false)
15
- $ReviewPhases = @('controller-dev-review', 'qa-review', 'controller-acceptance')
16
-
17
- function Get-TaskBulletValue([string[]] $Lines, [string] $Heading) {
18
- for ($i = 0; $i -lt $Lines.Length; $i++) {
19
- if ($Lines[$i].Trim() -eq $Heading) {
20
- for ($j = $i + 1; $j -lt $Lines.Length; $j++) {
21
- $candidate = $Lines[$j].Trim()
22
- if (-not $candidate) { continue }
23
- if ($candidate.StartsWith('- ')) {
24
- return $candidate.Substring(2).Trim()
25
- }
26
- break
27
- }
28
- }
29
- }
30
- return ''
31
- }
32
-
33
- function Resolve-RepoPath([string] $RepoRootPath, [string] $CandidatePath) {
34
- if ([string]::IsNullOrWhiteSpace($CandidatePath)) { return '' }
35
- if ([System.IO.Path]::IsPathRooted($CandidatePath)) { return $CandidatePath }
36
- return Join-Path $RepoRootPath $CandidatePath
37
- }
38
-
39
- function Append-FileText([string] $Path, [string] $Text) {
40
- if ([string]::IsNullOrWhiteSpace($Text)) { return }
41
- [System.IO.File]::AppendAllText($Path, [Environment]::NewLine + $Text, $Utf8NoBom)
42
- }
43
-
44
- function Invoke-PhaseArtifactValidation([string[]] $TaskLines, [string] $RepoRootPath, [string] $ReportPath, [string] $LogPath, [string] $ValidatorPath) {
45
- $phase = Get-TaskBulletValue $TaskLines 'Phase:'
46
- if ($ReviewPhases -notcontains $phase) { return }
47
-
48
- $artifactValue = Get-TaskBulletValue $TaskLines 'Primary Formal Artifact:'
49
- if ([string]::IsNullOrWhiteSpace($artifactValue)) { return }
50
- if (-not (Test-Path $ValidatorPath)) { return }
51
-
52
- $artifactPath = Resolve-RepoPath $RepoRootPath $artifactValue
53
- if (-not (Test-Path $artifactPath)) {
54
- $skip = "[MAILBOX PHASE VALIDATION] skipped: primary formal artifact not found at $artifactPath"
55
- Append-FileText $ReportPath $skip
56
- if ($LogPath) { Append-FileText $LogPath $skip }
57
- return
58
- }
59
-
60
- $validationOutput = (& python $ValidatorPath --phase $phase --artifact $artifactPath 2>&1 | Out-String).TrimEnd()
61
- $validationBlock = "[MAILBOX PHASE VALIDATION]`n$validationOutput"
62
- Append-FileText $ReportPath $validationBlock
63
- if ($LogPath) { Append-FileText $LogPath $validationBlock }
64
-
65
- if ($LASTEXITCODE -ne 0) {
66
- throw "Mailbox phase artifact validation failed for $artifactPath"
67
- }
68
- }
69
-
70
- if (-not (Test-Path $RepoRoot)) { throw "RepoRoot not found: $RepoRoot" }
71
- if (-not (Test-Path $TaskFile)) { throw "TaskFile not found: $TaskFile" }
72
-
73
- $taskLines = Get-Content $TaskFile -Encoding UTF8
74
- $prompt = [string]($taskLines | Out-String)
75
- New-Item -ItemType Directory -Force -Path ([System.IO.Path]::GetDirectoryName($ReportFile)) | Out-Null
76
- if ($LogFile) {
77
- New-Item -ItemType Directory -Force -Path ([System.IO.Path]::GetDirectoryName($LogFile)) | Out-Null
78
- }
79
-
80
- $cliArgs = @('-p', '--output-format', 'text', '--no-session-persistence', '--add-dir', $RepoRoot, '--permission-mode', $PermissionMode, '--effort', $Effort)
81
- if ($SessionName) { $cliArgs += @('--name', $SessionName) }
82
- if ($Model) { $cliArgs += @('--model', $Model) }
83
- $cliArgs += $prompt
84
-
85
- if ($DryRun) {
86
- $safeArgs = @('-p', '--output-format', 'text', '--no-session-persistence', '--add-dir', $RepoRoot, '--permission-mode', $PermissionMode, '--effort', $Effort)
87
- if ($SessionName) { $safeArgs += @('--name', $SessionName) }
88
- if ($Model) { $safeArgs += @('--model', $Model) }
89
- [pscustomobject]@{
90
- Cli = 'claude'
91
- RepoRoot = $RepoRoot
92
- TaskFile = $TaskFile
93
- ReportFile = $ReportFile
94
- LogFile = $LogFile
95
- Args = $safeArgs
96
- PromptLength = $prompt.Length
97
- PromptPreview = if ($prompt.Length -gt 240) { $prompt.Substring(0, 240) } else { $prompt }
98
- } | ConvertTo-Json -Depth 4
99
- exit 0
100
- }
101
-
102
- $output = & claude @cliArgs 2>&1
103
- $outputText = ($output | Out-String)
104
- [System.IO.File]::WriteAllText($ReportFile, $outputText, $Utf8NoBom)
105
- if ($LogFile) {
106
- [System.IO.File]::WriteAllText($LogFile, $outputText, $Utf8NoBom)
107
- }
108
-
109
- $validatorPath = Join-Path $PSScriptRoot 'validate-mailbox-formal-artifact.py'
110
- Invoke-PhaseArtifactValidation -TaskLines $taskLines -RepoRootPath $RepoRoot -ReportPath $ReportFile -LogPath $LogFile -ValidatorPath $validatorPath
111
- Write-Host "Claude report written to: $ReportFile"
1
+ param(
2
+ [Parameter(Mandatory = $true)] [string] $RepoRoot,
3
+ [Parameter(Mandatory = $true)] [string] $TaskFile,
4
+ [Parameter(Mandatory = $true)] [string] $ReportFile,
5
+ [string] $LogFile = '',
6
+ [string] $SessionName = '',
7
+ [string] $Model = '',
8
+ [ValidateSet('default','dontAsk','acceptEdits','auto','bypassPermissions','plan')] [string] $PermissionMode = 'dontAsk',
9
+ [ValidateSet('low','medium','high','max')] [string] $Effort = 'medium',
10
+ [switch] $DryRun
11
+ )
12
+
13
+ $ErrorActionPreference = 'Stop'
14
+ $Utf8NoBom = [System.Text.UTF8Encoding]::new($false)
15
+ $ReviewPhases = @('controller-dev-review', 'qa-review', 'controller-acceptance')
16
+ $ReadOnlyPermissionMode = 'read-only'
17
+ $WritablePermissionMode = 'workspace-write-approved'
18
+ $NotRequiredApprovalStatus = 'not-required'
19
+ $HumanApprovedStatus = 'human-approved'
20
+ $WritableClaudeModes = @('acceptEdits', 'auto', 'bypassPermissions')
21
+
22
+ function Get-TaskBulletValue([string[]] $Lines, [string] $Heading) {
23
+ for ($i = 0; $i -lt $Lines.Length; $i++) {
24
+ if ($Lines[$i].Trim() -eq $Heading) {
25
+ for ($j = $i + 1; $j -lt $Lines.Length; $j++) {
26
+ $candidate = $Lines[$j].Trim()
27
+ if (-not $candidate) { continue }
28
+ if ($candidate.StartsWith('- ')) {
29
+ return $candidate.Substring(2).Trim()
30
+ }
31
+ break
32
+ }
33
+ }
34
+ }
35
+ return ''
36
+ }
37
+
38
+
39
+ function Get-TaskListValues([string[]] $Lines, [string] $Heading) {
40
+ $values = New-Object System.Collections.Generic.List[string]
41
+ $foundHeading = $false
42
+ for ($i = 0; $i -lt $Lines.Length; $i++) {
43
+ $trimmed = $Lines[$i].Trim()
44
+ if (-not $foundHeading) {
45
+ if ($trimmed -eq $Heading) {
46
+ $foundHeading = $true
47
+ }
48
+ continue
49
+ }
50
+
51
+ if (-not $trimmed) {
52
+ if ($values.Count -gt 0) { break }
53
+ continue
54
+ }
55
+
56
+ $headingMatch = [regex]::Match($trimmed, '^[A-Za-z].*:$')
57
+ if ($headingMatch.Success) { break }
58
+
59
+ $listMatch = [regex]::Match($trimmed, '^(?:-|\d+\.)\s+(?<value>.+)$')
60
+ if ($listMatch.Success) {
61
+ $values.Add($listMatch.Groups['value'].Value.Trim())
62
+ continue
63
+ }
64
+
65
+ if ($values.Count -gt 0) { break }
66
+ }
67
+ return $values.ToArray()
68
+ }
69
+
70
+ function Resolve-RepoPath([string] $RepoRootPath, [string] $CandidatePath) {
71
+ if ([string]::IsNullOrWhiteSpace($CandidatePath)) { return '' }
72
+ if ([System.IO.Path]::IsPathRooted($CandidatePath)) { return $CandidatePath }
73
+ return Join-Path $RepoRootPath $CandidatePath
74
+ }
75
+
76
+ function Append-FileText([string] $Path, [string] $Text) {
77
+ if ([string]::IsNullOrWhiteSpace($Text)) { return }
78
+ [System.IO.File]::AppendAllText($Path, [Environment]::NewLine + $Text, $Utf8NoBom)
79
+ }
80
+
81
+ function Normalize-TaskValue([string] $Value, [string] $Default = '') {
82
+ if ([string]::IsNullOrWhiteSpace($Value)) { return $Default }
83
+ return $Value.Trim()
84
+ }
85
+
86
+
87
+ function Convert-ToBulletBlock([string[]] $Items) {
88
+ if ($null -eq $Items -or $Items.Count -eq 0) {
89
+ return '- (none declared)'
90
+ }
91
+ return (($Items | ForEach-Object { "- $_" }) -join [Environment]::NewLine)
92
+ }
93
+
94
+ function New-BoundedExecutionPrompt([string[]] $TaskLines) {
95
+ $phase = Normalize-TaskValue (Get-TaskBulletValue $TaskLines 'Phase:') 'other'
96
+ $objective = Normalize-TaskValue (Get-TaskBulletValue $TaskLines 'Objective:') 'n/a'
97
+ $boundaryMode = Normalize-TaskValue (Get-TaskBulletValue $TaskLines 'Boundary Mode:') 'n/a'
98
+ $inputs = Get-TaskListValues $TaskLines 'Inputs:'
99
+ $includeBoundary = Get-TaskListValues $TaskLines 'Include Boundary:'
100
+ $excludeBoundary = Get-TaskListValues $TaskLines 'Exclude Boundary:'
101
+ $verification = Get-TaskListValues $TaskLines 'Required Verification:'
102
+ $taskBody = [string]($TaskLines | Out-String)
103
+
104
+ $envelope = @"
105
+ [MAILBOX BOUNDED EXECUTION MODE]
106
+ You are running under controller-enforced bounded execution mode.
107
+
108
+ Phase: $phase
109
+ Objective: $objective
110
+ Boundary Mode: $boundaryMode
111
+
112
+ Execution Discipline:
113
+ 1. Read every listed input first and treat the `Inputs:` section as the authoritative starting source set.
114
+ 2. Do not run broad repo-wide or directory-wide discovery before you have read the listed inputs.
115
+ 3. Only inspect additional files when they are directly required to modify an included path or execute a required verification command.
116
+ 4. Any additional inspection must stay inside the include boundary and must not cross the exclude boundary.
117
+ 5. Do not mine `governance/ai/reviews/shared/` or similar directories for examples unless a specific file is already listed in `Inputs:`.
118
+ 6. If the listed inputs are insufficient, stop and report the exact missing dependency instead of broad scanning.
119
+ 7. Deliver the bounded patch and formal artifact before optional example-hunting or style exploration.
120
+
121
+ Authoritative Inputs:
122
+ $(Convert-ToBulletBlock $inputs)
123
+
124
+ Include Boundary:
125
+ $(Convert-ToBulletBlock $includeBoundary)
126
+
127
+ Exclude Boundary:
128
+ $(Convert-ToBulletBlock $excludeBoundary)
129
+
130
+ Required Verification:
131
+ $(Convert-ToBulletBlock $verification)
132
+
133
+ [ORIGINAL TASK PACKET]
134
+ "@
135
+
136
+ return $envelope.TrimEnd() + [Environment]::NewLine + [Environment]::NewLine + $taskBody
137
+ }
138
+
139
+ function Test-PlaceholderValue([string] $Value) {
140
+ $normalized = Normalize-TaskValue $Value
141
+ if ([string]::IsNullOrWhiteSpace($normalized)) { return $true }
142
+ return @('n/a', 'na', 'none', 'not-applicable') -contains $normalized.ToLowerInvariant()
143
+ }
144
+
145
+ function New-PermissionAuditBlock(
146
+ [string] $DeclaredPermission,
147
+ [string] $EffectiveMode,
148
+ [string] $ApprovalStatus,
149
+ [string] $ApprovedBy,
150
+ [string] $ApprovalReason,
151
+ [string] $ApprovedScope,
152
+ [string] $ApprovalReference,
153
+ [string] $DecisionSummary
154
+ ) {
155
+ return @"
156
+ [MAILBOX EXECUTION PERMISSION AUDIT]
157
+ - Declared Execution Permission: $DeclaredPermission
158
+ - Effective Runtime Permission Mode: $EffectiveMode
159
+ - Permission Approval Status: $ApprovalStatus
160
+ - Approved By: $ApprovedBy
161
+ - Approval Reason: $ApprovalReason
162
+ - Approved Writable Scope: $ApprovedScope
163
+ - Approval Reference: $ApprovalReference
164
+ - Launcher Decision Summary: $DecisionSummary
165
+ "@.TrimEnd()
166
+ }
167
+
168
+ function Write-PermissionFailure(
169
+ [string] $ReportPath,
170
+ [string] $LogPath,
171
+ [string] $AuditBlock,
172
+ [string] $Message
173
+ ) {
174
+ Append-FileText $ReportPath $AuditBlock
175
+ Append-FileText $ReportPath "[MAILBOX PERMISSION VALIDATION] failed: $Message"
176
+ if ($LogPath) {
177
+ Append-FileText $LogPath $AuditBlock
178
+ Append-FileText $LogPath "[MAILBOX PERMISSION VALIDATION] failed: $Message"
179
+ }
180
+ throw $Message
181
+ }
182
+
183
+ function Invoke-PhaseArtifactValidation([string[]] $TaskLines, [string] $RepoRootPath, [string] $ReportPath, [string] $LogPath, [string] $ValidatorPath) {
184
+ $phase = Get-TaskBulletValue $TaskLines 'Phase:'
185
+ if ($ReviewPhases -notcontains $phase) { return }
186
+
187
+ $artifactValue = Get-TaskBulletValue $TaskLines 'Primary Formal Artifact:'
188
+ if ([string]::IsNullOrWhiteSpace($artifactValue)) { return }
189
+ if (-not (Test-Path $ValidatorPath)) { return }
190
+
191
+ $artifactPath = Resolve-RepoPath $RepoRootPath $artifactValue
192
+ if (-not (Test-Path $artifactPath)) {
193
+ $skip = "[MAILBOX PHASE VALIDATION] skipped: primary formal artifact not found at $artifactPath"
194
+ Append-FileText $ReportPath $skip
195
+ if ($LogPath) { Append-FileText $LogPath $skip }
196
+ return
197
+ }
198
+
199
+ $validationOutput = (& python $ValidatorPath --phase $phase --artifact $artifactPath 2>&1 | Out-String).TrimEnd()
200
+ $validationBlock = "[MAILBOX PHASE VALIDATION]`n$validationOutput"
201
+ Append-FileText $ReportPath $validationBlock
202
+ if ($LogPath) { Append-FileText $LogPath $validationBlock }
203
+
204
+ if ($LASTEXITCODE -ne 0) {
205
+ throw "Mailbox phase artifact validation failed for $artifactPath"
206
+ }
207
+ }
208
+
209
+ if (-not (Test-Path $RepoRoot)) { throw "RepoRoot not found: $RepoRoot" }
210
+ if (-not (Test-Path $TaskFile)) { throw "TaskFile not found: $TaskFile" }
211
+
212
+ $taskLines = Get-Content $TaskFile -Encoding UTF8
213
+ $phase = Normalize-TaskValue (Get-TaskBulletValue $taskLines 'Phase:')
214
+ $declaredPermission = Normalize-TaskValue (Get-TaskBulletValue $taskLines 'Execution Permission:') $ReadOnlyPermissionMode
215
+ $approvalStatus = Normalize-TaskValue (Get-TaskBulletValue $taskLines 'Permission Approval Status:') $NotRequiredApprovalStatus
216
+ $approvedBy = Normalize-TaskValue (Get-TaskBulletValue $taskLines 'Approved By:') 'n/a'
217
+ $approvalReason = Normalize-TaskValue (Get-TaskBulletValue $taskLines 'Approval Reason:') 'n/a'
218
+ $approvedScope = Normalize-TaskValue (Get-TaskBulletValue $taskLines 'Approved Writable Scope:') 'n/a'
219
+ $approvalReference = Normalize-TaskValue (Get-TaskBulletValue $taskLines 'Approval Reference:') 'n/a'
220
+ $prompt = New-BoundedExecutionPrompt $taskLines
221
+ New-Item -ItemType Directory -Force -Path ([System.IO.Path]::GetDirectoryName($ReportFile)) | Out-Null
222
+ if ($LogFile) {
223
+ New-Item -ItemType Directory -Force -Path ([System.IO.Path]::GetDirectoryName($LogFile)) | Out-Null
224
+ }
225
+
226
+ $effectiveMode = $PermissionMode
227
+ $decisionSummary = ''
228
+ $approvalFieldsArePlaceholder = (Test-PlaceholderValue $approvedBy) -and (Test-PlaceholderValue $approvalReason) -and (Test-PlaceholderValue $approvedScope)
229
+ $isWritableClaudeMode = $WritableClaudeModes -contains $PermissionMode
230
+
231
+ if ($ReviewPhases -contains $phase) {
232
+ if ($declaredPermission -ne $ReadOnlyPermissionMode) {
233
+ $auditBlock = New-PermissionAuditBlock -DeclaredPermission $declaredPermission -EffectiveMode $PermissionMode -ApprovalStatus $approvalStatus -ApprovedBy $approvedBy -ApprovalReason $approvalReason -ApprovedScope $approvedScope -ApprovalReference $approvalReference -DecisionSummary 'review phase attempted writable permission and was rejected before launch'
234
+ Write-PermissionFailure -ReportPath $ReportFile -LogPath $LogFile -AuditBlock $auditBlock -Message "Review-phase mailbox runs must declare 'Execution Permission: read-only'."
235
+ }
236
+ if ($approvalStatus -ne $NotRequiredApprovalStatus -or -not $approvalFieldsArePlaceholder) {
237
+ $auditBlock = New-PermissionAuditBlock -DeclaredPermission $declaredPermission -EffectiveMode $PermissionMode -ApprovalStatus $approvalStatus -ApprovedBy $approvedBy -ApprovalReason $approvalReason -ApprovedScope $approvedScope -ApprovalReference $approvalReference -DecisionSummary 'review phase approval metadata was inconsistent for a read-only run'
238
+ Write-PermissionFailure -ReportPath $ReportFile -LogPath $LogFile -AuditBlock $auditBlock -Message "Read-only review phases must use 'Permission Approval Status: not-required' and leave writable approval fields as 'n/a'."
239
+ }
240
+ if ($isWritableClaudeMode) {
241
+ $auditBlock = New-PermissionAuditBlock -DeclaredPermission $declaredPermission -EffectiveMode $PermissionMode -ApprovalStatus $approvalStatus -ApprovedBy $approvedBy -ApprovalReason $approvalReason -ApprovedScope $approvedScope -ApprovalReference $approvalReference -DecisionSummary 'review phase requested writable Claude permission mode and was rejected before launch'
242
+ Write-PermissionFailure -ReportPath $ReportFile -LogPath $LogFile -AuditBlock $auditBlock -Message "Read-only mailbox tasks may not use writable Claude permission modes such as acceptEdits, auto, or bypassPermissions."
243
+ }
244
+ $decisionSummary = 'review phase allowed only non-writable Claude permission mode'
245
+ } elseif ($phase -eq 'implementation') {
246
+ if ($declaredPermission -eq $WritablePermissionMode) {
247
+ if ($approvalStatus -ne $HumanApprovedStatus) {
248
+ $auditBlock = New-PermissionAuditBlock -DeclaredPermission $declaredPermission -EffectiveMode $PermissionMode -ApprovalStatus $approvalStatus -ApprovedBy $approvedBy -ApprovalReason $approvalReason -ApprovedScope $approvedScope -ApprovalReference $approvalReference -DecisionSummary 'writable Claude implementation requested without human-approved status'
249
+ Write-PermissionFailure -ReportPath $ReportFile -LogPath $LogFile -AuditBlock $auditBlock -Message "Writable implementation runs require 'Permission Approval Status: human-approved'."
250
+ }
251
+ if ((Test-PlaceholderValue $approvedBy) -or (Test-PlaceholderValue $approvalReason) -or (Test-PlaceholderValue $approvedScope)) {
252
+ $auditBlock = New-PermissionAuditBlock -DeclaredPermission $declaredPermission -EffectiveMode $PermissionMode -ApprovalStatus $approvalStatus -ApprovedBy $approvedBy -ApprovalReason $approvalReason -ApprovedScope $approvedScope -ApprovalReference $approvalReference -DecisionSummary 'writable Claude implementation requested without complete approval metadata'
253
+ Write-PermissionFailure -ReportPath $ReportFile -LogPath $LogFile -AuditBlock $auditBlock -Message 'Writable implementation runs require Approved By, Approval Reason, and Approved Writable Scope.'
254
+ }
255
+ if (-not $isWritableClaudeMode) {
256
+ $auditBlock = New-PermissionAuditBlock -DeclaredPermission $declaredPermission -EffectiveMode $PermissionMode -ApprovalStatus $approvalStatus -ApprovedBy $approvedBy -ApprovalReason $approvalReason -ApprovedScope $approvedScope -ApprovalReference $approvalReference -DecisionSummary 'writable Claude implementation requested without explicit writable Claude permission mode'
257
+ Write-PermissionFailure -ReportPath $ReportFile -LogPath $LogFile -AuditBlock $auditBlock -Message 'Writable Claude implementation runs require an explicit writable permission mode such as acceptEdits, auto, or bypassPermissions.'
258
+ }
259
+ $decisionSummary = 'writable Claude implementation run approved and enabled from task-packet approval record'
260
+ } elseif ($declaredPermission -eq $ReadOnlyPermissionMode) {
261
+ if ($approvalStatus -ne $NotRequiredApprovalStatus -or -not $approvalFieldsArePlaceholder) {
262
+ $auditBlock = New-PermissionAuditBlock -DeclaredPermission $declaredPermission -EffectiveMode $PermissionMode -ApprovalStatus $approvalStatus -ApprovedBy $approvedBy -ApprovalReason $approvalReason -ApprovedScope $approvedScope -ApprovalReference $approvalReference -DecisionSummary 'read-only implementation run carried contradictory writable approval metadata'
263
+ Write-PermissionFailure -ReportPath $ReportFile -LogPath $LogFile -AuditBlock $auditBlock -Message "Read-only implementation runs must use 'Permission Approval Status: not-required' and leave writable approval fields as 'n/a'."
264
+ }
265
+ if ($isWritableClaudeMode) {
266
+ $auditBlock = New-PermissionAuditBlock -DeclaredPermission $declaredPermission -EffectiveMode $PermissionMode -ApprovalStatus $approvalStatus -ApprovedBy $approvedBy -ApprovalReason $approvalReason -ApprovedScope $approvedScope -ApprovalReference $approvalReference -DecisionSummary 'read-only implementation run requested writable Claude permission mode and was rejected before launch'
267
+ Write-PermissionFailure -ReportPath $ReportFile -LogPath $LogFile -AuditBlock $auditBlock -Message "Read-only mailbox tasks may not use writable Claude permission modes such as acceptEdits, auto, or bypassPermissions."
268
+ }
269
+ $decisionSummary = 'implementation run remained non-writable because no writable approval was declared'
270
+ } else {
271
+ $auditBlock = New-PermissionAuditBlock -DeclaredPermission $declaredPermission -EffectiveMode $PermissionMode -ApprovalStatus $approvalStatus -ApprovedBy $approvedBy -ApprovalReason $approvalReason -ApprovedScope $approvedScope -ApprovalReference $approvalReference -DecisionSummary 'unknown execution permission rejected before launch'
272
+ Write-PermissionFailure -ReportPath $ReportFile -LogPath $LogFile -AuditBlock $auditBlock -Message "Unknown execution permission mode '$declaredPermission'."
273
+ }
274
+ } else {
275
+ if ($declaredPermission -ne $ReadOnlyPermissionMode) {
276
+ $auditBlock = New-PermissionAuditBlock -DeclaredPermission $declaredPermission -EffectiveMode $PermissionMode -ApprovalStatus $approvalStatus -ApprovedBy $approvedBy -ApprovalReason $approvalReason -ApprovedScope $approvedScope -ApprovalReference $approvalReference -DecisionSummary 'non-implementation phase attempted writable permission and was rejected before launch'
277
+ Write-PermissionFailure -ReportPath $ReportFile -LogPath $LogFile -AuditBlock $auditBlock -Message 'Only implementation-phase mailbox runs may request writable execution.'
278
+ }
279
+ if ($approvalStatus -ne $NotRequiredApprovalStatus -or -not $approvalFieldsArePlaceholder) {
280
+ $auditBlock = New-PermissionAuditBlock -DeclaredPermission $declaredPermission -EffectiveMode $PermissionMode -ApprovalStatus $approvalStatus -ApprovedBy $approvedBy -ApprovalReason $approvalReason -ApprovedScope $approvedScope -ApprovalReference $approvalReference -DecisionSummary 'non-implementation phase approval metadata was inconsistent for a read-only run'
281
+ Write-PermissionFailure -ReportPath $ReportFile -LogPath $LogFile -AuditBlock $auditBlock -Message "Non-implementation read-only runs must use 'Permission Approval Status: not-required' and leave writable approval fields as 'n/a'."
282
+ }
283
+ if ($isWritableClaudeMode) {
284
+ $auditBlock = New-PermissionAuditBlock -DeclaredPermission $declaredPermission -EffectiveMode $PermissionMode -ApprovalStatus $approvalStatus -ApprovedBy $approvedBy -ApprovalReason $approvalReason -ApprovedScope $approvedScope -ApprovalReference $approvalReference -DecisionSummary 'non-implementation phase requested writable Claude permission mode and was rejected before launch'
285
+ Write-PermissionFailure -ReportPath $ReportFile -LogPath $LogFile -AuditBlock $auditBlock -Message "Read-only mailbox tasks may not use writable Claude permission modes such as acceptEdits, auto, or bypassPermissions."
286
+ }
287
+ $decisionSummary = 'non-implementation phase allowed only non-writable Claude permission mode'
288
+ }
289
+
290
+ $permissionAuditBlock = New-PermissionAuditBlock -DeclaredPermission $declaredPermission -EffectiveMode $PermissionMode -ApprovalStatus $approvalStatus -ApprovedBy $approvedBy -ApprovalReason $approvalReason -ApprovedScope $approvedScope -ApprovalReference $approvalReference -DecisionSummary $decisionSummary
291
+ $cliArgs = @('-p', '--output-format', 'text', '--no-session-persistence', '--add-dir', $RepoRoot, '--permission-mode', $PermissionMode, '--effort', $Effort)
292
+ if ($SessionName) { $cliArgs += @('--name', $SessionName) }
293
+ if ($Model) { $cliArgs += @('--model', $Model) }
294
+ $cliArgs += $prompt
295
+
296
+ if ($DryRun) {
297
+ [pscustomobject]@{
298
+ Cli = 'claude'
299
+ RepoRoot = $RepoRoot
300
+ TaskFile = $TaskFile
301
+ ReportFile = $ReportFile
302
+ LogFile = $LogFile
303
+ Args = $cliArgs
304
+ PromptLength = $prompt.Length
305
+ PromptPreview = if ($prompt.Length -gt 2000) { $prompt.Substring(0, 2000) } else { $prompt }
306
+ DeclaredExecutionPermission = $declaredPermission
307
+ EffectiveRuntimePermissionMode = $PermissionMode
308
+ PermissionApprovalStatus = $approvalStatus
309
+ ApprovedBy = $approvedBy
310
+ ApprovalReason = $approvalReason
311
+ ApprovedWritableScope = $approvedScope
312
+ ApprovalReference = $approvalReference
313
+ LauncherDecisionSummary = $decisionSummary
314
+ } | ConvertTo-Json -Depth 4
315
+ exit 0
316
+ }
317
+
318
+ $output = & claude @cliArgs 2>&1
319
+ $outputText = ($output | Out-String)
320
+ [System.IO.File]::WriteAllText($ReportFile, $outputText, $Utf8NoBom)
321
+ if ($LogFile) {
322
+ [System.IO.File]::WriteAllText($LogFile, $outputText, $Utf8NoBom)
323
+ }
324
+
325
+ Append-FileText $ReportFile $permissionAuditBlock
326
+ if ($LogFile) {
327
+ Append-FileText $LogFile $permissionAuditBlock
328
+ }
329
+
330
+ $validatorPath = Join-Path $PSScriptRoot 'validate-mailbox-formal-artifact.py'
331
+ Invoke-PhaseArtifactValidation -TaskLines $taskLines -RepoRootPath $RepoRoot -ReportPath $ReportFile -LogPath $LogFile -ValidatorPath $validatorPath
332
+ Write-Host "Claude report written to: $ReportFile"