Skip to content

feat(loop): add autonomous run-loop with planner agent and frozen gate - #1

Open
senblet wants to merge 1 commit into
mainfrom
feat/autonomous-run-loop
Open

feat(loop): add autonomous run-loop with planner agent and frozen gate#1
senblet wants to merge 1 commit into
mainfrom
feat/autonomous-run-loop

Conversation

@senblet

@senblet senblet commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Adds an end-to-end autonomous path to the template: a human writes TASK.md, a planner subagent turns it into an executable contract, then the loop iterates to green without further input.

The core idea

The planner's deliverable is the gate, not a checklist. Each plan item must name the check that proves it, so "the plan is done" becomes verify.sh exiting 0 rather than the agent's own judgment. An agent that decides its own plan is complete is just self-assessment with extra steps — this keeps the template's central invariant intact under full autonomy.

Three rails

  • Red before green. The freshly-written gate must exit non-zero before any work starts. A gate that's already green proves nothing, and this is the cheap defense against the planner writing weak checks to make its own life easier.
  • The gate is frozen. scripts/hashes.sh fingerprints verify.sh and TASK.md into STATE.md; every pass re-checks them. Editing the thing that judges you is how a loop manufactures success, so a mismatch aborts the run.
  • The planner can refuse. It runs the four-box test itself and returns REFUSED for unloopable tasks — replacing the human who used to say "this shouldn't be a loop."

With nobody watching, escalation means a clean abort with a written reason, never working around the contract.

/run-loop phases

0  preflight: reject placeholder TASK.md, note dirty tree, reset STATE.md
1  spawn planner (synchronous) -> REFUSED aborts, no retry
2  arm: gate must exit non-zero, then fingerprint -> frozen
3  iterate until green / cap / stuck / tampered
4  report the literal exit code

Files

New: TASK.md, .claude/agents/planner.md, .claude/commands/run-loop.md, scripts/hashes.sh

Modified: LOOP.md (two new stop conditions: stuck, tampering), STATE.md (phase + fingerprint fields), scripts/verify.sh (freeze note; fail-closed default unchanged), .claude/commands/iterate.md (hash check, never-edit-the-gate rule), .claude/commands/setup-loop.md (scoped to project setup only), CLAUDE.md, README.md

Notes

  • /run-loop deliberately does not commit. An unattended run producing unreviewed commits is a worse default than one leaving a diff.
  • The planner's four-box test swaps "repeats weekly" for "bounded" — the README version decides whether to build a loop at all, the planner's decides whether a given task belongs in one. Documented in the README.

Testing

No test framework in this repo (markdown + two shell scripts). Both scripts pass bash -n, hashes.sh runs clean, and verify.sh still fails closed at exit=1 as intended.

Run /iterate by hand on a real task before trusting /run-loop — what needs proving is whether the gate is honest, not whether the agent can code.

🤖 Generated with Claude Code

Adds an end-to-end autonomous path: a human writes TASK.md, a planner
subagent turns it into an executable contract, then the loop iterates to
green without further input.

The planner's deliverable is the gate, not a checklist — each plan item
must name the check that proves it, so "the plan is done" is decided by
verify.sh rather than by self-assessment.

Three rails keep that honest:
- the freshly-written gate must exit non-zero before work starts, so a
  vacuous gate can't hand the run instant fake success
- verify.sh and TASK.md are fingerprinted into STATE.md and re-checked
  every pass, so editing the gate mid-run aborts instead of passing
- the planner runs the four-box test itself and can return REFUSED,
  replacing the human who used to say "this shouldn't be a loop"

With no human watching, escalation becomes a clean abort with a written
reason rather than working around the contract.

New:      TASK.md, .claude/agents/planner.md,
          .claude/commands/run-loop.md, scripts/hashes.sh
Modified: LOOP.md, STATE.md, scripts/verify.sh, CLAUDE.md, README.md,
          .claude/commands/{iterate,setup-loop}.md

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant