# Files and safety

**Who this page is for:** developers and anyone responsible for a machine the Workbench runs
on: which files it writes, and how its site stays reachable from this computer only.

The Workbench can write files: the project's cases files, the project's Python when an edit is
saved, and recorded runs when a run is answered. So it keeps everything it writes for itself in
one folder of the project, and it serves its site in a way that nothing outside this computer,
and no other web page in your browser, can use it.

- **You will learn:** what lives in `.gvn/workbench/`, what else the Workbench writes, and the
  rules every request to the site passes.
- **Read first:** [The Workbench](index.md).
- **Time:** about 5 minutes.

## What the Workbench writes

```mermaid
flowchart LR
    wb["The Workbench"]
    subgraph project ["The project's folder"]
        direction TB
        python["Python files<br/>only on a save you confirm"]
        cases["Cases files<br/>only when a run becomes a case"]
        journal[("The project's journal<br/>only when you answer there")]
        home[(".gvn/workbench/<br/>everything else")]
    end
    wb --> python
    wb --> cases
    wb --> journal
    wb --> home
```

Reading never changes the project. Every action that writes says what it writes and where.

| Where | What | Written when |
|---|---|---|
| the project's Python files | a patch of an edit group | you save an edit group or a proposal, after preview and verification ([Editing a harness](editing.md)) |
| a cases file of the project | one case appended | you save a run as an eval case ([Evaluating a change](evaluating-a-change.md#a-run-becomes-an-eval-case)) |
| the project's journal | an answer, and the records the run then writes | you answer or continue a run in the project's journal, after confirming ([Forks and answers](forks-and-answers.md#in-a-fork-or-in-the-projects-journal)) |
| the eval stores and files | cases and reviews | the Evals section writes what [the web page](../evals/web-page.md) describes |

## The Workbench's own folder

Everything else is under `.gvn/workbench/` in the project's folder, made with mode 0700:

| Path | What it holds |
|---|---|
| `mcp-token` | the token coding agents send to `/mcp`; made on the first start (mode 0600) and kept |
| `forks/<id>.sqlite` | one journal per fork |
| `forks/<id>.json` | the fork's note: the journal, run and moment it was forked from |
| `opened.json` | the journal files opened to be read, by path |
| `proposals/` | the edit groups agents proposed, waiting for a person |
| `layouts.json` | the positions of the boxes on each drawing |
| `guide.sqlite` | the guide's conversations, journaled as gvn runs |

Nothing in this folder is needed to run the harness, and nothing the project ships reads it.
Keep `.gvn/` out of version control, as the release review example does; its journal and
results stores are there too.

## How the site stays on this computer

The site listens on **127.0.0.1** only, never on another interface: no other computer can reach
it. Every request, whichever section answers it, passes the same rules:

- **The Host header** must name this computer, `127.0.0.1` or `localhost`, with the site's
  port. A web page elsewhere cannot reach the site by pointing a name of its own at 127.0.0.1.
- **Changing requests** (POST, PUT, DELETE, PATCH) must carry the header `X-Gvn-Token` with the
  page's token, and, when the browser names an `Origin`, come from the site itself. The page's
  token is random, made when the Workbench starts and written only into the page it serves.
- **Requests to `/mcp`**, of any method, must carry the MCP token instead, and, with an
  `Origin`, come from the site itself.
- **Request bodies** are at most 1 MB, announced by their length.
- **Every answer** carries `Content-Security-Policy: default-src 'self'`,
  `X-Content-Type-Options: nosniff`, `Cache-Control: no-store`, `X-Frame-Options: DENY` and
  `Referrer-Policy: no-referrer`. The page loads nothing from other sites.
- **Static files** come only from each section's own folder, with a fixed list of types.

A refused request gets one sentence saying why, as JSON.

### Two tokens

| Token | Where it comes from | What it reaches |
|---|---|---|
| The page's token | made at each start, written into the page | every changing request of the site, except `/mcp` |
| The MCP token | `.gvn/workbench/mcp-token`, kept between starts | `/mcp` only |

The two are never interchangeable. That is what makes "agents propose, people approve" hold:
an agent with the MCP token can read and propose, but saving a proposal, answering a run or
saving a case needs the page's token, which only the page holds. While the Workbench restarts
after a save, its supervisor keeps the port and both tokens, so an open page and a connected
agent keep working.

## Recap

- The Workbench writes the project's Python, cases files and journal only on actions that say
  so; everything else it keeps under `.gvn/workbench/`.
- The site listens on 127.0.0.1, checks the Host header, requires the page's token for changes
  and the MCP token for `/mcp`, and serves nothing from elsewhere.

**Next:** [The JSON interface](reference.md).
