Skip to content

Self-hosting on Cloudflare

A deployment is one Worker in your Cloudflare account, talking to your GitHub App. Nothing is operated by Yomorai. This page lists every resource, permission and secret, and how to install, check, upgrade and roll back.

Read first. The deployment has not yet been run end to end in a Cloudflare account. Its logic is tested in Node against look-alike bindings (verification/conformance/worker.integration.test.ts); the Workers runtime pieces are not. See Status.

Terminal window
node apps/cli/src/bin.ts init --cloudflare --dry-run

prints the GitHub App manifest and every step without running anything (this was run for this page). Without --dry-run, pass --worker-url https://yomorai.<your-subdomain>.workers.dev; each step that creates a cloud resource asks first (--yes skips the questions). The steps, in order:

  1. Create the GitHub App from the manifest (manual; see below).
  2. wrangler d1 create yomorai — copy the printed database_id into apps/worker/wrangler.jsonc.
  3. wrangler r2 bucket create yomorai-evidence.
  4. wrangler secret put for GITHUB_APP_ID, GITHUB_APP_PRIVATE_KEY, GITHUB_WEBHOOK_SECRET, GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, YOMORAI_PROFILE_KEY.
  5. Model API keys, if you configure models (manual).
  6. wrangler d1 migrations apply yomorai --remote — see the warning in Database schema.
  7. wrangler deploy.
  8. yomorai doctor --url <worker url>.

All wrangler commands run in apps/worker. The manual equivalent follows.

Create the App from the manifest that init --cloudflare writes to .yomorai/github-app-manifest.json: open https://github.com/settings/apps/new (or https://github.com/organizations/<org>/settings/apps/new) and submit it. GitHub returns the App id, a private key, the webhook secret and an OAuth client id and secret. The webhook URL is https://<worker>/webhooks/github, the callback URL https://<worker>/auth/github/callback. The App is private.

The default manifest (appManifest({ variant: 'default' }) in packages/github/src/manifest.ts) requests exactly these:

Permission Access Why
checks write Publish one check run per reviewed commit, with the approval button. Only GitHub Apps can write checks.
pull_requests write Read the pull request, its files and diff; receive pull_request events. Comments on pull requests are also listed under this permission.
issues write Receive issue_comment events (maintainer commands such as /yomorai approve <sha>) and create or update the single consolidated review comment.
contents read Read the configuration file from the default branch and the source files the route analysis needs.
deployments read Find preview deployments of the head commit and receive deployment_status events.
metadata read Mandatory for every App; also needed to read a collaborator’s permission when someone approves.

The test-export variant differs only in contents: write, which opening a pull request with exported test candidates requires. Use it only if you want that; nothing else needs write access to code. Nothing pushes to existing branches.

Event Used for
pull_request Create reviews; a new head commit supersedes the old review and its approval
issue_comment /yomorai approve <sha>, /yomorai review, /yomorai cancel, /yomorai revoke
check_run The approval button on the check run
deployment_status Learn that a preview deployment became ready

Declared in apps/worker/wrangler.jsonc (Workers Paid plan: Containers and the higher Browser Run limits need it).

Binding Kind Used for
DB D1 database Reviews, findings, evidence records, usage, audit log, configuration versions, API token hashes, encrypted authentication profiles. Replace the placeholder database_id.
EVIDENCE R2 bucket Evidence objects at evidence/sha256/<hash>, written once; review inputs under review-inputs/ while a review runs
BROWSER Browser Run The browsers that open production and preview
AI Workers AI Only for a workers-ai model when no CLOUDFLARE_API_TOKEN is set
REPO_AGENT Durable Object RepoAgent (SQLite) One per repository: the single writer of review state, approvals and publication decisions
LEDGER Durable Object LedgerObject (SQLite) One per installation: the budget ledger
PERF_RUNNER Durable Object with a container PerfRunner The Lighthouse runner, standard-3, at most 2 instances
BATCH_RUNNER Durable Object BatchRunner (SQLite, stores nothing) One per scenario batch of a review: runs the batch’s browser work outside the review Workflow’s memory
REVIEW_WORKFLOW Workflow ReviewWorkflow One instance per review
ASSETS Static assets The dashboard, built from apps/web to apps/web/dist
cron 17 3 * * * Trigger Daily retention run

Variables (vars, not secret): DASHBOARD_URL, CORS_ORIGINS, CLOUDFLARE_ACCOUNT_ID, PERF_RUNNER_URL, LANGFUSE_BASE_URL, OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, YOMORAI_PROFILE_KEY_VERSION. Each is explained in apps/worker/README.md.

Set each with wrangler secret put <NAME> in apps/worker. None belongs in a file. The Worker reads them only from its environment.

