diff --git a/docs/architecture.md b/docs/architecture.md index d5446b3..77dcca8 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -80,12 +80,38 @@ repos_base_paths = [ ## Cycle Flow -1. **Discovery**: Find all git repos across configured base paths -2. **Status Check**: For each repo, check `git status --porcelain` -3. **Skip Clean**: Repos with no changes are skipped -4. **Generate Message**: Send diff to llama-service for commit message -5. **Commit**: Stage all changes and commit with generated message -6. **Push**: Push to configured remote (default: origin/master) +The service uses a **two-phase batch workflow**: + +``` +Phase 1: Commit All Phase 2: Push All +───────────────────── ───────────────────── +repo-a → commit ✓ repo-a → push ✓ +repo-b → commit ✓ repo-b → push ✓ +repo-c → no changes repo-c → (skip) +repo-d → commit ✓ repo-d → push ✓ + ↓ ↓ + All commits done All pushes done +``` + +### Phase 1: Sloppy-Atomic Commits +For each repo: +1. Check `git status --porcelain` +2. Skip if no changes +3. Get diff and send to llama-service for commit message +4. Stage all changes (`git add -A`) +5. Commit with generated message +6. **Do NOT push yet** - return `COMMITTED` status + +### Phase 2: Batch Push +Only after ALL commits complete: +1. For each repo with `COMMITTED` status +2. Push to remote (with retry + rebase on rejection) +3. Update status to `SUCCESS` or `ERROR` + +### Why Two Phases? +- **Atomic batch**: All commits happen before any push +- **Fail-safe**: If commit fails mid-way, no partial pushes +- **Consistent state**: Remote only sees complete batch updates ## API Endpoints