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,228 @@
1
+ #!/usr/bin/env bash
2
+ # ============================================================================
3
+ # mr-validation.sh — Validate Merge Request / Pull Request (GitHub & GitLab)
4
+ #
5
+ # Run as: bash .pi/scripts/mr-validation.sh [pr-number]
6
+ # Checks: CI status, architecture, security, integration
7
+ # ============================================================================
8
+ set -euo pipefail
9
+
10
+ PR_NUMBER="${1:-}"
11
+
12
+ RED='\033[0;31m'
13
+ GREEN='\033[0;32m'
14
+ YELLOW='\033[1;33m'
15
+ BLUE='\033[0;34m'
16
+ NC='\033[0m'
17
+
18
+ ERRORS=()
19
+ PASS_COUNT=0
20
+
21
+ pass() { echo -e "${GREEN}✅ PASS${NC} $1"; PASS_COUNT=$((PASS_COUNT + 1)); }
22
+ fail() { echo -e "${RED}❌ FAIL${NC} $1"; ERRORS+=("$1"); }
23
+ warn() { echo -e "${YELLOW}⚠️ WARN${NC} $1"; }
24
+
25
+ detect_platform() {
26
+ if [ -f "guardian-manifest.json" ]; then
27
+ local tool=$(jq -r '.repoTool // ""' guardian-manifest.json 2>/dev/null || echo "")
28
+ if [[ "$tool" == "glab" ]]; then echo "gitlab"; return; fi
29
+ if [[ "$tool" == "gh" ]]; then echo "github"; return; fi
30
+ fi
31
+ if [[ -n "${GIT_PLATFORM:-}" ]]; then
32
+ echo "$GIT_PLATFORM"
33
+ elif command -v gh &>/dev/null && gh auth status &>/dev/null 2>&1; then
34
+ echo "github"
35
+ elif command -v glab &>/dev/null && glab auth status &>/dev/null 2>&1; then
36
+ echo "gitlab"
37
+ else
38
+ echo "none"
39
+ fi
40
+ }
41
+
42
+ echo "============================================"
43
+ echo " MR Validation"
44
+ echo "============================================"
45
+ echo ""
46
+
47
+ PLATFORM=$(detect_platform)
48
+
49
+ if [[ "$PLATFORM" == "none" ]]; then
50
+ echo -e "${RED}❌ No git platform detected${NC}"
51
+ echo " Install and authenticate gh (GitHub) or glab (GitLab) CLI."
52
+ exit 1
53
+ fi
54
+
55
+ # ---------------------------------------------------------------------------
56
+ # Get MR/PR Number
57
+ # ---------------------------------------------------------------------------
58
+ if [ -z "$PR_NUMBER" ]; then
59
+ BRANCH_NAME=$(git branch --show-current)
60
+
61
+ case "$PLATFORM" in
62
+ github)
63
+ PR_NUMBER=$(gh pr view --json number -q '.number' 2>/dev/null || echo "")
64
+ ;;
65
+ gitlab)
66
+ PR_NUMBER=$(glab mr list --source-branch "$BRANCH_NAME" --json 'iid' -q '.[0].iid' 2>/dev/null || echo "")
67
+ ;;
68
+ esac
69
+
70
+ if [ -z "$PR_NUMBER" ]; then
71
+ echo -e "${RED}❌ MR/PR number required${NC}"
72
+ echo "Usage: mr-validation.sh [mr-number]"
73
+ echo " Or run from the MR/PR branch"
74
+ exit 1
75
+ fi
76
+ fi
77
+
78
+ echo "Validating MR/PR #$PR_NUMBER on $PLATFORM..."
79
+
80
+ # ---------------------------------------------------------------------------
81
+ # Get MR/PR Status
82
+ # ---------------------------------------------------------------------------
83
+ case "$PLATFORM" in
84
+ github)
85
+ PR_INFO=$(gh pr view "$PR_NUMBER" --json title,state,mergeable,statusCheckRollup,headRefName 2>/dev/null || echo "{}")
86
+ PR_STATE=$(echo "$PR_INFO" | jq -r '.state // "unknown"')
87
+ PR_MERGEABLE=$(echo "$PR_INFO" | jq -r '.mergeable // "unknown"')
88
+ PR_BRANCH=$(echo "$PR_INFO" | jq -r '.headRefName // "unknown"')
89
+ echo "Title: $(echo "$PR_INFO" | jq -r '.title')"
90
+ ;;
91
+ gitlab)
92
+ MR_INFO=$(glab mr view "$PR_NUMBER" --output json 2>/dev/null || echo "{}")
93
+ PR_STATE=$(echo "$MR_INFO" | jq -r '.state // "unknown"')
94
+ PR_MERGEABLE=$(echo "$MR_INFO" | jq -r '.merge_status // "unknown"')
95
+ PR_BRANCH=$(echo "$MR_INFO" | jq -r '.source_branch // "unknown"')
96
+ echo "Title: $(echo "$MR_INFO" | jq -r '.title')"
97
+ ;;
98
+ esac
99
+
100
+ echo "State: $PR_STATE"
101
+ echo "Branch: $PR_BRANCH"
102
+ echo ""
103
+
104
+ # ---------------------------------------------------------------------------
105
+ # CI Status Check
106
+ # ---------------------------------------------------------------------------
107
+ echo "--- CI Status ---"
108
+
109
+ case "$PLATFORM" in
110
+ github)
111
+ STATUS_CHECKS=$(echo "$PR_INFO" | jq -r '.statusCheckRollup[]?.status // "unknown"' 2>/dev/null || echo "unknown")
112
+ ;;
113
+ gitlab)
114
+ STATUS_CHECKS=$(echo "$MR_INFO" | jq -r '.head_pipeline.status // "unknown"' 2>/dev/null || echo "unknown")
115
+ ;;
116
+ esac
117
+
118
+ if [ "$STATUS_CHECKS" = "SUCCESS" ] || [ "$STATUS_CHECKS" = "success" ] || [ "$STATUS_CHECKS" = "passed" ]; then
119
+ pass "CI checks passed"
120
+ elif [ "$STATUS_CHECKS" = "IN_PROGRESS" ] || [ "$STATUS_CHECKS" = "pending" ] || [ "$STATUS_CHECKS" = "running" ]; then
121
+ warn "CI checks in progress"
122
+ echo " Wait for completion and re-run"
123
+ else
124
+ fail "CI checks failed or unknown: $STATUS_CHECKS"
125
+ fi
126
+
127
+ # ---------------------------------------------------------------------------
128
+ # Mergeable Check
129
+ # ---------------------------------------------------------------------------
130
+ echo ""
131
+ echo "--- Mergeable Status ---"
132
+
133
+ if [ "$PR_MERGEABLE" = "MERGEABLE" ] || [ "$PR_MERGEABLE" = "true" ] || [ "$PR_MERGEABLE" = "can_be_merged" ]; then
134
+ pass "MR/PR is mergeable"
135
+ elif [ "$PR_MERGEABLE" = "CONFLICTING" ] || [ "$PR_MERGEABLE" = "false" ] || [ "$PR_MERGEABLE" = "cannot_be_merged" ]; then
136
+ fail "MR/PR has merge conflicts"
137
+ echo " Resolve conflicts before merge"
138
+ else
139
+ warn "Mergeable status unknown: $PR_MERGEABLE"
140
+ fi
141
+
142
+ # ---------------------------------------------------------------------------
143
+ # Run Local Validators
144
+ # ---------------------------------------------------------------------------
145
+ echo ""
146
+ echo "--- Local Validation ---"
147
+
148
+ # Checkout MR/PR branch
149
+ git checkout "$PR_BRANCH" 2>/dev/null || {
150
+ warn "Could not checkout branch $PR_BRANCH"
151
+ }
152
+
153
+ # Run validation scripts
154
+ if [ -f ".pi/scripts/validate-ci.sh" ]; then
155
+ bash .pi/scripts/validate-ci.sh 2>&1 | tail -5
156
+ fi
157
+
158
+ if [ -f ".pi/scripts/validate-security.sh" ]; then
159
+ bash .pi/scripts/validate-security.sh 2>&1 | tail -5
160
+ fi
161
+
162
+ # ---------------------------------------------------------------------------
163
+ # Architecture Check
164
+ # ---------------------------------------------------------------------------
165
+ echo ""
166
+ echo "--- Architecture Check ---"
167
+
168
+ case "$PLATFORM" in
169
+ github)
170
+ CHANGED_FILES=$(gh pr diff "$PR_NUMBER" --name-only 2>/dev/null || git diff --name-only "origin/main"..HEAD)
171
+ ;;
172
+ gitlab)
173
+ CHANGED_FILES=$(glab mr diff "$PR_NUMBER" --name-only 2>/dev/null || git diff --name-only "origin/main"..HEAD)
174
+ ;;
175
+ esac
176
+
177
+ for FILE in $CHANGED_FILES; do
178
+ if [ -f "$FILE" ] && [[ "$FILE" == *.rs ]]; then
179
+ NEW_FNS=$(git diff "origin/main"..HEAD -- "$FILE" | grep "^[+]pub fn\|^[+]pub async fn" || true)
180
+ if [ -n "$NEW_FNS" ]; then
181
+ echo -e "${BLUE}ℹ️ New public functions in $FILE:${NC}"
182
+ echo "$NEW_FNS" | head -5
183
+ fi
184
+ fi
185
+ done
186
+
187
+ # ---------------------------------------------------------------------------
188
+ # Check for Tests
189
+ # ---------------------------------------------------------------------------
190
+ echo ""
191
+ echo "--- Test Coverage Check ---"
192
+
193
+ TEST_FILES=$(echo "$CHANGED_FILES" | grep -E "test.*\.|\.test\.|tests/" || true)
194
+ SRC_FILES=$(echo "$CHANGED_FILES" | grep -E "src/|lib/" | grep -v test || true)
195
+
196
+ if [ -n "$SRC_FILES" ] && [ -z "$TEST_FILES" ]; then
197
+ warn "Source files changed but no test files"
198
+ echo " Consider adding tests for:"
199
+ echo "$SRC_FILES" | head -5
200
+ else
201
+ pass "Test coverage present"
202
+ fi
203
+
204
+ # ---------------------------------------------------------------------------
205
+ # Summary
206
+ # ---------------------------------------------------------------------------
207
+ echo ""
208
+ echo "============================================"
209
+ echo " Summary"
210
+ echo "============================================"
211
+ echo -e " Passed: ${GREEN}${PASS_COUNT}${NC}"
212
+ echo -e " Failed: ${RED}${#ERRORS[@]}${NC}"
213
+ echo ""
214
+
215
+ if [ ${#ERRORS[@]} -gt 0 ]; then
216
+ echo "BLOCKERS:"
217
+ for err in "${ERRORS[@]}"; do
218
+ echo " - $err"
219
+ done
220
+ echo ""
221
+ echo "Fix blockers before merging"
222
+ exit 1
223
+ fi
224
+
225
+ echo -e "${GREEN}MR validation passed. Ready for merge.${NC}"
226
+ echo ""
227
+
228
+ exit 0
@@ -0,0 +1,153 @@
1
+ #!/usr/bin/env bash
2
+ # Architecture Readiness Validator
3
+ #
4
+ # Validates that the epic slice is architecturally complete before closing.
5
+ # Checks: runbook, DR plan, docs update, canonical refs synced, observability.
6
+ #
7
+ # Usage: bash .pi/scripts/validate-architecture-readiness.sh
8
+ #
9
+ # Exit codes:
10
+ # 0 — All readiness checks passed
11
+ # 1 — One or more readiness checks failed
12
+
13
+ set -euo pipefail
14
+
15
+ PI_DIR=".pi"
16
+ ARCH_DIR="${PI_DIR}/architecture"
17
+
18
+ RED='\033[0;31m'
19
+ GREEN='\033[0;32m'
20
+ YELLOW='\033[1;33m'
21
+ NC='\033[0m'
22
+
23
+ PASS=0
24
+ FAIL=0
25
+
26
+ log_pass() { echo -e " ${GREEN}✓ PASS${NC} $1"; ((PASS++)); }
27
+ log_fail() { echo -e " ${RED}✗ FAIL${NC} $1 — $2"; ((FAIL++)); }
28
+ log_skip() { echo -e " ${YELLOW}⊘ SKIP${NC} $1 — $2"; ((PASS++)); }
29
+
30
+ echo "═══ Architecture Readiness Checks ═══"
31
+ echo ""
32
+
33
+ # 1. Runbook readiness
34
+ echo "Checking runbook readiness..."
35
+ if [[ -f "docs/runbook.md" || -f "docs/RUNBOOK.md" || -f "RUNBOOK.md" ]]; then
36
+ # Check runbook has required sections
37
+ RUNBOOK=$(find . -name "runbook.md" -o -name "RUNBOOK.md" 2>/dev/null | head -1)
38
+ if grep -qiE "(incident|escalation|rollback|recovery|on.call)" "$RUNBOOK" 2>/dev/null; then
39
+ log_pass "Runbook readiness (runbook exists with incident/rollback sections)"
40
+ else
41
+ log_fail "Runbook readiness" "Runbook exists but missing incident/rollback sections"
42
+ fi
43
+ else
44
+ log_fail "Architecture readiness" "No runbook.md found. Create docs/runbook.md with incident procedures."
45
+ fi
46
+
47
+ # 2. DR plan
48
+ echo "Checking DR plan..."
49
+ if [[ -f "docs/dr-plan.md" || -f "docs/disaster-recovery.md" || -f "docs/DR.md" ]]; then
50
+ DR_FILE=$(find . -name "dr-plan.md" -o -name "disaster-recovery.md" -o -name "DR.md" 2>/dev/null | head -1)
51
+ if grep -qiE "(rto|rpo|backup|restore|failover|recovery)" "$DR_FILE" 2>/dev/null; then
52
+ log_pass "DR plan readiness (DR plan exists with RTO/RPO sections)"
53
+ else
54
+ log_fail "DR plan readiness" "DR plan exists but missing RTO/RPO/recovery sections"
55
+ fi
56
+ else
57
+ log_fail "Architecture readiness" "No dr-plan.md found. Create docs/dr-plan.md with RTO/RPO targets."
58
+ fi
59
+
60
+ # 3. Docs updated
61
+ echo "Checking documentation sync..."
62
+ if command -v git &>/dev/null; then
63
+ # Check if any architecture module was recently updated
64
+ recently_updated=false
65
+ if [[ -d "$ARCH_DIR/modules" ]]; then
66
+ for module_file in "${ARCH_DIR}"/modules/*.md; do
67
+ [[ -f "$module_file" ]] || continue
68
+ if git log -1 --since="1 day ago" -- "$module_file" 2>/dev/null | grep -q .; then
69
+ recently_updated=true
70
+ break
71
+ fi
72
+ done
73
+ fi
74
+ if [[ "$recently_updated" == "true" ]]; then
75
+ log_pass "Documentation sync (architecture docs recently updated)"
76
+ else
77
+ log_skip "Documentation sync" "Architecture docs not recently updated (may be fine for small slices)"
78
+ fi
79
+ else
80
+ log_pass "Documentation sync (git not available, skipping)"
81
+ fi
82
+
83
+ # 4. Canonical refs synced
84
+ echo "Checking canonical references..."
85
+ if [[ -f "${PI_DIR}/scripts/validate-canonical.sh" ]]; then
86
+ if bash "${PI_DIR}/scripts/validate-canonical.sh" >/dev/null 2>&1; then
87
+ log_pass "Canonical references (validate-canonical.sh passed)"
88
+ else
89
+ log_fail "Canonical references" "validate-canonical.sh failed — some files lack canonical refs"
90
+ fi
91
+ else
92
+ log_skip "Canonical references" "validate-canonical.sh not found"
93
+ fi
94
+
95
+ # 5. Observability readiness
96
+ echo "Checking observability readiness..."
97
+ HAS_TRACING=false
98
+ HAS_METRICS=false
99
+ HAS_LOGGING=false
100
+
101
+ for f in $(find . -name "*.py" -o -name "*.ts" -o -name "*.rs" -o -name "*.go" 2>/dev/null | head -30); do
102
+ grep -qiE "(opentelemetry|jaeger|zipkin|tracing\.)" "$f" 2>/dev/null && HAS_TRACING=true
103
+ grep -qiE "(prometheus|datadog|metrics\.|counter|histogram)" "$f" 2>/dev/null && HAS_METRICS=true
104
+ grep -qiE "(structured.log|json.log|log\.info|log\.error|logger\.)" "$f" 2>/dev/null && HAS_LOGGING=true
105
+ done
106
+
107
+ if [[ "$HAS_TRACING" == "true" ]]; then
108
+ log_pass "Observability: tracing detected"
109
+ else
110
+ log_skip "Observability: tracing" "No tracing framework detected"
111
+ fi
112
+
113
+ if [[ "$HAS_METRICS" == "true" ]]; then
114
+ log_pass "Observability: metrics detected"
115
+ else
116
+ log_skip "Observability: metrics" "No metrics framework detected"
117
+ fi
118
+
119
+ if [[ "$HAS_LOGGING" == "true" ]]; then
120
+ log_pass "Observability: structured logging detected"
121
+ else
122
+ log_skip "Observability: logging" "No structured logging detected"
123
+ fi
124
+
125
+ # 6. Architecture conformance (re-run to verify)
126
+ echo "Re-running architecture conformance..."
127
+ if [[ -f "${PI_DIR}/scripts/ci/check_architecture_conformance.sh" ]]; then
128
+ if bash "${PI_DIR}/scripts/ci/check_architecture_conformance.sh" >/dev/null 2>&1; then
129
+ log_pass "Architecture conformance (all checks pass)"
130
+ else
131
+ log_fail "Architecture conformance" "Some conformance checks failed — fix before closing epic"
132
+ fi
133
+ else
134
+ log_skip "Architecture conformance" "check_architecture_conformance.sh not found"
135
+ fi
136
+
137
+ # ── Summary ──
138
+
139
+ echo ""
140
+ echo "═══ Architecture Readiness Summary ═══"
141
+ echo -e " ${GREEN}Pass: ${PASS}${NC}"
142
+ echo -e " ${RED}Fail: ${FAIL}${NC}"
143
+ echo " Total: $((PASS + FAIL))"
144
+
145
+ if [[ $FAIL -gt 0 ]]; then
146
+ echo ""
147
+ echo -e "${RED}✗ Architecture readiness FAILED. Fix the issues above before closing the epic.${NC}"
148
+ exit 1
149
+ fi
150
+
151
+ echo ""
152
+ echo -e "${GREEN}✓ Architecture readiness complete. Epic can be closed.${NC}"
153
+ exit 0
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env bash
2
+ # validate-architecture.sh — Dispatcher
3
+ set -euo pipefail
4
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
5
+
6
+ detect_language() {
7
+ if [ -f "poetry.lock" ] || [ -f "pyproject.toml" ]; then echo "python"
8
+ elif [ -f "Cargo.lock" ] || [ -f "Cargo.toml" ]; then echo "rust"
9
+ elif [ -f "go.mod" ]; then echo "go"
10
+ elif [ -f "package.json" ]; then echo "typescript"
11
+ else echo "unknown"; fi
12
+ }
13
+
14
+ LANG=$(detect_language)
15
+ LANG_SCRIPT="${SCRIPT_DIR}/languages/${LANG}/validate-architecture.sh"
16
+
17
+ if [ -f "$LANG_SCRIPT" ]; then
18
+ exec bash "$LANG_SCRIPT" "$@"
19
+ else
20
+ echo "No architecture validator for language: $LANG"
21
+ exit 0
22
+ fi
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env bash
2
+ # validate-canonical.sh — Dispatcher
3
+ set -euo pipefail
4
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
5
+
6
+ detect_language() {
7
+ if [ -f "poetry.lock" ] || [ -f "pyproject.toml" ]; then echo "python"
8
+ elif [ -f "Cargo.lock" ] || [ -f "Cargo.toml" ]; then echo "rust"
9
+ elif [ -f "go.mod" ]; then echo "go"
10
+ elif [ -f "package.json" ]; then echo "typescript"
11
+ else echo "unknown"; fi
12
+ }
13
+
14
+ LANG=$(detect_language)
15
+ LANG_SCRIPT="${SCRIPT_DIR}/languages/${LANG}/validate-canonical.sh"
16
+
17
+ if [ -f "$LANG_SCRIPT" ]; then
18
+ exec bash "$LANG_SCRIPT" "$@"
19
+ else
20
+ echo "No canonical validator for language: $LANG"
21
+ exit 0
22
+ fi
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env bash
2
+ # ============================================================================
3
+ # validate-ci.sh — Dispatcher
4
+ #
5
+ # Detects the project language and delegates to the language-specific script.
6
+ # Language-specific scripts live in: .pi/scripts/languages/<lang>/validate-ci.sh
7
+ # ============================================================================
8
+ set -euo pipefail
9
+
10
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
11
+
12
+ detect_language() {
13
+ if [ -f "poetry.lock" ]; then
14
+ echo "python"
15
+ elif [ -f "pyproject.toml" ]; then
16
+ echo "python"
17
+ elif [ -f "Cargo.lock" ] || [ -f "Cargo.toml" ]; then
18
+ echo "rust"
19
+ elif [ -f "go.mod" ]; then
20
+ echo "go"
21
+ elif [ -f "package.json" ]; then
22
+ echo "typescript"
23
+ else
24
+ echo "unknown"
25
+ fi
26
+ }
27
+
28
+ LANG=$(detect_language)
29
+ LANG_SCRIPT="${SCRIPT_DIR}/languages/${LANG}/validate-ci.sh"
30
+
31
+ if [ -f "$LANG_SCRIPT" ]; then
32
+ exec bash "$LANG_SCRIPT" "$@"
33
+ else
34
+ echo "No CI validator for language: $LANG"
35
+ echo "Create: $LANG_SCRIPT"
36
+ exit 0
37
+ fi
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env bash
2
+ # validate-integration.sh — Dispatcher
3
+ set -euo pipefail
4
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
5
+
6
+ detect_language() {
7
+ if [ -f "poetry.lock" ] || [ -f "pyproject.toml" ]; then echo "python"
8
+ elif [ -f "Cargo.lock" ] || [ -f "Cargo.toml" ]; then echo "rust"
9
+ elif [ -f "go.mod" ]; then echo "go"
10
+ elif [ -f "package.json" ]; then echo "typescript"
11
+ else echo "unknown"; fi
12
+ }
13
+
14
+ LANG=$(detect_language)
15
+ LANG_SCRIPT="${SCRIPT_DIR}/languages/${LANG}/validate-integration.sh"
16
+
17
+ if [ -f "$LANG_SCRIPT" ]; then
18
+ exec bash "$LANG_SCRIPT" "$@"
19
+ else
20
+ echo "No integration validator for language: $LANG"
21
+ exit 0
22
+ fi
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env bash
2
+ # validate-operations.sh — Dispatcher
3
+ set -euo pipefail
4
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
5
+
6
+ detect_language() {
7
+ if [ -f "poetry.lock" ] || [ -f "pyproject.toml" ]; then echo "python"
8
+ elif [ -f "Cargo.lock" ] || [ -f "Cargo.toml" ]; then echo "rust"
9
+ elif [ -f "go.mod" ]; then echo "go"
10
+ elif [ -f "package.json" ]; then echo "typescript"
11
+ else echo "unknown"; fi
12
+ }
13
+
14
+ LANG=$(detect_language)
15
+ LANG_SCRIPT="${SCRIPT_DIR}/languages/${LANG}/validate-operations.sh"
16
+
17
+ if [ -f "$LANG_SCRIPT" ]; then
18
+ exec bash "$LANG_SCRIPT" "$@"
19
+ else
20
+ echo "No operations validator for language: $LANG"
21
+ exit 0
22
+ fi
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env bash
2
+ # validate-security.sh — Dispatcher
3
+ set -euo pipefail
4
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
5
+
6
+ detect_language() {
7
+ if [ -f "poetry.lock" ] || [ -f "pyproject.toml" ]; then echo "python"
8
+ elif [ -f "Cargo.lock" ] || [ -f "Cargo.toml" ]; then echo "rust"
9
+ elif [ -f "go.mod" ]; then echo "go"
10
+ elif [ -f "package.json" ]; then echo "typescript"
11
+ else echo "unknown"; fi
12
+ }
13
+
14
+ LANG=$(detect_language)
15
+ LANG_SCRIPT="${SCRIPT_DIR}/languages/${LANG}/validate-security.sh"
16
+
17
+ if [ -f "$LANG_SCRIPT" ]; then
18
+ exec bash "$LANG_SCRIPT" "$@"
19
+ else
20
+ echo "No security validator for language: $LANG"
21
+ exit 0
22
+ fi
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env bash
2
+ # validate-tests.sh — Dispatcher
3
+ set -euo pipefail
4
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
5
+
6
+ detect_language() {
7
+ if [ -f "poetry.lock" ] || [ -f "pyproject.toml" ]; then echo "python"
8
+ elif [ -f "Cargo.lock" ] || [ -f "Cargo.toml" ]; then echo "rust"
9
+ elif [ -f "go.mod" ]; then echo "go"
10
+ elif [ -f "package.json" ]; then echo "typescript"
11
+ else echo "unknown"; fi
12
+ }
13
+
14
+ LANG=$(detect_language)
15
+ LANG_SCRIPT="${SCRIPT_DIR}/languages/${LANG}/validate-tests.sh"
16
+
17
+ if [ -f "$LANG_SCRIPT" ]; then
18
+ exec bash "$LANG_SCRIPT" "$@"
19
+ else
20
+ echo "No test validator for language: $LANG"
21
+ exit 0
22
+ fi