Secret Needed Purpose
GITHUB_APP_ID always Signs the App’s JWT
GITHUB_APP_PRIVATE_KEY always Exchanged for short-lived installation tokens
GITHUB_WEBHOOK_SECRET always Verifies X-Hub-Signature-256 before a webhook body is parsed
GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET always Dashboard sign-in
SESSION_SECRET always At least 32 random characters; encrypts the dashboard session cookie. The Worker refuses API requests until it is set.
YOMORAI_PROFILE_KEY for authentication profiles 64 hex characters (32 bytes); AES-256-GCM key for stored credentials
DEEPSEEK_API_KEY for a deepseek model
MODEL_API_KEY (or the name in apiKeySecret) for an openai-compatible model
CLOUDFLARE_API_TOKEN optional Workers AI over REST, and required for cloudflare-pages / cloudflare-workers discovery
LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY, OTEL_EXPORTER_OTLP_HEADERS optional Trace export
PERF_RUNNER_TOKEN for performance analysis At least 16 characters; passed to the container as RUNNER_TOKEN. Without it performance is reported as not measured.
SELFTEST_TOKEN optional Enables the operator self-test routes. Unset: they answer 404.

Generate random values locally, for example openssl rand -hex 32, and paste them when wrangler asks.

The schema is defined in TypeScript (packages/storage/src/migrations.ts, currently version 2) and shared by D1 and local SQLite. The Worker answers 503 schema_out_of_date on every API and webhook route until the database is at the version it needs, and /healthz reports both versions.

The D1 migrations that wrangler d1 migrations apply yomorai --remote runs (the step init --cloudflare lists) are in apps/worker/migrations, one file per schema version: 0001_initial.sql (version 1) and 0002_spend_ledger.sql (version 1 to 2). They are generated from the TypeScript migrations by node_modules/.bin/tsx docs/scripts/d1-schema.ts --write, and a test fails if a committed file is stale. Applied in order to local SQLite they create 24 tables and 7 triggers and leave the store at the version the Worker expects.

Wrangler records each file it has applied and applies only the ones it has not, so the same command both sets up a new database and upgrades one at an earlier version: a database migrated before version 2 gets 0002_spend_ledger.sql alone. A file never changes once released; a new schema version adds a file.

/healthz (and GET /healthz/deep) then report the expected version.

Terminal window
pnpm --filter @yomorai/web build # the dashboard assets
cd apps/worker && wrangler deploy

Building the container image needs Docker. wrangler deploy --containers-rollout=none deploys without it; performance analysis then needs PERF_RUNNER_URL pointing at a runner hosted elsewhere. To check that the Worker bundles without deploying:

Terminal window
wrangler deploy --dry-run --outdir /tmp/yomorai-worker --containers-rollout=none

Then install the GitHub App on the repositories to review and add a yomorai.config.yaml to their default branch (reference).

Terminal window
node apps/cli/src/bin.ts doctor --url https://yomorai.<your-subdomain>.workers.dev

The deployment check calls /healthz and fails when the deployment is unhealthy or its schema is behind. The model:* checks probe each configured model with the keys in your local environment, not the Worker’s.

With the SELFTEST_TOKEN secret set, four routes check the deployment from inside it, before any repository is connected. Each needs Authorization: Bearer <SELFTEST_TOKEN>; without the secret they answer 404. They read no customer data.

Route What it does
GET /healthz/deep Database schema version, a write-once evidence write and read-back in R2, and one Browser Run page with the accessibility engine: this deployment’s /healthz/page, or ?url=<https origin>. Browser Run has been seen to get 404 from the deployment’s own workers.dev hostname without the request reaching the Worker; pass ?url= with another site you control in that case.
POST /healthz/review Starts a full review of two origins with a pull request you supply, and answers 202 { reviewId, repository, baseSha, headSha }.
GET /healthz/review/<id> The review’s state, per-stage timings, findings, spend by category and stage, and every metered operation (each model call with its tokens, reasoning tokens, latency, status and output limit).
POST /healthz/models Calls each default Workers AI model (or { "models": ["@cf/..."] }) with every documented reasoning effort and a json_schema answer, an image, and a 32-token output limit, and reports what each accepted.

The review is the real one: the ReviewWorkflow runs every stage, on Browser Run, with the repository’s plan-default models (YOMORAI_PLAN), the spend ledger and evidence in R2. Only GitHub is left out: the review belongs to the reserved repository yomorai-selftest/<name>, the token holder is recorded as the approver, and the report is not published anywhere.

