Skip to content

Develop against lab or staging ​

Lab and staging are for the platform team and invited partners; they run on our own hardware and answer on the owner's network (see "Honest limits" below). External ISVs build against production with a sandbox organisation and sandbox API keys, and use fakeLane (JS and .NET) or a local mock in tests. Until the lab sandbox-organisation flow has been checked end to end, sandbox keys are promised for the REST API only, not for OIDC sign-in or MCP token verification.

The recipe ​

Any stack. Run the command through the CLI. It sets the lane and the development tier for that command only, writes no file, and works from a package.json script, an IDE run configuration or an AI agent:

bash
te lane exec lab -- npm run dev          # "dev:lab": "te lane exec lab -- npm run dev"

te lane exec refuses on a deployed machine (a TENANCYENGINE_DEPLOYMENT of lab, staging or production, a staging or production framework variable, a CI environment) and inside a container unless you set TENANCYENGINE_EXEC_ALLOW=container (one log line records it). Running a production-mode build locally against a non-production lane is intentionally unsupported.

Node and JavaScript. te lane exec lab -- npm run dev, or te lane use lab --write-env and then node --env-file=.env.lane.local app.js. The dedicated file is not loaded by Next, Vite or any framework on its own, so a production build never sees it. te lane use only ever writes .env.lane.local or .env.lane.<name>.local, adds it to .gitignore and .dockerignore, and refuses a link, a committed file, or a file that already sets routing variables.

.NET. No tier variable is needed: F5, dotnet run and dotnet watch run as Development, which is already a development signal (a host environment name passed to the SDK counts, so --environment=Development works). Flip the lane with te lane use lab --dotnet-secrets, which sets TenancyEngine:Lane in user secrets (loaded in Development only, outside the repository, never deployed); flip back with dotnet user-secrets remove TenancyEngine:Lane. Or use te lane exec lab -- dotnet watch. Worker and console hosts with neither ASPNETCORE_ENVIRONMENT nor DOTNET_ENVIRONMENT set DOTNET_ENVIRONMENT=Development or use exec. A committed launchSettings.json must not carry the tier variable (te lane lint fails it).

Browser (Vite). A browser has no environment, so the build decides. Add the plugin once, run te lane init --browser, then te lane use lab points the dev server at lab (it reloads on its own) and te lane use production points it back:

ts
// vite.config.ts
import tenancyEngineLane from '@tenancyengine/vite-plugin';
export default defineConfig({ plugins: [tenancyEngineLane()] });
ts
import { createClient, resolveLane } from '@tenancyengine/browser-sdk';
import { options } from '@tenancyengine/lane-snapshot';
export const te = createClient({ appSlug: 'my-app', lane: resolveLane(options) });

.tenancyengine/lane.snapshot.json is gitignored and dockerignored; it holds a lane id and nothing else, is read in development and test builds only, and te lane lint fails a committed non-production one. Every other build, a production build included, bakes the production lane (the plugin ships that file; no .tenancyengine/ directory is needed) and contains no lab or staging host. Other bundlers pass their build mode and snapshot to resolveLane themselves. On the server half of Next, Nuxt, Remix or SvelteKit the package resolves to its server entry, which reads the process environment like every other server SDK and never reads a snapshot.

Mobile. A device has no environment either: a release build is the production tier and a debug build is the development tier. The auth packages (Android, iOS, Flutter, React Native, MAUI) take the lane as an explicit argument or a build-time value (--dart-define, a build property), refuse a release build that names anything but production, and expose an in-app indicator (laneIndicator) so a debug build always shows when it is not on production.

Sign in and verify tokens against a lane from a local app ​

createOidcLogin and verifyAccessToken follow the same lane switch. On a development machine they accept a lab or staging issuer when you write allowNonProductionIssuer: true in code. Two more things are specific to a local proof:

  • Callback. The redirect URI may be http://127.0.0.1:<port>/auth/callback (or [::1]), because this process is at the local tier. localhost is refused on purpose, and staging and production deployments must use https. Register the same URL (or the loopback form without a port) on the client. Details and the full rule table are in Run your own MCP server.
  • Resource. Your local MCP server may listen on http://127.0.0.1:4318/mcp, but the resource identifier is the https API base URL registered for the environment, and that is the string you pass as resource to verifyAccessToken. A loopback http resource is refused.

Spend the sign-in transaction once (transaction_replayed otherwise) and keep it out of anything a browser can replay; see "Use the transaction once" on the same page. Request the least scopes (companystudio.state.read, not an administrative one); the sandbox-organisation sign-in flow on lab is not recorded as checked end to end yet, so treat OIDC against lab as a platform-team and invited-partner path.

The key for a lane ​

A key is read from a lane-qualified variable: TENANCYENGINE_API_KEY_LAB or TE_API_KEY_LAB (both set to different values is an error), ..._STAGING for staging. The generic TENANCYENGINE_API_KEY / TE_API_KEY is your production key and is never read for another lane. te keys create --lane lab --write-env .env.lane.local and te env pull --with-key --lane lab write the lane-qualified name for you.

