sdtk-spec-kit 0.3.13 → 0.3.15

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 (61) hide show
  1. package/assets/manifest/toolkit-bundle.manifest.json +96 -156
  2. package/assets/manifest/toolkit-bundle.sha256.txt +45 -57
  3. package/assets/toolkit/toolkit/AGENTS.md +17 -15
  4. package/assets/toolkit/toolkit/README.md +3 -2
  5. package/assets/toolkit/toolkit/SDTK_TOOLKIT.md +11 -1
  6. package/assets/toolkit/toolkit/install.ps1 +60 -50
  7. package/assets/toolkit/toolkit/runtimes/claude/CLAUDE_TEMPLATE.md +2 -2
  8. package/assets/toolkit/toolkit/scripts/agents/run-claude-task.ps1 +110 -51
  9. package/assets/toolkit/toolkit/scripts/agents/run-codex-task.ps1 +76 -3
  10. package/assets/toolkit/toolkit/scripts/agents/validate-mailbox-formal-artifact.py +87 -0
  11. package/assets/toolkit/toolkit/scripts/generate-code-handoff.ps1 +9 -0
  12. package/assets/toolkit/toolkit/scripts/install-claude-skills.ps1 +179 -169
  13. package/assets/toolkit/toolkit/skills/sdtk-api-design-spec/SKILL.md +111 -84
  14. package/assets/toolkit/toolkit/skills/sdtk-api-doc/SKILL.md +46 -10
  15. package/assets/toolkit/toolkit/skills/sdtk-arch/SKILL.md +85 -85
  16. package/assets/toolkit/toolkit/skills/sdtk-ba/SKILL.md +7 -0
  17. package/assets/toolkit/toolkit/skills/sdtk-design-layout/SKILL.md +42 -3
  18. package/assets/toolkit/toolkit/skills/sdtk-dev/SKILL.md +1 -0
  19. package/assets/toolkit/toolkit/skills/sdtk-dev-backend/SKILL.md +61 -5
  20. package/assets/toolkit/toolkit/skills/sdtk-dev-frontend/SKILL.md +63 -5
  21. package/assets/toolkit/toolkit/skills/sdtk-mailbox-dispatch/SKILL.md +5 -4
  22. package/assets/toolkit/toolkit/skills/sdtk-pm/SKILL.md +22 -13
  23. package/assets/toolkit/toolkit/skills/sdtk-screen-design-spec/SKILL.md +53 -33
  24. package/assets/toolkit/toolkit/skills/sdtk-test-case-spec/SKILL.md +60 -24
  25. package/assets/toolkit/toolkit/skills/skills.catalog.yaml +9 -9
  26. package/assets/toolkit/toolkit/skills-claude/api-design-spec/SKILL.md +116 -90
  27. package/assets/toolkit/toolkit/skills-claude/api-doc/SKILL.md +49 -9
  28. package/assets/toolkit/toolkit/skills-claude/arch/SKILL.md +3 -3
  29. package/assets/toolkit/toolkit/skills-claude/ba/SKILL.md +9 -1
  30. package/assets/toolkit/toolkit/skills-claude/design-layout/SKILL.md +36 -2
  31. package/assets/toolkit/toolkit/skills-claude/dev/SKILL.md +1 -0
  32. package/assets/toolkit/toolkit/skills-claude/dev-backend/SKILL.md +58 -5
  33. package/assets/toolkit/toolkit/skills-claude/dev-frontend/SKILL.md +60 -5
  34. package/assets/toolkit/toolkit/skills-claude/mailbox-dispatch/SKILL.md +5 -4
  35. package/assets/toolkit/toolkit/skills-claude/pm/SKILL.md +9 -0
  36. package/assets/toolkit/toolkit/skills-claude/screen-design-spec/SKILL.md +49 -27
  37. package/assets/toolkit/toolkit/skills-claude/test-case-spec/SKILL.md +74 -20
  38. package/assets/toolkit/toolkit/templates/README.md +5 -1
  39. package/assets/toolkit/toolkit/templates/docs/api/API_DESIGN_CREATION_RULES.md +1 -2
  40. package/assets/toolkit/toolkit/templates/docs/api/API_DESIGN_FLOWCHART_CREATION_RULES.md +468 -468
  41. package/assets/toolkit/toolkit/templates/docs/api/FLOWCHART_CREATION_RULES.md +3 -3
  42. package/assets/toolkit/toolkit/templates/docs/api/YAML_CREATION_RULES.md +128 -128
  43. package/assets/toolkit/toolkit/templates/docs/product/CONDENSED_UPSTREAM_INPUT_TEMPLATE.md +140 -0
  44. package/assets/toolkit/toolkit/templates/handoffs/DEV_TO_SDTK_CODE.md +26 -0
  45. package/assets/toolkit/toolkit/templates/handoffs/PM_TO_BA.md +2 -2
  46. package/assets/toolkit/toolkit/templates/mailbox/AGENT_REPORT_TEMPLATE.md +12 -8
  47. package/assets/toolkit/toolkit/templates/mailbox/AGENT_TASK_TEMPLATE.md +8 -2
  48. package/package.json +48 -48
  49. package/assets/toolkit/toolkit/skills/sdtk-api-design-spec/references/API_DESIGN_CREATION_RULES.md +0 -22
  50. package/assets/toolkit/toolkit/skills/sdtk-api-design-spec/references/API_DESIGN_FLOWCHART_CREATION_RULES.md +0 -468
  51. package/assets/toolkit/toolkit/skills/sdtk-api-design-spec/references/FLOWCHART_CREATION_RULES.md +0 -20
  52. package/assets/toolkit/toolkit/skills/sdtk-api-doc/references/API_DESIGN_FLOWCHART_CREATION_RULES.md +0 -468
  53. package/assets/toolkit/toolkit/skills/sdtk-api-doc/references/FLOWCHART_CREATION_RULES.md +0 -20
  54. package/assets/toolkit/toolkit/skills/sdtk-api-doc/references/YAML_CREATION_RULES.md +0 -128
  55. package/assets/toolkit/toolkit/skills/sdtk-arch/references/API_DESIGN_CREATION_RULES.md +0 -22
  56. package/assets/toolkit/toolkit/skills/sdtk-arch/references/API_DESIGN_FLOWCHART_CREATION_RULES.md +0 -468
  57. package/assets/toolkit/toolkit/skills/sdtk-arch/references/FLOWCHART_CREATION_RULES.md +0 -20
  58. package/assets/toolkit/toolkit/skills/sdtk-arch/references/FLOW_ACTION_SPEC_CREATION_RULES.md +0 -220
  59. package/assets/toolkit/toolkit/skills/sdtk-arch/references/YAML_CREATION_RULES.md +0 -128
  60. package/assets/toolkit/toolkit/skills/sdtk-screen-design-spec/references/FLOW_ACTION_SPEC_CREATION_RULES.md +0 -220
  61. package/assets/toolkit/toolkit/skills/sdtk-test-case-spec/references/TEST_CASE_CREATION_RULES.md +0 -129
