Files
claude-archeflow-plugin/skills/autonomous-mode/SKILL.md
Christian Nennemann 83e09b70f2 feat: workflow intelligence, quality loop, completion promises, parallel teams
Sprint 1 — Workflow Intelligence (A1-A3):
- Conditional escalation: fast→standard on 2+ CRITICALs
- Guardian fast-path: skip remaining reviewers on clean pass
- Confidence-triggered escalation: pause/upgrade/probe on low scores

Sprint 2 — Quality Loop (B1-B2, B5-B6):
- Maker self-review checklist before submitting to Check phase
- Proposal diff ("What Changed") on cycle 2+ revisions
- Convergence detection: escalate to user if same finding persists 2 cycles
- Cross-archetype dedup: merge duplicate findings from different reviewers

Sprint 3 — Completion & Verification (B3-B4):
- Completion promise: user-defined done criteria checked in Act phase
- Post-merge verification: run tests on main, auto-revert on failure

Sprint 4 — Parallel & Scale (C1-C4):
- Parallel team orchestration: 2-3 independent teams with merge gate
- Task dependency graph in autonomous queue format
- Auto-resume on interruption via .archeflow/state.json
- Budget-aware scheduling with automatic workflow downgrade
2026-04-03 06:17:53 +02:00

214 lines
7.4 KiB
Markdown

