Pipeline loops
automatic-loop
>
Source recipe
Copyable Markdown
# automatic-loop
## Purpose
>
## Source
- Source: Pi Pipelines
- Repository: Rybens92/pi-pipelines
- Path: pipelines/automatic-loop.pipeline.yaml
## Workflow
- analyze
- converge
- execute
- fix-gaps
- synthesize
## Verifier
Includes review gates or goal-loop checks in the source pipeline.
## Source Artifact
```yaml
name: automatic-loop
description: >
Universal automatic-looping pipeline for arbitrary project tasks. Classifies the
task, extracts a testable Definition of Done and a holistic success goal, then
converges inside a goal-loop: each iteration executes the work under a scored
review gate, fixes the reviewers' critiques under a second gate, and a critic
decides whether the whole mission is achieved. Combines per-stage scored gates
(quality bar) with a goal-loop (holistic mission convergence). Best-effort on
exhaustion — never hard-fails on iteration/round limits.
preflight:
topics:
- type of task and expected output (research / planning / implementation / refactoring / bug-fix / review / other)
- quality requirements (expected level of thoroughness, specific constraints or boundaries)
- project context and affected files/modules
report: false
stages:
- id: analyze
agent: planner
tier: big
task: >
Analyze the following query about this project: {task}
Produce a structured analysis with:
1. **Task type** — classify as one of:
research, planning, implementation, refactoring, bug-fix, code review, or other.
2. **Definition of Done** — explicit, testable criteria that verify
successful task completion. Each criterion must be written so a
reviewer can definitively say "yes, met" or "no, not met".
3. **Affected files or modules** — what areas of the project will
be touched or researched.
4. **Edge cases and risks** — what could go wrong, what to watch for,
what unusual scenarios the executor should handle.
5. **Reviewer focus guidance** — what aspects the reviewers should pay
special attention to when scoring the output.
6. **Holistic success goal** — 1-2 sentences describing what "the whole
mission is accomplished" means for this task. It must be a single,
coherent success criterion that a critic can verify as met or not met
(not a checklist). It is the high-level bar the goal-loop converges on,
complementing the detailed DoD checklist above.
Be specific and concrete. The DoD criteria and the holistic goal together
define what success means. The DoD is used by the gate reviewers; the goal
is used by the goal-loop critic.
### Output format (required)
Focus on producing: (1) a numbered Definition-of-Done checklist, (2) the affected
files/modules as a bullet list, (3) edge cases/risks as a bullet list, and
(4) the one-sentence holistic success goal. Keep the whole output under 500 words — it is
injected verbatim into the worker stages.
report:
mode: summary
maxLength: 700
instruction: >
Distill to: the Definition-of-Done checklist, affected files, edge cases,
and the one-sentence holistic goal. Drop any narrative or implementation plan.
- id: converge
goal-loop:
maxIterations: 3
goal:
derive: true
hint: >
Extract the "Holistic success goal" from item 6 of the analysis.
If the analysis does not have an explicit item 6 or the goal is
absent, derive a single testable success criterion from the
Definition of Done (item 2). The criterion must be verifiable by
a critic reading the task output and/or the changed files.
context:
- task
- outputs.analyze
critic:
agent: oracle
tier: big
stages:
- id: execute
agent: worker
tier: small
task: >
Execute the following task for the project: {task}
Goal-loop iteration {iteration}.
Goal: {goal}
Prior critic feedback: {goalFeedback}
### Analysis & DoD
{outputs.analyze}
Follow the Definition of Done criteria carefully — address each one
completely. Keep changes focused and follow project conventions.
If you discover something unexpected, handle it cleanly and note it.
### Editing is required
You MUST create or edit files now — do not return a plan or a summary.
Make the actual changes to the codebase.
gate:
type: review-loop
maxRounds: 2
targetScore: 8
judgeModel: big
reviewers:
- focus: >
Correctness against Definition of Done: does the output satisfy
ALL DoD criteria from the analysis stage? Identify specific
criteria that are not met or only partially met.
- focus: >
Completeness: are there gaps, missing pieces, overlooked edge
cases, or parts of the task that were not addressed at all?
Is the output complete relative to the original task?
- focus: >
Project conventions and quality: does the output follow the
project's established patterns, naming conventions, code style,
and structure? Is it maintainable, clean, and well-organized?
- id: fix-gaps
agent: worker
tier: small
task: >
Review the previous attempt and fix ALL gaps and issues identified
by the reviewers.
Goal-loop iteration {iteration}.
Goal: {goal}
### Original Task
{task}
### Analysis & DoD
{outputs.analyze}
### Previous Output
{outputs.execute}
### Reviewer Critiques
{lastFeedback}
Address each reviewer critique point by point. If the output already
meets all DoD criteria and no critiques remain, confirm it is
production-ready and complete — do not invent work.
Do not introduce new issues or unrelated changes. If reviewers
identified missing or incomplete DoD criteria, complete them now.
If reviewers found quality issues, fix them now.
Do NOT skip any critique. Each one must be explicitly addressed.
### Editing is required
Make the edits now — do not return a plan. Apply fixes directly to files.
If every critique was already addressed, confirm explicitly and stop.
gate:
type: review-loop
maxRounds: 2
targetScore: 8
judgeModel: big
reviewers:
- focus: >
Precision of fixes: did the worker address EVERY specific
critique from the execute review? No critique should remain
unaddressed or only partially addressed.
- focus: >
Final polish: is the output thorough, well-structured, and
production-ready? Are there any remaining rough edges,
incomplete parts, or verbosity issues?
- focus: >
No regressions: did the fixes introduce new issues,
inconsistencies, or break existing functionality? Is the
overall result stable and coherent?
- id: synthesize
agent: planner
tier: big
task: >
Synthesize a final summary of the completed work.
### Original Task
{task}
### Analysis
{outputs.analyze}
### Goal-Loop Result (execute → fix-gaps, possibly across iterations)
{outputs.converge}
### User Answers
{answers}
Produce a structured report:
1. **What was accomplished** — clear summary of the work done.
2. **What changed** — files modified, outputs produced, decisions made.
3. **Goal achievement** — whether the goal-loop critic confirmed the
mission was achieved, and how many iterations were needed.
4. **Quality assessment** — how well the Definition of Done criteria
were met, based on the gate scores.
5. **Residual risks** — any known limitations, edge cases not covered,
or things to be aware of before merging or using the output.
6. **Next steps** — recommended follow-up work or actions.
```