moai-adk 0.9.0__py3-none-any.whl → 0.9.1__py3-none-any.whl
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.
Potentially problematic release.
This version of moai-adk might be problematic. Click here for more details.
- moai_adk/cli/commands/update.py +214 -56
- moai_adk/core/tags/pre_commit_validator.py +0 -1
- moai_adk/core/tags/reporter.py +1 -2
- moai_adk/templates/.claude/hooks/alfred/.moai/cache/version-check.json +9 -0
- moai_adk/templates/.claude/hooks/alfred/README.md +343 -0
- moai_adk/templates/.claude/hooks/alfred/TROUBLESHOOTING.md +471 -0
- moai_adk/templates/.claude/hooks/alfred/shared/core/project.py +10 -77
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/user.py +19 -0
- moai_adk/templates/.github/workflows/tag-report.yml +261 -0
- moai_adk/templates/.github/workflows/tag-validation.yml +176 -0
- moai_adk/templates/.moai/docs/quick-issue-creation-guide.md +219 -0
- moai_adk/templates/.moai/hooks/install.sh +79 -0
- moai_adk/templates/.moai/hooks/pre-commit.sh +66 -0
- moai_adk/templates/.moai/memory/GITFLOW-PROTECTION-POLICY.md +220 -0
- moai_adk/templates/.moai/memory/gitflow-protection-policy.md +30 -140
- moai_adk/templates/.moai/memory/spec-metadata.md +356 -0
- moai_adk/templates/src/moai_adk/core/__init__.py +5 -0
- moai_adk/templates/src/moai_adk/core/tags/__init__.py +86 -0
- moai_adk/templates/src/moai_adk/core/tags/ci_validator.py +433 -0
- moai_adk/templates/src/moai_adk/core/tags/cli.py +283 -0
- moai_adk/templates/src/moai_adk/core/tags/pre_commit_validator.py +354 -0
- moai_adk/templates/src/moai_adk/core/tags/reporter.py +956 -0
- moai_adk/templates/src/moai_adk/core/tags/validator.py +897 -0
- {moai_adk-0.9.0.dist-info → moai_adk-0.9.1.dist-info}/METADATA +69 -333
- {moai_adk-0.9.0.dist-info → moai_adk-0.9.1.dist-info}/RECORD +28 -13
- moai_adk/templates/.claude/hooks/alfred/core/project.py +0 -750
- moai_adk/templates/README.md +0 -256
- {moai_adk-0.9.0.dist-info → moai_adk-0.9.1.dist-info}/WHEEL +0 -0
- {moai_adk-0.9.0.dist-info → moai_adk-0.9.1.dist-info}/entry_points.txt +0 -0
- {moai_adk-0.9.0.dist-info → moai_adk-0.9.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# @CODE:DOC-TAG-004 | Component 1: Pre-commit hook installer
|
|
3
|
+
#
|
|
4
|
+
# This script installs the TAG validation pre-commit hook into .git/hooks/
|
|
5
|
+
#
|
|
6
|
+
# Usage:
|
|
7
|
+
# ./install.sh # Install hook
|
|
8
|
+
# ./install.sh --uninstall # Remove hook
|
|
9
|
+
|
|
10
|
+
set -e
|
|
11
|
+
|
|
12
|
+
# Colors
|
|
13
|
+
GREEN='\033[0;32m'
|
|
14
|
+
YELLOW='\033[1;33m'
|
|
15
|
+
RED='\033[0;31m'
|
|
16
|
+
NC='\033[0m'
|
|
17
|
+
|
|
18
|
+
# Get repository root
|
|
19
|
+
REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || echo ".")
|
|
20
|
+
HOOK_SOURCE="${REPO_ROOT}/.moai/hooks/pre-commit.sh"
|
|
21
|
+
HOOK_TARGET="${REPO_ROOT}/.git/hooks/pre-commit"
|
|
22
|
+
|
|
23
|
+
# Function to install hook
|
|
24
|
+
install_hook() {
|
|
25
|
+
echo "🔧 Installing TAG validation pre-commit hook..."
|
|
26
|
+
|
|
27
|
+
# Check if source exists
|
|
28
|
+
if [ ! -f "$HOOK_SOURCE" ]; then
|
|
29
|
+
echo -e "${RED}Error: Hook source not found at $HOOK_SOURCE${NC}"
|
|
30
|
+
exit 1
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
# Check if target already exists
|
|
34
|
+
if [ -f "$HOOK_TARGET" ]; then
|
|
35
|
+
echo -e "${YELLOW}Warning: Pre-commit hook already exists.${NC}"
|
|
36
|
+
echo "Backing up existing hook to ${HOOK_TARGET}.backup"
|
|
37
|
+
cp "$HOOK_TARGET" "${HOOK_TARGET}.backup"
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
# Create .git/hooks directory if it doesn't exist
|
|
41
|
+
mkdir -p "$(dirname "$HOOK_TARGET")"
|
|
42
|
+
|
|
43
|
+
# Copy hook
|
|
44
|
+
cp "$HOOK_SOURCE" "$HOOK_TARGET"
|
|
45
|
+
chmod +x "$HOOK_TARGET"
|
|
46
|
+
|
|
47
|
+
echo -e "${GREEN}✓ Pre-commit hook installed successfully!${NC}"
|
|
48
|
+
echo ""
|
|
49
|
+
echo "The hook will now validate TAG annotations on every commit."
|
|
50
|
+
echo ""
|
|
51
|
+
echo "To uninstall: $0 --uninstall"
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
# Function to uninstall hook
|
|
55
|
+
uninstall_hook() {
|
|
56
|
+
echo "🔧 Uninstalling TAG validation pre-commit hook..."
|
|
57
|
+
|
|
58
|
+
if [ ! -f "$HOOK_TARGET" ]; then
|
|
59
|
+
echo -e "${YELLOW}No pre-commit hook installed.${NC}"
|
|
60
|
+
exit 0
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
# Check if backup exists
|
|
64
|
+
if [ -f "${HOOK_TARGET}.backup" ]; then
|
|
65
|
+
echo "Restoring backup..."
|
|
66
|
+
mv "${HOOK_TARGET}.backup" "$HOOK_TARGET"
|
|
67
|
+
echo -e "${GREEN}✓ Backup restored.${NC}"
|
|
68
|
+
else
|
|
69
|
+
rm "$HOOK_TARGET"
|
|
70
|
+
echo -e "${GREEN}✓ Pre-commit hook removed.${NC}"
|
|
71
|
+
fi
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
# Parse command line arguments
|
|
75
|
+
if [ "$1" = "--uninstall" ]; then
|
|
76
|
+
uninstall_hook
|
|
77
|
+
else
|
|
78
|
+
install_hook
|
|
79
|
+
fi
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# @CODE:DOC-TAG-004 | Component 1: Pre-commit hook for TAG validation
|
|
3
|
+
#
|
|
4
|
+
# This hook validates TAG annotations in staged files before commit.
|
|
5
|
+
# It checks:
|
|
6
|
+
# - TAG format (@DOC:DOMAIN-TYPE-NNN)
|
|
7
|
+
# - Duplicate TAG detection
|
|
8
|
+
# - Orphan TAG detection (warnings only)
|
|
9
|
+
#
|
|
10
|
+
# Exit codes:
|
|
11
|
+
# 0 - Validation passed
|
|
12
|
+
# 1 - Validation failed (duplicates or format errors)
|
|
13
|
+
|
|
14
|
+
set -e # Exit on error
|
|
15
|
+
|
|
16
|
+
# Colors for output
|
|
17
|
+
RED='\033[0;31m'
|
|
18
|
+
GREEN='\033[0;32m'
|
|
19
|
+
YELLOW='\033[1;33m'
|
|
20
|
+
NC='\033[0m' # No Color
|
|
21
|
+
|
|
22
|
+
# Get repository root
|
|
23
|
+
REPO_ROOT=$(git rev-parse --show-toplevel)
|
|
24
|
+
|
|
25
|
+
# Check if Python module is available
|
|
26
|
+
if ! python3 -c "import moai_adk.core.tags.pre_commit_validator" 2>/dev/null; then
|
|
27
|
+
echo -e "${YELLOW}Warning: moai_adk TAG validator not found.${NC}"
|
|
28
|
+
echo "Skipping TAG validation. Install moai_adk to enable validation."
|
|
29
|
+
exit 0
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
# Get staged files
|
|
33
|
+
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM)
|
|
34
|
+
|
|
35
|
+
if [ -z "$STAGED_FILES" ]; then
|
|
36
|
+
echo -e "${GREEN}No staged files to validate.${NC}"
|
|
37
|
+
exit 0
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
echo "🔍 Validating TAG annotations in staged files..."
|
|
41
|
+
|
|
42
|
+
# Run TAG validation
|
|
43
|
+
# Pass staged files as arguments to validator
|
|
44
|
+
python3 -m moai_adk.core.tags.pre_commit_validator \
|
|
45
|
+
--files $STAGED_FILES
|
|
46
|
+
|
|
47
|
+
VALIDATION_RESULT=$?
|
|
48
|
+
|
|
49
|
+
# Check result
|
|
50
|
+
if [ $VALIDATION_RESULT -eq 0 ]; then
|
|
51
|
+
echo -e "${GREEN}✓ TAG validation passed.${NC}"
|
|
52
|
+
exit 0
|
|
53
|
+
else
|
|
54
|
+
echo -e "${RED}✗ TAG validation failed.${NC}"
|
|
55
|
+
echo ""
|
|
56
|
+
echo "Commit blocked due to TAG validation errors."
|
|
57
|
+
echo ""
|
|
58
|
+
echo "To fix:"
|
|
59
|
+
echo " 1. Fix duplicate TAGs or format errors shown above"
|
|
60
|
+
echo " 2. Stage your changes with 'git add'"
|
|
61
|
+
echo " 3. Try committing again"
|
|
62
|
+
echo ""
|
|
63
|
+
echo "To skip this validation (not recommended):"
|
|
64
|
+
echo " git commit --no-verify"
|
|
65
|
+
exit 1
|
|
66
|
+
fi
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# GitFlow Advisory Policy
|
|
2
|
+
|
|
3
|
+
**Document ID**: @DOC:GITFLOW-POLICY-001
|
|
4
|
+
**Published**: 2025-10-17
|
|
5
|
+
**Status**: Advisory (recommended, not enforced)
|
|
6
|
+
**Scope**: Personal and Team modes
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
MoAI-ADK **recommends** a GitFlow-inspired workflow. This policy shares best practices while letting teams adapt them as needed.
|
|
13
|
+
|
|
14
|
+
## Key Recommendations
|
|
15
|
+
|
|
16
|
+
### 1. Main Branch Access (Recommended)
|
|
17
|
+
|
|
18
|
+
| Recommendation | Summary | Enforcement |
|
|
19
|
+
|----------------|---------|-------------|
|
|
20
|
+
| **Merge via develop** | Prefer merging `develop` into `main` | Advisory ⚠️ |
|
|
21
|
+
| **Feature branches off develop** | Branch from `develop` and raise PRs back to `develop` | Advisory ⚠️ |
|
|
22
|
+
| **Release process** | Release flow: `develop` → `main` (release engineer encouraged) | Advisory ⚠️ |
|
|
23
|
+
| **Force push** | Warn when force-pushing, but allow it | Warning ⚠️ |
|
|
24
|
+
| **Direct push** | Warn on direct pushes to `main`, but allow them | Warning ⚠️ |
|
|
25
|
+
|
|
26
|
+
### 2. Git Workflow (Recommended)
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
┌─────────────────────────────────────────────────────────┐
|
|
30
|
+
│ RECOMMENDED GITFLOW │
|
|
31
|
+
└─────────────────────────────────────────────────────────┘
|
|
32
|
+
|
|
33
|
+
develop (recommended base branch)
|
|
34
|
+
↑ ↓
|
|
35
|
+
┌─────────────────┐
|
|
36
|
+
│ │
|
|
37
|
+
│ developer work │
|
|
38
|
+
│ │
|
|
39
|
+
↓ ↑
|
|
40
|
+
feature/SPEC-{ID} [PR: feature -> develop]
|
|
41
|
+
[code review + approval]
|
|
42
|
+
[Merge to develop]
|
|
43
|
+
|
|
44
|
+
develop (stable)
|
|
45
|
+
↓
|
|
46
|
+
│ (release manager prepares)
|
|
47
|
+
↓
|
|
48
|
+
[PR: develop -> main]
|
|
49
|
+
[CI/CD validation]
|
|
50
|
+
[tag creation]
|
|
51
|
+
↓
|
|
52
|
+
main (release)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Flexibility**: Direct pushes to `main` are still possible, but the workflow above is preferred.
|
|
56
|
+
|
|
57
|
+
## Technical Implementation
|
|
58
|
+
|
|
59
|
+
### Pre-push Hook (Advisory Mode)
|
|
60
|
+
|
|
61
|
+
**Location**: `.git/hooks/pre-push`
|
|
62
|
+
**Purpose**: Warn on `main` branch pushes without blocking them
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# When attempting to push to main:
|
|
66
|
+
⚠️ ADVISORY: Non-standard GitFlow detected
|
|
67
|
+
|
|
68
|
+
Current branch: feature/SPEC-123
|
|
69
|
+
Target branch: main
|
|
70
|
+
|
|
71
|
+
Recommended GitFlow workflow:
|
|
72
|
+
1. Work on feature/SPEC-{ID} branch (created from develop)
|
|
73
|
+
2. Push to feature/SPEC-{ID} and create PR to develop
|
|
74
|
+
3. Merge into develop after code review
|
|
75
|
+
4. When develop is stable, create PR from develop to main
|
|
76
|
+
5. Release manager merges develop -> main with tag
|
|
77
|
+
|
|
78
|
+
✓ Push will proceed (flexibility mode enabled)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Force Push Advisory
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
⚠️ ADVISORY: Force-push to main branch detected
|
|
85
|
+
|
|
86
|
+
Recommended approach:
|
|
87
|
+
- Use GitHub PR with proper code review
|
|
88
|
+
- Ensure changes are merged via fast-forward
|
|
89
|
+
|
|
90
|
+
✓ Push will proceed (flexibility mode enabled)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Workflow Examples
|
|
96
|
+
|
|
97
|
+
### Scenario 1: Standard Feature Development (Recommended)
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# 1. Sync latest code from develop
|
|
101
|
+
git checkout develop
|
|
102
|
+
git pull origin develop
|
|
103
|
+
|
|
104
|
+
# 2. Create a feature branch (from develop)
|
|
105
|
+
git checkout -b feature/SPEC-001-new-feature
|
|
106
|
+
|
|
107
|
+
# 3. Implement the change
|
|
108
|
+
# ... write code and tests ...
|
|
109
|
+
|
|
110
|
+
# 4. Commit
|
|
111
|
+
git add .
|
|
112
|
+
git commit -m "..."
|
|
113
|
+
|
|
114
|
+
# 5. Push
|
|
115
|
+
git push origin feature/SPEC-001-new-feature
|
|
116
|
+
|
|
117
|
+
# 6. Open a PR: feature/SPEC-001-new-feature -> develop
|
|
118
|
+
|
|
119
|
+
# 7. Merge into develop after review and approval
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Scenario 2: Fast Hotfix (Flexible)
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# When an urgent fix is required:
|
|
126
|
+
|
|
127
|
+
# Option 1: Recommended (via develop)
|
|
128
|
+
git checkout develop
|
|
129
|
+
git checkout -b hotfix/critical-bug
|
|
130
|
+
# ... apply fix ...
|
|
131
|
+
git push origin hotfix/critical-bug
|
|
132
|
+
# Open PRs: hotfix -> develop -> main
|
|
133
|
+
|
|
134
|
+
# Option 2: Direct fix on main (allowed, not recommended)
|
|
135
|
+
git checkout main
|
|
136
|
+
# ... apply fix ...
|
|
137
|
+
git commit -m "Fix critical bug"
|
|
138
|
+
git push origin main # ⚠️ Advisory warning appears but push continues
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Scenario 3: Release (Standard or Flexible)
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Standard approach (recommended):
|
|
145
|
+
git checkout develop
|
|
146
|
+
gh pr create --base main --head develop --title "Release v1.0.0"
|
|
147
|
+
|
|
148
|
+
# Direct push (allowed):
|
|
149
|
+
git checkout develop
|
|
150
|
+
git push origin main # ⚠️ Advisory warning appears but push continues
|
|
151
|
+
git tag -a v1.0.0 -m "Release v1.0.0"
|
|
152
|
+
git push origin v1.0.0
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Policy Modes
|
|
158
|
+
|
|
159
|
+
### Strict Mode (Legacy, Currently Disabled)
|
|
160
|
+
|
|
161
|
+
- ❌ Block direct pushes to `main`
|
|
162
|
+
- ❌ Block force pushes
|
|
163
|
+
- ❌ Block merges into `main` from any branch other than `develop`
|
|
164
|
+
|
|
165
|
+
### Advisory Mode (Active, v0.3.5+)
|
|
166
|
+
|
|
167
|
+
- ⚠️ Warn but allow direct pushes to `main`
|
|
168
|
+
- ⚠️ Warn but allow force pushes
|
|
169
|
+
- ⚠️ Recommend best practices while preserving flexibility
|
|
170
|
+
- ✅ Respect user judgment
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Recommended Checklist
|
|
175
|
+
|
|
176
|
+
Every contributor should ensure:
|
|
177
|
+
|
|
178
|
+
- [ ] `.git/hooks/pre-push` exists and is executable (755)
|
|
179
|
+
- [ ] Feature branches fork from `develop`
|
|
180
|
+
- [ ] Pull requests target `develop`
|
|
181
|
+
- [ ] Releases merge `develop` → `main`
|
|
182
|
+
|
|
183
|
+
**Verification Commands**:
|
|
184
|
+
```bash
|
|
185
|
+
ls -la .git/hooks/pre-push
|
|
186
|
+
git branch -vv
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## FAQ
|
|
192
|
+
|
|
193
|
+
**Q: Can we merge into `main` from branches other than `develop`?**
|
|
194
|
+
A: Yes. You will see an advisory warning, but the merge proceeds. The recommended path remains `develop` → `main`.
|
|
195
|
+
|
|
196
|
+
**Q: Are force pushes allowed?**
|
|
197
|
+
A: Yes. You receive a warning, but the push succeeds. Use with caution.
|
|
198
|
+
|
|
199
|
+
**Q: Can we commit/push directly to `main`?**
|
|
200
|
+
A: Yes. Expect an advisory warning, yet the push continues.
|
|
201
|
+
|
|
202
|
+
**Q: Can I disable the hook entirely?**
|
|
203
|
+
A: Yes. Remove `.git/hooks/pre-push` or strip its execute permission.
|
|
204
|
+
|
|
205
|
+
**Q: Why switch to Advisory Mode?**
|
|
206
|
+
A: To promote best practices while respecting contributor flexibility and judgment.
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Policy Change Log
|
|
211
|
+
|
|
212
|
+
| Date | Change | Owner |
|
|
213
|
+
|------|------|--------|
|
|
214
|
+
| 2025-10-17 | Initial policy drafted (Strict Mode) | git-manager |
|
|
215
|
+
| 2025-10-17 | Switched to Advisory Mode (warnings only) | git-manager |
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
**This policy is advisory—adapt it to fit your project needs.**
|
|
220
|
+
**Reach out to the team lead or release engineer for questions or suggestions.**
|
|
@@ -1,40 +1,36 @@
|
|
|
1
|
-
# GitFlow
|
|
1
|
+
# GitFlow Advisory Policy
|
|
2
2
|
|
|
3
|
-
**Document ID**: @DOC:GITFLOW-POLICY-
|
|
4
|
-
**Published**: 2025-10-17
|
|
5
|
-
**
|
|
6
|
-
**Status**: **Enforced via GitHub Branch Protection** (v0.8.3+)
|
|
3
|
+
**Document ID**: @DOC:GITFLOW-POLICY-001
|
|
4
|
+
**Published**: 2025-10-17
|
|
5
|
+
**Status**: Advisory (recommended, not enforced)
|
|
7
6
|
**Scope**: Personal and Team modes
|
|
8
7
|
|
|
9
8
|
---
|
|
10
9
|
|
|
11
10
|
## Overview
|
|
12
11
|
|
|
13
|
-
MoAI-ADK **
|
|
12
|
+
MoAI-ADK **recommends** a GitFlow-inspired workflow. This policy shares best practices while letting teams adapt them as needed.
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
## Key Recommendations
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
### 1. Main Branch Access (Recommended)
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
| Recommendation | Summary | Enforcement |
|
|
19
|
+
|----------------|---------|-------------|
|
|
20
|
+
| **Merge via develop** | Prefer merging `develop` into `main` | Advisory ⚠️ |
|
|
21
|
+
| **Feature branches off develop** | Branch from `develop` and raise PRs back to `develop` | Advisory ⚠️ |
|
|
22
|
+
| **Release process** | Release flow: `develop` → `main` (release engineer encouraged) | Advisory ⚠️ |
|
|
23
|
+
| **Force push** | Warn when force-pushing, but allow it | Warning ⚠️ |
|
|
24
|
+
| **Direct push** | Warn on direct pushes to `main`, but allow them | Warning ⚠️ |
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
|-------------|---------|-------------|
|
|
23
|
-
| **Merge via develop** | MUST merge `develop` into `main` | ✅ Enforced |
|
|
24
|
-
| **Feature branches off develop** | MUST branch from `develop` and raise PRs back to `develop` | ✅ Enforced |
|
|
25
|
-
| **Release process** | Release flow: `develop` → `main` (PR required) | ✅ Enforced |
|
|
26
|
-
| **Force push** | Blocked on `main` | ✅ Blocked |
|
|
27
|
-
| **Direct push** | Blocked on `main` (PR required) | ✅ Blocked |
|
|
28
|
-
|
|
29
|
-
### 2. Git Workflow (Required)
|
|
26
|
+
### 2. Git Workflow (Recommended)
|
|
30
27
|
|
|
31
28
|
```
|
|
32
29
|
┌─────────────────────────────────────────────────────────┐
|
|
33
|
-
│
|
|
34
|
-
│ (GitHub Branch Protection Active) │
|
|
30
|
+
│ RECOMMENDED GITFLOW │
|
|
35
31
|
└─────────────────────────────────────────────────────────┘
|
|
36
32
|
|
|
37
|
-
develop (
|
|
33
|
+
develop (recommended base branch)
|
|
38
34
|
↑ ↓
|
|
39
35
|
┌─────────────────┐
|
|
40
36
|
│ │
|
|
@@ -50,15 +46,13 @@ feature/SPEC-{ID} [PR: feature -> develop]
|
|
|
50
46
|
│ (release manager prepares)
|
|
51
47
|
↓
|
|
52
48
|
[PR: develop -> main]
|
|
53
|
-
[Code review + approval REQUIRED]
|
|
54
|
-
[All discussions resolved]
|
|
55
49
|
[CI/CD validation]
|
|
56
50
|
[tag creation]
|
|
57
51
|
↓
|
|
58
|
-
main (
|
|
52
|
+
main (release)
|
|
59
53
|
```
|
|
60
54
|
|
|
61
|
-
**
|
|
55
|
+
**Flexibility**: Direct pushes to `main` are still possible, but the workflow above is preferred.
|
|
62
56
|
|
|
63
57
|
## Technical Implementation
|
|
64
58
|
|
|
@@ -162,29 +156,18 @@ git push origin v1.0.0
|
|
|
162
156
|
|
|
163
157
|
## Policy Modes
|
|
164
158
|
|
|
165
|
-
### Strict Mode (
|
|
166
|
-
|
|
167
|
-
**GitHub Branch Protection Enabled**:
|
|
168
|
-
- ✅ **enforce_admins: true** - Administrators must follow all rules
|
|
169
|
-
- ✅ **required_pull_request_reviews** - 1 approval required
|
|
170
|
-
- ✅ **required_conversation_resolution** - All discussions must be resolved
|
|
171
|
-
- ✅ **Block direct pushes to `main`** - PR required for all users
|
|
172
|
-
- ✅ **Block force pushes** - Prevents history rewriting
|
|
173
|
-
- ✅ **Block branch deletion** - Protects main from accidental deletion
|
|
159
|
+
### Strict Mode (Legacy, Currently Disabled)
|
|
174
160
|
|
|
175
|
-
|
|
176
|
-
- ❌
|
|
177
|
-
-
|
|
178
|
-
- ✅ PRs require code review approval
|
|
179
|
-
- ✅ All code discussions must be resolved before merge
|
|
180
|
-
- ✅ Enforces proper GitFlow: feature → develop → main
|
|
161
|
+
- ❌ Block direct pushes to `main`
|
|
162
|
+
- ❌ Block force pushes
|
|
163
|
+
- ❌ Block merges into `main` from any branch other than `develop`
|
|
181
164
|
|
|
182
|
-
### Advisory Mode (
|
|
165
|
+
### Advisory Mode (Active, v0.3.5+)
|
|
183
166
|
|
|
184
|
-
- ⚠️
|
|
185
|
-
- ⚠️
|
|
186
|
-
- ⚠️
|
|
187
|
-
-
|
|
167
|
+
- ⚠️ Warn but allow direct pushes to `main`
|
|
168
|
+
- ⚠️ Warn but allow force pushes
|
|
169
|
+
- ⚠️ Recommend best practices while preserving flexibility
|
|
170
|
+
- ✅ Respect user judgment
|
|
188
171
|
|
|
189
172
|
---
|
|
190
173
|
|
|
@@ -219,98 +202,8 @@ A: Yes. Expect an advisory warning, yet the push continues.
|
|
|
219
202
|
**Q: Can I disable the hook entirely?**
|
|
220
203
|
A: Yes. Remove `.git/hooks/pre-push` or strip its execute permission.
|
|
221
204
|
|
|
222
|
-
**Q: Why switch to Advisory Mode?**
|
|
223
|
-
A:
|
|
224
|
-
|
|
225
|
-
**Q: What if develop falls behind main?**
|
|
226
|
-
A: This can happen when hotfixes or releases go directly to main. Regularly sync main → develop to prevent divergence. See "Maintaining develop-main Sync" section below.
|
|
227
|
-
|
|
228
|
-
**Q: Can I bypass branch protection in emergencies?**
|
|
229
|
-
A: No. Even administrators must follow the PR process. For true emergencies, temporarily disable protection via GitHub Settings (requires admin access), but re-enable immediately after.
|
|
230
|
-
|
|
231
|
-
---
|
|
232
|
-
|
|
233
|
-
## Maintaining develop-main Sync
|
|
234
|
-
|
|
235
|
-
### ⚠️ Critical Rule: develop Must Stay Current
|
|
236
|
-
|
|
237
|
-
**Problem**: When main receives direct commits (hotfixes, emergency releases) without syncing back to develop, GitFlow breaks:
|
|
238
|
-
|
|
239
|
-
```
|
|
240
|
-
❌ BAD STATE:
|
|
241
|
-
develop: 3 commits ahead, 29 commits behind main
|
|
242
|
-
- develop has outdated dependencies
|
|
243
|
-
- New features branch from old code
|
|
244
|
-
- Merge conflicts multiply over time
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
### Signs of Drift
|
|
248
|
-
|
|
249
|
-
Monitor for these warnings:
|
|
250
|
-
- `git status` shows "Your branch is X commits behind main"
|
|
251
|
-
- Feature branches conflict with main during PR
|
|
252
|
-
- CI/CD failures due to dependency mismatches
|
|
253
|
-
- Version numbers in develop don't match main
|
|
254
|
-
|
|
255
|
-
### Recovery Procedure
|
|
256
|
-
|
|
257
|
-
When develop falls behind main:
|
|
258
|
-
|
|
259
|
-
1. **Assess the Gap**
|
|
260
|
-
```bash
|
|
261
|
-
git log --oneline develop..main # Commits in main but not develop
|
|
262
|
-
git log --oneline main..develop # Commits in develop but not main
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
2. **Sync Strategy: Merge main into develop (Recommended)**
|
|
266
|
-
```bash
|
|
267
|
-
git checkout develop
|
|
268
|
-
git pull origin develop # Get latest develop
|
|
269
|
-
git merge main # Merge main into develop
|
|
270
|
-
# Resolve conflicts if any (prefer main for version/config files)
|
|
271
|
-
git push origin develop
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
3. **Emergency Only: Reset develop to main (Destructive)**
|
|
275
|
-
```bash
|
|
276
|
-
# ⚠️ ONLY if develop's unique commits are unwanted
|
|
277
|
-
git checkout develop
|
|
278
|
-
git reset --hard main
|
|
279
|
-
git push origin develop --force
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
### Prevention: Regular Sync Schedule
|
|
283
|
-
|
|
284
|
-
**After every main release** (REQUIRED):
|
|
285
|
-
```bash
|
|
286
|
-
# Immediately after merging develop → main:
|
|
287
|
-
git checkout develop
|
|
288
|
-
git merge main
|
|
289
|
-
git push origin develop
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
**Weekly maintenance** (for active projects):
|
|
293
|
-
```bash
|
|
294
|
-
# Every Monday morning:
|
|
295
|
-
git checkout develop
|
|
296
|
-
git pull origin main
|
|
297
|
-
git push origin develop
|
|
298
|
-
```
|
|
299
|
-
|
|
300
|
-
### Real-World Case Study (2025-10-29)
|
|
301
|
-
|
|
302
|
-
**Situation**: develop was 29 commits behind main due to:
|
|
303
|
-
- v0.8.2, v0.8.3 released directly to main
|
|
304
|
-
- No reverse sync to develop
|
|
305
|
-
- Feature branches contained outdated code
|
|
306
|
-
|
|
307
|
-
**Resolution**:
|
|
308
|
-
- Merged main → develop (14 file conflicts)
|
|
309
|
-
- Resolved conflicts prioritizing main's versions
|
|
310
|
-
- TAG validation bypassed for merge commit
|
|
311
|
-
- Enabled Strict Mode to prevent future direct pushes
|
|
312
|
-
|
|
313
|
-
**Lesson**: With Strict Mode active, this won't happen again. All releases must go through develop → main PR flow.
|
|
205
|
+
**Q: Why switch to Advisory Mode?**
|
|
206
|
+
A: To promote best practices while respecting contributor flexibility and judgment.
|
|
314
207
|
|
|
315
208
|
---
|
|
316
209
|
|
|
@@ -320,9 +213,6 @@ git push origin develop
|
|
|
320
213
|
|------|------|--------|
|
|
321
214
|
| 2025-10-17 | Initial policy drafted (Strict Mode) | git-manager |
|
|
322
215
|
| 2025-10-17 | Switched to Advisory Mode (warnings only) | git-manager |
|
|
323
|
-
| 2025-10-29 | **Enabled GitHub Branch Protection (Strict Mode)** | Alfred |
|
|
324
|
-
| 2025-10-29 | Added develop-main sync guidelines and real-world case study | Alfred |
|
|
325
|
-
| 2025-10-29 | Enforced `enforce_admins`, `required_conversation_resolution` | Alfred |
|
|
326
216
|
|
|
327
217
|
---
|
|
328
218
|
|