Skip to content
Source
Sign inSign up

Turn on the factory pass engine

Site administration

Turn on the factory pass engine

A factory run makes many model calls, and a deploy can reset the object that runs it. The pass engine runs a factory run in passes. Each pass is one alarm of the FactoryJobObject of the run, and makes at most one model call. So a deploy cuts at most one pass of a run. This page turns the pass engine on for one repository, then for every repository, and turns it off again.

14 min read

What to know first:

  • Four kinds of runs use the pass engine:
  • Agent workflow jobs with a step that uses a coding CLI or code mode do not use the pass engine.
  • Each run keeps the engine that it started with. A change of the setting changes only the runs that start after it.
  • Each Worker reads the setting again within 60 seconds.

You need:

  • psql, and neonctl signed in to the Neon organization of the forge.

  • The URL of the database of the forge in PG_URL. The URL holds a password, so keep it in your shell only:

    PG_URL="$(neonctl connection-string main --project-id tiny-unit-38538247 --role-name app --database-name source)"
  • Ravion, set up for CI. See Set up Ravion for CI.

  • A repository to prove it on, with the Security audit and PR review turned on. See Turn on the agents.

1. Check that the Ravion pipeline takes the job image

A container run on the pass engine starts its VM with the job image. The file apps/web/ravion/pipeline.yaml lists job in the values of the input image, so a pipeline made from it takes the image. A pipeline made from an older copy of the file takes only node and browser.

  1. In Ravion, open the pipeline of the forge. Its id is the value of RAVION_PIPELINE_ID.

  2. Look at the values of the input image. When job is not one of them, add it, and save the pipeline:

    - id: image
      type: string
      description: The image of the job. The agent gets the image from the forge, so the step does not read this input.
      values:
        - value: node
        - value: browser
        - value: job

If the pipeline does not take the job image, no container run on the pass engine gets a VM. Each one fails as never started, about 10 minutes after it got its slot.

2. Turn it on for one repository

Prove the pass engine on one repository first, for example a test repository.

Caution

Add the list of repositories before you turn the engine on. While the engine is passes and there is no list, every repository gets the pass engine.

  1. Find the id of the repository:

    psql "$PG_URL" -c "SELECT r.id FROM repos r LEFT JOIN orgs o ON r.owner_kind = 'org' AND o.id = r.owner_id LEFT JOIN users u ON r.owner_kind = 'user' AND u.id = r.owner_id WHERE r.name = '<name>' AND coalesce(o.name, u.username) = '<owner>'"

    Type the owner with the same capital letters as on the forge, for example TanStack. The answer has one row: the id of the repository.

  2. Put the repository in the list:

    psql "$PG_URL" -c "INSERT INTO site_settings (key, value, updated_at) VALUES ('factory.engine_repos', json_build_array('<repository id>')::text, (extract(epoch from now()) * 1000)::bigint) ON CONFLICT (key) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at"

    For more repositories, give each id: json_build_array('<id 1>', '<id 2>').

  3. Turn the engine on:

    psql "$PG_URL" -c "INSERT INTO site_settings (key, value, updated_at) VALUES ('factory.engine', 'passes', (extract(epoch from now()) * 1000)::bigint) ON CONFLICT (key) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at"

Within 60 seconds, the new reader runs, container runs, custom agent runs and agent workflow jobs of the repository use the pass engine.

3. Check a run

  1. On the repository, start a reader run. For example, start the Security audit of a pull request. See Start an agent run.
  2. Start a container run. For example, start PR review on the same pull request.
  3. When each run ends, open its page. See Find and read a run.
  4. Make sure that each run succeeded, and that its log shows the messages of the agent and its verdict.
  5. In Ravion, make sure that the pipeline has a run for the VM of the PR review. Its description starts with Source CI job factory-.

An audit can say Clean with no log, when its first check decided it and no agent ran. See An audit with no log. In that case, start another reader run, for example Triage on an issue.

4. Turn it on for every repository

On every repository, the container runs take VMs next to the CI jobs. Turn it on for every repository only when Ravion has room for both:

  • The AWS account of Ravion can run at least 64 vCPU: both EC2 limits of Prepare the AWS account are at 64 or more. On 2026-12-01 they were at 48, and the CI jobs alone filled them in busy hours.
  • At the same time, raise Remote CI jobs per account by at least 10. It is in the card CI and AI of Admin, then Limits. On 2026-12-01 it was 9. The container runs of an account that pays take places in it next to its CI jobs. See How much of Ravion the pass engine takes.