@@ -115,24 +115,26 @@ In addition to `ARCH_DESIGN`, ARCH may generate:
115
115
  - SDTK-CODE handoff generator: `toolkit/scripts/generate-code-handoff.ps1`
116
116
 
117
117
  ## 7) Mandatory Rule References
118
- Rule files are installed locally by the runtime. Skills resolve these at:
119
- - Claude Code: `.claude/skills/references/`
120
- - Codex: `$CODEX_HOME/skills/<skill>/references/`
118
+ Canonical source-of-truth for shared rule files now lives under `toolkit/templates/docs/**`.
119
+ Use those paths when editing or reviewing the source toolkit.
120
+
121
+ Shared canonical rule files:
122
+ - `toolkit/templates/docs/api/YAML_CREATION_RULES.md` -- API YAML docs
123
+ - `toolkit/templates/docs/api/API_DESIGN_FLOWCHART_CREATION_RULES.md` -- API design detail + flow docs
124
+ - `toolkit/templates/docs/api/FLOWCHART_CREATION_RULES.md` -- API flow compatibility note
125
+ - `toolkit/templates/docs/api/API_DESIGN_CREATION_RULES.md` -- API design compatibility note
126
+ - `toolkit/templates/docs/specs/FLOW_ACTION_SPEC_CREATION_RULES.md` -- Screen flow-action specs
127
+ - `toolkit/templates/docs/qa/TEST_CASE_CREATION_RULES.md` -- QA test-case specs
128
+
129
+ Retained skill-specific local references:
130
+ - `toolkit/skills/sdtk-screen-design-spec/references/numbering-rules.md` -- Flow-action numbering policy
131
+ - `toolkit/skills/sdtk-screen-design-spec/references/figma-mcp.md` -- Figma MCP integration
132
+ - `toolkit/skills/sdtk-screen-design-spec/references/excel-image-export.md` -- Excel image export
133
+
134
+ Runtime-installed mirrors may surface these rule files under skill-local runtime paths such as `.claude/skills/<skill>/references/` or `$CODEX_HOME/skills/<skill>/references/`. Do not treat those runtime copies as the maintainer source of truth.
121
135
 
