# Runs, logs and insights

Every job that ran on Groundbox can be read with an API key with `ci:read`: its run, its log, how it compares with GitHub's runners, and how the job does over time.

```
groundbox ci runs --repo acme/app --failed --limit 20          # newest first
groundbox ci logs <job_id>                                      # the whole log, by step
groundbox ci logs <job_id> --follow                             # a running job's log as it comes
groundbox ci job <job_id> --compare                             # the job, and beside GitHub-hosted runners
groundbox ci search "connection refused" --repo acme/app         # search the logs
groundbox ci insights                                           # per job: time, failures, cost, a size tip
groundbox tests flaky                                           # tests that failed and passed on one commit
```

- API: `GET /v1/ci/runs` (`?result=failed` for the jobs that failed or timed out), `GET /v1/ci/jobs/{id}`, `GET /v1/ci/jobs/{id}/logs`, `GET /v1/ci/jobs/{id}/comparison`, `GET /v1/ci/logs/search`, `GET /v1/ci/insights` and `GET /v1/ci/tests`, all with `ci:read`.
- `GET /v1/ci/tests` is worked out in the background and kept a few minutes: `computed_at` says when, and `refreshing` is true while newer numbers are on their way (ask again in a few seconds). The first answer for a period with a lot of results can take a few seconds: until then `computed_at` is null and the lists are empty. The SDKs and the CLI wait for it.
- Live log: `GET /v1/ci/jobs/{id}/log/live` (`ci:read`) answers with Server-Sent Events while the job runs: `hello`, then `log` events with new lines and step changes, and `bye` when it ends. A job that has ended answers 404; read its log with `/logs`. A key holds a few streams at once, and its streams end when it is revoked.
- SDKs, in TypeScript and Python: `list_ci_runs`, `get_ci_logs`, `follow_ci_log`, `get_ci_job`, `get_ci_job_comparison`, `search_ci_logs`, `get_ci_insights` and `get_flaky_tests`.
- MCP: `ci` (actions `runs`, `logs`, `search_logs`, `wait`, `diagnosis`) and `ci_stats` (actions `insights`, `flaky`, `timings`, `auto_sizes`).
