Ralph Loop v2: codified autonomous software-building harness - #10
Merged
Merged
Conversation
Split into packages/create-ralph-loop (scaffolder, bumped to 2.0.0, chalk dropped, eta added) and packages/ralph (new ralph-loop runtime, bin: ralph, CommonJS). Root becomes a private workspaces root with shared tsx/vitest/tsc tooling. No user-facing behavior change yet. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…s + util zod schemas for ralph.config.json (Fable/Codex/Haiku default routing) and features.json v2 (status/depends_on/attempts/verification/lease). Adapter and event type contracts. Cross-platform proc runner (cross-spawn, no execa/ESM), git helpers, paths, logger, and the Gate context contract. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adapters: claude (-p --output-format json, usage/cost parse), codex (exec --json, sandbox tiers), mock (scripted turns for tests), registry. Gates: baseline-relative command gates (tsc/test/build), featureIntegrity (hash), diffSize. 43 unit tests. Also fix a Windows cross-spawn bug: shell:true misreported exit code 1 as ENOENT, which would break gate commands like `npm test`. runShell now uses Node's native spawn for the shell path; cross-spawn stays for argv spawns. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- features: FeatureStore (harness-only transitions, deterministic serialization + integrity hash), DAG validation/selection with depends_on gating, v1->v2 migration - devserver: cross-platform TS dev-server lifecycle (spawnDetached + fetch readiness + tree-kill), replacing the bash dev-up/down scripts - events: progress.jsonl EventLog + resumable run-state store with per-role usage accounting - prompts: eta template rendering (override-aware) + fail-closed <ralph-result>/ <ralph-verdict>/<ralph-plan-update> parsing; v2 prompt assets (coding injects the feature, no self-grading; verifier; replanner; dependency-minimized init; prd; gardener) 108 unit tests, full strict build green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The orchestrator: iteration state machine (checkpoint -> coder -> stage -> mechanical gates -> independent fail-closed verifier -> accept-commit or hard-revert), DAG-eligible feature selection, bounded retries then block, per-role token/cost accounting, cost/iteration/time budgets, stall detection, and webhook/desktop notifications. CLI: run, dev up|down|status, doctor, status, migrate (v1 feature_list.json + bash scripts -> v2). Completion is now "all features verified" — the vestigial <promise>COMPLETE </promise> sentinel is gone. Success is no longer self-graded: the harness owns features.json (integrity gate) and an independent verifier confirms every pass. 7 end-to-end scenarios (real git, mock adapters) cover happy path, verifier pass/fail, gate-failure retry+block, features.json tamper revert, dependency ordering, and agent give-up. 115 tests total, strict build green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…Ms, exports - replanner: strong-model periodic review emitting validated <ralph-plan-update> ops (reprioritize/block/unblock/split/prune/add_dependency); verified features protected; DAG re-validated before apply. Wired into the loop on a cadence. - gardener: periodic entropy/"AI slop" cleanup pass, gated like a coding turn. - aider adapter: local-LLM path (ollama/openrouter models) behind the adapter interface; role-based routing table already honored end to end. - CLI: `ralph plan` (planner generates PRD/app_spec/features), `ralph export --format eval-jsonl` (verification records for offline eval). - config: garden cadence + devServer.portRange groundwork for parallel tracks. - JSON Schema generation (schema/ralph.config.schema.json) for editor validation. - Tests: replanner ops, aider parsing, replan e2e scenario. 130 tests total. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Emit projects for the ralph-loop v2 runtime: ralph.config.json (with $schema,
Fable/Codex/Haiku routing, gates/budgets/replan/verify), features.json v2 seed
(dependency-minimized INFRA/UI/FEAT), AGENTS.md as a docs/ table-of-contents,
docs/ knowledge-base skeleton. Delete the shipped bash loop/dev scripts and old
prompt files (the runtime owns these now) and the duplicated adopt-mode script
string literals from cli.ts. Templating moves from a naive {{var}} regex to eta.
Detection feeds the rendered config (devServer command/port, gates.test). Adopt
merges ralph-loop into devDependencies and points at `ralph migrate`. 5 smoke
tests validate the output against the runtime's zod schemas.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… README for v2 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add npm-landing READMEs for ralph-loop (runtime) and create-ralph-loop (scaffolder), copy LICENSE into each package for clean publishing, and add a root CHANGELOG documenting the v1→v2 rewrite and migration. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
spawnDetached passed the log-file descriptor to the child but never closed the parent's copy. On Windows that keeps dev-server.log locked for the life of the harness, so deleting/cleaning .ralph fails with ENOTEMPTY (red on windows CI). Close the parent fd after spawn; the child keeps its own inherited handle. Also harden two tests: retry temp-dir removal in the dev-server test (residual child-handle release lag on Windows) and recreate src/ in the e2e coder fixture (git clean -fd removes it on revert, which was masking retries as ENOENT throws). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ground-up v2 of the Ralph technique: replaces the 55-line
ralph.shwith a cross-platform TypeScript runtime (ralph-loop, binralph) in an npm-workspaces monorepo, alongside the slimmedcreate-ralph-loopscaffolder. Supervised-by-exception autonomous building with real, mechanical guardrails.Highlights
Guardrailed loop — each iteration is a harness-driven state machine:
git checkpoint → coder implements ONE feature → mechanical gates → independent verifier → accept-commit or hard-revert.featureIntegritygate makingfeatures.jsonharness-owned (no more self-grading).<promise>COMPLETE</promise>sentinel is gone..ralph/run-state.json; structured.ralph/progress.jsonl.<ralph-plan-update>ops, DAG-checked, verified features protected) and periodic gardener pass against entropy/"AI slop".Multi-model routing & local LLMs — roles → (adapter, model, permission tier) in
ralph.config.json. Default: Fable for planning, Codex for building, Haiku for cheap fail-closed verify. Adapters:claude,codex,aider(local viaollama/…).Parallel-ready schema —
features.jsonv2 withdepends_on/status/attempts/verification/dormantlease; DAG-aware selection; planner prompt rewritten to minimize inter-feature dependencies;devServer.portRangegroundwork.Windows-native — no bash in the happy path. Fixed a real cross-spawn bug where
shell:trueexit code 1 (e.g. failingnpm test) was misreported as ENOENT on Windows.CLI
ralph run|plan|dev|doctor|status|migrate|export— includingralph migrateto upgrade v1 projects (feature_list.json + ralph.sh → v2).Testing
ralph doctorpasses end to end (detects installed codex/claude CLIs).Deferred
Multi-framework greenfield template packs (old issue #1). The runtime is already framework-agnostic (configurable
devServer.command/gates; adopt-mode detects Vite/Remix/Astro/Next); shipping untested per-framework packs was left as a scoped follow-up.Design provenance: OpenAI harness-engineering, hermes-agent/Nightwire fail-closed verification, Anthropic multi-agent coordination guidance, Aider Architect/Editor + RouteLLM routing.
🤖 Generated with Claude Code