Then delete the list:

psql "$PG_URL" -c "DELETE FROM site_settings WHERE key = 'factory.engine_repos'"

Within 60 seconds, the new reader runs, container runs, custom agent runs and agent workflow jobs of every repository use the pass engine.

5. Go back to the Workflow engine

Set the engine to workflow:

psql "$PG_URL" -c "UPDATE site_settings SET value = 'workflow', updated_at = (extract(epoch from now()) * 1000)::bigint WHERE key = 'factory.engine'"

Within 60 seconds, new runs use the Workflow engine. A run that started on the pass engine ends on the pass engine.

Done

The new reader runs, container runs, custom agent runs and agent workflow jobs of every repository use the pass engine. A deploy now cuts at most one pass of such a run, or one call of a custom agent.

A container run on the pass engine

  • It waits for its slot in the CI queue of its account, with the CI jobs that run on VMs. Their limits count it too.
  • The usage ledger counts it as a small Ravion VM (ravion-small), not as a container.
  • Its VM runs in the US environment of Ravion (RAVION_EE_US), or in the environment of its repository when it has one. See Give a repository its own Ravion hosts.
  • When the author of the item has write access, the VM keeps a disk for the factory runs of the repository (src-<repository id>-factory). Otherwise the VM starts on a clean disk, and keeps none.
  • When the VM is not ready within 10 minutes, the run fails as never started. Then the forge stops the VM.
  • A command of its agent (run_command) can run for up to 30 minutes, longer than a pass. A short command ends in the pass that started it: the tool call waits for it for up to 1 minute. A longer command ends the pass and runs on the VM with no open call. It keeps its output and its exit code in files on the VM. While it runs, the run makes no model call, and its FactoryJobObject reads the state of the command each minute. The pass after the end of the command gives its result to the model. A cancel of the run stops its commands first.
  • Its commands run as the user 1000 of its container (node in the job image), in a workspace that the runner agent keeps in a folder of the VM. The files of a long command are in a folder that only root writes, so a command can't change the output or the exit code that the run reads.
  • The runner agent keeps the repository scope of the run from outside its container: it freezes and thaws the container, stops the commands of the run, and writes the proofs that a checkpoint needs. This needs agent protocol version 2. A VM whose agent is older takes no factory run: the run's container is lost.
  • After a tool call that can change files, at most every 5 minutes, the run saves a checkpoint of its workspace. The agent freezes the container, archives the workspace, and sends the archive to the forge, which keeps it with the run's other checkpoints (factory-checkpoints/<repository id>/<run id>/). Then the container goes on. A save that fails is logged, and the next one comes 5 minutes later, not after the next tool call.
  • When the run loses its VM (its agent does not connect again within 2 minutes), the run starts a new VM. Its agent restores the newest checkpoint of the run there, or the commit is checked out when the run has none, and the run goes on from its log. Work after that checkpoint is gone from the files, so a command of the agent can run again. A run starts at most 4 VMs. A run whose new VM is not ready within 10 minutes fails.

An agent workflow job on the pass engine

A job of an agent workflow runs its steps one unit at a time, and each pass runs at most one unit:

  • A run step runs on the VM as one command. When it ends within 1 minute, the step ends in the same pass. A longer command ends the pass, and the pass after its end reads its exit code and its output.
  • A do step and the job's if run the bundle of the workflow on the VM as one command, in the same way.
  • An agent step runs in passes of its own, and each pass makes at most one model call. The step after an agent step starts in the next pass. Its prompt function, its custom tools and their descriptions run the bundle on the VM as one command each, as a do step does. A command of the agent (run_command) runs as for a container run.
  • When the start of a bundle run never reached the VM, the job starts it again. After a reset of the object, it waits 1 minute, then starts it with a new secret.
  • After each step that ended, the job saves a checkpoint of its workspace through the runner agent of its VM, and only then reports the step. A step that ended in one pass and could not be reported then, for example because a deploy reset the object during its save, saves its checkpoint in the next pass.
  • When its VM is lost, the job ends, and the next job of the cell starts at the first step that did not end. Its agent restores the checkpoint of the step before it on the new VM, so the files that the earlier steps wrote are there. When the checkpoint does not restore, the job ends before its steps run: they never run on a fresh checkout that misses those files.

A dependency run on the pass engine

