guardian-framework 0.1.0

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 (216) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +463 -0
  3. package/dist/cli.js +12958 -0
  4. package/dist/exports.js +12765 -0
  5. package/package.json +61 -0
  6. package/templates/languages/go-patterns.md +411 -0
  7. package/templates/languages/java-patterns.md +545 -0
  8. package/templates/languages/python-patterns.md +312 -0
  9. package/templates/languages/rust-patterns.md +232 -0
  10. package/templates/languages/typescript-patterns.md +313 -0
  11. package/templates/pi/INDEX.md +437 -0
  12. package/templates/pi/agent/AGENTS.md +166 -0
  13. package/templates/pi/agents/architecture-coordinator.md +40 -0
  14. package/templates/pi/agents/architecture-validator.md +36 -0
  15. package/templates/pi/agents/bootstrap-implementer.md +37 -0
  16. package/templates/pi/agents/issue-factory.md +31 -0
  17. package/templates/pi/agents/operations-validator.md +32 -0
  18. package/templates/pi/agents/security-validator.md +33 -0
  19. package/templates/pi/architecture/CHANGELOG.md +78 -0
  20. package/templates/pi/architecture/decisions/ADR-template.md +76 -0
  21. package/templates/pi/architecture/diagrams/system-overview.md +159 -0
  22. package/templates/pi/architecture/modules/module-template.md +152 -0
  23. package/templates/pi/context/checklists.md +91 -0
  24. package/templates/pi/context/domain-workflow.md +180 -0
  25. package/templates/pi/context/output-formats.md +135 -0
  26. package/templates/pi/context/patterns-base.md +47 -0
  27. package/templates/pi/context/patterns.md +38 -0
  28. package/templates/pi/context/project.md +88 -0
  29. package/templates/pi/domain/exploration.md +93 -0
  30. package/templates/pi/domain/ubiquitous-language.md +24 -0
  31. package/templates/pi/extensions/architect-lib/generators.ts +528 -0
  32. package/templates/pi/extensions/architect-lib/helpers.ts +344 -0
  33. package/templates/pi/extensions/architect-lib/types.ts +117 -0
  34. package/templates/pi/extensions/architect.ts +1425 -0
  35. package/templates/pi/extensions/ask-user-question.ts +579 -0
  36. package/templates/pi/extensions/bash-guard.ts +556 -0
  37. package/templates/pi/extensions/config-reload.ts +115 -0
  38. package/templates/pi/extensions/coordinator.ts +304 -0
  39. package/templates/pi/extensions/curator.ts +543 -0
  40. package/templates/pi/extensions/domain-explorer.ts +990 -0
  41. package/templates/pi/extensions/filechanges.ts +656 -0
  42. package/templates/pi/extensions/goal-loop.ts +717 -0
  43. package/templates/pi/extensions/hooks.ts +452 -0
  44. package/templates/pi/extensions/kanban.ts +547 -0
  45. package/templates/pi/extensions/pipeline.ts +1246 -0
  46. package/templates/pi/extensions/plan-mode.ts +209 -0
  47. package/templates/pi/extensions/project-scaffolder.ts +284 -0
  48. package/templates/pi/extensions/read-only-mode.ts +192 -0
  49. package/templates/pi/extensions/redaction.ts +128 -0
  50. package/templates/pi/extensions/session-persistence.ts +174 -0
  51. package/templates/pi/extensions/slash-commands.ts +229 -0
  52. package/templates/pi/extensions/snippets.ts +201 -0
  53. package/templates/pi/extensions/validation-runner.ts +100 -0
  54. package/templates/pi/github/agents/architecture-coordinator.agent.md +27 -0
  55. package/templates/pi/github/agents/architecture-validator.agent.md +20 -0
  56. package/templates/pi/github/agents/bootstrap-implementer.agent.md +20 -0
  57. package/templates/pi/github/agents/epic-planner.agent.md +70 -0
  58. package/templates/pi/github/agents/issue-factory.agent.md +20 -0
  59. package/templates/pi/github/agents/operations-validator.agent.md +20 -0
  60. package/templates/pi/github/agents/security-validator.agent.md +20 -0
  61. package/templates/pi/github/copilot/settings.json +16 -0
  62. package/templates/pi/github/copilot-instructions.md +155 -0
  63. package/templates/pi/github/instructions/architecture.instructions.md +71 -0
  64. package/templates/pi/github/instructions/validation.instructions.md +69 -0
  65. package/templates/pi/github/workflows/01-planning-workflow.md +75 -0
  66. package/templates/pi/github/workflows/02-issue-generation-workflow.md +69 -0
  67. package/templates/pi/github/workflows/03-implementation-workflow.md +80 -0
  68. package/templates/pi/github/workflows/04-validation-workflow.md +68 -0
  69. package/templates/pi/preflight_report.json +99 -0
  70. package/templates/pi/prompts/blueprint-update.md +262 -0
  71. package/templates/pi/prompts/blueprint-validate.md +218 -0
  72. package/templates/pi/prompts/bug-fix.md +50 -0
  73. package/templates/pi/prompts/ci-blueprint.md +131 -0
  74. package/templates/pi/prompts/context-refresh.md +258 -0
  75. package/templates/pi/prompts/epic-plan.md +356 -0
  76. package/templates/pi/prompts/epic-template.md +186 -0
  77. package/templates/pi/prompts/feature-development.md +131 -0
  78. package/templates/pi/prompts/git-issues.md +243 -0
  79. package/templates/pi/prompts/hotfix.md +71 -0
  80. package/templates/pi/prompts/issue-closeout.md +342 -0
  81. package/templates/pi/prompts/issue-draft.md +218 -0
  82. package/templates/pi/prompts/issue-implementation-series.md +173 -0
  83. package/templates/pi/prompts/issue-merge.md +372 -0
  84. package/templates/pi/prompts/issue-template-set.md +392 -0
  85. package/templates/pi/prompts/issue-template.md +207 -0
  86. package/templates/pi/prompts/pattern-extract.md +269 -0
  87. package/templates/pi/prompts/plan-to-issues.md +430 -0
  88. package/templates/pi/prompts/refactoring.md +82 -0
  89. package/templates/pi/prompts/scope-analyzer.md +254 -0
  90. package/templates/pi/prompts/sync-check.md +230 -0
  91. package/templates/pi/scripts/categorize-issues.sh +171 -0
  92. package/templates/pi/scripts/ci/check_architecture_conformance.sh +748 -0
  93. package/templates/pi/scripts/ci/check_planning_packet.py +228 -0
  94. package/templates/pi/scripts/ci/run_hardening_stages.sh +264 -0
  95. package/templates/pi/scripts/ci/run_preflight.sh +649 -0
  96. package/templates/pi/scripts/ci/run_stage.sh +193 -0
  97. package/templates/pi/scripts/ci/stage_docs_policy.sh +82 -0
  98. package/templates/pi/scripts/ci/stage_integration.sh +3 -0
  99. package/templates/pi/scripts/ci/stage_lint.sh +130 -0
  100. package/templates/pi/scripts/ci/stage_migration_verify.sh +3 -0
  101. package/templates/pi/scripts/ci/stage_package_build.sh +3 -0
  102. package/templates/pi/scripts/ci/stage_release_readiness.sh +3 -0
  103. package/templates/pi/scripts/ci/stage_remaining.sh +242 -0
  104. package/templates/pi/scripts/ci/stage_security.sh +3 -0
  105. package/templates/pi/scripts/ci/stage_static_analysis.sh +114 -0
  106. package/templates/pi/scripts/ci/stage_unit.sh +119 -0
  107. package/templates/pi/scripts/ci/validate_agent_output.py +181 -0
  108. package/templates/pi/scripts/ci/validate_agent_output.sh +243 -0
  109. package/templates/pi/scripts/create-feature-branch.sh +136 -0
  110. package/templates/pi/scripts/create-mr.sh +117 -0
  111. package/templates/pi/scripts/fetch-issues.sh +131 -0
  112. package/templates/pi/scripts/generate-architecture.sh +161 -0
  113. package/templates/pi/scripts/git/close-epic.sh +69 -0
  114. package/templates/pi/scripts/git/close-issue.sh +35 -0
  115. package/templates/pi/scripts/git/create-tracking-issue.sh +174 -0
  116. package/templates/pi/scripts/git/link-issue-to-epic.sh +51 -0
  117. package/templates/pi/scripts/git/update-tracking-issue.sh +66 -0
  118. package/templates/pi/scripts/languages/go/validate-architecture.sh +139 -0
  119. package/templates/pi/scripts/languages/go/validate-canonical.sh +129 -0
  120. package/templates/pi/scripts/languages/go/validate-ci.sh +132 -0
  121. package/templates/pi/scripts/languages/go/validate-integration.sh +156 -0
  122. package/templates/pi/scripts/languages/go/validate-operations.sh +146 -0
  123. package/templates/pi/scripts/languages/go/validate-security.sh +135 -0
  124. package/templates/pi/scripts/languages/go/validate-tests.sh +125 -0
  125. package/templates/pi/scripts/languages/java/validate-annotations.sh +185 -0
  126. package/templates/pi/scripts/languages/java/validate-architecture.sh +159 -0
  127. package/templates/pi/scripts/languages/java/validate-canonical.sh +114 -0
  128. package/templates/pi/scripts/languages/java/validate-ci.sh +269 -0
  129. package/templates/pi/scripts/languages/java/validate-integration.sh +149 -0
  130. package/templates/pi/scripts/languages/java/validate-operations.sh +142 -0
  131. package/templates/pi/scripts/languages/java/validate-security.sh +174 -0
  132. package/templates/pi/scripts/languages/java/validate-spring-architecture.sh +227 -0
  133. package/templates/pi/scripts/languages/java/validate-tests.sh +159 -0
  134. package/templates/pi/scripts/languages/python/validate-architecture.sh +99 -0
  135. package/templates/pi/scripts/languages/python/validate-canonical.sh +124 -0
  136. package/templates/pi/scripts/languages/python/validate-ci.sh +130 -0
  137. package/templates/pi/scripts/languages/python/validate-integration.sh +119 -0
  138. package/templates/pi/scripts/languages/python/validate-operations.sh +107 -0
  139. package/templates/pi/scripts/languages/python/validate-security.sh +68 -0
  140. package/templates/pi/scripts/languages/python/validate-tests.sh +102 -0
  141. package/templates/pi/scripts/languages/rust/validate-architecture.sh +188 -0
  142. package/templates/pi/scripts/languages/rust/validate-canonical.sh +146 -0
  143. package/templates/pi/scripts/languages/rust/validate-ci.sh +147 -0
  144. package/templates/pi/scripts/languages/rust/validate-integration.sh +149 -0
  145. package/templates/pi/scripts/languages/rust/validate-operations.sh +154 -0
  146. package/templates/pi/scripts/languages/rust/validate-security.sh +153 -0
  147. package/templates/pi/scripts/languages/rust/validate-tests.sh +150 -0
  148. package/templates/pi/scripts/languages/typescript/validate-architecture.sh +157 -0
  149. package/templates/pi/scripts/languages/typescript/validate-canonical.sh +135 -0
  150. package/templates/pi/scripts/languages/typescript/validate-ci.sh +244 -0
  151. package/templates/pi/scripts/languages/typescript/validate-integration.sh +166 -0
  152. package/templates/pi/scripts/languages/typescript/validate-operations.sh +162 -0
  153. package/templates/pi/scripts/languages/typescript/validate-security.sh +169 -0
  154. package/templates/pi/scripts/languages/typescript/validate-tests.sh +158 -0
  155. package/templates/pi/scripts/merge-mr.sh +95 -0
  156. package/templates/pi/scripts/mr-validation.sh +228 -0
  157. package/templates/pi/scripts/validate-architecture-readiness.sh +153 -0
  158. package/templates/pi/scripts/validate-architecture.sh +22 -0
  159. package/templates/pi/scripts/validate-canonical.sh +22 -0
  160. package/templates/pi/scripts/validate-ci.sh +37 -0
  161. package/templates/pi/scripts/validate-integration.sh +22 -0
  162. package/templates/pi/scripts/validate-operations.sh +22 -0
  163. package/templates/pi/scripts/validate-security.sh +22 -0
  164. package/templates/pi/scripts/validate-tests.sh +22 -0
  165. package/templates/pi/scripts/validate-ubiquitous-language.sh +291 -0
  166. package/templates/pi/scripts/validation-cache.sh +139 -0
  167. package/templates/pi/skills/agents/architecture-coordinator.md +178 -0
  168. package/templates/pi/skills/agents/architecture-generator.md +79 -0
  169. package/templates/pi/skills/agents/architecture-validator.md +74 -0
  170. package/templates/pi/skills/agents/ci-mr-validator.md +46 -0
  171. package/templates/pi/skills/agents/code-developer.md +76 -0
  172. package/templates/pi/skills/agents/commit.md +46 -0
  173. package/templates/pi/skills/agents/curator.md +71 -0
  174. package/templates/pi/skills/agents/debug.md +59 -0
  175. package/templates/pi/skills/agents/documentation-maintainer.md +36 -0
  176. package/templates/pi/skills/agents/goal-loop.md +125 -0
  177. package/templates/pi/skills/agents/hooks.md +122 -0
  178. package/templates/pi/skills/agents/integration-validator.md +35 -0
  179. package/templates/pi/skills/agents/issue-creator.md +75 -0
  180. package/templates/pi/skills/agents/issue-factory.md +143 -0
  181. package/templates/pi/skills/agents/kanban.md +85 -0
  182. package/templates/pi/skills/agents/land.md +59 -0
  183. package/templates/pi/skills/agents/operations-validator.md +43 -0
  184. package/templates/pi/skills/agents/pipeline.md +113 -0
  185. package/templates/pi/skills/agents/plan-mode.md +77 -0
  186. package/templates/pi/skills/agents/pull.md +40 -0
  187. package/templates/pi/skills/agents/push.md +41 -0
  188. package/templates/pi/skills/agents/security-validator.md +85 -0
  189. package/templates/pi/skills/agents/session-persistence.md +119 -0
  190. package/templates/pi/skills/agents/slash-commands.md +117 -0
  191. package/templates/pi/skills/agents/snippets.md +99 -0
  192. package/templates/pi/skills/agents/subagent-registry.md +78 -0
  193. package/templates/pi/skills/agents/test-validator.md +42 -0
  194. package/templates/pi/skills/validators/architecture-validator.md +43 -0
  195. package/templates/pi/skills/validators/ci-validator.md +27 -0
  196. package/templates/pi/skills/validators/context-compaction.md +73 -0
  197. package/templates/pi/skills/validators/integration-validator.md +38 -0
  198. package/templates/pi/skills/validators/model-registry.md +96 -0
  199. package/templates/pi/skills/validators/operations-validator.md +34 -0
  200. package/templates/pi/skills/validators/security-guards.md +72 -0
  201. package/templates/pi/skills/validators/security-validator.md +41 -0
  202. package/templates/pi/skills/validators/system-prompt-tiers.md +69 -0
  203. package/templates/pi/skills/validators/test-validator.md +33 -0
  204. package/templates/pi/types.ts +62 -0
  205. package/templates/pi/validators/README.md +93 -0
  206. package/templates/pi/validators/default.toml +209 -0
  207. package/templates/pi/validators/spring.toml +142 -0
  208. package/templates/pi/workpad.md +53 -0
  209. package/templates/project/java/Dockerfile +14 -0
  210. package/templates/project/java/README.md +40 -0
  211. package/templates/project/java/pom.xml +132 -0
  212. package/templates/project/typescript/Dockerfile +15 -0
  213. package/templates/project/typescript/README.md +29 -0
  214. package/templates/project/typescript/package.json +23 -0
  215. package/templates/project/typescript/tsconfig.json +21 -0
  216. package/templates/workflow.md +123 -0
