<!-- TokenOS docs · Building apps · Markdown mirror of https://tokenos.ai/docs/build-pipeline · HTML: https://tokenos.ai/docs/build-pipeline · index: https://tokenos.ai/llms.txt -->

# Build pipeline & harness

A build is a sequence of deterministic phases around a handful of model calls. Understanding the phases explains what Mission Control is streaming, why a task stays *processing* after the files exist, and what the credits buy.

### Phases of `POST /api/create-project-async`

1. **Request classification** — Jev classifies the prompt (intent, complexity, whether it touches money, whether it needs a browser check) and suggests a model tier. The wallet signature on the body is verified and credits are reserved.
2. **Advanced project analysis** — The CIE deep-researches the prompt into a product plan: pages, data model, on-chain actions, design direction. Plans are cached so a retry is cheap.
3. **Design system** — Tokens, type scale and component conventions are fixed for the whole app so pages generated in parallel look like one product.
4. **Page generation** — Every page is produced as two parallel passes — a data layer and a JSX render layer — with truncation detection, brace / paren balance checks, JSX-tag salvage trim and automatic cross-provider fallback.
5. **Web3 runtime injection + hazard repair** — The deterministic runtime (`config.js`, `lib/web3.js`, `hooks/useWallet.js`, `lib/walletBridge.js`) is written and `repair_page_hazards` rewrites common mistakes (treating the `wallet` string as a provider, missing state declarations, keyed RPC URLs).
6. **Brand art** — Every `/media/…` reference is resolved to a real asset: raster hero / feature images from the Gemini image model, procedural SVG logos. Assets are stored and materialised into the preview. See [Quality gate & brand art](https://tokenos.ai/docs/quality-gate).
7. **Preview build** — The project is bundled with Vite into a static preview served under a sandboxed path; a node-free in-browser fallback exists for environments without a bundler.
8. **Render gate** — Headless Chromium mounts the preview, captures console / page errors and a screenshot. Failures are sent back to the model for up to **2 repair rounds**; the outcome is recorded as `result.render`.
9. **Completion** — Only now does the task flip to `completed` with `result.preview_url` and `result.render`. If generation failed outright the reserved credits are refunded.

### Task status payload

**GET /api/task-status/{task_id}**

```json
{
  "task_id": "fae5e70e-…",
  "status": "completed",                 // pending → processing → completed | failed
  "progress": 100,
  "current_phase": "render_gate",
  "result": {
    "preview_url": "/api/vite-previews/fae5e70e-…/index.html",
    "render": {
      "status": "repaired",             // verified | repaired | degraded | unverified
      "rounds": 1,
      "errors": [],
      "screenshot_url": "/api/previews/fae5e70e-…/render.png",
      "checked_at": "2026-10-01T00:12:44Z"
    },
    "files": ["src/App.jsx", "src/pages/Overview.jsx", "src/config.js", "..."]
  }
}
```

### Build harness (sprints)

For larger goals the **harness** runs plan → sprint → evaluate loops against an existing project with self-healing between sprints. Start it from the Agents window (⌘J) or `POST /api/harness/start` (wallet-signed).

| Parameter | Value |
| --- | --- |
| Costs | plan 10 credits · each sprint 15 · each eval 5 |
| Limits | max_sprints ≤ 6 · max_attempts ≤ 4 · budget = 60 × max_sprints credits |
| Verification stages | static checks → isolated LLM evaluator → browser (optional, verify_browser) → Jev acceptance |
| Memory & snapshots | `GET /api/harness/memory/{project_id}`, `GET /api/harness/snapshots/{project_id}`, `POST /api/harness/snapshots/{id}/apply` |
| Status | `GET /api/harness/status` |

### Best-of-N

Run the same goal on **2 – 3 distinct models** in parallel, compare the evaluator scores and apply the winning snapshot. `POST /api/harness/best-of-n`, 20 credits per model. Runs appear in the Sessions rail and under `GET /api/runs`.

> **Note — Reliability features you get for free**
> - Per-provider concurrency caps and model-aware output budgets.
> - Truncation auto-retry with tighter prompts; a Retry pill in the IDE when an upstream provider hiccups.
> - Automatic fallback chains per provider so a build never dead-ends on an outage.
> - Build-status registry with auto-rebuild of stale previews.

---

*Building apps · TokenOS documentation. Canonical page: https://tokenos.ai/docs/build-pipeline. All docs as Markdown: https://tokenos.ai/llms.txt. Payments on TokenOS are for metered usage only; nothing on this page is investment advice or a promise of income.*