Terminal window
curl -X POST https://<your-worker>/healthz/review \
-H "Authorization: Bearer $SELFTEST_TOKEN" -H 'content-type: application/json' \
-d '{
"production": "https://example-shop.pages.dev",
"preview": "https://pr-102.example-shop.pages.dev",
"routes": ["/", "/products", "/checkout"],
"viewports": ["desktop-1440", "mobile-390"],
"pr": { "number": 102, "title": "Tidy footer spacing", "body": "...", "diff": "<git diff output>" }
}'
Field Meaning
production, preview https origins. Both are visited; production only under the production guard.
pr title and body (required), number, labels, author, and the changed files as diff (unified diff) or files.
routes, viewports What to review (default / at desktop-1440). The routes are configured as critical routes.
productionSha, previewSha The commits the origins serve. Default: read from buildIdPath (default /build-id). A new previewSha with the same production commit is a re-push: it reuses the production-baseline cache.
name Reviews under one name share a baseline cache (default sample).
source Optional source files of the head commit for impact analysis, bounded like a prepared review’s.

The same pull request and head commit cannot be reviewed twice; pass another previewSha or pr.number. Model calls and Browser Run time are billed to your account like any review’s, and appear in the spend ledger under the installation selftest.

  • Upgrade: pull the new release, apply any new migrations, wrangler deploy. Migrations are ordered and forward-only; each is applied with its schema_version row in one transaction.
  • A Worker whose database is behind refuses to serve (503 schema_out_of_date) rather than run against the wrong schema.
  • Rollback: wrangler rollback to the previous Worker version. A previous version runs against a newer schema only if that schema is not behind what it expects (current >= expected); migrations within v0.0.x are meant to be additive.
  • Rotating YOMORAI_PROFILE_KEY makes stored authentication profiles unreadable; change YOMORAI_PROFILE_KEY_VERSION and store the credentials again. Changing SESSION_SECRET signs everyone out.

Lighthouse needs Node and a Chrome it controls, so it cannot run in a Worker. It runs in a container built from apps/perf-runner/Dockerfile (Node 26 with Chromium, unprivileged user), invoked through the PerfRunner Durable Object.

  • Instance type standard-3 (2 vCPU, 8 GiB): the smallest that meets Lighthouse’s guidance of two dedicated cores. One audit at a time.
  • POST /measure requires Authorization: Bearer <PERF_RUNNER_TOKEN> and refuses any URL whose origin is not in its ALLOWED_ORIGINS (403 origin_not_allowed).
  • Settings are Lighthouse’s desktop and mobile presets, identical for both environments; measurements with different settings are never compared.
  • Alternatively host the runner anywhere (docker run …, see apps/perf-runner/README.md) and set PERF_RUNNER_URL.
  • The option of running Lighthouse against Browser Run over CDP is disabled (CDP_PROVIDER_ENABLED = false): it has not been verified.

One deployment serves every repository its GitHub App is installed on: one D1 database and one R2 bucket, with every row tagged by repository, a Durable Object per repository for its reviews and approvals, browser slots per repository, and a budget ledger per installation. Its operators (whoever controls the Cloudflare account) can see every repository’s reviews.

When teams must not see each other’s reviews, or pay their own bills, each team runs its own deployment:

  • Its own Cloudflare account and deployment. init --cloudflare --name <name> names the Worker, database and bucket; nothing is shared between deployments: data, model keys, budgets and spend are each team’s own.
  • Its own GitHub App. A GitHub App has exactly one webhook URL, so one App cannot serve two deployments; init creates one per deployment from a manifest. An organisation can have many Apps; each team installs its own only on its own repositories.
  • Never two Apps on one repository. Each deployment knows only its own installation and cannot see another one: a repository with two Yomorai Apps installed gets two reviews and two comments for every push.
  • The CLI and MCP server per checkout. yomorai connect --repo owner/name --url <deployment> records which deployment a checkout talks to.

Each repository’s configuration lives in the repository (.github/yomorai.yaml), so moving a repository to another team’s deployment is: uninstall one App, install the other.

Every metered operation reserves its estimated maximum cost against the review, repository and installation budgets before it starts. When it ends, what it used is written to the spend ledger: one append-only, hash-chained entry per model call (provider-reported input, cached, output and reasoning tokens, latency, status, cache use, effort and call profile) and per other metered operation (browser time, performance-runner time, stored evidence). The reservation is then settled with exactly the sum of those entries, so a review’s settled total always equals its ledger. The ledger’s hash chain is verified with every spend view; a changed or removed entry makes the totals report as unverified.

Costs are integer micro-dollars from a dated, versioned price table (PRICE_TABLE in packages/core/src/pricing.ts, version 2026-12-01.1), rounded up to the next micro-dollar per entry. A model with no price is never called: the review fails with unpriced_operation. Prices in budgets.prices replace the entries they name, and the version then says so.