@@ -0,0 +1,262 @@
1
+ # Blueprint Update Workflow
2
+
3
+ **Purpose:** Reverse-sync implementation changes back to blueprint. Use when code evolves and blueprint needs to reflect reality.
4
+
5
+ ---
6
+
7
+ ## Prerequisites
8
+
9
+ - Implementation changes completed
10
+ - `.pi/` blueprint exists
11
+ - Changes approved and validated
12
+ - Need to update blueprint to match new reality
13
+
14
+ ---
15
+
16
+ ## Canonical Reference Requirement
17
+
18
+ **When updating blueprint from implementation:**
19
+
20
+ ```markdown
21
+ <!--
22
+ Canonical Reference: .pi/[file].md
23
+ Blueprint Source: Guardian Framework v[X]
24
+ Updated from implementation: [date]
25
+ Implementation source: src/[file].ts
26
+ -->
27
+ ```
28
+
29
+ **Implementation file must reference blueprint:**
30
+
31
+ ```typescript
32
+ /**
33
+ * Canonical Reference: .pi/[blueprint-section]
34
+ * Implementation of [spec-name]
35
+ * Changes should sync back to blueprint via /blueprint-update
36
+ */
37
+ ```
38
+
39
+ ---
40
+
41
+ ## Workflow Steps
42
+
43
+ ### 1. Identify Changes to Sync
44
+
45
+ Find implementation changes that affect blueprint:
46
+
47
+ ```bash
48
+ # Recent changes
49
+ git log --oneline --since="1 week ago" src/
50
+
51
+ # Changed files
52
+ git diff HEAD~5 HEAD --name-only src/
53
+
54
+ # Compare to blueprint
55
+ for file in src/lib/*.ts; do
56
+ # Check if blueprint mentions this file
57
+ if ! grep -q "$file" .pi/context/project.md; then
58
+ echo "⚠️ $file not documented in blueprint"
59
+ fi
60
+ done
61
+ ```
62
+
63
+ ### 2. Categorize Changes
64
+
65
+ Determine what needs updating:
66
+
67
+ **Categories:**
68
+
69
+ | Category | Blueprint File | What to Update |
70
+ |----------|----------------|----------------|
71
+ | Commands | project.md | Build/test/lint commands |
72
+ | Dependencies | project.md | Dependency list |
73
+ | Patterns | patterns.md | New patterns, pattern changes |
74
+ | Architecture | project.md | Structure, modules |
75
+ | Quality gates | AGENTS.md | Validation steps |
76
+ | Workflows | prompts/*.md | Workflow adjustments |
77
+
78
+ ### 3. Extract Updates from Code
79
+
80
+ For each category, extract current state:
81
+
82
+ **Commands:**
83
+ ```bash
84
+ # Actual commands from package.json
85
+ jq '.scripts.build' package.json
86
+ jq '.scripts.test' package.json
87
+ jq '.scripts.lint' package.json
88
+ ```
89
+
90
+ **Dependencies:**
91
+ ```bash
92
+ jq '.dependencies' package.json
93
+ jq '.devDependencies' package.json
94
+ ```
95
+
96
+ **Patterns:**
97
+ ```bash
98
+ # Use /pattern-extract workflow for new patterns
99
+ ```
100
+
101
+ ### 4. Validate Changes Before Sync
102
+
103
+ Ensure changes are valid and tested:
104
+
105
+ ```bash
106
+ # Run validators
107
+ bash .pi/scripts/validate-ci.sh
108
+ bash .pi/scripts/validate-tests.sh
109
+
110
+ # Check tests pass
111
+ [test command]
112
+
113
+ # Ensure no breaking changes
114
+ ```
115
+
116
+ ### 5. Update Blueprint Files
117
+
118
+ Apply updates to .pi/ files:
119
+
120
+ **Update project.md:**
121
+ ```markdown
122
+ ## Commands (Updated [date])
123
+
124
+ ### Build
125
+ ```bash
126
+ [new build command]
127
+ ```
128
+
129
+ ## Dependencies (Updated [date])
130
+ - Added: [deps]
131
+ - Removed: [deps]
132
+ ```
133
+
134
+ **Update patterns.md:**
135
+ ```markdown
136
+ ## Patterns (Updated [date])
137
+
138
+ ### New Patterns
139
+ [From /pattern-extract]
140
+
141
+ ### Updated Patterns
142
+ [Pattern modifications]
143
+ ```
144
+
145
+ **Update AGENTS.md:**
146
+ ```markdown
147
+ ## Quality Gates (Updated [date])
148
+ - [ ] [new command] succeeds
149
+ ```
150
+
151
+ ### 6. Add Sync Metadata
152
+
153
+ Record update in manifest:
154
+
155
+ ```bash
156
+ # Update guardian.manifest.json
157
+ jq '.lastBlueprintSync = "2026-04-26"' guardian.manifest.json > tmp.json
158
+ mv tmp.json guardian.manifest.json
159
+
160
+ jq '.blueprintUpdates += [{"date": "2026-04-26", "source": "implementation", "files": ["project.md", "patterns.md"]}]' guardian.manifest.json > tmp.json
161
+ mv tmp.json guardian.manifest.json
162
+ ```
163
+
164
+ ### 7. Validate Canonical References
165
+
166
+ Check implementation files reference blueprint:
167
+
168
+ ```bash
169
+ for file in src/**/*.ts; do
170
+ if grep -q "Canonical Reference:" "$file"; then
171
+ ref=$(grep "Canonical Reference:" "$file" | grep -o '.pi/[^"]*')
172
+ if [ -f "$ref" ]; then
173
+ echo "✅ $file → $ref"
174
+ else
175
+ echo "❌ Invalid ref in $file: $ref"
176
+ # Add canonical reference
177
+ echo "Consider adding: Canonical Reference: .pi/context/patterns.md#[section]"
178
+ fi
179
+ else
180
+ echo "⚠️ $file missing canonical reference"
181
+ fi
182
+ done
183
+ ```
184
+
185
+ ---
186
+
187
+ ## Output Summary
188
+
189
+ ```markdown
190
+ ## Blueprint Update Report
191
+
192
+ ### Changes Synced
193
+
194
+ #### project.md
195
+ - Commands updated: [list]
196
+ - Dependencies updated: [list]
197
+ - Architecture updated: [sections]
198
+
199
+ #### patterns.md
200
+ - Patterns added: [count]
201
+ - Patterns updated: [count]
202
+
203
+ #### AGENTS.md
204
+ - Quality gates updated: [list]
205
+
206
+ ### Files Modified
207
+ - .pi/context/project.md
208
+ - .pi/context/patterns.md
209
+ - .pi/agent/AGENTS.md
210
+
211
+ ### Canonical Reference Coverage
212
+ - Before: [X]%
213
+ - After: [Y]%
214
+
215
+ ### Manifest Updated
216
+ - lastBlueprintSync: [date]
217
+ - blueprintUpdates: [entry added]
218
+
219
+ ### Next Steps
220
+ 1. Review changes in .pi/
221
+ 2. Run `/blueprint-validate`
222
+ 3. Run `guardian generate`
223
+ ```
224
+
225
+ ---
226
+
227
+ ## Acceptance Criteria
228
+
229
+ - [ ] Implementation changes identified
230
+ - [ ] Changes categorized by type
231
+ - [ ] Changes validated (tests pass)
232
+ - [ ] Blueprint files updated
233
+ - [ ] Sync metadata recorded in manifest
234
+ - [ ] Canonical references in implementation verified
235
+ - [ ] Blueprint integrity maintained
236
+
237
+ ---
238
+
239
+ ## Next Workflow
240
+
241
+ After blueprint update:
242
+ 1. `/blueprint-validate`
243
+ 2. `guardian generate`
244
+ 3. `/sync-check`
245
+
246
+ ---
247
+
248
+ ## Important Notes
249
+
250
+ **Reverse sync is exception, not norm:**
251
+ - Blueprint is canonical truth
252
+ - Implementation should follow blueprint
253
+ - Only reverse sync when:
254
+ - Implementation discovered better approach
255
+ - Commands evolved organically
256
+ - New patterns emerged naturally
257
+ - Bug fixes revealed needed patterns
258
+
259
+ **Never reverse sync:**
260
+ - Breaking changes without approval
261
+ - Unvalidated code
262
+ - Work-in-progress implementations
@@ -0,0 +1,218 @@
1
+ # Blueprint Validate Workflow
2
+
3
+ <!--
4
+ Canonical Reference: .pi/prompts/blueprint-validate.md
5
+ Blueprint Source: Guardian Framework v1.2
6
+ -->
7
+
8
+ **Purpose:** Validate the `.pi/` blueprint is complete, consistent, and properly structured before starting implementation. Includes architecture documentation validation.
9
+
10
+ ---
11
+
12
+ ## Prerequisites
13
+
14
+ - `.pi/` directory exists with blueprint files
15
+ - No active implementation work in progress
16
+
17
+ ---
18
+
19
+ ## Architecture Documentation Validation
20
+
21
+ **Check architecture structure exists:**
22
+
23
+ ```bash
24
+ # Required architecture directories
25
+ for dir in architecture/modules architecture/diagrams architecture/decisions; do
26
+ if [ -d ".pi/$dir" ]; then
27
+ echo "✅ .pi/$dir exists"
28
+ else
29
+ echo "❌ MISSING: .pi/$dir"
30
+ fi
31
+ done
32
+
33
+ # Required files
34
+ if [ -f ".pi/architecture/CHANGELOG.md" ]; then
35
+ echo "✅ Architecture CHANGELOG exists"
36
+ else
37
+ echo "❌ MISSING: .pi/architecture/CHANGELOG.md (required for change tracking)"
38
+ fi
39
+ ```
40
+
41
+ **Architecture Module Validation:**
42
+
43
+ Each module in `.pi/architecture/modules/` must have:
44
+ - [ ] Overview section
45
+ - [ ] Components table with file paths
46
+ - [ ] Data flow documentation
47
+ - [ ] Dependencies section
48
+ - [ ] Security considerations
49
+ - [ ] Testing requirements
50
+ - [ ] Change log references
51
+
52
+ ---
53
+
54
+ ## Workflow Steps
55
+
56
+ ### 1. Structure Validation
57
+
58
+ Check that all required blueprint directories exist:
59
+
60
+ ```bash
61
+ # Required directories
62
+ for dir in agent context skills prompts scripts; do
63
+ if [ -d ".pi/$dir" ]; then
64
+ echo "✅ .pi/$dir exists"
65
+ else
66
+ echo "❌ MISSING: .pi/$dir"
67
+ fi
68
+ done
69
+ ```
70
+
71
+ **Required Structure:**
72
+
73
+ ```
74
+ .pi/
75
+ ├── agent/AGENTS.md # Required
76
+ ├── context/
77
+ │ ├── project.md # Required
78
+ │ ├── patterns.md # Required
79
+ │ ├── checklists.md # Optional
80
+ │ └── output-formats.md # Optional
81
+ ├── skills/agents/ # Required
82
+ ├── skills/validators/ # Required
83
+ ├── prompts/ # Required
84
+ └── scripts/ # Required
85
+ ```
86
+
87
+ ### 2. AGENTS.md Validation
88
+
89
+ Verify project instructions are complete:
90
+
91
+ **Checklist:**
92
+ - [ ] Project name and version defined
93
+ - [ ] Development commands listed
94
+ - [ ] Architecture patterns documented
95
+ - [ ] Key files to read specified
96
+ - [ ] Quality gates defined
97
+
98
+ ### 3. Context Files Validation
99
+
100
+ Validate each context file:
101
+
102
+ **project.md:**
103
+ - [ ] Project facts accurate
104
+ - [ ] Build/test/lint commands match reality
105
+ - [ ] Dependencies listed
106
+
107
+ **patterns.md:**
108
+ - [ ] Code patterns for language exist
109
+ - [ ] Patterns are current (not stale)
110
+ - [ ] Example code snippets valid
111
+
112
+ ### 4. Cross-Reference Validation
113
+
114
+ Check that blueprint references are consistent:
115
+
116
+ ```bash
117
+ # Check for broken references in blueprint
118
+ grep -r "see .pi/" .pi/ | while read line; do
119
+ ref=$(echo "$line" | grep -o '.pi/[^"]*')
120
+ if [ ! -e "$ref" ]; then
121
+ echo "❌ BROKEN REF: $ref"
122
+ fi
123
+ done
124
+ ```
125
+
126
+ ### 5. Workflow Integrity Check
127
+
128
+ Verify all workflows have required sections:
129
+
130
+ ```bash
131
+ for workflow in .pi/prompts/*.md; do
132
+ echo "Checking: $workflow"
133
+ # Check for required sections
134
+ grep -q "## Prerequisites" "$workflow" || echo " ⚠️ Missing Prerequisites"
135
+ grep -q "## Workflow Steps" "$workflow" || echo " ⚠️ Missing Workflow Steps"
136
+ grep -q "## Acceptance Criteria" "$workflow" || echo " ⚠️ Missing Acceptance Criteria"
137
+ done
138
+ ```
139
+
140
+ ### 6. Validator Scripts Check
141
+
142
+ Ensure validator scripts are executable and functional:
143
+
144
+ ```bash
145
+ for script in .pi/scripts/validate-*.sh; do
146
+ if [ -x "$script" ]; then
147
+ echo "✅ $script is executable"
148
+ else
149
+ echo "❌ $script not executable"
150
+ fi
151
+ # Dry-run check
152
+ bash "$script" --dry-run 2>/dev/null || echo "⚠️ $script may have issues"
153
+ done
154
+ ```
155
+
156
+ ---
157
+
158
+ ## Canonical Reference Requirement
159
+
160
+ **All blueprint files must include canonical reference header:**
161
+
162
+ ```markdown
163
+ <!--
164
+ Canonical Reference: .pi/[category]/[filename].md
165
+ Blueprint Source: Guardian Framework v[X]
166
+ Generated: NEVER (this is the source)
167
+ -->
168
+ ```
169
+
170
+ **Validation Check:**
171
+ - Each blueprint file must have canonical reference header
172
+ - Reference must point to self (blueprint is source, not generated)
173
+ - Framework version must match manifest
174
+
175
+ ---
176
+
177
+ ## Output Summary
178
+
179
+ ```markdown
180
+ ## Blueprint Validation Report
181
+
182
+ ### Structure
183
+ - [PASS/FAIL] Directory structure complete
184
+
185
+ ### Content
186
+ - [PASS/FAIL] AGENTS.md valid
187
+ - [PASS/FAIL] Context files valid
188
+ - [PASS/FAIL] Workflows valid
189
+
190
+ ### References
191
+ - [PASS/FAIL] Cross-references valid
192
+ - [PASS/FAIL] Canonical headers present
193
+
194
+ ### Validators
195
+ - [PASS/FAIL] Scripts executable
196
+
197
+ ### Recommendations
198
+ - [List of fixes needed]
199
+ ```
200
+
201
+ ---
202
+
203
+ ## Acceptance Criteria
204
+
205
+ - [ ] All required directories exist
206
+ - [ ] AGENTS.md has all required sections
207
+ - [ ] Context files are valid and current
208
+ - [ ] No broken cross-references
209
+ - [ ] All workflows have required structure
210
+ - [ ] Validator scripts are executable
211
+ - [ ] All files have canonical reference headers
212
+ - [ ] Blueprint ready for implementation
213
+
214
+ ---
215
+
216
+ ## Next Workflow
217
+
218
+ When blueprint validated, proceed to `/epic-plan` or `/feature-development`
@@ -0,0 +1,50 @@
1
+ # Bug Fix Workflow
2
+
3
+ **Scope:** Simple, Moderate
4
+ **Optimized for:** Speed — minimal validation, direct fix
5
+
6
+ ## Flow
7
+
8
+ ```
9
+ Bug Report
10
+
11
+
12
+ ┌─────────────────────────────────┐
13
+ │ 1. COORDINATOR: Classify scope │
14
+ │ Most bugs = Simple/Moderate │
15
+ └──────────────┬──────────────────┘
16
+
17
+
18
+ ┌─────────────────────────────────┐
19
+ │ 2. CODE-DEVELOPER: Fix bug │
20
+ │ Load: context/patterns.md │
21
+ │ Output: Fixed code + test │
22
+ └──────────────┬──────────────────┘
23
+
24
+
25
+ ┌─────────────────────────────────┐
26
+ │ 3. AUTOMATED: Run validators │
27
+ │ • validate-ci.sh │
28
+ │ • validate-tests.sh │
29
+ └──────────────┬──────────────────┘
30
+
31
+
32
+ ┌─────────────────────────────────┐
33
+ │ 4. CI-MR: Create PR + merge │
34
+ │ Simple scope = ci-mr only │
35
+ └─────────────────────────────────┘
36
+ ```
37
+
38
+ ## Rules
39
+
40
+ - **Simple bugs** (1 file, < 50 lines): Fix → automated checks → merge. No LLM validators.
41
+ - **Moderate bugs** (2-5 files): Fix → automated checks → architecture-validator wiring check → merge.
42
+ - **Complex bugs** (root cause in architecture): Escalate to Feature Development workflow.
43
+
44
+ ## Commands
45
+
46
+ ```bash
47
+ # Quick fix verification
48
+ bash .pi/scripts/validate-ci.sh
49
+ bash .pi/scripts/validate-tests.sh
50
+ ```
@@ -0,0 +1,131 @@
1
+ # Guardian CI Blueprint
2
+
3
+ > **Generates `.gitlab-ci.yml` or `.github/workflows/ci.yml` from architecture conformance requirements.**
4
+
5
+ ## Purpose
6
+
7
+ Defines the CI/CD pipeline configuration that Guardian generates or validates. Every MR must pass this pipeline before merge.
8
+
9
+ ## Pipeline Structure
10
+
11
+ ```yaml
12
+ stages:
13
+ - docs_policy
14
+ - architecture_conformance
15
+ - lint
16
+ - static_analysis
17
+ - unit
18
+ - integration
19
+ - security
20
+ - migration_verify
21
+ - package_build
22
+ - release_readiness
23
+ ```
24
+
25
+ ## Stage 1: Docs Policy
26
+
27
+ Verifies MR traceability and documentation sync.
28
+
29
+ | Job | Script | Allow Failure |
30
+ |-----|--------|---------------|
31
+ | `mr_traceability_check` | `.pi/scripts/ci/stage_docs_policy.sh` | No |
32
+ | `docs_sync_guard` | `.pi/scripts/ci/stage_docs_policy.sh` | No |
33
+
34
+ ## Stage 2: Architecture Conformance
35
+
36
+ 11+ architectural contract checks.
37
+
38
+ | Job | Script | Allow Failure |
39
+ |-----|--------|---------------|
40
+ | `tenant_isolation_conformance` | `.pi/scripts/ci/check_architecture_conformance.sh` | No |
41
+ | `event_ordering_conformance` | `.pi/scripts/ci/check_architecture_conformance.sh` | No |
42
+ | `outbox_dlq_conformance` | `.pi/scripts/ci/check_architecture_conformance.sh` | No |
43
+ | `replay_upcaster_conformance` | `.pi/scripts/ci/check_architecture_conformance.sh` | No |
44
+ | `architecture_sanity` | `.pi/scripts/ci/check_architecture_conformance.sh` | No |
45
+ | `import_boundary_check` | `.pi/scripts/ci/check_architecture_conformance.sh` | No |
46
+
47
+ ## Stage 3: Lint
48
+
49
+ Language-specific linting.
50
+
51
+ | Language | Lint Job | Format Job |
52
+ |----------|----------|------------|
53
+ | Python | `ruff check .` | `ruff format --check .` |
54
+ | TypeScript | `biome check .` | `biome format --check .` |
55
+ | Rust | `cargo clippy -- -D warnings` | `cargo fmt --check` |
56
+ | Go | `golangci-lint run` | `gofmt -d .` |
57
+
58
+ ## Stage 4: Static Analysis
59
+
60
+ | Job | Script | Allow Failure |
61
+ |-----|--------|---------------|
62
+ | `type_check` | `mypy` / `tsc --noEmit` / `cargo check` / `go vet` | No |
63
+ | `import_boundary_check` | `.pi/scripts/ci/stage_static_analysis.sh` | No |
64
+ | `sanity_checks` | `.pi/scripts/ci/stage_static_analysis.sh` | No |
65
+ | `settings_env_collision_check` | `.pi/scripts/ci/stage_static_analysis.sh` | No |
66
+
67
+ ## Stage 5: Unit
68
+
69
+ | Job | Script | Allow Failure |
70
+ |-----|--------|---------------|
71
+ | `unit_domain` | `pytest tests/unit/domain` | No |
72
+ | `unit_application` | `pytest tests/unit/application` | No |
73
+ | `unit_contract` | `pytest tests/contract` | No |
74
+ | `unit_verification` | `pytest tests/verification` | No |
75
+ | `coverage_threshold_check` | `.pi/scripts/ci/check_coverage_thresholds.py` | No |
76
+
77
+ ## Stage 6: Integration
78
+
79
+ | Job | Script | Allow Failure |
80
+ |-----|--------|---------------|
81
+ | `integration` | `pytest tests/integration` | No |
82
+
83
+ ## Stage 7: Security
84
+
85
+ | Job | Script | Allow Failure |
86
+ |-----|--------|---------------|
87
+ | `sbom_and_provenance` | `.pi/scripts/ci/generate_sbom.py` | No |
88
+ | `container_scan` | `trivy image --severity HIGH,CRITICAL` | No |
89
+ | `secret_scan` | `.pi/scripts/ci/secret_scan.py` | No |
90
+ | `dependency_scan` | `pip-audit` / `npm audit` / `cargo audit` | No |
91
+
92
+ ## Stage 8: Migration Verify
93
+
94
+ **Conditional:** Only triggers when migration-related files change.
95
+
96
+ | Job | Script | Allow Failure |
97
+ |-----|--------|---------------|
98
+ | `migration_apply_check` | `alembic upgrade head` | No |
99
+ | `index_policy_verify` | `.pi/scripts/ci/verify_indexes_and_policies.py` | No |
100
+
101
+ ## Stage 9: Package Build
102
+
103
+ **Conditional:** Only on main branch.
104
+
105
+ | Job | Script | Allow Failure |
106
+ |-----|--------|---------------|
107
+ | `build_backend_image` | `docker build -t app:${CI_COMMIT_SHA} .` | Yes |
108
+
109
+ ## Stage 10: Release Readiness
110
+
111
+ | Job | Script | Allow Failure |
112
+ |-----|--------|---------------|
113
+ | `runbook_readiness_check` | `.pi/scripts/validate-architecture-readiness.sh` | No |
114
+ | `observability_readiness_check` | `.pi/scripts/validate-architecture-readiness.sh` | No |
115
+ | `release_policy_check` | `.pi/scripts/ci/check_release_policy.py` | No |
116
+
117
+ ## Conditional Rules
118
+
119
+ | Rule | Jobs Using It |
120
+ |------|---------------|
121
+ | `rules_default` (MRs or main branch) | Most jobs |
122
+ | `rules_sonar` (requires `$SONAR_TOKEN` + `$SONAR_HOST_URL`) | coverage_report, sonar_quality_gate |
123
+ | `rules_main_only` | `package_build` |
124
+ | `rules_migration_changes` (migration file changes only) | `migration_verify` stage |
125
+
126
+ ## Generated Pipeline Files
127
+
128
+ Guardian generates or validates:
129
+ - `.gitlab-ci.yml` for GitLab projects
130
+ - `.github/workflows/ci.yml` for GitHub projects
131
+ - Both are derived from `.pi/scripts/ci/run_hardening_stages.sh`