Use the helper, in two lines (the one-liner presupposes a lane variable):

ts
import { TenancyEngineClient, laneApiKey, resolveLane } from '@tenancyengine/sdk';

const lane = resolveLane();
const te = new TenancyEngineClient({
  apiKey: laneApiKey(lane),
  appId: process.env.TENANCYENGINE_APP_ID!,
});
csharp
var lane = builder.Configuration.AddTenancyEngineEnvironment(builder.Environment.EnvironmentName);
var key = LaneApiKey.FromEnvironment(lane);
using var http = TenancyEngineClient.CreateLaneHttpClient(lane);
var client = TenancyEngineClient.ForLane(http, key);

The helpers for the other server SDKs ship with their lane support: Go LaneAPIKeyFromEnv(lane), Python lane_api_key_from_env(lane), PHP LaneApiKey::fromEnv($lane), Ruby LaneApiKey.from_env(lane), Java LaneApiKey.fromEnv(lane). A plain apiKey string keeps working; on a non-production lane it logs one warning per process start, and it is refused when it equals the value of the generic production variable.

The CLI and the MCP server read the generic TE_API_KEY for a non-production lane only on a development machine and only until 2027-02-01, with a warning on every start; after that date, and at any other tier, they refuse it.

Which tier a process has ​

TENANCYENGINE_DEPLOYMENT (local, lab, staging, production) is authoritative when set. Otherwise the framework variable decides. Nothing else makes a process a development machine; an unset or unrecognised value is unknown and is guarded exactly like production.

LanguageFramework variableCounts as a development machine
JavaScript and TypeScript (server)NODE_ENVdevelopment, test
Go, Python, PHP, JavaAPP_ENVdevelopment, dev, test, local
RubyAPP_ENV, RAILS_ENV, RACK_ENV (first set)development, dev, test, local
.NETASPNETCORE_ENVIRONMENT, DOTNET_ENVIRONMENT, or the host environment nameDevelopment, Test, Testing
TENANCYENGINE_DEPLOYMENT \ framework valuenonedevelopmentstagingproductionother
unsetunknownlocalstagingproductionunknown
locallocallocalerrorerrorlocal
lablablablablablab
stagingstagingstagingstagingstagingstaging
productionproductionproduction (warns)productionproductionproduction

TENANCYENGINE_DEPLOYMENT=local next to a staging or production framework value (any spelling: prod, PROD, Production) throws instead of resolving local: a development setting is being loaded into a production build. Residual: in Go, Python, PHP and Java, TENANCYENGINE_DEPLOYMENT=local loaded into a production process with no APP_ENV is tier local and there is no conflict to detect; te lane lint is the only control there, so never put the value in a file you deploy.

Nothing resolves at import time, so next build, vite build and dotnet publish never trip these rules unless your code builds a client during the build.

Keep the development setting out of anything you deploy ​

te lane lint fails an active TENANCYENGINE_DEPLOYMENT=local in a Dockerfile, a compose file, a CI workflow, any other YAML (Helm, Kubernetes), a committed .env*, package.json, launchSettings.json, appsettings*.json, .mcp.json, .cursor/mcp.json and .vscode/mcp.json; a Dockerfile without ENV TENANCYENGINE_DEPLOYMENT=production; and a Dockerfile that copies .env.lane.local. A dev compose file may use the dedicated file as its env_file only when it is named compose.lane.local.yml (or docker-compose.lane.local.yml) and is gitignored. te lane init adds the ignore lines and a commented block to .env.example.

An MCP server for a non-production lane is launched through the same wrapper, so its configuration file carries no tier value and no key:

json
{ "mcpServers": { "tenancyengine-lab": { "command": "te", "args": ["lane", "exec", "lab", "--", "node", "dist/index.js"] } } }

The MCP server never reads a project lane file; it takes its lane and tier from the environment alone.

Testing ​

Set TENANCYENGINE_DEPLOYMENT=local in the test runner's own configuration, never in a deployed file. Every language uses a local mock for now; a fakeLane helper for JavaScript and .NET is planned (TE-LANES slice 2, #1070) and is not shipped yet. In CI the lane is chosen with environment variables on the job, not with te lane exec.

Which lane answered ​

Every response from the SaaSRuntime API carries X-TenancyEngine-Lane: <lane id> (production, staging, lab, local or test), and /health reports the same value as tenancyEngine. The value is validated against the lane table: a platform process configured with a name that is not a lane id answers unknown (and logs a startup error), never the configured string. Use it to confirm that the lane your SDK resolved is the lane that answered. Clients do not enforce this yet; the binding check starts as warn-only (TE-LANES slice 3, #1071).

Honest limits ​

The lab and staging hostnames are on the platform owner's network, and the staging apex pages sit behind Cloudflare Access. A developer outside that network needs a tunnel or a Cloudflare Access service token before those hosts answer at all.

See also the upgrade notes in each package README, and Run your own MCP server for token verification per lane.

TenancyEngine platform documentation