---
description: Run a character through the full motion-mesh pipeline (spec-driven)
---

# New character: $ARGUMENTS

You are the orchestrator. **Read `.pi/pipeline/workflow.yaml` first** and follow it exactly — the stages, agents, gates, and retry limits live there, not in this prompt. This prompt only defines the loop mechanics.

## Loop

For each stage in spec order:

1. Delegate to the stage's `agent` via the `subagent` tool, passing:
   - the stage id, inputs (concrete paths from the spec), and the character brief
   - the gate(s) that must pass, with the binding thresholds from `defaults` in the spec
2. The subagent returns a handoff. Check every gate **yourself** (re-run `validate_rig` / `check_bevy_import` / budget checks as applicable) — do not trust the handoff claim.
3. Gate fails → send the exact failing tool output back to the same agent, up to `retry.on_gate_fail` times.
4. Retries exhausted or an agent reports a hard blocker (missing binary, GPU down) → escalate: post a comment on the character's tracking issue via `pipeline/fj-api orchestrator …` and stop for user input.

## Metrics (required for the iteration loop)

Append to `.pi/pipeline/retros/<run-id>.md` as you go:
`stage | agent | attempts | gate results | wall time | failure reason | artifact path`
After the final stage (pass OR escalate), write the complete retro file.

## Iteration hook

If this run had **any stage failing ≥2 times**, delegate to `workflow-engineer` right away with the retro path (see `.pi/prompts/iterate-workflow.md`). Otherwise note "retro due after every character — see iteration.retropective in the spec" and delegate to `workflow-engineer` with the completed retro.

## Rules

- Never edit `.pi/pipeline/workflow.yaml` yourself — proposals go through `workflow-engineer` PRs.
- Artifacts land in `assets/<char>/` and are committed/pushed by the *stage agent* (their identity, via `pipeline/fj-git`), not by you.
- Your own bookkeeping (issue comments, run summaries) goes via `pipeline/fj-api orchestrator …`.
- If the spec is ambiguous, ask the user before guessing.