122
136
  Workflow governance docs:
123
137
  - `governance/ai/core/SDTK_VERIFICATION_BEFORE_COMPLETION_POLICY.md` -- verification-before-completion gate
124
138
  - `governance/ai/core/SDTK_SKILL_AUTHORING_AND_TESTING.md` -- maintainer authoring/test guide
125
-
126
- Available rule files:
127
- - `YAML_CREATION_RULES.md` -- API YAML docs
128
- - `API_DESIGN_FLOWCHART_CREATION_RULES.md` -- API design detail + flow docs
129
- - `FLOWCHART_CREATION_RULES.md` -- Flowchart (legacy compat)
130
- - `API_DESIGN_CREATION_RULES.md` -- API design (legacy compat)
131
- - `FLOW_ACTION_SPEC_CREATION_RULES.md` -- Screen flow-action specs
132
- - `TEST_CASE_CREATION_RULES.md` -- QA test-case specs
133
- - `numbering-rules.md` -- Flow-action numbering policy
134
- - `figma-mcp.md` -- Figma MCP integration
135
- - `excel-image-export.md` -- Excel image export
136
-
137
139
  Flow-action numbering policy:
138
140
  - Use one global numbering mode for the whole document (no per-screen reset).
@@ -17,7 +17,7 @@ Use the root `README.md` for suite-level framing and `products/sdtk-code/toolkit
17
17
  SDTK-SPEC standardizes feature delivery with a multi-agent SDLC model.
18
18
  The current shipped technical interface remains `sdtk-spec-kit` / `sdtk-spec`.
19
19
  It supports runtime adapters (Codex and Claude Code) while keeping one shared core for templates, skills, and quality gates.
20
- `SDTK-OPS` is not documented here as a runnable product because it is still planned/partial only in the current suite.
20
+ `SDTK-OPS` is a real suite product surface, but the runnable product guidance for SDTK-OPS lives in its own product docs rather than this SDTK-SPEC source folder.
21
21
 
22
22
  ## Highlights
23
23
  - 6-phase SDLC flow: PM -> BA -> ARCH -> DEV planning/handoff -> QA release decision.
@@ -29,7 +29,8 @@ It supports runtime adapters (Codex and Claude Code) while keeping one shared co
29
29
  - Reusable handoff templates under `toolkit/templates/handoffs/` to reduce ambiguity between PM, BA, ARCH, DEV, SDTK-CODE, and QA.
30
30
  - `## Critical Constraints` encoded in every core `SKILL.md` so non-negotiable workflow rules are visible before execution.
31
31
  - Public onboarding examples under `examples/` for common delivery scenarios.
32
- - Runtime readiness audit via `toolkit/scripts/check-runtime-readiness.ps1`.
32
+ - Runtime readiness audit via `toolkit/scripts/check-runtime-readiness.ps1`.
33
+ - Repo source now contains two bounded proof families (`service/request tracker`, `approval/workflow`) expressed as golden samples plus executable acceptance fixtures.
33
34
 
34
35
  ## Quality Contracts
35
36
  DEV phase now ends at planning + readiness gating. The canonical outputs are `FEATURE_IMPL_PLAN` and `CODE_HANDOFF`. See `toolkit/skills/sdtk-dev/SKILL.md` for the exact handoff contract.
@@ -15,7 +15,13 @@ It provides:
15
15
  - specialized skills for each phase,
16
16
  - and explicit quality gates.
17
17
 
18
- This guide does not document `SDTK-OPS` as a runnable product because that surface is still planned/partial only.
18
+ This guide stays product-specific to SDTK-SPEC. `SDTK-OPS` is a real suite product surface, but its runnable product guidance lives in its own SDTK-OPS docs rather than this SDTK-SPEC guide.
19
+
20
+ ## 1.1 Current Source-Proof Status
21
+ The current repo source is ahead of the latest public `sdtk-spec-kit` package line. In addition to the shipped mailbox-dispatch skill, the source tree now contains two bounded proof families:
22
+ - `service/request tracker` golden samples + executable fixture and acceptance harness
23
+ - `approval/workflow` golden samples + executable fixture and acceptance harness
24
+ These proof surfaces strengthen the lean small-app factory claim in source control. Treat public package claims separately until the next SPEC release is published.
19
25
 
20
26
  ## 2. SDLC Model
