# Rollouts & ATIF Trajectory

Shipyard captures evaluation runs with full fidelity, structuring outputs according to the **Agent Trajectory Interchange Format (ATIF)**.

---

## Directory Organization

Every evaluation creates a timestamped or named rollout directory inside `rollouts/`:

```
<eval-dir>/rollouts/<run-id>/
├── trajectory.json    # Standardized ATIF trajectory schema
├── conversation.json  # Raw message transcripts (if captured)
├── tool_calls.json    # Detailed tool invocation captures
├── metrics.json       # v1 metrics: verdict, usage, timing, turn counts
├── rubrics.json       # Itemized rubric scoring results
├── run.json           # Provenance for this rollout
├── aggregate.json     # Aggregate verdict and statistics
├── results.json       # Suite results (consumed by compare/report)
└── artifacts/         # Environment artifacts, diffs, and container logs
    └── environment.log
```

### Layout with `--repeat K`

With `k > 1`, the per-repeat artifacts move into per-repeat subdirectories and
the suite-level files stay at the run root:

```
<eval-dir>/rollouts/<run-id>/
├── repeat-1/
│   ├── trajectory.json
│   ├── conversation.json
│   ├── tool_calls.json
│   ├── metrics.json
│   ├── rubrics.json
│   └── artifacts/
├── repeat-2/
│   └── ...
├── repeat-3/
│   └── ...
├── run.json           # one per rollout
├── aggregate.json     # k, pass@k, pass^k, mean/sigma, per-repeat records
└── results.json       # suite results across evals
```

Each repeat is an isolated sample: the eval workspace is restored between
repeats and after the run (unless `--keep-workdir` / `--keep-env` is passed).

---

## ATIF Trajectory Schema (`trajectory.json`)

The ATIF schema enables cross-platform interchange, analysis, and replay of agent behaviors.

### Example `trajectory.json`

```json
{
  "version": "1.0.0",
  "eval_name": "fix-memory-leak",
  "agent": "claude-code",
  "start_time": "2026-09-21T13:30:00Z",
  "end_time": "2026-09-21T13:30:45Z",
  "steps": [
    {
      "turn": 1,
      "messages": [
        {
          "role": "system",
          "content": "You are an autonomous engineering agent."
        },
        {
          "role": "user",
          "content": "Find and fix the memory leak in cache.go."
        }
      ],
      "tool_calls": [
        {
          "tool": "bash",
          "arguments": { "command": "grep -rn 'sync.Pool' ." }
        }
      ],
      "action": "bash",
      "output": "cache.go:42: var pool = sync.Pool{}",
      "timestamp": "2026-09-21T13:30:10Z"
    },
    {
      "turn": 2,
      "messages": [
        {
          "role": "assistant",
          "content": "Found the unreleased buffer. Writing patch now."
        }
      ],
      "action": "edit",
      "output": "Successfully patched cache.go",
      "timestamp": "2026-09-21T13:30:35Z"
    }
  ]
}
```

---

## Metrics Schema (`metrics.json`)

v1 of `metrics.json` carries the verdict for one repeat, plus usage when the
harness can report it:

```json
{
  "schema_version": "1",
  "run_id": "2026-09-21T13-30-00Z",
  "eval_name": "fix-memory-leak",
  "repeat_index": 1,
  "verdict": "passed",
  "score": 1.0,
  "turns": 2,
  "duration_ms": 45120,
  "timestamp": "2026-09-21T13:30:45Z",
  "status": "completed",
  "usage": {
    "input_tokens": 18422,
    "output_tokens": 3110
  }
}
```

### Verdict taxonomy

| Field | Values | Notes |
|---|---|---|
| `verdict` | `passed` \| `failed` \| `errored` | Per repeat. |
| `error_kind` | `agent` \| `infra` \| `rubric` | Omitted when the repeat passed. Infra kills (sandbox failure, timeout, killed container) and rubric process failures fail closed and are labeled `infra` or `rubric`, never "the agent failed". |
| `usage` | object or `null` | `null` when the harness cannot report tokens (CLI harnesses show n/a, API plugins report real numbers). See [Costs & tokens](/docs/costs-and-tokens). |

