| name | evolve_loop |
| description | 12-hour autonomous evolution loop — observe, measure, diagnose, fix, repeat every 10min. Drives zero-touch rate up by finding friction and dispatching fixes. |
| type | skill |
Purpose
Autonomous self-improving loop that observes the AO ecosystem, measures zero-touch rate, diagnoses friction, creates beads for gaps, dispatches fixes via /claw, and records everything. Runs via /loop 10m for max 12 hours.
Notes (implementation): Run /auton using ~/.claude/skills/auton/SKILL.md (read CLAUDE.md, agent-orchestrator.yaml, SOUL.md first). ao-pr-poller is deprecated — never treat its absence as failure. Lifecycle launchd label may be ai.agento.lifecycle-all or com.agentorchestrator.lifecycle-jleechanbrain — verify with launchctl list | rg -i lifecycle. Harness-specific backlog eloop: skills/jleechanbrain-eloop.md (see also .claude/skills/jleechanbrain-eloop/SKILL.md).
AUTONOMOUS CONTINUATION — MANDATORY
After completing Phase 7 (Recap), IMMEDIATELY start Phase 1 of the next cycle. Do NOT:
- Ask "want me to continue?"
- Ask "shall I proceed to the next cycle?"
- Pause for user confirmation between cycles
- Output "Cycle N done" and wait
The loop runs autonomously until one of these termination conditions:
- User explicitly says "stop" or "pause"
- 12 hours elapsed since first cycle
- Context window > 90% consumed (use
/checkpoint before hitting limit)
- System is 100% stable for 3 consecutive healthy cycles (all canary checks pass, 0 pong warnings, 0 lock issues, 0 orphan processes)
If the user said "keep going" or "until stable" — that is a STANDING DIRECTIVE. Treat it as permanently active until a termination condition is met.
Adaptive Behavior — NOT Every Phase Every Cycle
This loop is problem-driven. If the system is healthy:
- Healthy cycle (~30s): Observe → Measure → Recap "all good, waiting"
- Problem cycle (~5min): Observe → Measure → Diagnose → Plan → Record → Fix → Recap
Decision tree after Phase 2 (Measure):
- Zero-touch rate unchanged AND above 20% AND no new friction AND all workers alive → SKIP to Phase 7 (Recap)
- Zero-touch rate below 20% (chronic problem) → run Phase 3-6 with deep diagnosis (read automation code, not just infra state)
- New dead worker or new PR failure → run Phase 3-6
- Worker stuck (same output 3 checks) → kill + respawn, skip full diagnosis
- Build broken on main → fix immediately, skip /harness
Chronic problem detection: If zero-touch rate has been below 20% for 3+ consecutive cycles, escalate to code-level diagnosis — read the actual automation code (skeptic-cron.yml, lifecycle-manager.ts, agentRules) to find bugs, don't just check infrastructure liveness.
Loop Body (executed every 10 minutes)
Phase 1: OBSERVE — System State Snapshot
1a. Run /auton — get autonomy diagnostic across all repos.
1b. Check AO workers — for each repo AO manages:
jleechanorg/agent-orchestrator (primary)
jleechanorg/worldai_claw (worldai)
jleechanorg/jleechanbrain (orchestration — deprecated but may have active workers)
- Antigravity orchestrator (special — check launchd daemon status)
tmux list-sessions 2>/dev/null | grep -E '(ao|jc|wa|cc|ra|wc)-[0-9]+'
for repo in agent-orchestrator worldai_claw jleechanbrain; do
gh api "repos/jleechanorg/$repo/pulls?state=open&per_page=20" \
--jq '.[]|"\(.number) \(.head.ref) \(.mergeable_state)"' 2>/dev/null
done
1c. Read worker tmux conversations — capture last 30 lines from each active ao-* worker. Look for:
- Stuck patterns (same output for 10+ min)
- Error loops (repeated failures)
- Waiting for input
- Context exhaustion (>80%)
for sess in $(tmux list-sessions -F '#{session_name}' 2>/dev/null | grep -E '^(bb5e6b7f8db3-)?(ao|jc|wa|wc)-[0-9]+$'); do
echo "=== $sess ==="
tmux capture-pane -t "$sess" -p 2>/dev/null | tail -30
done
1d. Merged-PR zombie sweep — kill workers burning tokens on already-merged PRs (session names may be hash-prefixed, e.g. bb5e6b7f8db3-ao-3323):
echo "=== MERGED-PR ZOMBIE SWEEP ==="
for sess in $(tmux list-sessions -F '#{session_name}' 2>/dev/null | grep -E '(bb5e6b7f8db3-)?(ao|jc|wa|wc)-[0-9]+'); do
pr_num=$(tmux capture-pane -t "$sess" -p 2>/dev/null | grep -oE "PR: #[0-9]+" | head -1 | grep -oE "[0-9]+")
[ -z "$pr_num" ] && continue
case "$sess" in
*-ao-*) repo="jleechanorg/agent-orchestrator" ;;
*-jc-*) repo="jleechanorg/jleechanbrain" ;;
*-wa-*) repo="jleechanorg/worldarchitect.ai" ;;
*-wc-*) repo="jleechanorg/worldai_claw" ;;
*) continue ;;
esac
merged=$(gh api "repos/$repo/pulls/$pr_num" --jq '.merged' 2>/dev/null)
if [ "$merged" = "true" ]; then
echo " ZOMBIE: $sess on PR #$pr_num ($repo) — killing"
tmux kill-session -t "$sess" 2>/dev/null && echo " KILLED $sess" || echo " FAILED to kill $sess"
fi
done
1e. Read fiction/novel entries — workers write friction narratives in novel/ and docs/novel/:
find novel/ docs/novel/ -name '*.md' -newer /tmp/evolve_loop_last_run 2>/dev/null
Phase 2: MEASURE — Zero-Touch Rate
Calculate the [agento] zero-touch rate per the SOUL.md convention:
gh api 'repos/jleechanorg/agent-orchestrator/pulls?state=closed&per_page=30&sort=updated&direction=desc' \
--jq '.[] | select(.merged_at != null and .merged_at > "YESTERDAY_ISO") |
{number, title: .title[:70], agento: (.title | test("^\\[agento\\]"))}'
For each non-[agento] merged PR, determine WHY:
- Missing prefix (tagging gap) → bead if no existing bead
- Operator had to fix code directly → bead for the root cause
- Manual conflict resolution → bead for the conflict pattern
- CR/review required operator action → bead for review automation gap
Phase 3: DIAGNOSE — Root Cause Analysis
3a. Run /harness on each new friction point found. /harness asks:
- Is this a harness gap (tests, CI, hooks, instructions)?
- What systemic fix prevents recurrence?
- 5 Whys on both the technical failure AND why the agent went down that path
3b. Check existing beads — don't duplicate:
br list --open 2>/dev/null | head -30
3c. Stale bead detection — beads marked in_progress with no active worker are zombies:
cat .beads/issues.jsonl | python3 -c "
import sys, json
for line in sys.stdin:
try:
d = json.loads(line.strip())
if d.get('status') == 'in_progress':
print(f\"{d['id']} | {d.get('title','')[:60]}\")
except: pass
" 2>/dev/null
For each in_progress bead, search active tmux sessions for mentions. If no session references it AND the bead's PR (if any) is merged/closed, the bead is stale — dispatch a fresh worker or close it.
3d. Automation code audit (when zero-touch rate < 20%):
When the merge pipeline is chronically broken, don't just check infrastructure — read the automation code:
.github/workflows/skeptic-cron.yml — are gate checks correct?
packages/core/src/lifecycle-manager.ts — are reactions firing correctly?
~/.smartclaw/agent-orchestrator.yaml — are agentRules and reactions configured correctly?
Compare what the code does vs what the 7-green definition says. Log specific bugs found.
Phase 4: PLAN — Next Steps
4a. Run /nextsteps — situational assessment and roadmap update.
4b. Prioritize — rank fixes by impact on zero-touch rate:
- P0: Fixes that unblock multiple stalled PRs
- P1: Fixes that prevent recurring friction patterns
- P2: Nice-to-have improvements
Phase 5: RECORD — Beads + Roadmap + Push
5a. Create/update beads for each new friction point:
br create --priority P1 --title "..." --body "..." 2>/dev/null
5b. Update roadmap doc — append findings to roadmap/evolve-loop-findings.md:
## YYYY-MM-DD HH:MM cycle
### Zero-touch rate: X% (N/M)
### New friction points: [list]
### Fixes dispatched: [list]
### Beads created: [list]
5c. Push to origin main:
git add roadmap/evolve-loop-findings.md .beads/issues.jsonl
git commit -m "docs(evolve): cycle YYYY-MM-DD HH:MM — zero-touch X%, N friction points"
git push origin main
Phase 6: FIX — Dispatch Workers
6a. Use /claw for each actionable bead:
/claw "Fix bd-XXX: <description>.
After implementing:
1. Run /er on the PR evidence bundle to validate authenticity — fix any evidence issues before merging
2. Ensure 7-green (CI, no conflicts, CR APPROVED, Bugbot clean, comments resolved, evidence reviewed, Skeptic PASS)
3. Run /learn to capture any reusable patterns"
6b. Babysit open PRs — for each open PR not owned by a live worker:
gh api 'repos/jleechanorg/agent-orchestrator/pulls?state=open&per_page=20' \
--jq '.[] | {number, title: .title[:60], head: .head.ref, mergeable_state}' 2>/dev/null
For each PR without a live AO session:
- If CI failing → dispatch worker to fix
- If CR CHANGES_REQUESTED → dispatch worker to address comments + post
@coderabbitai all good?
- If Evidence Gate failing → run
/er inline and fix PR body
- If at 6-green but Skeptic pending → post
@coderabbitai approve to trigger skeptic if needed
- If 7-green → admin merge immediately
6c. Run /er on PRs approaching 7-green — for any PR where:
- CI is green AND CR is APPROVED AND comments resolved AND Skeptic PASS pending or already PASS
Run /er inline (not delegated to worker) to validate evidence NOW:
/er <PR-number>
If /er finds issues: edit the PR body directly via gh api repos/.../pulls/N --method PATCH -f body="..." and push a new commit if code changes are needed. Do NOT wait for a worker — fix it yourself.
6d. If /claw fails (GraphQL exhausted, session cap, etc.):
- Fall back to manual worktree +
claude --dangerously-skip-permissions in tmux
- Or create PR directly if the fix is small (config change, agentRules edit)
- Record the /claw failure in a bead
6e. Pre-merge 7-green verification (MANDATORY before ANY merge):
PR_NUM=NNN; REPO="jleechanorg/REPO"
echo "=== PRE-MERGE 7-GREEN CHECK PR #$PR_NUM ==="
STATE=$(gh api "repos/$REPO/pulls/$PR_NUM" --jq '{state, merged}')
echo "$STATE" | grep -q '"merged":true' && echo "ALREADY MERGED — skip" && continue
CI=$(gh api "repos/$REPO/commits/$(gh api repos/$REPO/pulls/$PR_NUM --jq '.head.sha')/status" --jq '.state')
echo " [1] CI: $CI"
MERGEABLE=$(gh api "repos/$REPO/pulls/$PR_NUM" --jq '.mergeable_state')
echo " [2] Mergeable: $MERGEABLE"
CR=$(gh api "repos/$REPO/pulls/$PR_NUM/reviews" --jq '[.[] | select(.user.login=="coderabbitai[bot]") | select(.state=="APPROVED" or .state=="CHANGES_REQUESTED")] | sort_by(.submitted_at) | last | .state // "NONE"')
echo " [3] CR: $CR"
UNRESOLVED=$(gh api graphql -f query='query($pr:Int!){repository(owner:"'$(echo $REPO|cut -d/ -f1)'",name:"'$(echo $REPO|cut -d/ -f2)'"){pullRequest(number:$pr){reviewThreads(first:100){nodes{isResolved}}}}}' -F pr=$PR_NUM --jq '[.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved==false)] | length' 2>/dev/null || echo "?")
echo " [5] Unresolved: $UNRESOLVED"
echo " [6] Running /er on PR #$PR_NUM..."
SKEPTIC=$(gh api "repos/$REPO/issues/$PR_NUM/comments" --jq '[.[] | select(.body | test("VERDICT:"; "i"))] | sort_by(.created_at) | last | .body' 2>/dev/null | grep -oiE "VERDICT: (PASS|FAIL|SKIPPED)")
echo " [7] Skeptic: $SKEPTIC"
if [ "$CI" != "success" ] || [ "$MERGEABLE" = "dirty" ] || [ "$CR" != "APPROVED" ] || [ "$UNRESOLVED" != "0" ] || [ "$SKEPTIC" != "VERDICT: PASS" ]; then
echo " *** BLOCKED — NOT 7-GREEN. DO NOT MERGE. ***"
else
echo " *** 7-GREEN — safe to merge ***"
fi
NEVER merge a PR that fails this check. If a PR is not 7-green, dispatch a worker to fix it — do not merge it to "show progress."
6f. REST API fallback — always prefer REST over GraphQL:
gh api repos/OWNER/REPO/pulls/NUM/merge --method PUT -f merge_method=squash
gh api repos/OWNER/REPO/pulls --method POST -f title="..." -f head="BRANCH" -f base="main" -f body="..."
gh api repos/OWNER/REPO/issues/NUM/comments --method POST -f body="..."
Phase 7: RECAP — Cycle Summary
Output a concise cycle summary:
## Evolve Loop Cycle — HH:MM
- Zero-touch rate: X% (trend: ↑/↓/→)
- Workers: N alive, N dead, N stuck
- PRs: N open, N merged since last cycle
- Friction: N new points found
- Fixes: N dispatched via /claw, N direct
- Beads: N created, N updated
- Roadmap: pushed to main
Touch the timestamp file for next cycle:
touch /tmp/evolve_loop_last_run
Invocation
/loop 10m /eloop
/eloop
The /loop wrapper handles the 12-hour max and 10-minute interval. Each /eloop invocation runs one complete cycle.
Anti-Stall Rules
- If GraphQL is exhausted, switch to REST immediately — never sleep-retry
- If session cap is hit (>30), do not spawn — report and defer
- If a worker is stuck (same output 3 consecutive checks), kill and respawn
- If /claw fails twice on the same bead, create PR directly
- If main repo is on wrong branch, fix it silently (git checkout main)
- If build is broken on main, fix it before dispatching workers
Key Files
roadmap/evolve-loop-findings.md — cumulative findings log
.beads/issues.jsonl — bead tracker
~/.smartclaw/SOUL.md — zero-touch convention ([agento] prefix)
~/.smartclaw/agent-orchestrator.yaml — agentRules config
novel/ — worker friction narratives