Tensor LabsTENSORLABS

Give every pull request its own running copy

Review should mean using the thing, not reading it

June 30, 20263 min read4 sectionsBy Ahmed Abdullah
Give every pull request its own running copy

Introduction

A senior engineer left one comment on the pull request. Not about the logic, not about the tests. Just: "can I see this running somewhere?" The author paused, because the honest answer was no. To see it running you pulled the branch, rebuilt, reset your local database, ran the migration, seeded some test data, and hoped your laptop resembled production closely enough to mean anything. Forty minutes of setup to answer a ten-second question. So most of the time nobody asked it, and the diff got approved on faith.

That is the quiet compromise in most review processes. Reading a diff is reading a recipe. You approve the ingredients and find out at dinner whether it was edible.

You cannot review what you cannot run.

The right way: a real environment per branch

The fix is to stop treating "an environment" as a scarce, shared, hand-tended thing, the single staging box everyone queues behind, and make it disposable instead. Every pull request automatically gets its own running copy of the application: built, seeded, reachable at its own URL, with the link posted straight back into the PR. Open the branch, click through, use the feature the way a customer would, before a single approval is given.

What keeps it trustworthy is that the environment is defined in the same repo as the code. It is created on push and torn down on merge, so it always matches the branch and never lingers afterward.

The part that makes it affordable

Here is the piece most teams get stuck on. A real preview seems to require copying the production database for every branch, which is absurd at terabyte scale. The technique that makes it cheap is database branching through copy-on-write. A branched database shares the same underlying storage as its parent and only writes a new page when a row actually changes. Spinning up a full, production-shaped database for one pull request takes seconds and costs almost nothing, because you are not duplicating the data, you are sharing it until someone edits it. Each preview gets an isolated database that looks exactly like production, can be migrated and mutated freely, and is discarded on merge.

A preview is only honest if its data looks like production. Copy-on-write is what makes that free.

Why it matters more now

What turned this from a luxury into a baseline is how much code now arrives from AI assistants. Volume is up, and so is the share of changes no human reasoned through line by line. A diff that looks plausible and a feature that actually works have drifted further apart, and that gap is exactly where a runnable environment earns its keep. You stop debating whether the code reads correctly and start checking whether the thing does what it claims, which is the only question that was ever real.

Teardown matters as much as spin-up. Ephemeral has to mean ephemeral: the environment expires on its own, so you never accumulate a graveyard of orphaned previews quietly billing you. Create on open, destroy on merge, no human in the loop for either.

We built this loop for a team whose staging box was a permanent traffic jam, one queue everyone waited behind, and the jam cleared because there was no longer a single environment to wait for. Every branch carried its own.

Give every pull request a running copy of itself and review stops being an act of imagination. It becomes what it was meant to be: someone using the thing before the customer does.

TensorLabs builds the preview-environment and database-branching infrastructure that makes perbranch testing the default.