---
name: git-integration
description: |
Git-per-phase commit strategy for ArcheFlow runs. Creates a branch per run, commits after
every phase transition and agent completion, and merges (squash or no-ff) on success.
Enables rollback to any phase boundary and full audit trail via git history.
Automatically loaded by archeflow:run when git.enabled is true
User: "archeflow rollback --to plan"
---
# Git Integration -- Per-Phase Commit Strategy
Every run creates branch `archeflow/`. Each phase transition and agent completion produces a commit. On success, merge back. On failure, branch stays for inspection.
## Branch Strategy
```
main
+-- archeflow/
+-- archeflow(plan): explorer research
+-- archeflow(plan): creator outline
+-- archeflow(plan->do): phase transition
+-- archeflow(do): maker draft
+-- archeflow(check): guardian review
+-- archeflow(act): cycle 1 complete
+-- archeflow(run): complete
```
## Commit Points
| Trigger | Message format |
|---------|----------------|
| `agent.complete` | `archeflow(): ` |
| `phase.transition` | `archeflow(->): phase transition` |
| `fix.applied` | `archeflow(fix): -- ` |
| `cycle.boundary` | `archeflow(act): cycle ` |
| `run.complete` | `archeflow(run): complete -- ` |
## Commit Protocol
- Stage only relevant files: `.archeflow/artifacts//`, event log, project files from maker
- Never `git add -A`
- Exclude: `progress.md`, `explorer-cache/`, `session-log.md`
- Use conventional commit format
- Signing opt-in via `git.signing_key` config
## All operations go through `./lib/archeflow-git.sh`:
| Run event | Command |
|-----------|---------|
| `run.start` | `init ` (create+switch branch) |
| `agent.complete` | `commit "" [files]` |
| `phase.transition` | `phase-commit ` |
| `run.complete` (ok) | `merge [--squash|--no-ff]` |
| `run.complete` (fail) | branch preserved |
## Merge
1. Verify all changes committed
2. Switch to base branch
3. Merge with configured strategy (squash default)
4. Branch NOT auto-deleted (user may inspect)
## Rollback
`./lib/archeflow-git.sh rollback --to `
Targets: `plan`, `do`, `check`, `act`, `cycle-N`. Only works on `archeflow/` branch. Resets to last commit for target phase and trims event JSONL.
## Post-Merge Validation
After merge, runs project test suite (from `test_command` in config) with 5-min timeout. If tests fail: `git revert --no-edit HEAD`.
## Configuration
```yaml
git:
enabled: true
branch_prefix: "archeflow/"
merge_strategy: squash # squash | no-ff | rebase
auto_push: false
signing_key: null
```
## Safety Rules
- Never force-push
- Never modify main history
- Branch stays intact on failure
- Clean merge or abort (no force-resolve on conflicts)
- Worktree-compatible (Maker's worktree branch is sub-branch of run branch)