spec-loop-engine is a small, durable, spec-driven runner for long sequential plans:
- one fresh process per phase
- one fresh verifier process after every phase
- resumable state if the run or machine is interrupted
- append-only journal and per-attempt artifacts
- generic shell commands or a built-in
codex execadapter
The default shape is: execute -> verify -> retry/fix if needed -> next phase.
This engine deliberately absorbs a few state-of-the-art orchestration ideas:
- durable execution and resume semantics
- exactly-ordered, auditable step history
- explicit state transitions instead of implicit shell glue
- idempotent retries and verifier-driven repair loops
In practice that means every run writes:
- a resolved spec snapshot
state.jsonjournal.jsonl- per-phase / per-attempt prompts, stdout, stderr, last messages, and parsed results
Inside this repo, the simplest entry point is:
./bin/spec-loop run specs/demo-codex.yamlThe wrapper uses uv run --project so you do not need to install the package globally.
Validate a spec:
./bin/spec-loop validate specs/demo-codex.yamlRun a spec:
./bin/spec-loop run specs/demo-codex.yamlOverride variables from the command line:
./bin/spec-loop run specs/system0-plan.yaml \
--set model=gpt-5.4 \
--set execute_effort=high \
--set verify_effort=mediumForce a fresh run instead of resuming the latest unfinished run:
./bin/spec-loop run specs/demo-codex.yaml --freshSpecs can be YAML or JSON. Top-level fields:
version: 1
name: demo-codex
workspace: /absolute/or/relative/workspace
vars:
model: gpt-5.4
defaults:
max_attempts: 3
runner:
type: codex_exec
sandbox: danger-full-access
verifier:
type: codex_exec
sandbox: read-only
phases:
- id: phase-01
title: Do something
run:
prompt: |
Do the work.
verify:
prompt: |
Audit the work.String values can reference runtime variables with ${name} placeholders.
Useful runtime placeholders include:
${workspace}${spec_name}${phase_id}${phase_title}${attempt}${run_id}${run_dir}${phase_dir}${attempt_dir}${latest_verifier_feedback_path}${latest_runner_result_path}
Two step types are supported:
codex_execshell
codex_exec is a convenience adapter around codex exec and can enforce structured JSON output with --output-schema.
shell can run either:
program+args- or
commandthrough the configured shell
For shell, exit codes map to statuses:
- success:
success_exit_codesorpassed_exit_codes - retry:
retry_exit_codes - blocked:
blocked_exit_codes
This repo also contains a generated spec for your System Zero phased build plan:
./bin/spec-loop run specs/system0-plan.yamlIt runs each phase with one fresh Codex CLI process, then runs a second fresh Codex CLI verifier before allowing the next phase to start. The System Zero verifier uses full-access mode because later phases must independently check public GitHub, PyPI, and Fly.io launch surfaces.