Every verdict JSON carries `schema_version`. The aggregate verdict adds
`flaked` (the repeats disagreed), so a run can be `passed`, `failed`,
`errored`, or `flaked`. The counts in the example are illustrative; the
contract is the field: harness-reported numbers, or `null`.

---

## Rubrics Schema (`rubrics.json`)

Contains the itemized grading score produced by the rubric:

```json
{
  "eval_name": "fix-memory-leak",
  "items": [
    {
      "name": "unit-tests-pass",
      "score": 1.0,
      "threshold": 1.0,
      "passed": true,
      "description": "All existing unit tests pass"
    },
    {
      "name": "benchmark-no-alloc",
      "score": 1.0,
      "threshold": 1.0,
      "passed": true,
      "description": "Memory allocations reduced by > 50%"
    }
  ],
  "aggregate_score": 1.0,
  "passed": true
}
```

`conversation.json` and `tool_calls.json` hold the message transcript and the
tool invocations for the rollout. Both are also handed to the rubric on stdin;
see [Asserting on tool calls & conversations](/docs/tool-and-conversation-rollouts).

---

## Provenance (`run.json`)

One `run.json` per rollout records what produced the score: engine/CLI/Go
versions and commits, the agent plugin and resolved command, model,
best-effort `harness_version`, the resolved `environment` (`type`, `image`,
`image_id`, `dockerfile`), `config_hash`, `suite_digest`, and timestamps.
`config_hash` covers the resolved execution config (two machines with the same
config produce the same hash); `suite_digest` covers the bound eval
definition. Full field reference: [Provenance](/docs/provenance).

---

## Aggregate (`aggregate.json`)

The aggregate is written once per rollout and carries:

| Field | Meaning |
|---|---|
| `k` | Repeats per eval. |
| counts | Passed / failed / flaked / errored totals. |
| `flaked` | Whether the repeats disagreed. |
| `verdict` | The aggregate verdict. |
| `pass@k` / `pass^k` | At-least-one pass / all-repeat pass. |
| `mean_score`, `sigma_score`, `score_ci95` | Distribution of repeat scores. |
| `usage` | Aggregated usage, or `null` / `partial` when not every repeat could report. |
| per-repeat records | Per-repeat verdicts and scores. |
| `suite_digest`, `definition_digest`, `definition_files` | The same-suite binding plus per-file hashes. |

---

## Suite Results (`results.json`)

`results.json` is the suite-level document, and the file `compare` and
`report` consume:

| Field | Meaning |
|---|---|
| `schema_version` | Schema version for the results document. |
| `target_type`, `target_name` | Eval or evalset, and its name. |
| `run_id` | The run these results came from. |
| `suite_digest` | Digest of the bound suite definition. |
| `k` | Repeats per eval. |
| `verdict` | Suite verdict. |
| `totals` | `evals`, `passed`, `failed`, `flaked`, `errored`, `mean_score`, `usage`. |
| `evals[]` | Per-eval aggregates (the same data a baseline stores). |

`shipyard run --json` prints this document to stdout (without changing the
exit code's meaning), and `shipyard run --report` writes it to disk. A later
job can re-render Markdown, JSON, and JUnit from it with `shipyard report`, and
`shipyard baseline save --results results.json` can freeze it as a baseline.

---

## Where each file is consumed

| File | Consumed by |
|---|---|
| `trajectory.json` | ATIF tooling, replay, human review. |
| `conversation.json`, `tool_calls.json` | Rubric assertions via stdin; post-mortems. |
| `metrics.json` | Per-repeat verdicts, usage, and cost estimates. |
| `rubrics.json` | Why an eval scored what it scored. |
| `run.json` | Provenance, compare attribution, CI diagnostics. |
| `aggregate.json` | Repeats & statistics, flake detection, baselines. |
| `results.json` | `shipyard compare`, `shipyard report`, `baseline save --results`. |
| `baselines/<name>.json` | The committed reference for `shipyard compare`. |
