Docs/Agent test environments
#

Agent test environments

Give your agent, your tests and your pull requests their own live copy of your app, with data and logins ready.

Claim a sandbox of my app

One command gives you a running copy of your app, called a sandbox or test environment, with data and logins ready. You, a test or a coding agent can use it, break it and throw it away without touching anything else.

Each sandbox is a full virtual machine, so your database and background services run in it. Outside services like email and sign-in are replaced by stand-ins. You describe the sandbox once in cofactor.sandbox.yaml. If your application has none yet, build one from GitHub or from a pushed image.

Claim a sandbox

  1. Find your application.

    bash
    cofactor application list
    
  2. Claim a copy.

    Open Test environments in the app, find your application and select Claim on an environment.

    The claim prints a URL for each public port, a login for each role (with its password), and what the seeds created. If your agent keeps a log, have it report only the URLs and emails.

    The Test environments page. An application lists its environments with a Claim button, and the live sandboxes table shows the build, status and expiry.
  3. Use it. Open the URL and sign in with a printed login. You can also run a test on it.

    bash
    cofactor workflow run <workflow id> --sandbox <sandbox id> --stream
    
  4. Put your changes in it. See Test locally.

    bash
    cofactor sandbox sync <sandbox id>
    
  5. Destroy it.

    bash
    cofactor sandbox destroy <sandbox id>
    

Check it worked

bash
cofactor sandbox claims
cofactor sandbox show <sandbox id>

The status reads ready. The URL serves your app over https and each login signs in with its role. After destroy, claims no longer lists it.

Go deeper

Advanced

How claims work, flavors, lifetimes and errors.

How a claim works. Cofactor builds and seeds your app once per version and environment, and saves the result as a ready snapshot. Each claim restores its own copy. Only the first claim of a new version waits for the build.

Flavors. An environment is the same sandbox with different data or settings, such as default or free-plan. --environment <name> picks one. Each shows up as an environment of your application.

Versions. --at <version> claims a commit SHA for GitHub, or a push id or tag for an image. --from-local starts from your uncommitted files.

Lifetimes. A claimed sandbox lasts 2 hours. Each sync adds 2 hours, up to 8 hours after the claim. A PR preview expires 24 hours after the last push to the pull request, and never lives past two weeks.

Fit. A sandbox is one Linux amd64 machine with no Docker inside. Run cofactor sandbox guide feasibility to check each dependency before you build.

Limits.

LimitValue
Ports per sandbox8, including the ports Cofactor adds for sync, emulators and object storage
vCPUs (resources.vcpus)1 to 32
Memory (resources.memory_mib)1,024 to 65,536 MiB
Definition file size256 KB
Action timeout1 to 1,800 seconds, 60 by default
Time for services to turn healthy5 minutes
Layer size in a pushed image5 GB
Tags per push10
Claimed sandbox lease2 hours

Statuses. A sandbox is claiming, ready, failed or destroyed. A pushed image is uploading, importing, ready or failed, and becomes upgraded when a newer push replaces it after a platform upgrade.

Errors. A failed build, prepare or seed fails every claim waiting on it. Fix it and commit or push again.