Preto loop

From vaila-multimodaltoolbox/vaila · View interactive version

Preto loop is an AI agent skill from the GitHub repository vaila-multimodaltoolbox/vaila. Write and harden reusable agent-loop specification documents for biomechanics, data science, and vailá coding work. Use when the user says `/preto-loop`, asks to write/create/forge/specify/document an agent loop, turn an iterative vailá task into an autonomous loop, make an overnight loop, or design

How to use this skill

Skill file

Preto Loop

Write the specification of an agent loop for the user's biomechanics, data-science, and vailá development work. Do not execute the resulting loop. Produce a bounded, readable artifact that a person can version, inspect, and hand to an agent harness.

Domain scope: vailá and biomechanics

Classify the work before choosing the loop's check:

If a request crosses categories, state the interfaces and invariants between them. Keep scientific acceptance separate from code acceptance: a green test suite does not prove a biomechanical conclusion, and a plausible plot does not prove a correct implementation.

Preserve the distinction

Phase 0: Triage

Ask whether the outcome and verification evidence from each iteration can change the next action.

Phase 1: Interview one question at a time

Do not dump a questionnaire. Ask only the next unresolved question and reuse facts already supplied by the user.

  1. Define the concrete end state and a short hyphen-case loop name.
  2. Identify runtime inputs. Omit the Inputs section if none are required.
  3. Classify success using the verification ladder below and identify the strongest honest check available.
  4. Freeze the governing command, measurement, rule, rubric, or field signal and its exact completion criterion.
  5. Choose a manual, scheduled, or event-driven trigger and its cadence/event.
  6. Name terminal states beyond success: clean no-op, no-progress or stalled, blocked, and exhausted as applicable.
  7. Name the existing skills the loop composes. Avoid wrapping raw unguided generation in while true.
  8. Identify any nested loop by exact filename. Forbid circular references.
  9. Choose file-backed state and define what is curated there: baseline, attempts, accepted changes, rejected lessons, evidence, costs, and decisions.
  10. Set hard turn/token/cost limits and the exact actions requiring human approval.
  11. Ask where to save the specification: project-local ./loops/ or a user-specified global loops directory.
  12. Ask whether to create an optional launcher/command artifact, but only for a harness and command location the user identifies. Never invent support for a slash-command format.

For vailá work, also identify the input modality, coordinate system, units, sampling rate/frame rate, expected output schema, reference dataset or fixture, and whether the target is CPU, CUDA, or another hardware matrix.

When safe defaults would not materially alter behavior, propose them and log them rather than prolonging the interview. Never invent a verifier, budget, irreversible-action policy, or destination whose choice changes the loop materially.

Verification ladder

State the verifier's true level; never present assisted judgment as deterministic proof.

  1. Deterministic: assertion, exit code, golden output, exact metric.
  2. Rule/constraint: linter, schema, policy, static analysis.
  3. Delayed field truth: deployment result, experiment, customer or production signal.
  4. Model judge: score against a frozen rubric; opinion, not field truth.
  5. Human checkpoint: supervision, not automated verification.

Prefer levels 1–2 for unattended operation. Levels 1–3 are objective evidence. For level 4, use a distinct evaluator instance/model with isolated context, a frozen rubric, explicit evidence requirements, and preferably independent voting. Place consequential human approval at the irreversible action, not at a routine preparatory step.

Phase 2: Harden the design

Before drafting, enforce every applicable rule:

Read references/loop-engineering.md when explaining the theory, reviewing an existing loop, or resolving a verification/architecture tradeoff.

Read references/vaila-biomechanics.md for domain checks, vailá repository conventions, and scientific failure modes.

Vailá and scientific hardening

Apply the relevant gates before accepting an iteration:

Phase 3: Select actuation

Phase 4: Write artifacts

Write <name>-loop.md to the agreed location. Create parent directories only after the user has selected the location. Use the following skeleton, omitting only sections explicitly marked optional.