21
27
  Default flow:
@@ -165,6 +171,10 @@ Phase outputs:
165
171
  - `toolkit/templates/docs/specs/FLOW_ACTION_SPEC_CREATION_RULES.md`
166
172
  - QA test-case rules:
167
173
  - `toolkit/templates/docs/qa/TEST_CASE_CREATION_RULES.md`
174
+ - Skill-specific local references intentionally retained:
175
+ - `toolkit/skills/sdtk-screen-design-spec/references/numbering-rules.md`
176
+ - `toolkit/skills/sdtk-screen-design-spec/references/figma-mcp.md`
177
+ - `toolkit/skills/sdtk-screen-design-spec/references/excel-image-export.md`
168
178
 
169
179
  ## 12. Examples
170
180
  Use `examples/` for onboarding-ready scenario packs:
@@ -58,6 +58,37 @@ function Copy-File {
58
58
  Copy-Item -LiteralPath $SourcePath -Destination $DestinationPath -Force
59
59
  }
60
60
 
61
+ function Get-ClaudeManagedReferenceSources {
62
+ param(
63
+ [Parameter(Mandatory = $true)][string]$SkillName
64
+ )
65
+
66
+ switch ($SkillName) {
67
+ 'api-doc' { return @(
68
+ 'templates/docs/api/YAML_CREATION_RULES.md',
69
+ 'templates/docs/api/API_DESIGN_FLOWCHART_CREATION_RULES.md'
70
+ ) }
71
+ 'api-design-spec' { return @(
72
+ 'templates/docs/api/API_DESIGN_FLOWCHART_CREATION_RULES.md'
73
+ ) }
74
+ 'arch' { return @(
75
+ 'templates/docs/api/YAML_CREATION_RULES.md',
76
+ 'templates/docs/api/API_DESIGN_FLOWCHART_CREATION_RULES.md',
77
+ 'templates/docs/specs/FLOW_ACTION_SPEC_CREATION_RULES.md'
78
+ ) }
79
+ 'screen-design-spec' { return @(
80
+ 'templates/docs/specs/FLOW_ACTION_SPEC_CREATION_RULES.md',
81
+ 'skills/sdtk-screen-design-spec/references/numbering-rules.md',
82
+ 'skills/sdtk-screen-design-spec/references/figma-mcp.md',
83
+ 'skills/sdtk-screen-design-spec/references/excel-image-export.md'
84
+ ) }
85
+ 'test-case-spec' { return @(
86
+ 'templates/docs/qa/TEST_CASE_CREATION_RULES.md'
87
+ ) }
88
+ default { return @() }
89
+ }
90
+ }
91
+
61
92
  function Install-ClaudeSkillDirectory {
62
93
  param(
63
94
  [Parameter(Mandatory = $true)][System.IO.DirectoryInfo]$SkillDir,
@@ -95,6 +126,21 @@ function Install-ClaudeSkillDirectory {
95
126
  Copy-Item -LiteralPath $srcSubDir -Destination $destSubDir -Recurse -Force
96
127
  }
97
128
 
129
+ $referenceSources = @(Get-ClaudeManagedReferenceSources -SkillName $SkillDir.Name)
130
+ if ($referenceSources.Count -gt 0) {
131
+ $destRefDir = Join-Path $destDir 'references'
132
+ if (Test-Path -LiteralPath $destRefDir) {
133
+ Remove-Item -LiteralPath $destRefDir -Recurse -Force
134
+ }
135
+ New-Item -ItemType Directory -Force -Path $destRefDir | Out-Null
136
+
137
+ foreach ($relativeSource in $referenceSources) {
138
+ $srcRefPath = Join-Path $ToolkitRoot $relativeSource
139
+ $destRefPath = Join-Path $destRefDir ([System.IO.Path]::GetFileName($relativeSource))
140
+ Copy-File -SourcePath $srcRefPath -DestinationPath $destRefPath -Overwrite $true
141
+ }
142
+ }
143
+
98
144
  return $true
99
145
  }
100
146
 
@@ -147,68 +193,32 @@ function Install-ClaudeSkills {
147
193
  }
148
194
  }
149
195
 