A run of the dependency agent is a container run, with these rules:

  • An update run changes the versions of one group and opens its pull request. It calls no model. Its install, for example pnpm install, runs on the VM as one command, for up to 10 minutes. The first pass puts the checkout back on the run's commit, changes the versions in each package.json and starts the install. The passes after it only read whether the install ended. The last pass pushes the branch of the group and opens its pull request, or says why nothing was pushed, with the end of the output of the install.
  • When the start of the install never reached the VM, the next pass starts it again. It does not change the checkout again.
  • A fix run fixes the failed CI of an update. Its first pass puts the checkout on the last push of the update. The passes after it go on with the changes of the agent.

A CI cache run on the pass engine

A run of the CI cache agent is a container run. Its tool trace_job runs a whole CI job, so it works as run_command does:

  • The job runs on the VM as one command, for up to the time limit of the call: 15 minutes, unless the agent asks for another one, up to 30 minutes. It runs in a clean copy of the run's commit that only this call uses.
  • When the job ends within 1 minute, the call gives its trace in the same pass. A longer job ends the pass. While it runs, the run makes no model call, and the pass after its end gives the trace to the model.
  • One job runs at a time. When the agent asks for several jobs at once, the next one starts in a later pass.
  • When the start of the job never reached the VM, the call starts it again, with the same command.

A custom agent's run on the pass engine

  • It runs on a Ravion VM, as a container run of a built-in agent does, with the same slot, disk and area.
  • The agent's code (the bundle of its factory file) runs on the VM as one command, for up to the run's time limit. Each pass only starts it or reads whether it ended, and makes no model call.
  • Each model call and each forge tool call of the agent goes to the run's FactoryJobObject, as before. The run's session is in the object's storage, with only the sha256 of the run's secret, so a reset of the object between two calls does not start the agent again. The next call reads the session, and the object reads the model's key and makes the tools again.
  • A reset during a model call or a tool call cuts that call, and the agent's code sends it again with the same id. A model call runs again, and its cost counts once. A tool call runs again only when its tool may run twice: a tool with replay: 'safe', such as the read tools, comment and review (which post once for each call id), or a durable tool, such as run_command. Any other tool call, such as label, close or record_verdict, answers The tool may or may not have run. Check before you retry., and gives the same answer each time the agent asks again. So a write never runs twice. The harness has the same rule for the tool calls of a built-in agent. A factory file built with an older @tanstack-source/ci sends no ids: a reset fails its call, as before.
  • A command of the agent (run_command) runs within its tool call, for up to 30 minutes, as on the Workflow engine.
  • When the start of the agent's code never reached the VM, the run starts it again after 1 minute, with a new secret.
  • A cancel of the run stops the agent's code first.

How the setting picks the engine

The engine of a new run comes from two rows of site_settings:

factory.enginefactory.engine_reposEngine of a new reader run, container run, custom agent run or agent workflow job
No row, or a text that is not passesAnyWorkflow
passesNo row, or []Passes, on every repository
passesA JSON array of repository idsPasses on these repositories, Workflow on the others
passesNot a JSON array of repository idsWorkflow, on every repository

A typo in the list never turns the pass engine on for every repository. To read the two rows:

psql "$PG_URL" -c "SELECT key, value FROM site_settings WHERE key LIKE 'factory.engine%'"

How much of Ravion the pass engine takes

A reader run takes no VM. Each other run on the pass engine takes one VM, from its start to its end:

  • It waits for its place in the CI queue of its account, as a CI job on a VM does. For an account that pays, Remote CI jobs per account caps its container runs and its CI jobs on VMs together. Another account keeps the limits of its containers.
  • Its VM has the vCPU of the run's instance type. Most runs take a small VM, with 1 vCPU.

An estimate for the pass engine on every repository, from the factory runs of the week before 2026-12-01:

WhatHow much
Container runs96 to 210 a day, each about 1.5 to 4.6 minutes, and about 1 minute more to start and stop its VM
VM timeAbout 250 to 1,200 VM minutes a day, mostly 1 vCPU: 0.4% to 1.7% of what 48 vCPU give in a day
The busiest hour27 runs, about 2.4 VMs at once (about 5% of 48 vCPU), with short bursts of about 10 vCPU (about 20%)

In the same week, the CI jobs took 14,000 to 79,000 vCPU minutes a day. The CI of one busy repository can take 36 vCPU at once: 9 large jobs, at a Remote CI jobs per account of 9. That is why step 4 waits for 64 vCPU.