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,188 @@
1
+ #!/usr/bin/env bash
2
+ # ============================================================================
3
+ # validate-architecture.sh — Rust
4
+ # ============================================================================
5
+ set -euo pipefail
6
+
7
+ PASS_COUNT=0
8
+ ERRORS=()
9
+ WARNINGS=()
10
+
11
+ RED='\033[0;31m'
12
+ GREEN='\033[0;32m'
13
+ YELLOW='\033[1;33m'
14
+ NC='\033[0m'
15
+
16
+ pass() { echo -e "${GREEN}✅ PASS${NC} $1"; PASS_COUNT=$((PASS_COUNT + 1)); }
17
+ fail() { echo -e "${RED}❌ FAIL${NC} $1"; ERRORS+=("$1"); }
18
+ warn() { echo -e "${YELLOW}⚠️ WARN${NC} $1"; WARNINGS+=("$1"); }
19
+
20
+ echo "============================================"
21
+ echo " Architecture Validation (Rust)"
22
+ echo "============================================"
23
+ echo ""
24
+
25
+ if [ ! -f "Cargo.toml" ]; then
26
+ warn "No Cargo.toml found (skipping Rust architecture validation)"
27
+ echo ""
28
+ echo "============================================"
29
+ echo " Summary"
30
+ echo "============================================"
31
+ echo -e " Passed: ${GREEN}${PASS_COUNT}${NC}"
32
+ echo -e " Failed: ${RED}${#ERRORS[@]}${NC}"
33
+ echo ""
34
+ echo -e "${GREEN}No Rust project detected, nothing to validate.${NC}"
35
+ exit 0
36
+ fi
37
+
38
+ # ---------------------------------------------------------------------------
39
+ # Layer structure (clean architecture)
40
+ # ---------------------------------------------------------------------------
41
+ echo "--- Layer Structure ---"
42
+ LAYERS_FOUND=0
43
+ for layer in src/domain src/application src/infrastructure; do
44
+ if [ -d "$layer" ]; then
45
+ LAYERS_FOUND=$((LAYERS_FOUND + 1))
46
+ fi
47
+ done
48
+ if [ "$LAYERS_FOUND" -ge 2 ]; then
49
+ pass "Clean architecture layers detected ($LAYERS_FOUND/3)"
50
+ elif [ "$LAYERS_FOUND" -eq 1 ]; then
51
+ warn "Partial layer structure found (1/3 layers)"
52
+ else
53
+ # Check for alternative common structures
54
+ if [ -d "src/models" ] || [ -d "src/handlers" ] || [ -d "src/services" ]; then
55
+ warn "Alternative project structure detected (no clean architecture layers)"
56
+ else
57
+ fail "No architectural layers found (no src/domain/, src/application/, or src/infrastructure/)"
58
+ fi
59
+ fi
60
+
61
+ # ---------------------------------------------------------------------------
62
+ # Canonical references
63
+ # ---------------------------------------------------------------------------
64
+ echo ""
65
+ echo "--- Canonical References ---"
66
+ if [ -d ".pi/architecture/modules" ]; then
67
+ MODULE_COUNT=$(find .pi/architecture/modules -name "*.md" 2>/dev/null | wc -l | tr -d ' ')
68
+ if [ "$MODULE_COUNT" -gt 0 ]; then
69
+ pass "Architecture modules defined ($MODULE_COUNT module files)"
70
+ else
71
+ warn "No architecture module files found in .pi/architecture/modules/"
72
+ fi
73
+ else
74
+ warn "No .pi/architecture/modules/ directory (no canonical module references)"
75
+ fi
76
+
77
+ # ---------------------------------------------------------------------------
78
+ # Domain models
79
+ # ---------------------------------------------------------------------------
80
+ echo ""
81
+ echo "--- Domain Models ---"
82
+ DOMAIN_MODELS=0
83
+ for dir in src/domain src/models; do
84
+ if [ -d "$dir" ]; then
85
+ MODELS=$(grep -rlE '^\s*(pub\s+)?struct\s' "$dir" 2>/dev/null | wc -l | tr -d ' ')
86
+ DOMAIN_MODELS=$((DOMAIN_MODELS + MODELS))
87
+ fi
88
+ done
89
+ if [ "$DOMAIN_MODELS" -gt 0 ]; then
90
+ pass "Domain models found ($DOMAIN_MODELS files with struct definitions)"
91
+ else
92
+ # Check all of src as fallback
93
+ ALL_MODELS=$(grep -rlE '^\s*(pub\s+)?struct\s' src/ 2>/dev/null | wc -l | tr -d ' ')
94
+ if [ "$ALL_MODELS" -gt 0 ]; then
95
+ pass "Struct definitions found in src/ ($ALL_MODELS files)"
96
+ else
97
+ warn "No struct definitions found"
98
+ fi
99
+ fi
100
+
101
+ # ---------------------------------------------------------------------------
102
+ # Dependency direction
103
+ # ---------------------------------------------------------------------------
104
+ echo ""
105
+ echo "--- Dependency Direction ---"
106
+ if [ -d "src/domain" ]; then
107
+ DOMAIN_DEPS=$(grep -rE 'use\s+crate::infrastructure' src/domain/ 2>/dev/null | wc -l | tr -d ' ')
108
+ if [ "$DOMAIN_DEPS" -eq 0 ]; then
109
+ pass "Domain layer does not depend on infrastructure"
110
+ else
111
+ fail "Domain layer depends on infrastructure ($DOMAIN_DEPS violations)"
112
+ fi
113
+ else
114
+ warn "No src/domain/ directory (cannot check dependency direction)"
115
+ fi
116
+
117
+ # ---------------------------------------------------------------------------
118
+ # Error handling
119
+ # ---------------------------------------------------------------------------
120
+ echo ""
121
+ echo "--- Error Handling ---"
122
+ HAS_ERROR_TYPES=0
123
+ if command -v cargo &>/dev/null; then
124
+ # Check for thiserror, eyre, or anyhow in Cargo.toml
125
+ if grep -qE '(thiserror|eyre|anyhow)' Cargo.toml 2>/dev/null; then
126
+ HAS_ERROR_TYPES=1
127
+ fi
128
+ fi
129
+ # Also check for custom error enum definitions
130
+ CUSTOM_ERRORS=$(grep -rE 'enum\s+\w*Error' src/ 2>/dev/null | wc -l | tr -d ' ')
131
+ if [ "$HAS_ERROR_TYPES" -eq 1 ] || [ "$CUSTOM_ERRORS" -gt 0 ]; then
132
+ pass "Custom error handling detected"
133
+ else
134
+ warn "No custom error types found (consider thiserror, eyre, or anyhow)"
135
+ fi
136
+
137
+ # ---------------------------------------------------------------------------
138
+ # Trait definitions
139
+ # ---------------------------------------------------------------------------
140
+ echo ""
141
+ echo "--- Trait Definitions ---"
142
+ TRAITS=$(grep -rE '^\s*(pub\s+)?trait\s+' src/ 2>/dev/null | wc -l | tr -d ' ')
143
+ if [ "$TRAITS" -gt 0 ]; then
144
+ pass "Trait definitions found ($TRAITS interfaces)"
145
+ else
146
+ warn "No trait definitions found (consider using traits for interfaces)"
147
+ fi
148
+
149
+ # ---------------------------------------------------------------------------
150
+ # Crate structure
151
+ # ---------------------------------------------------------------------------
152
+ echo ""
153
+ echo "--- Crate Structure ---"
154
+ HAS_LIB=0
155
+ HAS_MAIN=0
156
+ [ -f "src/lib.rs" ] && HAS_LIB=1
157
+ [ -f "src/main.rs" ] && HAS_MAIN=1
158
+ if [ "$HAS_LIB" -eq 1 ] && [ "$HAS_MAIN" -eq 1 ]; then
159
+ pass "Both lib.rs and main.rs present (library + binary)"
160
+ elif [ "$HAS_LIB" -eq 1 ]; then
161
+ pass "Library crate detected (lib.rs)"
162
+ elif [ "$HAS_MAIN" -eq 1 ]; then
163
+ pass "Binary crate detected (main.rs)"
164
+ else
165
+ warn "No lib.rs or main.rs found"
166
+ fi
167
+
168
+ # ---------------------------------------------------------------------------
169
+ # Summary
170
+ # ---------------------------------------------------------------------------
171
+ echo ""
172
+ echo "============================================"
173
+ echo " Summary"
174
+ echo "============================================"
175
+ echo -e " Passed: ${GREEN}${PASS_COUNT}${NC}"
176
+ echo -e " Failed: ${RED}${#ERRORS[@]}${NC}"
177
+ echo ""
178
+
179
+ if [ ${#ERRORS[@]} -gt 0 ]; then
180
+ echo "FAILURES:"
181
+ for err in "${ERRORS[@]}"; do
182
+ echo " - $err"
183
+ done
184
+ exit 1
185
+ fi
186
+
187
+ echo -e "${GREEN}Architecture validation completed.${NC}"
188
+ exit 0
@@ -0,0 +1,146 @@
1
+ #!/usr/bin/env bash
2
+ # ============================================================================
3
+ # validate-canonical.sh — Rust
4
+ # ============================================================================
5
+ set -euo pipefail
6
+
7
+ PASS_COUNT=0
8
+ ERRORS=()
9
+ WARNINGS=()
10
+
11
+ RED='\033[0;31m'
12
+ GREEN='\033[0;32m'
13
+ YELLOW='\033[1;33m'
14
+ NC='\033[0m'
15
+
16
+ pass() { echo -e "${GREEN}✅ PASS${NC} $1"; PASS_COUNT=$((PASS_COUNT + 1)); }
17
+ fail() { echo -e "${RED}❌ FAIL${NC} $1"; ERRORS+=("$1"); }
18
+ warn() { echo -e "${YELLOW}⚠️ WARN${NC} $1"; WARNINGS+=("$1"); }
19
+
20
+ echo "============================================"
21
+ echo " Canonical Reference Validation (Rust)"
22
+ echo "============================================"
23
+ echo ""
24
+
25
+ if [ ! -f "Cargo.toml" ]; then
26
+ warn "No Cargo.toml found (skipping Rust canonical validation)"
27
+ echo ""
28
+ echo "============================================"
29
+ echo " Summary"
30
+ echo "============================================"
31
+ echo -e " Passed: ${GREEN}${PASS_COUNT}${NC}"
32
+ echo -e " Failed: ${RED}${#ERRORS[@]}${NC}"
33
+ echo ""
34
+ echo -e "${GREEN}No Rust project detected, nothing to validate.${NC}"
35
+ exit 0
36
+ fi
37
+
38
+ # ---------------------------------------------------------------------------
39
+ # Architecture reference tracing
40
+ # ---------------------------------------------------------------------------
41
+ echo "--- Architecture Reference Tracing ---"
42
+ CANONICAL_REFS=0
43
+ TOTAL_RS=0
44
+
45
+ # Count all Rust source files
46
+ TOTAL_RS=$(find src -name "*.rs" 2>/dev/null | wc -l | tr -d ' ')
47
+ if [ "$TOTAL_RS" -gt 0 ]; then
48
+ # Look for canonical reference patterns in doc comments
49
+ CANONICAL_REFS=$(grep -rE '(///\s*Canonical:|//!\s*@canonical|///\s*Reference:)' src/ 2>/dev/null | wc -l | tr -d ' ')
50
+ if [ "$CANONICAL_REFS" -gt 0 ]; then
51
+ PCT=$((CANONICAL_REFS * 100 / TOTAL_RS))
52
+ pass "Canonical references found: ${CANONICAL_REFS} files (${PCT}% of ${TOTAL_RS} Rust files)"
53
+ else
54
+ fail "No canonical references found in Rust doc comments"
55
+ fi
56
+ else
57
+ warn "No Rust source files in src/"
58
+ fi
59
+
60
+ # ---------------------------------------------------------------------------
61
+ # Module-to-implementation mapping
62
+ # ---------------------------------------------------------------------------
63
+ echo ""
64
+ echo "--- Module-to-Implementation Mapping ---"
65
+ if [ -d ".pi/architecture/modules" ]; then
66
+ MODULE_FILES=$(find .pi/architecture/modules -name "*.md" 2>/dev/null)
67
+ MAPPED=0
68
+ TOTAL_MODULES=0
69
+ for mf in $MODULE_FILES; do
70
+ TOTAL_MODULES=$((TOTAL_MODULES + 1))
71
+ MODULE_NAME=$(basename "$mf" .md)
72
+ # Check if a matching Rust file exists (exact match or containing module name)
73
+ if find src -name "*${MODULE_NAME}*" -name "*.rs" 2>/dev/null | grep -q .; then
74
+ MAPPED=$((MAPPED + 1))
75
+ fi
76
+ done
77
+ if [ "$TOTAL_MODULES" -gt 0 ] && [ "$MAPPED" -eq "$TOTAL_MODULES" ]; then
78
+ pass "All $TOTAL_MODULES architecture modules mapped to implementation"
79
+ elif [ "$MAPPED" -gt 0 ]; then
80
+ pass "$MAPPED/$TOTAL_MODULES architecture modules mapped to implementation"
81
+ else
82
+ fail "No architecture modules mapped to Rust implementation files"
83
+ fi
84
+ else
85
+ warn "No .pi/architecture/modules/ directory (no module mapping to validate)"
86
+ fi
87
+
88
+ # ---------------------------------------------------------------------------
89
+ # Module documentation
90
+ # ---------------------------------------------------------------------------
91
+ echo ""
92
+ echo "--- Module Documentation ---"
93
+ if [ "$TOTAL_RS" -gt 0 ]; then
94
+ MOD_DOCS=$(grep -rlE '^//!\s' src/ 2>/dev/null | wc -l | tr -d ' ')
95
+ if [ "$MOD_DOCS" -gt 0 ]; then
96
+ PCT=$((MOD_DOCS * 100 / TOTAL_RS))
97
+ pass "Module documentation found in ${MOD_DOCS}/${TOTAL_RS} files (${PCT}%)"
98
+ else
99
+ warn "No module-level doc comments found (use //! for module docs)"
100
+ fi
101
+ else
102
+ warn "No Rust source files to check for documentation"
103
+ fi
104
+
105
+ # ---------------------------------------------------------------------------
106
+ # ADR linkage
107
+ # ---------------------------------------------------------------------------
108
+ echo ""
109
+ echo "--- ADR Linkage ---"
110
+ if [ -d ".pi/architecture/decisions" ]; then
111
+ ADR_FILES=$(find .pi/architecture/decisions -name "*.md" 2>/dev/null | wc -l | tr -d ' ')
112
+ if [ "$ADR_FILES" -gt 0 ]; then
113
+ ADR_REFS=$(grep -rE '///\s*ADR-' src/ 2>/dev/null | wc -l | tr -d ' ')
114
+ if [ "$ADR_REFS" -gt 0 ]; then
115
+ pass "ADR references found in code ($ADR_REFS references)"
116
+ else
117
+ warn "No ADR references in code (consider adding /// ADR-NNN comments)"
118
+ fi
119
+ else
120
+ warn "No ADR files found in .pi/architecture/decisions/"
121
+ fi
122
+ else
123
+ warn "No .pi/architecture/decisions/ directory (no ADRs to link)"
124
+ fi
125
+
126
+ # ---------------------------------------------------------------------------
127
+ # Summary
128
+ # ---------------------------------------------------------------------------
129
+ echo ""
130
+ echo "============================================"
131
+ echo " Summary"
132
+ echo "============================================"
133
+ echo -e " Passed: ${GREEN}${PASS_COUNT}${NC}"
134
+ echo -e " Failed: ${RED}${#ERRORS[@]}${NC}"
135
+ echo ""
136
+
137
+ if [ ${#ERRORS[@]} -gt 0 ]; then
138
+ echo "FAILURES:"
139
+ for err in "${ERRORS[@]}"; do
140
+ echo " - $err"
141
+ done
142
+ exit 1
143
+ fi
144
+
145
+ echo -e "${GREEN}Canonical reference validation completed.${NC}"
146
+ exit 0
@@ -0,0 +1,147 @@
1
+ #!/usr/bin/env bash
2
+ # ============================================================================
3
+ # validate-ci.sh — Rust
4
+ # ============================================================================
5
+ set -euo pipefail
6
+
7
+ PASS_COUNT=0
8
+ ERRORS=()
9
+ WARNINGS=()
10
+
11
+ RED='\033[0;31m'
12
+ GREEN='\033[0;32m'
13
+ YELLOW='\033[1;33m'
14
+ NC='\033[0m'
15
+
16
+ pass() { echo -e "${GREEN}✅ PASS${NC} $1"; PASS_COUNT=$((PASS_COUNT + 1)); }
17
+ fail() { echo -e "${RED}❌ FAIL${NC} $1"; ERRORS+=("$1"); }
18
+ warn() { echo -e "${YELLOW}⚠️ WARN${NC} $1"; WARNINGS+=("$1"); }
19
+
20
+ echo "============================================"
21
+ echo " CI/MR Validation (Rust)"
22
+ echo "============================================"
23
+ echo ""
24
+
25
+ # ---------------------------------------------------------------------------
26
+ # Cargo.toml detection
27
+ # ---------------------------------------------------------------------------
28
+ echo "--- Project Detection ---"
29
+ if [ -f "Cargo.toml" ]; then
30
+ pass "Cargo.toml found"
31
+ # Extract workspace info if available
32
+ if grep -q '^\[workspace\]' Cargo.toml; then
33
+ echo " Workspace project detected"
34
+ fi
35
+ else
36
+ fail "No Cargo.toml found (not a Rust project)"
37
+ echo ""
38
+ echo "============================================"
39
+ echo " Summary"
40
+ echo "============================================"
41
+ echo -e " Passed: ${GREEN}${PASS_COUNT}${NC}"
42
+ echo -e " Failed: ${RED}${#ERRORS[@]}${NC}"
43
+ echo ""
44
+ if [ ${#ERRORS[@]} -gt 0 ]; then
45
+ echo "FAILURES:"
46
+ for err in "${ERRORS[@]}"; do
47
+ echo " - $err"
48
+ done
49
+ fi
50
+ exit 1
51
+ fi
52
+
53
+ # ---------------------------------------------------------------------------
54
+ # Build
55
+ # ---------------------------------------------------------------------------
56
+ echo ""
57
+ echo "--- Build ---"
58
+ if cargo build --quiet 2>/dev/null; then
59
+ pass "Build succeeded"
60
+ else
61
+ fail "Build failed"
62
+ fi
63
+
64
+ # ---------------------------------------------------------------------------
65
+ # Tests
66
+ # ---------------------------------------------------------------------------
67
+ echo ""
68
+ echo "--- Tests ---"
69
+ if cargo test --quiet 2>/dev/null; then
70
+ pass "All tests passed"
71
+ else
72
+ fail "Tests failed"
73
+ fi
74
+
75
+ # ---------------------------------------------------------------------------
76
+ # Lint
77
+ # ---------------------------------------------------------------------------
78
+ echo ""
79
+ echo "--- Lint ---"
80
+ if command -v cargo &>/dev/null && cargo clippy --version &>/dev/null; then
81
+ if cargo clippy --all-targets -- -D warnings 2>/dev/null; then
82
+ pass "Clippy passed"
83
+ else
84
+ fail "Clippy found issues"
85
+ fi
86
+ else
87
+ warn "cargo clippy not available, skipping lint"
88
+ fi
89
+
90
+ # ---------------------------------------------------------------------------
91
+ # Format
92
+ # ---------------------------------------------------------------------------
93
+ echo ""
94
+ echo "--- Format ---"
95
+ if command -v cargo &>/dev/null && cargo fmt --version &>/dev/null; then
96
+ if cargo fmt --check 2>/dev/null; then
97
+ pass "Format check passed"
98
+ else
99
+ fail "Format check failed (run 'cargo fmt')"
100
+ fi
101
+ else
102
+ warn "cargo fmt not available, skipping format check"
103
+ fi
104
+
105
+ # ---------------------------------------------------------------------------
106
+ # Security Audit
107
+ # ---------------------------------------------------------------------------
108
+ echo ""
109
+ echo "--- Security Audit ---"
110
+ if command -v cargo &>/dev/null && cargo audit --version &>/dev/null; then
111
+ AUDIT_OUT=$(cargo audit 2>&1 || true)
112
+ if echo "$AUDIT_OUT" | grep -q "No advisabilities found\|No known vulnerabilities\|info"; then
113
+ pass "No known vulnerabilities"
114
+ else
115
+ warn "cargo audit reported findings (review manually)"
116
+ fi
117
+ elif command -v cargo &>/dev/null && cargo deny --version &>/dev/null; then
118
+ if cargo deny check 2>/dev/null; then
119
+ pass "cargo deny passed"
120
+ else
121
+ warn "cargo deny reported issues (review manually)"
122
+ fi
123
+ else
124
+ warn "No Rust audit tools available (cargo audit / cargo deny), skipping vulnerability audit"
125
+ fi
126
+
127
+ # ---------------------------------------------------------------------------
128
+ # Summary
129
+ # ---------------------------------------------------------------------------
130
+ echo ""
131
+ echo "============================================"
132
+ echo " Summary"
133
+ echo "============================================"
134
+ echo -e " Passed: ${GREEN}${PASS_COUNT}${NC}"
135
+ echo -e " Failed: ${RED}${#ERRORS[@]}${NC}"
136
+ echo ""
137
+
138
+ if [ ${#ERRORS[@]} -gt 0 ]; then
139
+ echo "FAILURES:"
140
+ for err in "${ERRORS[@]}"; do
141
+ echo " - $err"
142
+ done
143
+ exit 1
144
+ fi
145
+
146
+ echo -e "${GREEN}All CI checks passed.${NC}"
147
+ exit 0
@@ -0,0 +1,149 @@
1
+ #!/usr/bin/env bash
2
+ # ============================================================================
3
+ # validate-integration.sh — Rust
4
+ # ============================================================================
5
+ set -euo pipefail
6
+
7
+ PASS_COUNT=0
8
+ ERRORS=()
9
+ WARNINGS=()
10
+
11
+ RED='\033[0;31m'
12
+ GREEN='\033[0;32m'
13
+ YELLOW='\033[1;33m'
14
+ NC='\033[0m'
15
+
16
+ pass() { echo -e "${GREEN}✅ PASS${NC} $1"; PASS_COUNT=$((PASS_COUNT + 1)); }
17
+ fail() { echo -e "${RED}❌ FAIL${NC} $1"; ERRORS+=("$1"); }
18
+ warn() { echo -e "${YELLOW}⚠️ WARN${NC} $1"; WARNINGS+=("$1"); }
19
+
20
+ echo "============================================"
21
+ echo " Integration Validation (Rust)"
22
+ echo "============================================"
23
+ echo ""
24
+
25
+ if [ ! -f "Cargo.toml" ]; then
26
+ warn "No Cargo.toml found (skipping Rust integration validation)"
27
+ echo ""
28
+ echo "============================================"
29
+ echo " Summary"
30
+ echo "============================================"
31
+ echo -e " Passed: ${GREEN}${PASS_COUNT}${NC}"
32
+ echo -e " Failed: ${RED}${#ERRORS[@]}${NC}"
33
+ echo ""
34
+ echo -e "${GREEN}No Rust project detected, nothing to validate.${NC}"
35
+ exit 0
36
+ fi
37
+
38
+ # ---------------------------------------------------------------------------
39
+ # Integration test runner
40
+ # ---------------------------------------------------------------------------
41
+ echo "--- Integration Test Runner ---"
42
+ if [ -d "tests" ]; then
43
+ INT_TEST_FILES=$(find tests -name "*.rs" 2>/dev/null | wc -l | tr -d ' ')
44
+ if [ "$INT_TEST_FILES" -gt 0 ]; then
45
+ if cargo test --test '*' --quiet 2>/dev/null; then
46
+ pass "Integration tests passed ($INT_TEST_FILES test files)"
47
+ else
48
+ fail "Integration tests failed"
49
+ fi
50
+ else
51
+ warn "tests/ directory exists but contains no .rs files"
52
+ fi
53
+ else
54
+ warn "No tests/ directory found (no integration tests to run)"
55
+ fi
56
+
57
+ # ---------------------------------------------------------------------------
58
+ # Docker/Compose services
59
+ # ---------------------------------------------------------------------------
60
+ echo ""
61
+ echo "--- Docker/Compose ---"
62
+ if [ -f "docker-compose.yml" ] || [ -f "docker-compose.yaml" ]; then
63
+ warn "Docker Compose detected — integration tests may require services (run docker-compose up)"
64
+ else
65
+ pass "No Docker Compose configuration found"
66
+ fi
67
+
68
+ # ---------------------------------------------------------------------------
69
+ # Contract tests
70
+ # ---------------------------------------------------------------------------
71
+ echo ""
72
+ echo "--- Contract Tests ---"
73
+ CONTRACT_TESTS=$(find . -name "*contract*test*.rs" -o -name "*test*contract*.rs" 2>/dev/null | wc -l | tr -d ' ')
74
+ if [ "$CONTRACT_TESTS" -gt 0 ]; then
75
+ pass "Contract test files found ($CONTRACT_TESTS)"
76
+ else
77
+ warn "No contract test files found (consider adding contract tests for external interfaces)"
78
+ fi
79
+
80
+ # ---------------------------------------------------------------------------
81
+ # Mock/stub detection
82
+ # ---------------------------------------------------------------------------
83
+ echo ""
84
+ echo "--- Mock/Stub Detection ---"
85
+ MOCK_LIBS=0
86
+ if grep -qE '^\s*(mockall|mockito|wiremock)\s*=' Cargo.toml 2>/dev/null; then
87
+ MOCK_LIBS=1
88
+ pass "Mocking library detected in Cargo.toml"
89
+ fi
90
+ if [ "$MOCK_LIBS" -eq 0 ]; then
91
+ # Also check for manual mock patterns
92
+ if grep -rqE '#\[mockall|MockServer|mock_' --include="*.rs" . 2>/dev/null; then
93
+ pass "Mocking patterns found in source"
94
+ else
95
+ warn "No mocking library or patterns detected (mockall, mockito, or wiremock)"
96
+ fi
97
+ fi
98
+
99
+ # ---------------------------------------------------------------------------
100
+ # Database integration
101
+ # ---------------------------------------------------------------------------
102
+ echo ""
103
+ echo "--- Database Integration ---"
104
+ DB_INTEG=$(find . -name "*_integration_test.rs" -o -name "*db*test*.rs" 2>/dev/null | wc -l | tr -d ' ')
105
+ if [ "$DB_INTEG" -gt 0 ]; then
106
+ pass "Database integration test files found ($DB_INTEG)"
107
+ else
108
+ warn "No database integration test files found"
109
+ fi
110
+
111
+ # ---------------------------------------------------------------------------
112
+ # HTTP integration
113
+ # ---------------------------------------------------------------------------
114
+ echo ""
115
+ echo "--- HTTP Integration ---"
116
+ HTTP_TEST=0
117
+ if grep -rqE 'axum::test|reqwest|actix_web::test' --include="*.rs" . 2>/dev/null; then
118
+ HTTP_TEST=1
119
+ pass "HTTP integration testing detected"
120
+ fi
121
+ if grep -qE '^\s*(axum|actix-web|warp|rocket)\s*=' Cargo.toml 2>/dev/null; then
122
+ if [ "$HTTP_TEST" -eq 0 ]; then
123
+ warn "HTTP framework detected but no HTTP test imports found (consider adding integration tests)"
124
+ fi
125
+ else
126
+ pass "No HTTP framework dependency found"
127
+ fi
128
+
129
+ # ---------------------------------------------------------------------------
130
+ # Summary
131
+ # ---------------------------------------------------------------------------
132
+ echo ""
133
+ echo "============================================"
134
+ echo " Summary"
135
+ echo "============================================"
136
+ echo -e " Passed: ${GREEN}${PASS_COUNT}${NC}"
137
+ echo -e " Failed: ${RED}${#ERRORS[@]}${NC}"
138
+ echo ""
139
+
140
+ if [ ${#ERRORS[@]} -gt 0 ]; then
141
+ echo "FAILURES:"
142
+ for err in "${ERRORS[@]}"; do
143
+ echo " - $err"
144
+ done
145
+ exit 1
146
+ fi
147
+
148
+ echo -e "${GREEN}Integration validation completed.${NC}"
149
+ exit 0