Skip to content

Commit 3c72456

Browse files
Kasper Jungeclaude
authored andcommitted
docs: document iterations endpoint and persistence layer so users can query run history via the API
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 317fef9 commit 3c72456

2 files changed

Lines changed: 73 additions & 2 deletions

File tree

docs/changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ All notable changes to ralphify are documented here.
2222
- **WebSocket event type reference** — dashboard docs now include a complete table of all event types and their data fields.
2323
- **Codebase migration cookbook recipe** — step-by-step guide for automating JavaScript-to-TypeScript migrations, with adaptation tips for Python 2→3, CommonJS→ESM, and more.
2424
- **Contributor docs** — new `docs/contributing/` section with a codebase map, replacing the old `agent_docs/` directory.
25+
- **Iterations API endpoint**`GET /api/runs/{run_id}/iterations` returns persisted iteration data with per-check results, enabling History tab drill-downs and custom reporting.
26+
- **Persistent run history** — the dashboard stores run history, iterations, and check results in a SQLite database at `~/.ralph/ui.db` that survives across restarts.
2527

2628
### Fixed
2729

docs/dashboard.md

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,19 @@ To apply primitive configuration changes to a running run, **stop** the run and
181181
!!! tip "Prompt edits are always live"
182182
The most common adjustment — adding a constraint or changing the task in your prompt — takes effect on the very next iteration without restarting. This is the primary way to steer the agent in real time.
183183

184+
## Data storage
185+
186+
The dashboard persists run history, iterations, check results, and raw events
187+
in a SQLite database at `~/.ralph/ui.db`. This is what powers the History tab
188+
and the iterations endpoint — data survives across dashboard restarts.
189+
190+
The database is created automatically on first launch. To reset all history,
191+
stop the dashboard and delete the file:
192+
193+
```bash
194+
rm ~/.ralph/ui.db
195+
```
196+
184197
## Architecture
185198

186199
The dashboard is a single-page app that talks to a FastAPI backend:
@@ -261,7 +274,13 @@ Response:
261274
"iteration": 0,
262275
"completed": 0,
263276
"failed": 0,
264-
"timed_out": 0
277+
"timed_out": 0,
278+
"prompt_name": null,
279+
"started_at": "2026-03-11T14:23:01.123456",
280+
"max_iterations": 5,
281+
"delay": 2.0,
282+
"timeout": 300.0,
283+
"stop_on_error": true
265284
}
266285
```
267286

@@ -285,7 +304,13 @@ curl http://127.0.0.1:8765/api/runs
285304
"iteration": 3,
286305
"completed": 2,
287306
"failed": 1,
288-
"timed_out": 0
307+
"timed_out": 0,
308+
"prompt_name": "docs",
309+
"started_at": "2026-03-11T14:23:01.123456",
310+
"max_iterations": 5,
311+
"delay": 2.0,
312+
"timeout": 300.0,
313+
"stop_on_error": true
289314
}
290315
]
291316
```
@@ -327,6 +352,50 @@ All fields are optional — only the ones you include are updated:
327352
| `timeout` | float\|null | New timeout per iteration |
328353
| `stop_on_error` | bool\|null | Whether to stop on agent errors |
329354

355+
#### Get iterations for a run
356+
357+
Retrieve persisted iteration data with per-check results — useful for reviewing
358+
past runs or building custom reports.
359+
360+
```bash
361+
curl http://127.0.0.1:8765/api/runs/a1b2c3d4/iterations
362+
```
363+
364+
```json
365+
[
366+
{
367+
"iteration": 1,
368+
"status": "success",
369+
"returncode": 0,
370+
"duration": "52.3s",
371+
"checks": [
372+
{"name": "tests", "passed": true, "exit_code": 0, "timed_out": false},
373+
{"name": "lint", "passed": true, "exit_code": 0, "timed_out": false}
374+
]
375+
},
376+
{
377+
"iteration": 2,
378+
"status": "failure",
379+
"returncode": 1,
380+
"duration": "23.1s",
381+
"checks": [
382+
{"name": "tests", "passed": false, "exit_code": 1, "timed_out": false},
383+
{"name": "lint", "passed": true, "exit_code": 0, "timed_out": false}
384+
]
385+
}
386+
]
387+
```
388+
389+
Each iteration includes:
390+
391+
| Field | Type | Description |
392+
|--------------|-------------------|----------------------------------------------------------|
393+
| `iteration` | int | Iteration number (1-indexed) |
394+
| `status` | string | `"success"`, `"failure"`, `"timeout"`, or `"running"` |
395+
| `returncode` | int\|null | Agent exit code (`null` if timed out or still running) |
396+
| `duration` | string\|null | Formatted duration (e.g. `"52.3s"`) |
397+
| `checks` | array\|null | Per-check results, or `null` if no checks ran |
398+
330399
### Primitives
331400

332401
Primitive endpoints use a base64-encoded `project_dir` in the URL path. Encode

0 commit comments

Comments
 (0)