150
- # Install reference files
151
- $refDest = Join-Path $skillsDest 'references'
152
- if (-not (Test-Path -LiteralPath $refDest)) {
153
- New-Item -ItemType Directory -Force -Path $refDest | Out-Null
154
- }
155
-
156
- $refCount = 0
157
- $missingRefs = @()
158
-
159
- # 6 files from toolkit/templates/docs/
160
- $templateRefs = @(
161
- @{ Src = 'templates/docs/api/YAML_CREATION_RULES.md' },
162
- @{ Src = 'templates/docs/api/API_DESIGN_FLOWCHART_CREATION_RULES.md' },
163
- @{ Src = 'templates/docs/api/FLOWCHART_CREATION_RULES.md' },
164
- @{ Src = 'templates/docs/api/API_DESIGN_CREATION_RULES.md' },
165
- @{ Src = 'templates/docs/specs/FLOW_ACTION_SPEC_CREATION_RULES.md' },
166
- @{ Src = 'templates/docs/qa/TEST_CASE_CREATION_RULES.md' }
167
- )
168
-
169
- foreach ($ref in $templateRefs) {
170
- $srcPath = Join-Path $ToolkitRoot $ref.Src
171
- $fileName = Split-Path -Leaf $srcPath
172
- $destPath = Join-Path $refDest $fileName
173
- if (Test-Path -LiteralPath $srcPath) {
174
- Copy-File -SourcePath $srcPath -DestinationPath $destPath -Overwrite $Overwrite
175
- $refCount++
176
- } else {
177
- $missingRefs += $srcPath
178
- }
196
+ # Remove obsolete shared Claude specialist reference catch-all if it exists
197
+ $legacyRefDest = Join-Path $skillsDest 'references'
198
+ if (Test-Path -LiteralPath $legacyRefDest) {
199
+ Remove-Item -LiteralPath $legacyRefDest -Recurse -Force
179
200
  }
180
201
 
181
- # 3 files from toolkit/skills/sdtk-screen-design-spec/references/
182
- $screenRefs = @('numbering-rules.md', 'figma-mcp.md', 'excel-image-export.md')
183
- foreach ($fileName in $screenRefs) {
184
- $srcPath = Join-Path $ToolkitRoot "skills/sdtk-screen-design-spec/references/$fileName"
185
- $destPath = Join-Path $refDest $fileName
186
- if (Test-Path -LiteralPath $srcPath) {
187
- Copy-File -SourcePath $srcPath -DestinationPath $destPath -Overwrite $Overwrite
188
- $refCount++
189
- } else {
190
- $missingRefs += $srcPath
202
+ $managedRefCount = 0
203
+ foreach ($skillName in @('arch', 'api-doc', 'api-design-spec', 'screen-design-spec', 'test-case-spec')) {
204
+ $refDir = Join-Path $skillsDest "$skillName/references"
205
+ if (Test-Path -LiteralPath $refDir) {
206
+ $managedRefCount += @(Get-ChildItem -LiteralPath $refDir -File).Count
191
207
  }
192
208
  }
193
209
 
194
- # Fail-fast: abort if any reference files are missing
195
- if ($missingRefs.Count -gt 0) {
196
- $list = ($missingRefs | ForEach-Object { " - $_" }) -join "`n"
197
- throw "Claude install failed. Missing reference files:`n$list"
198
- }
199
-
200
210
  # Strict count assertions
201
- $expectedSkills = 13
202
- $expectedRefs = 9
211
+ $expectedSkills = 14
212
+ $expectedManagedRefs = 11
203
213
  if ($skillCount -ne $expectedSkills) {
204
214
  throw "Claude install failed. Expected $expectedSkills skills but installed $skillCount."
205
215
  }
206
- if ($refCount -ne $expectedRefs) {
207
- throw "Claude install failed. Expected $expectedRefs reference files but installed $refCount."
216
+ if ($managedRefCount -ne $expectedManagedRefs) {
217
+ throw "Claude install failed. Expected $expectedManagedRefs specialist reference files but installed $managedRefCount."
208
218
  }
209
219
 
210
220
  Write-Host " Skills installed: $skillCount"
211
- Write-Host " Reference files : $refCount"
221
+ Write-Host " Specialist refs : $managedRefCount"
212
222
  }
213
223
 
214
224
  function Test-IsMaintainerRoot {
@@ -47,8 +47,8 @@ Skills are installed at `.claude/skills/` and provide slash commands:
47
47
  | `/dev-backend` | Backend code conventions |
48
48
  | `/dev-frontend` | Frontend code conventions |
49
49
 
50
- Rule reference files are installed at `.claude/skills/references/`.
50
+ Specialist rule reference files are installed inside each skill directory when that skill needs them (for example `.claude/skills/api-doc/references/`).
51
51
 
52
52
  ## 5) References
53
53
  - `sdtk-spec.config.json`
54
- - `.claude/skills/references/` (rule files)
54
+ - `.claude/skills/<skill>/references/` (skill-local rule files when required)
@@ -1,52 +1,111 @@
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
-
15
- if (-not (Test-Path $RepoRoot)) { throw "RepoRoot not found: $RepoRoot" }
16
- if (-not (Test-Path $TaskFile)) { throw "TaskFile not found: $TaskFile" }
17
-
18
- $prompt = [string](Get-Content $TaskFile -Raw -Encoding UTF8)
19
- New-Item -ItemType Directory -Force -Path ([System.IO.Path]::GetDirectoryName($ReportFile)) | Out-Null
20
- if ($LogFile) {
21
- New-Item -ItemType Directory -Force -Path ([System.IO.Path]::GetDirectoryName($LogFile)) | Out-Null
22
- }
23
-
24
- $cliArgs = @('-p', '--output-format', 'text', '--no-session-persistence', '--add-dir', $RepoRoot, '--permission-mode', $PermissionMode, '--effort', $Effort)
25
- if ($SessionName) { $cliArgs += @('--name', $SessionName) }
26
- if ($Model) { $cliArgs += @('--model', $Model) }
27
- $cliArgs += $prompt
28
-
29
- if ($DryRun) {
30
- $safeArgs = @('-p', '--output-format', 'text', '--no-session-persistence', '--add-dir', $RepoRoot, '--permission-mode', $PermissionMode, '--effort', $Effort)
31
- if ($SessionName) { $safeArgs += @('--name', $SessionName) }
32
- if ($Model) { $safeArgs += @('--model', $Model) }
33
- [pscustomobject]@{
34
- Cli = 'claude'
35
- RepoRoot = $RepoRoot
36
- TaskFile = $TaskFile
37
- ReportFile = $ReportFile
38
- LogFile = $LogFile
39
- Args = $safeArgs
40
- PromptLength = $prompt.Length
41
- PromptPreview = if ($prompt.Length -gt 240) { $prompt.Substring(0, 240) } else { $prompt }
42
- } | ConvertTo-Json -Depth 4
43
- exit 0
44
- }
45
-
46
- $output = & claude @cliArgs 2>&1
47
- $outputText = ($output | Out-String)
48
- [System.IO.File]::WriteAllText($ReportFile, $outputText, [System.Text.UTF8Encoding]::new($false))
49
- if ($LogFile) {
50
- [System.IO.File]::WriteAllText($LogFile, $outputText, [System.Text.UTF8Encoding]::new($false))
51
- }
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
52
111
  Write-Host "Claude report written to: $ReportFile"
@@ -9,18 +9,88 @@ param(
9
9
  )
10
10
 
11
11
  $ErrorActionPreference = 'Stop'
12
+ $Utf8NoBom = [System.Text.UTF8Encoding]::new($false)
13
+ $ReviewPhases = @('controller-dev-review', 'qa-review', 'controller-acceptance')
14
+ $WritablePermissionMode = 'workspace-write-approved'
15
+
16
+ function Get-TaskBulletValue([string[]] $Lines, [string] $Heading) {
17
+ for ($i = 0; $i -lt $Lines.Length; $i++) {
18
+ if ($Lines[$i].Trim() -eq $Heading) {
19
+ for ($j = $i + 1; $j -lt $Lines.Length; $j++) {
20
+ $candidate = $Lines[$j].Trim()
21
+ if (-not $candidate) { continue }
22
+ if ($candidate.StartsWith('- ')) {
23
+ return $candidate.Substring(2).Trim()
24
+ }
25
+ break
26
+ }
27
+ }
28
+ }
29
+ return ''
30
+ }
31
+
32
+ function Resolve-RepoPath([string] $RepoRootPath, [string] $CandidatePath) {
33
+ if ([string]::IsNullOrWhiteSpace($CandidatePath)) { return '' }
34
+ if ([System.IO.Path]::IsPathRooted($CandidatePath)) { return $CandidatePath }
35
+ return Join-Path $RepoRootPath $CandidatePath
36
+ }
37
+
38
+ function Append-FileText([string] $Path, [string] $Text) {
39
+ if ([string]::IsNullOrWhiteSpace($Text)) { return }
40
+ [System.IO.File]::AppendAllText($Path, [Environment]::NewLine + $Text, $Utf8NoBom)
41
+ }
42
+
43
+ function Invoke-PhaseArtifactValidation([string[]] $TaskLines, [string] $RepoRootPath, [string] $ReportPath, [string] $LogPath, [string] $ValidatorPath) {
44
+ $phase = Get-TaskBulletValue $TaskLines 'Phase:'
45
+ if ($ReviewPhases -notcontains $phase) { return }
46
+
47
+ $artifactValue = Get-TaskBulletValue $TaskLines 'Primary Formal Artifact:'
48
+ if ([string]::IsNullOrWhiteSpace($artifactValue)) { return }
49
+ if (-not (Test-Path $ValidatorPath)) { return }
50
+
51
+ $artifactPath = Resolve-RepoPath $RepoRootPath $artifactValue
52
+ if (-not (Test-Path $artifactPath)) {
53
+ $skip = "[MAILBOX PHASE VALIDATION] skipped: primary formal artifact not found at $artifactPath"
54
+ Append-FileText $ReportPath $skip
55
+ if ($LogPath) { Append-FileText $LogPath $skip }
56
+ return
57
+ }
58
+
59
+ $validationOutput = (& python $ValidatorPath --phase $phase --artifact $artifactPath 2>&1 | Out-String).TrimEnd()
60
+ $validationBlock = "[MAILBOX PHASE VALIDATION]`n$validationOutput"
61
+ Append-FileText $ReportPath $validationBlock
62
+ if ($LogPath) { Append-FileText $LogPath $validationBlock }
63
+
64
+ if ($LASTEXITCODE -ne 0) {
65
+ throw "Mailbox phase artifact validation failed for $artifactPath"
66
+ }
67
+ }
12
68
 
13
69
  if (-not (Test-Path $RepoRoot)) { throw "RepoRoot not found: $RepoRoot" }
14
70
  if (-not (Test-Path $TaskFile)) { throw "TaskFile not found: $TaskFile" }
15
71
 
16
- $prompt = [string](Get-Content $TaskFile -Raw -Encoding UTF8)
72
+ $taskLines = Get-Content $TaskFile -Encoding UTF8
73
+ $phase = Get-TaskBulletValue $taskLines 'Phase:'
74
+ $permissionMode = Get-TaskBulletValue $taskLines 'Execution Permission:'
75
+ $prompt = [string]($taskLines | Out-String)
17
76
  New-Item -ItemType Directory -Force -Path ([System.IO.Path]::GetDirectoryName($ReportFile)) | Out-Null
18
77
  if ($LogFile) {
19
78
  New-Item -ItemType Directory -Force -Path ([System.IO.Path]::GetDirectoryName($LogFile)) | Out-Null
20
79
  }
21
80
 
22
81
  $cliArgs = @('exec', '-c', 'mcp_servers={}', '-c', 'model_reasoning_effort="medium"', '-C', $RepoRoot, '--output-last-message', $ReportFile)
23
- if ($FullAuto) { $cliArgs += '--full-auto' }
82
+ $useWorkspaceWrite = $false
83
+ if ($FullAuto) {
84
+ $useWorkspaceWrite = $true
85
+ } elseif ($phase -eq 'implementation' -and $permissionMode -eq $WritablePermissionMode) {
86
+ $useWorkspaceWrite = $true
87
+ }
88
+
89
+ if ($useWorkspaceWrite) {
90
+ $cliArgs += '--full-auto'
91
+ } else {
92
+ $cliArgs += @('--sandbox', 'read-only')
93
+ }
24
94
  if ($Model) { $cliArgs += @('--model', $Model) }
25
95
  $cliArgs += '-'
26
96
 
@@ -41,4 +111,7 @@ if ($LogFile) {
41
111
  } else {
42
112
  $null = ($prompt | & codex @cliArgs 2>&1)
43
113
  }
44
- Write-Host "Codex report written to: $ReportFile"
114
+
115
+ $validatorPath = Join-Path $PSScriptRoot 'validate-mailbox-formal-artifact.py'
116
+ Invoke-PhaseArtifactValidation -TaskLines $taskLines -RepoRootPath $RepoRoot -ReportPath $ReportFile -LogPath $LogFile -ValidatorPath $validatorPath
117
+ Write-Host "Codex report written to: $ReportFile"
@@ -0,0 +1,87 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import re
5
+ import sys
6
+ from pathlib import Path
7
+
8
+ PHASE_RULES = {
9
+ 'controller-dev-review': {
10
+ 'filename': re.compile(r'^SDTK_BK\d{3}_CONTROLLER_DEV_REVIEW_R\d+_\d{8}\.md$'),
11
+ 'verdicts': {
12
+ 'APPROVED FOR QA HANDOFF',
13
+ 'CHANGES REQUIRED BEFORE QA',
14
+ },
15
+ },
16
+ 'qa-review': {
17
+ 'filename': re.compile(r'^SDTK_BK\d{3}_QA_CHECKPOINT_REPORT_R\d+_\d{8}\.md$'),
18
+ 'verdicts': {
19
+ 'APPROVED FOR CONTROLLER ACCEPTANCE',
20
+ 'CHANGES REQUIRED BEFORE CONTROLLER ACCEPTANCE',
21
+ },
22
+ },
23
+ 'controller-acceptance': {
24
+ 'filename': re.compile(r'^SDTK_BK\d{3}_CONTROLLER_ACCEPTANCE_R\d+_\d{8}\.md$'),
25
+ 'verdicts': {
26
+ 'APPROVED FOR COMMIT-READY STATE',
27
+ 'NOT APPROVED FOR COMMIT-READY STATE',
28
+ },
29
+ },
30
+ }
31
+
32
+ FORBIDDEN_TOKENS = (
33
+ 'QA_REVIEW',
34
+ 'APPROVED FOR CLOSE',
35
+ )
36
+ PHASE_RE = re.compile(r'(?mi)^(?:\*\*Phase:\*\*|Phase:)\s*`?([a-z\-]+)`?\s*$')
37
+
38
+
39
+ def main() -> int:
40
+ parser = argparse.ArgumentParser(description='Validate canonical mailbox review artifact naming and verdict vocabulary.')
41
+ parser.add_argument('--phase', required=True, choices=sorted(PHASE_RULES.keys()))
42
+ parser.add_argument('--artifact', required=True, type=Path)
43
+ args = parser.parse_args()
44
+
45
+ artifact = args.artifact.resolve()
46
+ if not artifact.exists():
47
+ print(f'[FAIL] mailbox-artifact-check missing artifact: {artifact}')
48
+ return 1
49
+
50
+ rule = PHASE_RULES[args.phase]
51
+ failures: list[str] = []
52
+ if not rule['filename'].match(artifact.name):
53
+ failures.append(
54
+ f'Artifact name {artifact.name} does not match canonical filename family for phase {args.phase}.'
55
+ )
56
+
57
+ text = artifact.read_text(encoding='utf-8', errors='replace')
58
+
59
+ phase_match = PHASE_RE.search(text)
60
+ if not phase_match:
61
+ failures.append('Artifact does not declare a Phase line.')
62
+ elif phase_match.group(1).strip() != args.phase:
63
+ failures.append(
64
+ f'Artifact phase {phase_match.group(1).strip()} does not match expected phase {args.phase}.'
65
+ )
66
+
67
+ if not any(verdict in text for verdict in rule['verdicts']):
68
+ failures.append(
69
+ 'Artifact does not contain a canonical verdict phrase for the selected phase.'
70
+ )
71
+
72
+ forbidden_hits = [token for token in FORBIDDEN_TOKENS if token in text or token in artifact.name]
73
+ if forbidden_hits:
74
+ failures.append('Artifact contains forbidden legacy tokens: ' + ', '.join(forbidden_hits))
75
+
76
+ if failures:
77
+ print('[FAIL] mailbox-artifact-check failed:')
78
+ for failure in failures:
79
+ print(f'- {failure}')
80
+ return 1
81
+
82
+ print(f'[OK] mailbox-artifact-check passed for {artifact.name} ({args.phase})')
83
+ return 0
84
+
85
+
86
+ if __name__ == '__main__':
87
+ sys.exit(main())
@@ -132,6 +132,15 @@ function Assert-RequiredRefCoverage {
132
132
  throw "Implementation slices reference flow scope, so required_refs must include docs/specs/[FEATURE_KEY]_FLOW_ACTION_SPEC.md."
133
133
  }
134
134
  }
135
+
136
+ if ($sliceText -match '\b(workflow|state|transition|approval|policy|actor|permission|role)\b') {
137
+ if (-not ($RequiredRefs | Where-Object { $_ -like 'docs/specs/*_FLOW_ACTION_SPEC.md' })) {
138
+ throw "Implementation slices reference workflow or state-transition scope, so required_refs must include docs/specs/[FEATURE_KEY]_FLOW_ACTION_SPEC.md."
139
+ }
140
+ if (-not ($RequiredRefs | Where-Object { $_ -like 'docs/database/*' })) {
141
+ throw "Implementation slices reference workflow or state-transition scope, so required_refs must include at least one docs/database/* source."
142
+ }
143
+ }
135
144
  }
136
145
 
137
146
  function Get-ImpactMap {