|
| 1 | +# Branch Protection & PR Workflow Guide |
| 2 | + |
| 3 | +## Purpose |
| 4 | +Establish a minimal, testnet-appropriate workflow that prevents direct pushes to `main`, enforces review, and preserves repository integrity while in beta. |
| 5 | + |
| 6 | +## Recommended Settings (GitHub > Settings > Branches > Branch protection rules) |
| 7 | +1. Protected Branch: `main` |
| 8 | +2. Require a pull request before merging: ENABLE |
| 9 | + - Require approvals: 1 (increase to 2 post-team expansion) |
| 10 | + - Dismiss stale approvals on new commits: ENABLE |
| 11 | + - Require review from Code Owners (optional if CODEOWNERS added) |
| 12 | +3. Require status checks to pass before merging: ENABLE |
| 13 | + - Required checks: `CI (ubuntu-latest / Python 3.12)`, `CI (windows-latest / Python 3.12)`, `lint`, `codeql` |
| 14 | + - Optionally add coverage threshold checks later. |
| 15 | +4. Require branches to be up to date before merging: ENABLE (prevents merging outdated PR base) |
| 16 | +5. Require signed commits: OPTIONAL (enable if enforcing signature policy) |
| 17 | +6. Require linear history: ENABLE (no merge commits; squash or rebase only) |
| 18 | +7. Include administrators: ENABLE (ensures consistency) |
| 19 | +8. Restrict who can push to matching branches: ENABLE (limit to release automation if needed) |
| 20 | +9. Lock branch: DISABLED (still in active development) |
| 21 | + |
| 22 | +## Pull Request Workflow |
| 23 | +1. Create feature or fix branch: `feature/<short-topic>` or `chore/<task>`. |
| 24 | +2. Implement changes with small logical commits. |
| 25 | +3. Run local tests: `pytest -q` and lint: `flake8 src tests`. |
| 26 | +4. Open PR targeting `main`; include concise summary, risk section, and test evidence. |
| 27 | +5. Ensure required checks pass (CI matrix & lint). Fix issues before requesting review. |
| 28 | +6. Reviewer validates: |
| 29 | + - No accidental inclusion of deferred modules from `src/_deferred/`. |
| 30 | + - No secrets or wallet data artifacts. |
| 31 | + - Feature flags respected for experimental code. |
| 32 | +7. Merge strategy: **Squash** (recommended for beta) for clean history. |
| 33 | + |
| 34 | +## Emergency Fix Protocol |
| 35 | +For critical testnet breakages: |
| 36 | +1. Branch `hotfix/<issue>` from `main`. |
| 37 | +2. Minimal patch only; no feature additions. |
| 38 | +3. PR with clear justification; expedite single approval. |
| 39 | +4. Post-merge, create follow-up issue for root cause analysis. |
| 40 | + |
| 41 | +## Release Tagging |
| 42 | +1. Prepare release branch `release/v0.1.1-testnet`. |
| 43 | +2. Update `src/VERSION.py`, `CHANGELOG.md`, create `docs/RELEASE_NOTE_<VERSION>.md`. |
| 44 | +3. PR merge. |
| 45 | +4. Tag: `git tag -a v0.1.1-testnet -m "0.1.1-testnet <focus>"; git push origin v0.1.1-testnet`. |
| 46 | +5. GitHub Release auto-generated by workflow (see `.github/workflows/release.yml`). |
| 47 | + |
| 48 | +## Deferred Feature Safeguards |
| 49 | +Before enabling `ENABLE_WEB3_BROWSER` or `ENABLE_CALORIE_DB`: |
| 50 | +1. Security review of dependencies & data flow. |
| 51 | +2. Add tests ensuring no sensitive leakage. |
| 52 | +3. Document activation rationale and rollback plan. |
| 53 | +4. Enable flag ONLY via PR with explicit reviewer sign-off. |
| 54 | + |
| 55 | +## Prohibited in PRs |
| 56 | +| Action | Reason | |
| 57 | +|--------|--------| |
| 58 | +| Committing wallet seed/mnemonic | Security risk | |
| 59 | +| Reintroducing removed backup files | Privacy breach | |
| 60 | +| Activating deferred features silently | Undocumented surface expansion | |
| 61 | +| Bypassing tests/lint with forced merges | Stability regression | |
| 62 | + |
| 63 | +## Future Enhancements |
| 64 | +- CODEOWNERS for security-sensitive paths. |
| 65 | +- Coverage threshold enforcement (>70% for core modules). |
| 66 | +- Secret scanning action on PR (GitHub Advanced Security or third-party). |
| 67 | + |
| 68 | +## Testnet Disclaimer |
| 69 | +All merges assume testnet-only operation; production deployment requires separate audit phase and explicit version bump out of `-testnet` suffix. |
0 commit comments