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.
- package/LICENSE +21 -0
- package/README.md +463 -0
- package/dist/cli.js +12958 -0
- package/dist/exports.js +12765 -0
- package/package.json +61 -0
- package/templates/languages/go-patterns.md +411 -0
- package/templates/languages/java-patterns.md +545 -0
- package/templates/languages/python-patterns.md +312 -0
- package/templates/languages/rust-patterns.md +232 -0
- package/templates/languages/typescript-patterns.md +313 -0
- package/templates/pi/INDEX.md +437 -0
- package/templates/pi/agent/AGENTS.md +166 -0
- package/templates/pi/agents/architecture-coordinator.md +40 -0
- package/templates/pi/agents/architecture-validator.md +36 -0
- package/templates/pi/agents/bootstrap-implementer.md +37 -0
- package/templates/pi/agents/issue-factory.md +31 -0
- package/templates/pi/agents/operations-validator.md +32 -0
- package/templates/pi/agents/security-validator.md +33 -0
- package/templates/pi/architecture/CHANGELOG.md +78 -0
- package/templates/pi/architecture/decisions/ADR-template.md +76 -0
- package/templates/pi/architecture/diagrams/system-overview.md +159 -0
- package/templates/pi/architecture/modules/module-template.md +152 -0
- package/templates/pi/context/checklists.md +91 -0
- package/templates/pi/context/domain-workflow.md +180 -0
- package/templates/pi/context/output-formats.md +135 -0
- package/templates/pi/context/patterns-base.md +47 -0
- package/templates/pi/context/patterns.md +38 -0
- package/templates/pi/context/project.md +88 -0
- package/templates/pi/domain/exploration.md +93 -0
- package/templates/pi/domain/ubiquitous-language.md +24 -0
- package/templates/pi/extensions/architect-lib/generators.ts +528 -0
- package/templates/pi/extensions/architect-lib/helpers.ts +344 -0
- package/templates/pi/extensions/architect-lib/types.ts +117 -0
- package/templates/pi/extensions/architect.ts +1425 -0
- package/templates/pi/extensions/ask-user-question.ts +579 -0
- package/templates/pi/extensions/bash-guard.ts +556 -0
- package/templates/pi/extensions/config-reload.ts +115 -0
- package/templates/pi/extensions/coordinator.ts +304 -0
- package/templates/pi/extensions/curator.ts +543 -0
- package/templates/pi/extensions/domain-explorer.ts +990 -0
- package/templates/pi/extensions/filechanges.ts +656 -0
- package/templates/pi/extensions/goal-loop.ts +717 -0
- package/templates/pi/extensions/hooks.ts +452 -0
- package/templates/pi/extensions/kanban.ts +547 -0
- package/templates/pi/extensions/pipeline.ts +1246 -0
- package/templates/pi/extensions/plan-mode.ts +209 -0
- package/templates/pi/extensions/project-scaffolder.ts +284 -0
- package/templates/pi/extensions/read-only-mode.ts +192 -0
- package/templates/pi/extensions/redaction.ts +128 -0
- package/templates/pi/extensions/session-persistence.ts +174 -0
- package/templates/pi/extensions/slash-commands.ts +229 -0
- package/templates/pi/extensions/snippets.ts +201 -0
- package/templates/pi/extensions/validation-runner.ts +100 -0
- package/templates/pi/github/agents/architecture-coordinator.agent.md +27 -0
- package/templates/pi/github/agents/architecture-validator.agent.md +20 -0
- package/templates/pi/github/agents/bootstrap-implementer.agent.md +20 -0
- package/templates/pi/github/agents/epic-planner.agent.md +70 -0
- package/templates/pi/github/agents/issue-factory.agent.md +20 -0
- package/templates/pi/github/agents/operations-validator.agent.md +20 -0
- package/templates/pi/github/agents/security-validator.agent.md +20 -0
- package/templates/pi/github/copilot/settings.json +16 -0
- package/templates/pi/github/copilot-instructions.md +155 -0
- package/templates/pi/github/instructions/architecture.instructions.md +71 -0
- package/templates/pi/github/instructions/validation.instructions.md +69 -0
- package/templates/pi/github/workflows/01-planning-workflow.md +75 -0
- package/templates/pi/github/workflows/02-issue-generation-workflow.md +69 -0
- package/templates/pi/github/workflows/03-implementation-workflow.md +80 -0
- package/templates/pi/github/workflows/04-validation-workflow.md +68 -0
- package/templates/pi/preflight_report.json +99 -0
- package/templates/pi/prompts/blueprint-update.md +262 -0
- package/templates/pi/prompts/blueprint-validate.md +218 -0
- package/templates/pi/prompts/bug-fix.md +50 -0
- package/templates/pi/prompts/ci-blueprint.md +131 -0
- package/templates/pi/prompts/context-refresh.md +258 -0
- package/templates/pi/prompts/epic-plan.md +356 -0
- package/templates/pi/prompts/epic-template.md +186 -0
- package/templates/pi/prompts/feature-development.md +131 -0
- package/templates/pi/prompts/git-issues.md +243 -0
- package/templates/pi/prompts/hotfix.md +71 -0
- package/templates/pi/prompts/issue-closeout.md +342 -0
- package/templates/pi/prompts/issue-draft.md +218 -0
- package/templates/pi/prompts/issue-implementation-series.md +173 -0
- package/templates/pi/prompts/issue-merge.md +372 -0
- package/templates/pi/prompts/issue-template-set.md +392 -0
- package/templates/pi/prompts/issue-template.md +207 -0
- package/templates/pi/prompts/pattern-extract.md +269 -0
- package/templates/pi/prompts/plan-to-issues.md +430 -0
- package/templates/pi/prompts/refactoring.md +82 -0
- package/templates/pi/prompts/scope-analyzer.md +254 -0
- package/templates/pi/prompts/sync-check.md +230 -0
- package/templates/pi/scripts/categorize-issues.sh +171 -0
- package/templates/pi/scripts/ci/check_architecture_conformance.sh +748 -0
- package/templates/pi/scripts/ci/check_planning_packet.py +228 -0
- package/templates/pi/scripts/ci/run_hardening_stages.sh +264 -0
- package/templates/pi/scripts/ci/run_preflight.sh +649 -0
- package/templates/pi/scripts/ci/run_stage.sh +193 -0
- package/templates/pi/scripts/ci/stage_docs_policy.sh +82 -0
- package/templates/pi/scripts/ci/stage_integration.sh +3 -0
- package/templates/pi/scripts/ci/stage_lint.sh +130 -0
- package/templates/pi/scripts/ci/stage_migration_verify.sh +3 -0
- package/templates/pi/scripts/ci/stage_package_build.sh +3 -0
- package/templates/pi/scripts/ci/stage_release_readiness.sh +3 -0
- package/templates/pi/scripts/ci/stage_remaining.sh +242 -0
- package/templates/pi/scripts/ci/stage_security.sh +3 -0
- package/templates/pi/scripts/ci/stage_static_analysis.sh +114 -0
- package/templates/pi/scripts/ci/stage_unit.sh +119 -0
- package/templates/pi/scripts/ci/validate_agent_output.py +181 -0
- package/templates/pi/scripts/ci/validate_agent_output.sh +243 -0
- package/templates/pi/scripts/create-feature-branch.sh +136 -0
- package/templates/pi/scripts/create-mr.sh +117 -0
- package/templates/pi/scripts/fetch-issues.sh +131 -0
- package/templates/pi/scripts/generate-architecture.sh +161 -0
- package/templates/pi/scripts/git/close-epic.sh +69 -0
- package/templates/pi/scripts/git/close-issue.sh +35 -0
- package/templates/pi/scripts/git/create-tracking-issue.sh +174 -0
- package/templates/pi/scripts/git/link-issue-to-epic.sh +51 -0
- package/templates/pi/scripts/git/update-tracking-issue.sh +66 -0
- package/templates/pi/scripts/languages/go/validate-architecture.sh +139 -0
- package/templates/pi/scripts/languages/go/validate-canonical.sh +129 -0
- package/templates/pi/scripts/languages/go/validate-ci.sh +132 -0
- package/templates/pi/scripts/languages/go/validate-integration.sh +156 -0
- package/templates/pi/scripts/languages/go/validate-operations.sh +146 -0
- package/templates/pi/scripts/languages/go/validate-security.sh +135 -0
- package/templates/pi/scripts/languages/go/validate-tests.sh +125 -0
- package/templates/pi/scripts/languages/java/validate-annotations.sh +185 -0
- package/templates/pi/scripts/languages/java/validate-architecture.sh +159 -0
- package/templates/pi/scripts/languages/java/validate-canonical.sh +114 -0
- package/templates/pi/scripts/languages/java/validate-ci.sh +269 -0
- package/templates/pi/scripts/languages/java/validate-integration.sh +149 -0
- package/templates/pi/scripts/languages/java/validate-operations.sh +142 -0
- package/templates/pi/scripts/languages/java/validate-security.sh +174 -0
- package/templates/pi/scripts/languages/java/validate-spring-architecture.sh +227 -0
- package/templates/pi/scripts/languages/java/validate-tests.sh +159 -0
- package/templates/pi/scripts/languages/python/validate-architecture.sh +99 -0
- package/templates/pi/scripts/languages/python/validate-canonical.sh +124 -0
- package/templates/pi/scripts/languages/python/validate-ci.sh +130 -0
- package/templates/pi/scripts/languages/python/validate-integration.sh +119 -0
- package/templates/pi/scripts/languages/python/validate-operations.sh +107 -0
- package/templates/pi/scripts/languages/python/validate-security.sh +68 -0
- package/templates/pi/scripts/languages/python/validate-tests.sh +102 -0
- package/templates/pi/scripts/languages/rust/validate-architecture.sh +188 -0
- package/templates/pi/scripts/languages/rust/validate-canonical.sh +146 -0
- package/templates/pi/scripts/languages/rust/validate-ci.sh +147 -0
- package/templates/pi/scripts/languages/rust/validate-integration.sh +149 -0
- package/templates/pi/scripts/languages/rust/validate-operations.sh +154 -0
- package/templates/pi/scripts/languages/rust/validate-security.sh +153 -0
- package/templates/pi/scripts/languages/rust/validate-tests.sh +150 -0
- package/templates/pi/scripts/languages/typescript/validate-architecture.sh +157 -0
- package/templates/pi/scripts/languages/typescript/validate-canonical.sh +135 -0
- package/templates/pi/scripts/languages/typescript/validate-ci.sh +244 -0
- package/templates/pi/scripts/languages/typescript/validate-integration.sh +166 -0
- package/templates/pi/scripts/languages/typescript/validate-operations.sh +162 -0
- package/templates/pi/scripts/languages/typescript/validate-security.sh +169 -0
- package/templates/pi/scripts/languages/typescript/validate-tests.sh +158 -0
- package/templates/pi/scripts/merge-mr.sh +95 -0
- package/templates/pi/scripts/mr-validation.sh +228 -0
- package/templates/pi/scripts/validate-architecture-readiness.sh +153 -0
- package/templates/pi/scripts/validate-architecture.sh +22 -0
- package/templates/pi/scripts/validate-canonical.sh +22 -0
- package/templates/pi/scripts/validate-ci.sh +37 -0
- package/templates/pi/scripts/validate-integration.sh +22 -0
- package/templates/pi/scripts/validate-operations.sh +22 -0
- package/templates/pi/scripts/validate-security.sh +22 -0
- package/templates/pi/scripts/validate-tests.sh +22 -0
- package/templates/pi/scripts/validate-ubiquitous-language.sh +291 -0
- package/templates/pi/scripts/validation-cache.sh +139 -0
- package/templates/pi/skills/agents/architecture-coordinator.md +178 -0
- package/templates/pi/skills/agents/architecture-generator.md +79 -0
- package/templates/pi/skills/agents/architecture-validator.md +74 -0
- package/templates/pi/skills/agents/ci-mr-validator.md +46 -0
- package/templates/pi/skills/agents/code-developer.md +76 -0
- package/templates/pi/skills/agents/commit.md +46 -0
- package/templates/pi/skills/agents/curator.md +71 -0
- package/templates/pi/skills/agents/debug.md +59 -0
- package/templates/pi/skills/agents/documentation-maintainer.md +36 -0
- package/templates/pi/skills/agents/goal-loop.md +125 -0
- package/templates/pi/skills/agents/hooks.md +122 -0
- package/templates/pi/skills/agents/integration-validator.md +35 -0
- package/templates/pi/skills/agents/issue-creator.md +75 -0
- package/templates/pi/skills/agents/issue-factory.md +143 -0
- package/templates/pi/skills/agents/kanban.md +85 -0
- package/templates/pi/skills/agents/land.md +59 -0
- package/templates/pi/skills/agents/operations-validator.md +43 -0
- package/templates/pi/skills/agents/pipeline.md +113 -0
- package/templates/pi/skills/agents/plan-mode.md +77 -0
- package/templates/pi/skills/agents/pull.md +40 -0
- package/templates/pi/skills/agents/push.md +41 -0
- package/templates/pi/skills/agents/security-validator.md +85 -0
- package/templates/pi/skills/agents/session-persistence.md +119 -0
- package/templates/pi/skills/agents/slash-commands.md +117 -0
- package/templates/pi/skills/agents/snippets.md +99 -0
- package/templates/pi/skills/agents/subagent-registry.md +78 -0
- package/templates/pi/skills/agents/test-validator.md +42 -0
- package/templates/pi/skills/validators/architecture-validator.md +43 -0
- package/templates/pi/skills/validators/ci-validator.md +27 -0
- package/templates/pi/skills/validators/context-compaction.md +73 -0
- package/templates/pi/skills/validators/integration-validator.md +38 -0
- package/templates/pi/skills/validators/model-registry.md +96 -0
- package/templates/pi/skills/validators/operations-validator.md +34 -0
- package/templates/pi/skills/validators/security-guards.md +72 -0
- package/templates/pi/skills/validators/security-validator.md +41 -0
- package/templates/pi/skills/validators/system-prompt-tiers.md +69 -0
- package/templates/pi/skills/validators/test-validator.md +33 -0
- package/templates/pi/types.ts +62 -0
- package/templates/pi/validators/README.md +93 -0
- package/templates/pi/validators/default.toml +209 -0
- package/templates/pi/validators/spring.toml +142 -0
- package/templates/pi/workpad.md +53 -0
- package/templates/project/java/Dockerfile +14 -0
- package/templates/project/java/README.md +40 -0
- package/templates/project/java/pom.xml +132 -0
- package/templates/project/typescript/Dockerfile +15 -0
- package/templates/project/typescript/README.md +29 -0
- package/templates/project/typescript/package.json +23 -0
- package/templates/project/typescript/tsconfig.json +21 -0
- 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
|