Item Price Source (read 2026-12-01)
Browser time $0.09 per browser-hour https://developers.cloudflare.com/browser-run/pricing/ (beyond 10 included hours a month)
Performance runner time $0.25 per hour Containers pricing for standard-3, rounded up
Evidence storage $0.015 per GB-month https://developers.cloudflare.com/r2/pricing/
@cf/google/gemma-4-26b-a4b-it $0.10 / $0.30 per million input / output tokens https://developers.cloudflare.com/workers-ai/platform/pricing/
@cf/qwen/qwen3.8-27b $0.45 / $3.20 (cached input $0.05) same
@cf/zai-org/glm-5.3 $1.40 / $4.40 (cached input $0.26) same
@cf/deepseek-ai/deepseek-v4.1-flash-1017 $0.30 / $1.20 (cached input $0.006) same
deepseek-flash $0.30 / $1.20 https://api-docs.deepseek.com/quick_start/pricing
deepseek-v4-pro $1.32 / $3.96 same
any other model no price: refused (unpriced_operation) add it under budgets.prices

Free allowances (Workers AI’s 10,000 neurons a day, Browser Run’s included hours) are noted in the table but never subtracted. Workers AI responses report tokens, not neurons, so models are priced by token at the dollar rates the pricing page gives for them. What the table does not model: Browser Run’s concurrency charge, the Workers Paid base fee, Workflows, Durable Object, D1 and R2 operation charges, and DeepSeek’s off-peak discount. Every amount is an estimate at the dated price table; the provider’s billing is authoritative. Spend is shown per review (by category, model and stage, with every model call), per repository and per installation by day and month: in the API (/api/reviews/<id>/spend, /api/repos/<owner>/<repo>/spend), the dashboard (Spend page, cost panel on a review), the CLI (yomorai review prints a summary; yomorai spend), MCP (get_review_status), on traces, and in the pull-request comment when report.costFooter is on (off by default).

A repository that configures no models uses the defaults of the account’s plan, set with the Worker variable YOMORAI_PLAN (free or paid; unset: no default models, deterministic analysis only). They are to be confirmed or replaced by the model bake-off (verification/evals/bakeoff.ts); no bake-off report has confirmed them yet, because it needs live model credentials.

Call site Free plan Paid plan
Vision @cf/google/gemma-4-26b-a4b-it (thinking off) @cf/qwen/qwen3.8-27b (effort low)
Intent and classification @cf/qwen/qwen3.8-27b (effort low) @cf/zai-org/glm-5.3 (effort low)
Judge (evaluations) @cf/google/gemma-4-26b-a4b-it (advisory on visual descriptions) @cf/deepseek-ai/deepseek-v4.1-flash-1017 (effort none)

Each model’s capabilities (image input, structured output, reasoning control) were read from its page under https://developers.cloudflare.com/workers-ai/models/ on 2026-12-01 and are recorded in packages/schemas/src/models.ts. glm-5.3 and deepseek-v4.1-flash-1017 need paid billing. yomorai doctor lists the profile of every call site, refuses a setting a model does not document, and reports a missing price.

To cache identical model requests, create an AI Gateway and set models.gateway.id; requests then carry cf-aig-cache-ttl (default one hour), requests under retention none carry cf-aig-skip-cache, and a cached answer is recorded as cached. This has not been checked against a live gateway yet.

Production-baseline pre-capture (off by default)

Section titled “Production-baseline pre-capture (off by default)”

A maintainer can turn on pre-capture for a repository in the dashboard (Settings › Production pre-capture) or with PUT /api/repos/<owner>/<repo>/settings/precapture. Every change, and every refused attempt by someone who is not a maintainer, is audited.

Pre-capture executes against production before and independently of pull-request approval. When a successful deployment_status arrives for a deployment of the default branch, the configured production scenarios run at the deployed commit, under the production guard and within the budget, and their captures enter the production-baseline cache. It never opens a preview and never runs pull-request code; it does generate production traffic and browser cost without a maintainer approving a specific pull request. A later review reuses those captures only under the cache’s rules: same production commit (re-read from readiness.buildIdPath), identical scenario steps, viewport, browser version, authentication profile and analysis configuration, within cache.productionTtlMinutes, with every evidence hash verified. Signed-in scenarios are not pre-captured.

The nightly workflow’s evaluations job runs verification/evals/nightly.ts: the adversarial and replay sets with recorded replies and, when CLOUDFLARE_ACCOUNT_ID and the EVAL_CLOUDFLARE_API_TOKEN secret are set, with live Workers AI models, plus the model bake-off. Without credentials the live parts are reported as skipped. Scores go to Langfuse when its keys are set.