moai-adk 0.10.1__py3-none-any.whl → 0.11.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/core/issue_creator.py +2 -2
- moai_adk/core/project/detector.py +285 -12
- moai_adk/core/project/phase_executor.py +4 -0
- moai_adk/core/tags/ci_validator.py +33 -3
- moai_adk/core/template_engine.py +6 -2
- moai_adk/templates/.claude/commands/alfred/0-project.md +60 -62
- moai_adk/templates/.claude/commands/alfred/1-plan.md +6 -0
- moai_adk/templates/.claude/commands/alfred/2-run.md +6 -0
- moai_adk/templates/.claude/commands/alfred/3-sync.md +6 -0
- moai_adk/templates/.claude/hooks/alfred/alfred_hooks.py +8 -9
- moai_adk/templates/.claude/hooks/alfred/core/project.py +22 -28
- moai_adk/templates/.claude/hooks/alfred/core/timeout.py +136 -0
- moai_adk/templates/.claude/hooks/alfred/core/ttl_cache.py +109 -0
- moai_adk/templates/.claude/hooks/alfred/core/version_cache.py +4 -4
- moai_adk/templates/.claude/hooks/alfred/notification__handle_events.py +10 -15
- moai_adk/templates/.claude/hooks/alfred/post_tool__log_changes.py +10 -15
- moai_adk/templates/.claude/hooks/alfred/pre_tool__auto_checkpoint.py +10 -15
- moai_adk/templates/.claude/hooks/alfred/session_end__cleanup.py +10 -15
- moai_adk/templates/.claude/hooks/alfred/session_start__show_project_info.py +10 -15
- moai_adk/templates/.claude/hooks/alfred/shared/core/__init__.py +2 -2
- moai_adk/templates/.claude/hooks/alfred/shared/core/project.py +19 -26
- moai_adk/templates/.claude/hooks/alfred/shared/core/tags.py +55 -23
- moai_adk/templates/.claude/hooks/alfred/shared/core/version_cache.py +4 -4
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/notification.py +134 -3
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/session.py +9 -10
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/tool.py +3 -6
- moai_adk/templates/.claude/hooks/alfred/stop__handle_interrupt.py +10 -15
- moai_adk/templates/.claude/hooks/alfred/subagent_stop__handle_subagent_end.py +10 -15
- moai_adk/templates/.claude/hooks/alfred/user_prompt__jit_load_docs.py +11 -20
- moai_adk/templates/.claude/hooks/alfred/utils/__init__.py +1 -0
- moai_adk/templates/.claude/hooks/alfred/utils/timeout.py +136 -0
- moai_adk/templates/.github/workflows/c-tag-validation.yml +83 -0
- moai_adk/templates/.github/workflows/cpp-tag-validation.yml +79 -0
- moai_adk/templates/.github/workflows/csharp-tag-validation.yml +65 -0
- moai_adk/templates/.github/workflows/dart-tag-validation.yml +82 -0
- moai_adk/templates/.github/workflows/java-tag-validation.yml +75 -0
- moai_adk/templates/.github/workflows/kotlin-tag-validation.yml +67 -0
- moai_adk/templates/.github/workflows/{release.yml → moai-adk-release.yml} +6 -2
- moai_adk/templates/.github/workflows/{tag-validation.yml → moai-adk-tag-validation.yml} +53 -8
- moai_adk/templates/.github/workflows/moai-gitflow.yml +6 -1
- moai_adk/templates/.github/workflows/php-tag-validation.yml +56 -0
- moai_adk/templates/.github/workflows/ruby-tag-validation.yml +68 -0
- moai_adk/templates/.github/workflows/rust-tag-validation.yml +73 -0
- moai_adk/templates/.github/workflows/shell-tag-validation.yml +65 -0
- moai_adk/templates/.github/workflows/swift-tag-validation.yml +79 -0
- moai_adk/templates/.moai/memory/GITFLOW-PROTECTION-POLICY.md +330 -0
- moai_adk/templates/.moai/memory/SPEC-METADATA.md +356 -0
- moai_adk/templates/CLAUDE.md +536 -65
- moai_adk/templates/workflows/go-tag-validation.yml +130 -0
- moai_adk/templates/workflows/javascript-tag-validation.yml +135 -0
- moai_adk/templates/workflows/python-tag-validation.yml +118 -0
- moai_adk/templates/workflows/typescript-tag-validation.yml +154 -0
- {moai_adk-0.10.1.dist-info → moai_adk-0.11.1.dist-info}/METADATA +70 -13
- {moai_adk-0.10.1.dist-info → moai_adk-0.11.1.dist-info}/RECORD +58 -37
- /moai_adk/templates/.github/workflows/{spec-issue-sync.yml → moai-adk-spec-issue-sync.yml} +0 -0
- {moai_adk-0.10.1.dist-info → moai_adk-0.11.1.dist-info}/WHEEL +0 -0
- {moai_adk-0.10.1.dist-info → moai_adk-0.11.1.dist-info}/entry_points.txt +0 -0
- {moai_adk-0.10.1.dist-info → moai_adk-0.11.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @CODE:LDE-001-RUBY | SPEC: SPEC-LANGUAGE-DETECTION-EXTENDED-001/spec.md
|
|
2
|
+
# Ruby TAG Validation Workflow
|
|
3
|
+
# Validates Ruby code with RSpec tests, Rubocop linting, and bundle dependencies
|
|
4
|
+
|
|
5
|
+
name: Ruby TAG Validation
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
pull_request:
|
|
9
|
+
types: [opened, synchronize, reopened, ready_for_review]
|
|
10
|
+
push:
|
|
11
|
+
branches: [main, develop, "feature/**"]
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
name: 🧪 Ruby Tests & Linting
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
|
|
18
|
+
# Skip validation on draft PRs (allow WIP)
|
|
19
|
+
if: github.event.pull_request.draft == false || github.event_name == 'push'
|
|
20
|
+
|
|
21
|
+
permissions:
|
|
22
|
+
contents: read
|
|
23
|
+
pull-requests: write
|
|
24
|
+
|
|
25
|
+
strategy:
|
|
26
|
+
matrix:
|
|
27
|
+
ruby-version: ['3.1', '3.2', '3.3']
|
|
28
|
+
|
|
29
|
+
steps:
|
|
30
|
+
- name: Checkout code
|
|
31
|
+
uses: actions/checkout@v4
|
|
32
|
+
with:
|
|
33
|
+
fetch-depth: 0 # Fetch all history for comprehensive validation
|
|
34
|
+
|
|
35
|
+
- name: Setup Ruby
|
|
36
|
+
uses: ruby/setup-ruby@v1
|
|
37
|
+
with:
|
|
38
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
39
|
+
bundler-cache: true # Enable bundler caching
|
|
40
|
+
|
|
41
|
+
- name: Install dependencies
|
|
42
|
+
run: |
|
|
43
|
+
gem install bundler
|
|
44
|
+
bundle install
|
|
45
|
+
|
|
46
|
+
- name: Run RSpec tests
|
|
47
|
+
run: bundle exec rspec --format documentation
|
|
48
|
+
|
|
49
|
+
- name: Run Rubocop linting
|
|
50
|
+
run: bundle exec rubocop
|
|
51
|
+
|
|
52
|
+
- name: Generate coverage report
|
|
53
|
+
if: always()
|
|
54
|
+
run: |
|
|
55
|
+
echo "## Ruby Test Coverage" >> $GITHUB_STEP_SUMMARY
|
|
56
|
+
if [ -f coverage/.last_run.json ]; then
|
|
57
|
+
cat coverage/.last_run.json | ruby -rjson -e "puts JSON.parse(STDIN.read)['result']['line'].to_s + '%'" >> $GITHUB_STEP_SUMMARY || echo "Coverage data not available" >> $GITHUB_STEP_SUMMARY
|
|
58
|
+
else
|
|
59
|
+
echo "Coverage report not generated" >> $GITHUB_STEP_SUMMARY
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
- name: Upload coverage artifacts
|
|
63
|
+
if: always()
|
|
64
|
+
uses: actions/upload-artifact@v4
|
|
65
|
+
with:
|
|
66
|
+
name: ruby-coverage-${{ matrix.ruby-version }}
|
|
67
|
+
path: coverage/
|
|
68
|
+
retention-days: 30
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# @CODE:LDE-004-RUST | SPEC: SPEC-LANGUAGE-DETECTION-EXTENDED-001/spec.md
|
|
2
|
+
# Rust TAG Validation Workflow
|
|
3
|
+
# Validates Rust code with cargo test, clippy linting, and rustfmt formatting
|
|
4
|
+
|
|
5
|
+
name: Rust TAG Validation
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
pull_request:
|
|
9
|
+
types: [opened, synchronize, reopened, ready_for_review]
|
|
10
|
+
push:
|
|
11
|
+
branches: [main, develop, "feature/**"]
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
name: 🧪 Rust Tests & Linting
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
|
|
18
|
+
if: github.event.pull_request.draft == false || github.event_name == 'push'
|
|
19
|
+
|
|
20
|
+
permissions:
|
|
21
|
+
contents: read
|
|
22
|
+
pull-requests: write
|
|
23
|
+
|
|
24
|
+
strategy:
|
|
25
|
+
matrix:
|
|
26
|
+
rust-version: ['stable', 'beta']
|
|
27
|
+
|
|
28
|
+
steps:
|
|
29
|
+
- name: Checkout code
|
|
30
|
+
uses: actions/checkout@v4
|
|
31
|
+
with:
|
|
32
|
+
fetch-depth: 0
|
|
33
|
+
|
|
34
|
+
- name: Setup Rust toolchain
|
|
35
|
+
uses: dtolnay/rust-toolchain@master
|
|
36
|
+
with:
|
|
37
|
+
toolchain: ${{ matrix.rust-version }}
|
|
38
|
+
components: rustfmt, clippy
|
|
39
|
+
|
|
40
|
+
- name: Cache cargo registry
|
|
41
|
+
uses: actions/cache@v4
|
|
42
|
+
with:
|
|
43
|
+
path: ~/.cargo/registry
|
|
44
|
+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
|
45
|
+
|
|
46
|
+
- name: Cache cargo index
|
|
47
|
+
uses: actions/cache@v4
|
|
48
|
+
with:
|
|
49
|
+
path: ~/.cargo/git
|
|
50
|
+
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
|
|
51
|
+
|
|
52
|
+
- name: Run cargo test
|
|
53
|
+
run: cargo test --verbose
|
|
54
|
+
|
|
55
|
+
- name: Run clippy (treat warnings as errors)
|
|
56
|
+
run: cargo clippy -- -D warnings
|
|
57
|
+
|
|
58
|
+
- name: Check formatting with rustfmt
|
|
59
|
+
run: cargo fmt -- --check
|
|
60
|
+
|
|
61
|
+
- name: Generate coverage report
|
|
62
|
+
if: matrix.rust-version == 'stable'
|
|
63
|
+
run: |
|
|
64
|
+
cargo install cargo-tarpaulin
|
|
65
|
+
cargo tarpaulin --out Xml --output-dir coverage
|
|
66
|
+
|
|
67
|
+
- name: Upload coverage artifacts
|
|
68
|
+
if: always() && matrix.rust-version == 'stable'
|
|
69
|
+
uses: actions/upload-artifact@v4
|
|
70
|
+
with:
|
|
71
|
+
name: rust-coverage
|
|
72
|
+
path: coverage/
|
|
73
|
+
retention-days: 30
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# @CODE:LDE-011-SHELL | SPEC: SPEC-LANGUAGE-DETECTION-EXTENDED-001/spec.md
|
|
2
|
+
# Shell TAG Validation Workflow
|
|
3
|
+
# Validates shell scripts with shellcheck and bats-core
|
|
4
|
+
|
|
5
|
+
name: Shell TAG Validation
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
pull_request:
|
|
9
|
+
types: [opened, synchronize, reopened, ready_for_review]
|
|
10
|
+
push:
|
|
11
|
+
branches: [main, develop, "feature/**"]
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
name: 🧪 Shell Tests & Linting
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
|
|
18
|
+
if: github.event.pull_request.draft == false || github.event_name == 'push'
|
|
19
|
+
|
|
20
|
+
permissions:
|
|
21
|
+
contents: read
|
|
22
|
+
pull-requests: write
|
|
23
|
+
|
|
24
|
+
steps:
|
|
25
|
+
- name: Checkout code
|
|
26
|
+
uses: actions/checkout@v4
|
|
27
|
+
with:
|
|
28
|
+
fetch-depth: 0
|
|
29
|
+
|
|
30
|
+
- name: Install shellcheck and bats
|
|
31
|
+
run: |
|
|
32
|
+
sudo apt-get update
|
|
33
|
+
sudo apt-get install -y shellcheck bats
|
|
34
|
+
|
|
35
|
+
- name: Run shellcheck on all shell scripts
|
|
36
|
+
run: |
|
|
37
|
+
echo "Running shellcheck on all .sh files"
|
|
38
|
+
find . -name "*.sh" -type f -print0 | xargs -0 shellcheck --severity=warning
|
|
39
|
+
|
|
40
|
+
- name: Check for POSIX compatibility
|
|
41
|
+
run: |
|
|
42
|
+
echo "Checking POSIX compatibility"
|
|
43
|
+
find . -name "*.sh" -type f -print0 | xargs -0 shellcheck --shell=sh
|
|
44
|
+
|
|
45
|
+
- name: Run bats tests
|
|
46
|
+
if: hashFiles('tests/**/*.bats') != ''
|
|
47
|
+
run: |
|
|
48
|
+
if [ -d "tests" ]; then
|
|
49
|
+
bats tests/
|
|
50
|
+
else
|
|
51
|
+
echo "No tests/ directory found, skipping bats tests"
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
- name: Generate test summary
|
|
55
|
+
if: always()
|
|
56
|
+
run: |
|
|
57
|
+
echo "## Shell Script Validation Summary" >> $GITHUB_STEP_SUMMARY
|
|
58
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
59
|
+
echo "- shellcheck: ✅ Passed" >> $GITHUB_STEP_SUMMARY
|
|
60
|
+
echo "- POSIX compatibility: ✅ Passed" >> $GITHUB_STEP_SUMMARY
|
|
61
|
+
if [ -d "tests" ]; then
|
|
62
|
+
echo "- bats tests: ✅ Executed" >> $GITHUB_STEP_SUMMARY
|
|
63
|
+
else
|
|
64
|
+
echo "- bats tests: ⚠️ No tests found" >> $GITHUB_STEP_SUMMARY
|
|
65
|
+
fi
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# @CODE:LDE-006-SWIFT | SPEC: SPEC-LANGUAGE-DETECTION-EXTENDED-001/spec.md
|
|
2
|
+
# Swift TAG Validation Workflow
|
|
3
|
+
# Validates Swift code with XCTest, SwiftLint, and Swift Package Manager
|
|
4
|
+
|
|
5
|
+
name: Swift TAG Validation
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
pull_request:
|
|
9
|
+
types: [opened, synchronize, reopened, ready_for_review]
|
|
10
|
+
push:
|
|
11
|
+
branches: [main, develop, "feature/**"]
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
name: 🧪 Swift Tests & Linting
|
|
16
|
+
runs-on: macos-latest # Swift requires macOS runner
|
|
17
|
+
|
|
18
|
+
if: github.event.pull_request.draft == false || github.event_name == 'push'
|
|
19
|
+
|
|
20
|
+
permissions:
|
|
21
|
+
contents: read
|
|
22
|
+
pull-requests: write
|
|
23
|
+
|
|
24
|
+
strategy:
|
|
25
|
+
matrix:
|
|
26
|
+
swift-version: ['5.9', '5.10']
|
|
27
|
+
|
|
28
|
+
steps:
|
|
29
|
+
- name: Checkout code
|
|
30
|
+
uses: actions/checkout@v4
|
|
31
|
+
with:
|
|
32
|
+
fetch-depth: 0
|
|
33
|
+
|
|
34
|
+
- name: Setup Swift
|
|
35
|
+
uses: swift-actions/setup-swift@v2
|
|
36
|
+
with:
|
|
37
|
+
swift-version: ${{ matrix.swift-version }}
|
|
38
|
+
|
|
39
|
+
- name: Detect project type
|
|
40
|
+
id: detect-project
|
|
41
|
+
run: |
|
|
42
|
+
if [ -f "Package.swift" ]; then
|
|
43
|
+
echo "type=spm" >> $GITHUB_OUTPUT
|
|
44
|
+
echo "Swift Package Manager project detected"
|
|
45
|
+
elif [ -n "$(find . -name '*.xcodeproj' -o -name '*.xcworkspace')" ]; then
|
|
46
|
+
echo "type=xcode" >> $GITHUB_OUTPUT
|
|
47
|
+
echo "Xcode project detected"
|
|
48
|
+
else
|
|
49
|
+
echo "No Swift project detected"
|
|
50
|
+
exit 1
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
- name: Install SwiftLint
|
|
54
|
+
run: brew install swiftlint
|
|
55
|
+
|
|
56
|
+
- name: Run SwiftLint
|
|
57
|
+
run: swiftlint lint --strict
|
|
58
|
+
|
|
59
|
+
- name: Build with Swift Package Manager
|
|
60
|
+
if: steps.detect-project.outputs.type == 'spm'
|
|
61
|
+
run: swift build
|
|
62
|
+
|
|
63
|
+
- name: Run tests with Swift Package Manager
|
|
64
|
+
if: steps.detect-project.outputs.type == 'spm'
|
|
65
|
+
run: swift test --enable-code-coverage
|
|
66
|
+
|
|
67
|
+
- name: Generate coverage report (SPM)
|
|
68
|
+
if: steps.detect-project.outputs.type == 'spm' && always()
|
|
69
|
+
run: |
|
|
70
|
+
xcrun llvm-cov export -format="lcov" .build/debug/*.xctest/Contents/MacOS/* \
|
|
71
|
+
-instr-profile .build/debug/codecov/default.profdata > coverage.lcov
|
|
72
|
+
|
|
73
|
+
- name: Upload coverage artifacts
|
|
74
|
+
if: always()
|
|
75
|
+
uses: actions/upload-artifact@v4
|
|
76
|
+
with:
|
|
77
|
+
name: swift-coverage-${{ matrix.swift-version }}
|
|
78
|
+
path: coverage.lcov
|
|
79
|
+
retention-days: 30
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
# GitFlow Protection Policy
|
|
2
|
+
|
|
3
|
+
**Document ID**: @DOC:GITFLOW-POLICY-ALIAS
|
|
4
|
+
**Published**: 2025-10-17
|
|
5
|
+
**Updated**: 2025-10-29
|
|
6
|
+
**Status**: **Enforced via GitHub Branch Protection** (v0.8.3+)
|
|
7
|
+
**Scope**: Personal and Team modes
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
MoAI-ADK **enforces** a GitFlow-inspired workflow through GitHub Branch Protection. As of v0.8.3, the `main` branch is protected and requires Pull Requests for all changes, including from administrators.
|
|
14
|
+
|
|
15
|
+
**What Changed**: Previously (v0.3.5-v0.8.2), we used an advisory approach with warnings. Now we enforce proper GitFlow to ensure code quality and prevent accidental direct pushes to main.
|
|
16
|
+
|
|
17
|
+
## Key Requirements (Enforced)
|
|
18
|
+
|
|
19
|
+
### 1. Main Branch Access (Enforced)
|
|
20
|
+
|
|
21
|
+
| Requirement | Summary | Enforcement |
|
|
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)
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
┌─────────────────────────────────────────────────────────┐
|
|
33
|
+
│ ENFORCED GITFLOW │
|
|
34
|
+
│ (GitHub Branch Protection Active) │
|
|
35
|
+
└─────────────────────────────────────────────────────────┘
|
|
36
|
+
|
|
37
|
+
develop (required base branch)
|
|
38
|
+
↑ ↓
|
|
39
|
+
┌─────────────────┐
|
|
40
|
+
│ │
|
|
41
|
+
│ developer work │
|
|
42
|
+
│ │
|
|
43
|
+
↓ ↑
|
|
44
|
+
feature/SPEC-{ID} [PR: feature -> develop]
|
|
45
|
+
[code review + approval]
|
|
46
|
+
[Merge to develop]
|
|
47
|
+
|
|
48
|
+
develop (stable)
|
|
49
|
+
↓
|
|
50
|
+
│ (release manager prepares)
|
|
51
|
+
↓
|
|
52
|
+
[PR: develop -> main]
|
|
53
|
+
[Code review + approval REQUIRED]
|
|
54
|
+
[All discussions resolved]
|
|
55
|
+
[CI/CD validation]
|
|
56
|
+
[tag creation]
|
|
57
|
+
↓
|
|
58
|
+
main (protected release)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Enforcement**: Direct pushes to `main` are **blocked** via GitHub Branch Protection. All changes must go through Pull Requests.
|
|
62
|
+
|
|
63
|
+
## Technical Implementation
|
|
64
|
+
|
|
65
|
+
### Pre-push Hook (Advisory Mode)
|
|
66
|
+
|
|
67
|
+
**Location**: `.git/hooks/pre-push`
|
|
68
|
+
**Purpose**: Warn on `main` branch pushes without blocking them
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# When attempting to push to main:
|
|
72
|
+
⚠️ ADVISORY: Non-standard GitFlow detected
|
|
73
|
+
|
|
74
|
+
Current branch: feature/SPEC-123
|
|
75
|
+
Target branch: main
|
|
76
|
+
|
|
77
|
+
Recommended GitFlow workflow:
|
|
78
|
+
1. Work on feature/SPEC-{ID} branch (created from develop)
|
|
79
|
+
2. Push to feature/SPEC-{ID} and create PR to develop
|
|
80
|
+
3. Merge into develop after code review
|
|
81
|
+
4. When develop is stable, create PR from develop to main
|
|
82
|
+
5. Release manager merges develop -> main with tag
|
|
83
|
+
|
|
84
|
+
✓ Push will proceed (flexibility mode enabled)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Force Push Advisory
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
⚠️ ADVISORY: Force-push to main branch detected
|
|
91
|
+
|
|
92
|
+
Recommended approach:
|
|
93
|
+
- Use GitHub PR with proper code review
|
|
94
|
+
- Ensure changes are merged via fast-forward
|
|
95
|
+
|
|
96
|
+
✓ Push will proceed (flexibility mode enabled)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Workflow Examples
|
|
102
|
+
|
|
103
|
+
### Scenario 1: Standard Feature Development (Recommended)
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# 1. Sync latest code from develop
|
|
107
|
+
git checkout develop
|
|
108
|
+
git pull origin develop
|
|
109
|
+
|
|
110
|
+
# 2. Create a feature branch (from develop)
|
|
111
|
+
git checkout -b feature/SPEC-001-new-feature
|
|
112
|
+
|
|
113
|
+
# 3. Implement the change
|
|
114
|
+
# ... write code and tests ...
|
|
115
|
+
|
|
116
|
+
# 4. Commit
|
|
117
|
+
git add .
|
|
118
|
+
git commit -m "..."
|
|
119
|
+
|
|
120
|
+
# 5. Push
|
|
121
|
+
git push origin feature/SPEC-001-new-feature
|
|
122
|
+
|
|
123
|
+
# 6. Open a PR: feature/SPEC-001-new-feature -> develop
|
|
124
|
+
|
|
125
|
+
# 7. Merge into develop after review and approval
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Scenario 2: Fast Hotfix (Flexible)
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# When an urgent fix is required:
|
|
132
|
+
|
|
133
|
+
# Option 1: Recommended (via develop)
|
|
134
|
+
git checkout develop
|
|
135
|
+
git checkout -b hotfix/critical-bug
|
|
136
|
+
# ... apply fix ...
|
|
137
|
+
git push origin hotfix/critical-bug
|
|
138
|
+
# Open PRs: hotfix -> develop -> main
|
|
139
|
+
|
|
140
|
+
# Option 2: Direct fix on main (allowed, not recommended)
|
|
141
|
+
git checkout main
|
|
142
|
+
# ... apply fix ...
|
|
143
|
+
git commit -m "Fix critical bug"
|
|
144
|
+
git push origin main # ⚠️ Advisory warning appears but push continues
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Scenario 3: Release (Standard or Flexible)
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Standard approach (recommended):
|
|
151
|
+
git checkout develop
|
|
152
|
+
gh pr create --base main --head develop --title "Release v1.0.0"
|
|
153
|
+
|
|
154
|
+
# Direct push (allowed):
|
|
155
|
+
git checkout develop
|
|
156
|
+
git push origin main # ⚠️ Advisory warning appears but push continues
|
|
157
|
+
git tag -a v1.0.0 -m "Release v1.0.0"
|
|
158
|
+
git push origin v1.0.0
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Policy Modes
|
|
164
|
+
|
|
165
|
+
### Strict Mode (Active, v0.8.3+) ✅ ENFORCED
|
|
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
|
|
174
|
+
|
|
175
|
+
**What This Means**:
|
|
176
|
+
- ❌ No one (including admins) can push directly to `main`
|
|
177
|
+
- ✅ All changes must go through Pull Requests
|
|
178
|
+
- ✅ PRs require code review approval
|
|
179
|
+
- ✅ All code discussions must be resolved before merge
|
|
180
|
+
- ✅ Enforces proper GitFlow: feature → develop → main
|
|
181
|
+
|
|
182
|
+
### Advisory Mode (Legacy, v0.3.5 - v0.8.2)
|
|
183
|
+
|
|
184
|
+
- ⚠️ Warned but allowed direct pushes to `main`
|
|
185
|
+
- ⚠️ Warned but allowed force pushes
|
|
186
|
+
- ⚠️ Recommended best practices while preserving flexibility
|
|
187
|
+
- ❌ **Deprecated** - Replaced by Strict Mode for better quality control
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Recommended Checklist
|
|
192
|
+
|
|
193
|
+
Every contributor should ensure:
|
|
194
|
+
|
|
195
|
+
- [ ] `.git/hooks/pre-push` exists and is executable (755)
|
|
196
|
+
- [ ] Feature branches fork from `develop`
|
|
197
|
+
- [ ] Pull requests target `develop`
|
|
198
|
+
- [ ] Releases merge `develop` → `main`
|
|
199
|
+
|
|
200
|
+
**Verification Commands**:
|
|
201
|
+
```bash
|
|
202
|
+
ls -la .git/hooks/pre-push
|
|
203
|
+
git branch -vv
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## FAQ
|
|
209
|
+
|
|
210
|
+
**Q: Can we merge into `main` from branches other than `develop`?**
|
|
211
|
+
A: Yes. You will see an advisory warning, but the merge proceeds. The recommended path remains `develop` → `main`.
|
|
212
|
+
|
|
213
|
+
**Q: Are force pushes allowed?**
|
|
214
|
+
A: Yes. You receive a warning, but the push succeeds. Use with caution.
|
|
215
|
+
|
|
216
|
+
**Q: Can we commit/push directly to `main`?**
|
|
217
|
+
A: Yes. Expect an advisory warning, yet the push continues.
|
|
218
|
+
|
|
219
|
+
**Q: Can I disable the hook entirely?**
|
|
220
|
+
A: Yes. Remove `.git/hooks/pre-push` or strip its execute permission.
|
|
221
|
+
|
|
222
|
+
**Q: Why switch to Advisory Mode?**
|
|
223
|
+
A: Advisory Mode was used in v0.3.5-v0.8.2. As of v0.8.3, we've switched to Strict Mode with GitHub Branch Protection for better quality control.
|
|
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.
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
## Policy Change Log
|
|
318
|
+
|
|
319
|
+
| Date | Change | Owner |
|
|
320
|
+
|------|------|--------|
|
|
321
|
+
| 2025-10-17 | Initial policy drafted (Strict Mode) | git-manager |
|
|
322
|
+
| 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
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
**This policy is advisory—adapt it to fit your project needs.**
|
|
330
|
+
**Reach out to the team lead or release engineer for questions or suggestions.**
|