# File & JSON schemas

> Exact fields and byte caps for pitafix.project-capture/1, CAPTURE.md, pitafix.trace/1, pitafix.tree/1, pitafix.blueprint/1, and agents/tasks/*.md.

Every file below is validated by PitaFix's Go runtime with regular-file checks (symlinks and escaping paths are refused) and hard byte caps.

## Size limits

| Artifact | Schema ID / Location | Cap |
| --- | --- | --- |
| Project capture config | `.pitafix/capture.json` (`pitafix.project-capture/1`) | `256 KiB` |
| Capture playbook | `.pitafix/CAPTURE.md` | `64 KiB` |
| Level-0 trace NDJSON line | `$PITAFIX_TRACES_DIR/<run>/trace.ndjson` (`pitafix.trace/1`) | `64 MiB` / line |
| Normalized UI tree | `artifacts/*.tree.json` (`pitafix.tree/1`) | `128 MiB` |
| Markdown task file | `agents/tasks/*.md` | `512 KiB` / file (`8,000` chars `## Result`, max `2,000` files) |
| MCP serialized reply | `pitafix mcp` | `2 MiB` |

## 1. `.pitafix/capture.json` (`pitafix.project-capture/1`)

Lives in `<repo>/.pitafix/capture.json` or sidecar `<PITAFIX_DATA_DIR>/projects/<rootCommit>/capture/capture.json`. Parsed with `DisallowUnknownFields()`.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `schema` | string | Yes | Always `"pitafix.project-capture/1"`. |
| `command` | `string[]` | Yes | Argv executed with recorder environment variables. |
| `kind` | string | No | `"web"`, `"native"`, `"mobile"`, or `"trace"`. |
| `name` | string | No | Display label for the capture setup. |
| `workDir` | string | No | Repo-relative working directory for `command`. |
| `diffScoped` | boolean | No | `true` when the script honors `PITAFIX_DIFF_SCOPED`, `PITAFIX_AFFECTED_JOURNEYS`, and `PITAFIX_CHANGED_FILES`. |
| `live` | boolean | No | `true` when the script supports `PITAFIX_LIVE=1` hand-over via `POST /v1/sessions/{id}/hold`. |
| `allowedHosts` | `string[]` | No | Up to `64` bare external DNS hostnames (no scheme, port, or wildcard); requires one-time human approval. |
| `runInCopy` | boolean | No | Declared optional flag (reserved for git-archive copy execution). |
| `timeoutSeconds` | integer | No | Execution timeout in seconds (default `900`, max `21600`). |

## 2. Level-0 trace (`pitafix.trace/1`)

Write one folder per run under `$PITAFIX_TRACES_DIR/<unique-run-id>/` (or `.pitafix/traces/`) containing `trace.ndjson`, `artifacts/*.png`, and `artifacts/*.tree.json`. Give each capture a unique `run` ID (already-ingested run IDs are skipped idempotently).

| Record `type` | Fields |
| --- | --- |
| `meta` | `schema: "pitafix.trace/1"`, `run`, `commit`, `dirty`, `source`, `dataSource`, `proofLevel`, `core`, `driver?`, `facets`, `clock?` |
| `journey` | `id`, `name`, `intent?`, `role?`, `expectedOutcome?`, `section?`, `sourceRefs?`, `seed?` |
| `step` | `id`, `seq`, `journey?`, `t?`, `dur?`, `status`, `error?`, `action`, `nav?`, `screen?`, `artifacts?: [{ kind, phase?, path, sha256?, w?, h?, format?, redaction? }]`, `counters?`, `depth?`, `parentStepId?`, `group?`, `attempt?`, `replayPath?`, `proofLevel?` |
| `attribution` | `step`, `file`, `symbol?`, `lines?` (for example `"511F,512P"`), `line?`, `count?`, `confidence?`, `tier`, `source`, `flags?`, `commit?`, `repo?` |
| `end` | `status`, `error?` (missing `end` marks a crashed or in-progress run) |

```json
{"type":"meta","schema":"pitafix.trace/1","run":"r_20261130_android_home","commit":"$PITAFIX_COMMIT","source":"test","dataSource":"fixture","proofLevel":"rendered-fixture","core":{"id":"project-capture","version":"1.0"},"facets":{"platform":"android","deviceModel":"Pixel 8"}}
{"type":"journey","id":"home","name":"Open home"}
{"type":"step","id":"st_1","seq":1,"journey":"home","status":"passed","action":{"kind":"launch","actor":"script"},"screen":{"name":"Home","identity":{"method":"manual","key":"/home"}},"artifacts":[{"kind":"screenshot","phase":"after","path":"artifacts/0001.png","sha256":"<sha256>","w":1080,"h":2400}]}
{"type":"attribution","step":"st_1","file":"shared/src/commonMain/kotlin/HomeScreen.kt","lines":"12F,13F","tier":"composable","source":"coverage"}
{"type":"end","status":"passed"}
```

## 3. Normalized UI tree (`pitafix.tree/1`)

```json
{
  "schema": "pitafix.tree/1",
  "w": 1080,
  "h": 2400,
  "root": {
    "name": "HomeScreen",
    "role": "button",
    "label": "Checkout",
    "id": "checkout-cta",
    "file": "shared/src/commonMain/kotlin/HomeScreen.kt",
    "line": 42,
    "bounds": { "x": 48, "y": 1960, "w": 984, "h": 112 },
    "children": []
  }
}
```

- `w`, `h`, and `bounds` use screenshot pixels; `file` is repo-relative; `line` is the 1-based call site.

## 4. Blueprint manifest (`pitafix.blueprint/1`)

Root file `blueprint.json` inside a blueprint directory or `.zip`/`.tar.gz` archive (stored immutably under `<PITAFIX_DATA_DIR>/blueprints/<id>/<version>/` and SHA-256 verified on every load; symlinks and non-local paths are refused):

| Field | Type | Description |
| --- | --- | --- |
| `schema` | string | `"pitafix.blueprint/1"` |
| `id`, `name`, `version` | string | Required bundle identity and version |
| `author`, `description` | string | Optional metadata |
| `commit` | object | `format`, `maxSubjectLength?`, `noBody?`, `noTrailingPeriod?`, `noToolTrailers?`, `types?`, `allowAreaOmission?`, `joinMultiple?`, `hookTemplate?`, `guidelinesDoc?`, `examples?` |
| `agents` | object | `rootFile?`, `noClaudeMd?`, `copilotPointer?`, `skillsDir?`, `claudeSkillsSymlink?`, `settingsTemplate?`, `prSkill?` |
| `stacks` | `map<string, Stack>` | `name`, `detect?`, `agentsTemplate?`, `packages?`, `templates?`, `skills?`, `subagents?`, `gates?: [{ id, label, command[], when? }]`, `passes?: [{ name, prompt, on }]`, `capture?: { dir?, attributionMiddleware? }` |
| `modules` | `map<string, Module>` | `name`, `appliesTo?`, `default?`, `path`, `description?` |
| `planSeed` | `map<string, PlanSeed[]>` | Starter `{ area, objective? }` rows |

## 5. Markdown task files (`agents/tasks/*.md`)

Written into `<repo>/agents/tasks/<number>-<slug>.md` with images in `agents/tasks/images/` (reopened history archived as `<number>-<slug>.done-N.md`). Completion steps live in [Work tasks & epics](https://pitafix.app/wiki/agents/work-tasks.md).

```yaml
---
comment: 12
id: c_01...
screen: "Checkout"
type: bug        # optional: task | bug | feature
status: open     # set to "done" when finished
commit: abc1234  # optional
---
```
