Lifecycle (agent)
August 24, 2026 · View on GitHub
This is the state machine the agent follows when running wgm. The authoritative, terse version is
SKILL.md; this doc explains the shape and the gates. Operators can read it too,
to see exactly what /wgm will do before they run it.
wgm is deliberately a state machine, not a checklist. Each phase ends in a gate that prints every item as PASS or FAIL. If any item is FAIL you do not advance — you ask one question, fix the artifact, or stop with a recorded blocker.
The phases
stateDiagram-v2
[*] --> Triage
Triage --> Grill
Grill --> Plan: Grill-exit gate
Plan --> Preflight: Plan-exit + consistency
Preflight --> Grill: readiness < 80
Preflight --> Loop: readiness >= 80
state Loop {
[*] --> Analyze
Analyze --> Implement
Implement --> Validate
Validate --> Review
Review --> Record
Record --> [*]
}
Loop --> Ship: tasks done AND satisfaction >= threshold
Loop --> Loop: more work / stall recovery
Ship --> [*]
Phase responsibilities
| Phase | Goal | Exit gate (abridged) |
|---|---|---|
| Triage | Parse mode; check .github/wgm-hive.yml consent — if absent, ask that one-time question before anything else; classify the work into a Quick/Standard/Full track (default Standard; detail in SKILL.md); choose Ralph-lite (same session) or Ralph-full (fresh context per iteration via loop.sh); set root vs .wgm/; discover optional host plugins as metadata only | Working dir decided; track chosen |
| Grill | Interview to alignment, one question at a time; seed the CONTEXT.md glossary | Goal, success criteria, constraints known or assumed |
| Plan | Write the constitution, optional CONTEXT.md glossary, specs (EARS-phrased acceptance), scenarios + IMPLEMENTATION_PLAN.md; run the consistency check and the /rugged plan gate | Conforms to the constitution; cross-artifact consistency; no placeholders; every task has validation + acceptance; demo path covered by a tier-1 scenario; exactly one recorded RUGGED verdict |
| Preflight | Score readiness 0–100 | Readiness ≥ 80 |
| Loop | One task per iteration (Analyze → Implement → Validate → ruggedness gate → two-stage review with dissent → Record); rotate context when it fills | Validation exited 0; exactly one recorded RUGGED verdict; satisfaction judged; plan updated |
| Ship | Summarize, leave repo resumable; audit the docs through a host-dispatched mandatory paper trail (Standard/Full — references/docs-audit.md); harvest a durable, always-anonymized lesson through the runner hook and report it automatically if .github/wgm-hive.yml consents | Demo path green; threshold met; docs-audit report committed or host limitation recorded |
Details per phase live in the references: grilling, artifacts, scoring, ralph-loop, and subagents.
Modes are entry points
Invocations like /wgm grill only or /wgm plan: … enter the machine at one phase and (with only)
hard-stop at its gate. build resumes the Loop from an existing plan; analyze reports findings on a
bare repo, or runs the cross-artifact consistency check once a plan exists. The single-phase modes
never roll forward past their gate — that is what makes wgm safe to drive incrementally.
Why gates, not vibes
A loop without a deterministic pass/fail signal is just hoping. The gates force the agent to make "done" observable at every step: a known goal, a runnable validation command, a satisfied judge. When in doubt, the gate fails closed.
See also: attractor-loop.md · scenarios-and-scoring.md · references/subagents.md (the swarm) · references/self-improvement.md (the flywheel).