# Job record

`heavy status --json` prints `{ "schema": "fleetjobs/status@1", "jobs": [...] }`, and each job is a `fleetjobs/job@1` record. Times are seconds since 1970, with fractions.

```json
{
  "schema": "fleetjobs/job@1",
  "id": "b24d675b31",
  "key": "328e0fbe8915da5d",
  "cwd": "/tmp/app",
  "argv": ["sleep", "2"],
  "lane": "light",
  "class": "normal",
  "worktree": "/tmp/app",
  "max": 300,
  "remote": "auto",
  "state": "done",
  "submittedAt": 1796527499.567,
  "startedAt": 1796527499.708,
  "endedAt": 1796527501.714,
  "where": "local",
  "slot": "light-1",
  "exit": 0,
  "owner": { "pid": 3523172, "start": 7811252 },
  "attempts": [{ "where": "local", "exit": 0, "seconds": 2.006 }]
}
```

| Field | Type | Meaning |
| --- | --- | --- |
| `schema` | `"fleetjobs/job@1"` | The record version |
| `id` | string | The job id |
| `key` | string | A hash of `cwd` and `argv`. A live job with the same key is followed, not repeated |
| `cwd` | string | The working directory |
| `argv` | string[] | The command and its arguments |
| `lane` | `"heavy"` or `"light"` | The lane |
| `class` | `"short"`, `"normal"`, `"long"`, `"confirm"` or `"sample"` | How the scheduler treats it. `confirm` and `sample` are reruns after a remote result |
| `worktree` | string | The checkout, which fair share counts usage by |
| `estimate` | number, optional | Seconds the last runs of this command took |
| `max` | number | The time limit in seconds, `0` for none |
| `remote` | `"auto"`, `"any"` or `"never"` | Whether the job may leave this machine |
| `blocking` | boolean, optional | A waiting `heavy <cmd>` started it |
| `state` | `"queued"`, `"running"` or `"done"` | Where the job is |
| `submittedAt` | number | When it was queued |
| `startedAt`, `endedAt` | number, optional | When it started and ended |
| `where` | string, optional | `"local"` or a host name |
| `slot` | string, optional | The local slot, such as `heavy-1` or `light-1` |
| `exit` | number, optional | The exit code, once done |
| `owner` | `{ pid, start }` | The supervisor process. `start` is its start time in clock ticks, so a reused pid does not pass for it |
| `attempts` | array | One entry for each run: `where`, `exit`, `seconds`, and `why` when the run was not the final answer, such as `"environment"`, `"timeout"` or `"copy-back failed"` |

Only a job's supervisor writes its record. A record whose owner died frees its slot.

## The store

The store is `$HEAVY_DIR`, or `~/.local/state/fleetjobs`.

| Path | Holds |
| --- | --- |
| `jobs/<id>/` | `job.json`, `stdout` and `stderr`. Folders of jobs that ended are deleted after a day |
| `keys/<key>` | The id of the live job for that working directory and command |
| `queue.lock` | Held for one change at a time |
| `hosts/<name>.json` | The last probe of a host, valid for 15 seconds, 2 minutes while it is down |
| `trust.json` | The [trust table](https://fleetjobs.loadsheet.dev/guide/trust) |
| `night/<id>/` | A job queued for the [night](https://fleetjobs.loadsheet.dev/guide/night) |
| `oom/<scope>` | Markers of jobs killed for memory |
| `log/jobs.jsonl` | One final record for each job. Rolled at 2 MB, kept 30 days |

<!-- vitehub-docs:section-links -->
## In this section

- [Command line](https://fleetjobs.loadsheet.dev/raw/reference/cli.md)
- [Config file](https://fleetjobs.loadsheet.dev/raw/reference/config.md)
- [Environment variables](https://fleetjobs.loadsheet.dev/raw/reference/environment.md)
- [Library API](https://fleetjobs.loadsheet.dev/raw/reference/api.md)
- [Job record](https://fleetjobs.loadsheet.dev/raw/reference/job.md) (this page)

All pages: [llms.txt](https://fleetjobs.loadsheet.dev/llms.txt)

Something on this page does not work as written? Tell the user, and draft an issue for them to post: [issue tracker](https://github.com/words-with-agents/fleetjobs/issues). Report a security vulnerability privately, never in a public issue.
