# Forks and answers

**Who this page is for:** anyone who wants to try "what if" on a recorded run, or answer a run
that waits on a person, from the Workbench.

A **fork** is a copy of a recorded run up to one moment, kept in a journal of its own in the
Workbench's folder. From that moment on it is an ordinary run: you can give it another answer,
let it ask the model again, and see where it ends, while the run it came from stays exactly as
it was recorded. **Answering** gives a run that waits on a person the answer it waits for, and
drives it on as far as it goes.

- **You will be able to:** fork a run from any moment of its timeline, find a fork beside the
  run it came from, answer a question or an approval in a fork, continue a fork, delete one,
  and decide when to answer in the project's own journal instead.
- **Read first:** [Reading a run](runs.md). [Forking a run](../guides/forking-a-run.md) is the
  same idea in Python.
- **Time:** about 10 minutes.

## Where a fork lives

```mermaid
flowchart LR
    project[("This project's journal<br/>.gvn/journal.sqlite<br/>release-awaiting-approval: 0 … 9")]
    fork[("Fork 1<br/>.gvn/workbench/forks/1.sqlite<br/>records 0 … 9, then its own")]
    launcher["A Launcher over the fork<br/>the project's model, tools, policy"]
    person(["You, answering"])
    project -- "copy of records 0 … 9" --> fork
    person -- "answer" --> launcher
    launcher -- "new records" --> fork
```

A fork is made by gvn's [`Fork`](../guides/forking-a-run.md): the run's first snapshot and its
records up to and including the chosen moment are copied, unchanged, into a new SQLite journal
under `.gvn/workbench/forks/`, one file per fork, with a small note beside it saying where it
came from. The fork keeps the run's id, its request ids and its tools' idempotency keys, which
is why it needs a journal of its own. The project's journal is only read.

When the fork is answered or continued, the Workbench drives it with a gvn
[`Launcher`](../concepts/harnesses.md#running-a-harness) over the fork's journal, built from
the harness and the project's own model and clock. Real work happens after the fork point:
the model is asked again, a tool runs. A fork's tools reach whatever the project's tools
reach, so a project whose tools change things in the world gives its development wiring tools
bound to a test service or to fakes, as the release review does with its fixed CI server.

## Forking a run

On a run page, the selected moment's row in the timeline has a **Fork here** button, with the
sentence "A fork is a copy of this run up to this moment, kept in the Workbench's own folder;
the original run is never changed." Pressing it makes the fork and opens it: the same run
page, now reading the fork's journal, with a note saying what it is a copy of and where its
file is.

Any moment can be forked, because every record is a point where the run could have been
recovered:

- fork at the moment before a person answered, and give another answer;
- fork at a moment where an actor had asked the model and not yet heard back, and continue:
  the model is asked again;
- fork the last moment of a waiting run, and answer it without touching the recorded run.

Each fork is listed under **Forks of this run** on the run it came from, and in the journal
chooser of **Runs** (see [Journals](journals.md)). A fork can be forked again. A fork is
deleted from its own page: its file and its note are removed, and nothing else.

## Answering what a run waits on

A run that waits on a person shows each question in its header, with a form to answer it.
**Waiting on you** lists them all, across the project's journal and every fork.

| The run asks | You give |
|---|---|
| a question (`request_input`, from an `Inquiry`) | one of its choices when it has any, and text |
| an approval (`request_approval`, from an `Approval` or an agent's held tool calls) | approve, or deny with a reason |

The answer is recorded with who gave it: a [principal](../reference/glossary.md#principal) named
"a person at the Workbench" unless another name is given, issued by "gvn workbench". Then the
run is driven on as far as it goes: to its end, or to the next thing it waits for. The page
says what was done and how many records were written.

An answer the question does not accept (a choice it does not offer, for example) is refused
with the reason, and nothing is written.

### In a fork, or in the project's journal

Where you answer decides what changes:

- **In a fork**, the answer is written to the fork's journal. The recorded run is unchanged, and
  you can make as many forks with as many answers as you like. This is the way to try an answer.
- **In the project's journal**, the answer is written to the project's own recorded run, as the
  harness would record it in production. The page asks you to confirm it first, and offers to
  fork and answer there instead. Over the JSON interface, such an answer must also say
  `"journal": "project"` in its body.

A run in a journal [opened from elsewhere](journals.md#a-journal-recorded-elsewhere) is never
answered: that journal is only read. Fork the run, and answer the fork.

For example, `release-awaiting-approval` waits on the release manager. Fork it at its last
moment, 9, and answer `revise` with the text "Add a smoke test.": the fork writes one record,
the `Inquiry` ends `answered`, the release decision reads `revise`, and the fork's run ends in
`needs_changes`. The project's run still waits.

## Continuing a run

A fork that stands still without waiting on a person (it was forked at a moment where it had
asked for work) has a **Continue the run** button. Continue recovers the run from its journal
and drives it on: the work it was waiting for is done again, a model is asked again, a tool
runs again. The same journal rules apply as for answering.

## What a fork shares with the run it came from

| Shared | Not shared |
|---|---|
| the run's id, its records up to the fork point, its request ids and idempotency keys | every record after the fork point |
| the harness and the project's wiring (model, tools, policy, clock) | the project's journal, which is only read |

[Forking a run](../guides/forking-a-run.md#what-the-fork-shares-with-the-original) explains why
the keys are shared, and what that means for tools that change things.

## Recap

- A fork is a copy of a run up to one moment, in its own journal under
  `.gvn/workbench/forks/`; the original is never changed.
- A fork is answered or continued with a gvn Launcher over its journal, with the project's
  wiring; real work happens after the fork point.
- Answer in a fork to try an answer; answer in the project's journal only to change the
  recorded run, after confirming. An opened journal is never answered.

**Next:** [Evaluating a change](evaluating-a-change.md).