---
name: autonomous-mode
description: Use when the user wants to run ArcheFlow orchestrations unattended — overnight sessions, batch processing multiple tasks, or fully autonomous coding. Handles self-organization, progress logging, and safe stopping.
---
# Autonomous Mode
ArcheFlow orchestrations can run fully autonomously because the archetypes self-organize through the PDCA cycle. The user sets the task queue, walks away, and reviews results later.
## How Autonomous Mode Works
The PDCA cycle provides natural quality gates at every turn of the spiral:
- **Plan** phase produces a proposal — reviewable artifact
- **Do** phase produces committed code in a worktree — isolated, reversible
- **Check** phase produces approval/rejection — automatic quality control
- **Act** phase either merges (safe) or cycles back (self-correcting)
No unreviewed code reaches the main branch. Ever. That's what makes overnight runs safe.
## Starting an Autonomous Session
```
You are entering AUTONOMOUS MODE.
Task queue:
1. "Add input validation to all API endpoints" (thorough)
2. "Refactor auth middleware to use JWT" (standard)
3. "Fix pagination bug in search results" (fast)
4. "Add rate limiting to public endpoints" (standard)
Rules:
- Process tasks sequentially (one orchestration at a time)
- Log progress to .archeflow/session-log.md after each task
- If a task fails after max cycles: log findings, skip to next task
- If 3 consecutive tasks fail: STOP and wait for user
- Commit and push after each successful merge
- Never force-push. Never modify main history.
```
## Session Log — Full Visibility
Every autonomous session writes to `.archeflow/session-log.md`:
```markdown
# ArcheFlow Autonomous Session
**Started:** 2026-04-02 22:00 UTC
**Mode:** autonomous
**Tasks:** 4 queued
---
## Task 1: Add input validation to all API endpoints
**Workflow:** thorough | **Status:** COMPLETED
**Cycles:** 2 of 3
**Cycle 1:** Guardian REJECTED (missing sanitization on 2 endpoints)
**Cycle 2:** All APPROVED
**Files changed:** 8 | **Tests added:** 24
**Branch:** merged to main (commit abc1234)
**Duration:** 12 min | **Completed:** 22:12 UTC
---
## Task 2: Refactor auth middleware to use JWT
**Workflow:** standard | **Status:** COMPLETED
**Cycles:** 1 of 2
**Cycle 1:** All APPROVED (clean implementation)
**Files changed:** 5 | **Tests added:** 15
**Branch:** merged to main (commit def5678)
**Duration:** 8 min | **Completed:** 22:20 UTC
---
## Task 3: Fix pagination bug in search results
**Workflow:** fast | **Status:** COMPLETED
**Cycles:** 1 of 1
**Cycle 1:** Guardian APPROVED
**Files changed:** 2 | **Tests added:** 3
**Branch:** merged to main (commit ghi9012)
**Duration:** 4 min | **Completed:** 22:24 UTC
---
## Task 4: Add rate limiting to public endpoints
**Workflow:** standard | **Status:** FAILED (max cycles)
**Cycles:** 2 of 2
**Cycle 1:** Skeptic REJECTED (Redis dependency not in Docker setup)
**Cycle 2:** Guardian REJECTED (race condition in token bucket)
**Unresolved:** Race condition in concurrent token bucket decrement
**Branch:** archeflow/maker-xyz (NOT merged — available for manual review)
**Duration:** 15 min | **Completed:** 22:39 UTC
---
## Session Summary
**Completed:** 3 of 4 tasks
**Failed:** 1 (rate limiting — needs human input on concurrency design)
**Total duration:** 39 min
**Files changed:** 15 | **Tests added:** 42
**Ended:** 22:39 UTC
```
## Safety Mechanisms
### Automatic Stop Conditions
The session halts and waits for the user when:
- **3 consecutive failures:** Something systemic is wrong
- **Destructive action detected:** Force push, branch deletion, schema drop
- **Shadow escalation:** Same shadow detected 3+ times across tasks
- **Budget exceeded:** If cost tracking is enabled, stop at budget limit
- **Test suite broken:** If existing tests fail after merge, halt immediately and revert
### Everything is Reversible
- Code changes live on worktree branches until explicitly merged
- Merges use `--no-ff` — every merge commit is individually revertable
- The session log captures every decision for post-hoc review
- Failed tasks leave their branches intact for manual inspection
### User Controls
The user can at any time:
- **Cancel:** Kill the session. All incomplete work stays on branches.
- **Pause:** Stop after current task completes. Resume later.
- **Skip:** Skip the current task, move to the next one.
- **Review:** Read `.archeflow/session-log.md` for real-time progress.
- **Intervene:** Jump into a worktree branch and fix something manually.
## Task Queue Formats
### Simple (inline)
```
Tasks:
1. "Fix the login bug" (fast)
2. "Add user profile page" (standard)
```
### From File
Create `.archeflow/queue.md`:
```markdown
- [ ] Fix the login bug | fast
- [ ] Add user profile page | standard
- [ ] Security audit of payment flow | thorough
- [x] Refactor database queries | standard (completed)
```
### With Dependencies
```markdown
- [ ] Add user model (standard)
- [ ] Add user API endpoints (standard) | depends: user model
- [ ] Add user UI (standard) | depends: user API endpoints
```
Dependencies are processed in order: a task with `depends: X` waits until X completes successfully. Tasks without dependencies or with resolved dependencies can run in parallel (see Parallel Team Orchestration in the orchestration skill).
### With Completion Criteria
```markdown
- [ ] Fix login bug | fast | done: login_test.py passes
- [ ] Add rate limiting | standard | done: Guardian approves AND load_test.sh passes
```
Completion criteria are checked in the Act phase. If the test command fails even when reviewers approve, the task cycles back.
## Budget-Aware Scheduling
Set a token or cost budget for the session. The orchestrator tracks estimated cost per task and adapts:
```
Budget: $5.00 (or ~2M tokens)
```
| Budget Remaining | Action |
|-----------------|--------|
| > 50% | Run tasks at their selected workflow level |
| 25-50% | Downgrade `thorough``standard`, `standard``fast` |
| < 25% | Run remaining tasks as `fast` only |
| Exhausted | Stop. Log remaining tasks as "skipped — budget exhausted" |
Budget is tracked per-task in the session log. Estimated cost = agents spawned x model tier pricing.
## Auto-Resume on Interruption
If a session is interrupted (crash, timeout, user cancel), save state for resumption:
### On Interruption
Write `.archeflow/state.json`:
```json
{
"session_id": "...",
"current_task": 2,
"current_phase": "check",
"current_cycle": 1,
"completed_tasks": [1],
"queue": ["task3", "task4"],
"worktree_branch": "archeflow/maker-abc",
"timestamp": "2026-04-03T22:15:00Z"
}
```
### On Next Session Start
If `.archeflow/state.json` exists:
1. Report: "Found interrupted ArcheFlow session from [timestamp]. Task [N] was in [phase] phase."
2. Offer: "Resume from where we left off? Or start fresh?"
3. If resume: pick up from the saved phase. The worktree branch is still intact.
4. If fresh: clean up state file and worktrees, start over.
## Overnight Session Checklist
Before starting an autonomous overnight session:
1. **Clean working tree:** `git status` — no uncommitted changes
2. **Tests passing:** Run the full test suite. Don't start on a broken baseline.
3. **Task queue defined:** Either inline or in `.archeflow/queue.md`
4. **Workflow selected per task:** Match risk level to workflow type
5. **Budget set (optional):** If cost matters, set a token/dollar limit
6. **Push access:** Verify git push works (SSH key, auth token)
Then: set it, forget it, read the session log in the morning.