---
name: <loop-name>
category: <Biomechanics | Data Science | Vailá | Evaluation | Coverage | Refactoring | Multi-Agent | other>
trigger: <manual | scheduled | event>
verification-level: <1 | 2 | 3 | 4 | 5>
theory-base: arXiv:2607.00038
---

# <Human-readable loop name>

## Description
<Purpose in one or two sentences.>

## Use When
<Concrete operational scenarios and important exclusions.>

## Inputs
<!-- Optional: omit if autonomous. -->
1. `<input>` — <meaning, validation, default if safe>.

## Goal
<Concrete end state and whether it is objectively verifiable.>

## Verification (Governing Check)
- **True level:** <1–5 and why>.
- **Check:** `<command>` or <measurement/frozen rubric/field signal>.
- **Evidence:** <raw output or result that must be recorded each iteration>.
- **Completion criterion:** <condition parsed directly from the evidence>.
- **Verifier protection:** <frozen files, holdout, red/green proof, isolated judge>.
- **Scientific validity:** <units, coordinate frame, reference fixture, uncertainty/leakage checks>.

## Trigger
<Who/what starts the loop, cadence/event, and duplicate-run protection.>

## Iteration
0. On the first iteration, validate and freeze runtime inputs.
1. Load the specification and durable state; confirm budget and approvals.
2. Snapshot the baseline and run the governing check.
3. Rank unresolved targets and select the worst/highest-priority one.
4. Invoke `<named-skill>` or `<sub-loop.md>` to make exactly one change.
5. Run the governing check and record raw evidence.
6. Retain the change only if accepted without regression; otherwise use the declared rollback.
7. Curate lessons and atomically persist state, evidence, counters, and cost.
8. Evaluate terminal states; otherwise begin the next iteration.

## Terminal States
- **success:** <exact evidence-backed condition>.
- **no-op:** <nothing actionable; clean outcome, if applicable>.
- **no-progress/stalled:** <measurable stagnation rule>.
- **blocked:** <specific condition requiring external intervention>.
- **exhausted:** <hard budget/turn ceiling reached>.

Errors, missing evidence, and budget exhaustion are never success.

## Guardrails
- **Maximum allocation:** <turns, tokens and/or currency>.
- **Human approval required:** <irreversible/external actions>.
- **Isolation and credentials:** <sandbox, network and least privilege>.
- **Protected verifier:** <what the maker cannot modify or silence>.
- **Rollback:** <recoverable method scoped to one iteration>.

## State Memory
- **Path:** `<state-file.json or markdown>`.
- **Persist:** baseline, terminal status, attempts, accepted/rejected changes, evidence, curated lessons, decisions, and cost.
- **Recovery:** <how a fresh context resumes safely and detects an interrupted write>.

## Skills
- `$<skill-name>` — <role in one iteration>.
- `$vaila-<module-or-domain>` — <use an existing vailá-specific skill when available>.

## Sub-Loops
<!-- Optional: omit if none. -->
- `<sub-name>-loop.md` — <call site and terminal-state contract>.

Parent and child limits yield at most `<parent × child>` child iterations. Circular calls are prohibited.

## Why It Works
<Map the check, architecture, atomic change, memory, stop states, and guardrails to the failure modes they prevent.>

## How to Trigger
### Context-bound
<Exact harness-native invocation, only if supported.>

### Fresh-context / Ralph
<External runner contract: re-read this file and state every turn; stop only on a named terminal state.>

## Health Metrics
- **Cost per accepted change:** `total cost / verified changes retained`.
- <Task-specific progress, regression, latency, and failure metrics>.

If requested and supported, write one launcher artifact that points to the absolute loop-document path, requires reading it before action, passes runtime arguments, and repeats that errors or exhaustion are not success.

Final quality gate

Before reporting completion, verify:

Report the created paths, the verifier's true level, the hard limits, and any unresolved assumptions. Do not start the loop.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.