> For AI agents: the complete documentation index is available at https://docs.phax.run/llms.txt, the full documentation bundle is available at https://docs.phax.run/llms-full.txt.

# Run records

## Records \{#records}

A record is what a phase leaves behind for later: on a `phax/records/v1` branch, one commit per phase, holding its manifest, its gate results and the surfaces they verified, its file reconciliation, its diff, its handoff and logs, and the agent's transcript if you keep it. A headless authoring session leaves one too, and so do every `phax artifact decide` session, every `phax artifact revise` session and every finding's fate. With records on, each compliance review a run generates is kept too, as a review entry `<runId>/compliance-review/` beside the run's phase records: its `compliance-review.json` and a `record.json`. An accepted `code-review.json` is kept as a `<runId>/code-review/` entry, as the compliance review's file is. A later review of the run replaces the file, and the earlier one stays in the branch's history. `phax records list` shows the entry, and `phax records status` lists it while it is unpushed. Worktrees come and go; the records stay, and they travel with a clone.

```bash
phax records init               # choose: keep transcripts, where the branch lives, push automatically
phax records status             # records not pushed yet, by run and phase
phax records sync               # bring the local records clone in line with its remote
phax records list [--run <id>]  # the records present, by run and phase
phax records explain <commit>   # a commit's record: prompt, diff, gates, handoff, transcript, usage
```

The branch can live in the same repository or in a separate one. Transcripts can hold anything the agent read, so phax refuses to keep them on a public repository's own records branch, and on one it cannot tell is private (the refusal quotes `gh`'s first line: retry after a network or authentication failure, or confirm the repository is private with `records.destination.acknowledgedUnknownVisibility`). `records explain` takes `--prompt`, `--diff`, `--transcript` or `--gates` to print each part in full. A phase that stopped for a person's review, declared or held, records its stop too (mode, cause, outcome, closer and sessions, never a transcript's content): see [The record of a stop](https://docs.phax.run/guide/run.md#the-record-of-a-stop). To read records from another tool, see [Read phax files from code](https://docs.phax.run/reference/formats.md#read-phax-files-from-code).

The default view lists each gate attempt under the `gates` line with its duration, then each step's command, surface, result and duration, then the protected-paths check. This is where the gate time went and what each fix attempt cost. The times come from the gate attribution of each attempt, `checks-attempt-NN.attribution.json`. The `profile` line above it names the gate profile that gated the run, or `(not recorded)` for a record written before phax recorded it.

```
profile  standard
gates    committed after 2 attempt(s)   surfaces  local, structural
  attempt 01   192.6 s
    pnpm typecheck     local        pass     712 ms
    pnpm test          local        fail    191.3 s
    protected paths                 pass      84 ms
  attempt 02   195.0 s
    pnpm typecheck     local        pass     705 ms
    pnpm test          local        pass    190.4 s
    pnpm lint          structural   pass      2.4 s
    protected paths                 pass      81 ms
```

A duration under a second shows in milliseconds. A record written before times were recorded shows `time unknown`. A skipped acceptance step shows `not run`. An attempt with no readable step record shows `steps unknown`. With `--json`, the answer's `gateAttempts` holds the same attempts, steps and times, and its `gateProfile` the profile's id, or `null` when the record did not record it.

### When the records branch and its remote disagree \{#when-the-records-branch-and-its-remote-disagree}

A record lands on top of the records remote's tip as phax last fetched it, so a branch that lags its remote catches up in the same step that writes the record. `phax records status` compares the local `phax/records/v1` with the remote's and reports one of seven states:

- **in sync**: both tips are the same commit.
- **ahead**: the local branch holds records the remote does not. They are pending; push them.
- **behind**: the remote holds records the local branch does not.
- **diverged**: each side holds records the other lacks.
- **unrelated**: the two branches share no commit.
- **missing locally**: the remote has a records branch and this clone has none.
- **not on the remote yet**: the local branch exists and the remote has none.

`phax records sync` fetches the remote, then acts on the state:

- missing locally: it creates the local branch at the remote's tip.
- behind: it fast-forwards the local branch to the remote's tip.
- ahead, in sync, not on the remote yet: it moves nothing and says where the branch stands.
- diverged or unrelated: it refuses and names `phax records sync --replay`.

`--replay` recommits each local-only record, oldest first, onto the remote's tip. A replayed record keeps its tree, its message and its author name, email and date; only its parent, committer and sha change. A local-only record the remote already holds, file for file, is left out and counted. One whose key the remote also holds with other content (a decision taken under the same number on two machines) is replayed all the same and its key is named: both stay on the branch, and readers take the newest. The previous tip is printed, and Git's reflog keeps it. In any other state `--replay` does what plain `sync` does and says there is nothing to replay. It works for a dedicated records repository and for the in-repo destination, where the records branch is fetched from `publish.remote`.

phax never forces the records branch: no push uses `--force` or a `+` refspec. A push that the remote refuses leaves the records pending and names the state and the sync command to run.

For example, a clone whose records branch was started again, so that it shares no commit with `origin`'s:

```console
$ phax records status
Records destination: repo "git@example.com:team/records.git" (local clone: /home/me/.phax/records/team-records)
Records branch: unrelated to origin's (local a41c0de, origin 3f2a9c1) — run `phax records sync --replay`
Pending: 3 record(s) across 1 run(s)
  add-export (phase-01, phase-02, phase-03)

$ phax records sync --replay
Fetched records into /home/me/.phax/records/team-records
Replayed 3 record(s) onto origin's tip 3f2a9c1 → new tip 8be40d2 (previous tip a41c0de)
Push them with the next record, or `git -C /home/me/.phax/records/team-records push origin phax/records/v1`
```

The next push, whether the next record's or the `git push` printed above, fast-forwards the remote.
