Side environments
Isolated full-stack cloud environments for feature branches. Staging is shared with main — do not verify in-progress work there.
Tooling: scripts/env/ (README.md is the detailed runbook).
Starting a side env as an agent (#704)
Owner decision (2026-10-09), documented in #704 (merged 2026-10-09 09:14 IDT, merge 343d0053, docs only): agents start side envs through the owner's own Cloudflare Access login (cached by cloudflared), never a separate key. When that login expires, the agent stops and asks the owner instead of working around it.
- Side envs are Neon branches of
golden(teardown docs no longer mention Aurora). - Setup:
cloudflaredAccess login plusBRILLIANT_SECRETS_SOURCE=store. The staging Neon key then comes from the secrets Worker understore(from #703); an explicit env var still wins, for CI. - Repo docs:
docs/agent-workflow.md→ Starting a side env has the exact commands and a zero-leftovers teardown check;scripts/env/README.mdhas an owner-machine agent section next to the remote (Sphera) one;docs/getting-started.mdand a boundary line inAGENTS.mdpoint there.
Related: Secrets and environments, Neon migration plan.
Branch routing was removed. #606 (merged 2026-10-07 22:31 IDT, merge f6628296; live on staging since 2026-10-08 09:22 IDT (deploy dce2558b, run 37735680926)) deleted branch:deploy, the x-brilliant-branch router and the Chrome switcher from main, because branch code can't reach Durable Objects, queues or named RPC, so every branch session quietly read and wrote staging state. Use env:up for every change. See Branch routing removal.
Only changing control-plane, dispatch or agents code? Use env:up too. The branch:deploy shortcut from #561 is gone; its sections below are kept only as history.
Landed: side-env DBs as Neon branches (#668, merged)
Wave 2 of the Neon plan (#620, merged) replaces the per-env Aurora database with a Neon branch side-<env> cut from a CI-rebuilt golden branch (migrations + E2E seed). #668 (merged 2026-10-08 19:10 IDT, merge 079b27d6) landed it: the PR measured the env:up DB phase at 8–10s instead of about 63s, and env:down deletes the branch. New env:ups use Neon branches; envs created before the move stay on Aurora until their next env:up. See Side-env DBs on Neon branches below and Drop AWS: Neon migration plan.
CD candidate (ci)
CD keeps a long-lived side env named ci as the pre-staging candidate (#222, merged). Deploy resolves one sha, runs env:up ci under the candidate GitHub Environment, then smoke + e2e there before staging. Do not point a personal worktree at ci or tear it down with env:down — it is shared CD infrastructure. See Verify & ship.
Model (PR #142, merged)
A side env is a Pulumi stack named side-<name> of the same infra program as staging/prod — not a bespoke orchestrator that shells wrangler … create for ~12 resources with its own state file.
Per-env resources (KV ×3, admin D1, Hyperdrive on the staging Aurora cluster, dispatch namespaces, caption queues + DLQ, wiki R2) keep byte-identical names to the legacy convention (contract side-env-resource-names-match-legacy). Side config is refused on non-side stacks and vice versa.
Each side env gets its own database: after #668 that is a Neon branch side-<name> of golden (see below); envs created before the move stay on the shared staging Aurora cluster until their next env:up. Each still has its own Hyperdrive config. Legacy Neon side-DB state (state.neon) is gone — deploy / e2e / session-replay no longer fall back to a worktree .dev.vars DATABASE_URL that might point at staging (#190, merged; Neon shim removed). Admin workers receive a real DATABASE_URL for that side DB. Each side env also has its own admin read-only role (brilliant_admin_ro via Hyperdrive) (#222, merged).
Lifecycle
bun run env:up <name> # database → pulumi up → render → deploy → smoke (re-run after any failure)
bun run deploy # from a service dir; re-renders side-env configs; respects .brilliant-env/current
bun scripts/e2e-smoke.ts --env <name>
bun scripts/e2e.ts --env <name>
bun run env:down <name> # workers → container app → pulumi destroy + stack rm → drop DBSide render throws instead of falling back to staging’s Hyperdrive/KV/D1.
env:down treats a stack as already gone only on Pulumi’s exact no stack named '…' found message. Broader “not found” / “does not exist” matches once swallowed expired AWS keys (InvalidAccessKeyId … does not exist in our records) and reported success while leaving resources behind — so auth and resource 404s must fail the destroy, not look like a clean teardown (PR #165). With a Cloudflare API token, a leftover conductor-<env>-workspacedo-native also fails the teardown (#337, merged) — see Leftover native container apps.
Prerequisites (devs)
- Pulumi CLI
- AWS SSO under the
defaultprofile (there is no namedbrilliantprofile — #189, merged) with the developer secrets policy (#178): read onbrilliant/dev,brilliant/side-env-base,brilliant/staging/auth0,brilliant/staging/bedrock, andbrilliant/cloudflare/staging(exact names; ARN suffix-??????) - Access to the Pulumi state bucket and KMS — side stacks use
alias/brilliant-pulumi-side(new stacks); older side stacks may still use the sharedalias/brilliant-pulumi. Shared-key / staging-or-prod state access still needs Admin, not BrilliantDeveloper alone - Confirm account roles after SSO: a refreshed session may only offer ReadOnly / BrilliantDeveloper. Stale static
AWS_ACCESS_KEY_*can still win overAWS_PROFILEand showExpiredTokenon.pulumi/meta.yamleven whenaws sts get-caller-identitylooks fine — export fresh creds from the intended profile into the child process before diagnosing backend permissions
Running as an agent (no SSO)
Landed in #190 (merged). Image reuse for Docker-less pods: #193 (merged). Cloud-agent Path 1 studio + side-env traps: #249 (merged).
Sphera (and similar) agents can’t do AWS SSO. Staging Pulumi owns a static IAM user brilliant-side-env-agent (infra/pulumi/src/side-env-agent.ts). Its key lives in ASM secret brilliant/staging/side-env-agent.
Allowed: side-* Pulumi state; KMS key alias/brilliant-pulumi-side; secrets brilliant/side-env-base, brilliant/staging/auth0, brilliant/staging/bedrock, brilliant/cloudflare/staging.
Explicitly denied (a later broader Allow still can’t reach them): shared alias/brilliant-pulumi, staging/prod state, and brilliant/prod* / brilliant/*/prod* secrets. Contract @cc side-env-agent-never-reaches-prod is tested against the emitted policy.
Known limits: can’t pulumi stack ls (that reads every stack file); can’t open side stacks created before the side KMS key existed; can still touch staging indirectly (side-env-base holds the staging Aurora admin URL; Cloudflare token is staging’s) but not prod.
Humans copy the four values into the agent secret store once — under exactly those uppercase names (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, PULUMI_BACKEND_URL). Lowercase names are ignored by the SDK, so the pod’s web-identity role wins and errors look like missing permissions on the wrong principal. Export them, unset AWS_PROFILE, and confirm aws sts get-caller-identity prints user/brilliant-side-env-agent. Then load the Cloudflare staging secret and run env:up / deploy / env:down as usual.
No Docker required (except on a new env, see Fresh VM: run cloud-prep) when a matching conductor image is already in the shared staging registry (see Conductor image reuse below). A branch that changes image inputs still needs one Docker-capable env:up to push; after that its tag is reusable too.
Ops note: agent resources are on the staging stack (applied from the PR branch before merge). pulumi up -s staging from main is safe for that set now that #190 is merged.
Staging work: for debugging, deploying or running Pulumi on staging itself, agents use the broader brilliant-staging-agent key instead (it also covers side-* state and the side key). See Secrets & environments — Staging agent key (#492, merged).
Cloud agent env:up traps (#249)
On Cursor cloud-agent VMs, /exec-daemon/node is often Node 22.14 and sits ahead of nvm on PATH. Pulumi’s nodejs host then imports infra/pulumi/index.ts as ESM and exits with ERR_UNKNOWN_FILE_EXTENSION after migrations already created brilliant_<name>. Export NODE_OPTIONS=--experimental-strip-types (Node 22.18+ strips types without the flag) and rerun — env:up is idempotent.
If CLOUDFLARE_API_TOKEN is unset, the next failure is Wrangler’s “non-interactive environment” message, and it happens after pulumi up has created side-<name>. Export api_token and account_id from brilliant/cloudflare/staging before env:up (scripts/env/README.md). A failed up still needs env:down so the database, stack, and workers do not leak.
Admin-only change, conductor never deploys (#381, merged): On a Docker-less agent VM, step 8 of env:up could log image: … matches but is not digest-pinned; pushing (before #538; now could not be resolved to a guarded digest; pushing when resolution fails) and then die on missing crane / Docker. Control plane and dispatch are already up; conductor stays undeployed. For an admin-only (or control-plane-only) change, that half-made env is enough — run bun scripts/env/deploy.ts admin --env <name> and verify there. Tear down with env:down when done. See gotchas/side-envs.md.
Fresh VM: run cloud-prep before env:up (#512, merged)
On a fresh Cloud Agent VM with the side-env agent key, env:up fails three times in a row before the env exists, even when the branch changed no image input:
Executable not found in $PATH: "pulumi": the Pulumi CLI isn't installed.It looks like the Pulumi SDK has not been installed:infra/pulumiis not a bun workspace member, so the rootbun installleaves it without its SDK.Error: crane is not installed or not in PATH: reuse needs crane even when no image input changed. Before #538 a matching tag was always pushed; since #538 crane resolves it to a digest (see digest-pinned reuse).
Fix: run bash scripts/env/cloud-prep.sh first. Since #512 it installs the CI-pinned Pulumi CLI into ~/.local/pulumi (add it to PATH with export PATH="$HOME/.local/pulumi:$PATH"), installs the infra/pulumi dependencies, and sets up Docker and crane as before. Only CLOUDFLARE_API_TOKEN is a hard requirement now: when the VM has working AWS credentials, a missing base secret (SESSION_SECRET, OPS_KEY, AUTH0_*) is only a warning, because env:up reads them from Secrets Manager (brilliant/side-env-base). Reruns of env:up are idempotent. Source: gotchas/side-envs.md ("Cloud agent env:up needs cloud-prep even when no image input changed").
Conductor image build on agent VMs: docker-buildx + vfs (#313)
When a branch changes IMAGE_INPUT_PATHS (e.g. packages/template for a named provider client like integrations.xero), the conductor image must rebuild on the agent VM. Two fixes landed in scripts/env/cloud-prep.sh and gotchas/side-envs.md (#313, merged):
- Install
docker-buildx— the legacy builder fails the/lib -> usr/libwildcardCOPY. - Use the
vfsstorage driver — on fuse-overlayfs the template step fails withtar: .: file changed as we read it.
Without both, image push for template-touching branches fails on cloud-agent VMs even when Docker itself is present.
What is isolated vs shared
Isolated: control-plane / dispatch / conductor (/ agents) Workers, apps + data dispatch namespaces, caption queues, policy KV, wiki R2, Aurora database + Hyperdrive config, per-env context signing key.
Shared (examples): Artifacts namespace, agent image registry, agent skills R2 bucket (tenant-keyed). Staging Aurora cluster is shared; each side env gets its own database + Hyperdrive config.
Rules of thumb
- One env per worktree; never point a worktree at another’s env.
bun run deployrefuses staging offmain.- Unset injected staging
*_URL/DATABASE_URL*when running e2e against a side-env from Cloud Agent VMs. - Hyperdrive soft account limits ≈ dozens of concurrent side-envs — always
downwhen done. - Conductor image: reuse a pushed registry tag when
IMAGE_INPUT_PATHSmatch HEAD; build/push only when nothing matches, inputs are dirty, or--force-image(see Conductor image reuse).
Container cap (PR #166)
Cloudflare Containers max_instances is reserved against the account’s 1,500 vCPU at deploy time (standard-3 = 2 vCPU). Side envs live on brilliant-ai-staging, which is ours alone, so patchConductorConfig defaults side-env conductor to max_instances: 10 (20 vCPU per side env next to staging’s 80).
The old default of 3 came from a shared account where a sibling project held most of the quota. With that cap, three smoke runs could wedge the env because each workspace that boots the coding agent keeps its container for the 90-minute preview lease (renewPreviewLease).
Staging still prewarms; side envs strip the prewarm pool so it does not hold half the cap idle. Override with maxInstances if needed.
Native conductor containers (#239)
Landed in #239 (merged). Side envs deploy conductor on Cloudflare’s native durable_object container scheduler (no Sandbox SDK, no root /sandbox server). Staging and prod stay on the legacy default-policy app until a separate cutover.
scripts/deploy/conductor.shrefuses ascheduling_policy: "durable_object"config unless--nativeis passed (sideenv:up/ deploy paths pass it).- Agent image is digest-pinned; push runs a 110 MB compressed per-layer guard; Wrangler 4.145 prepares named images before the version upload.
env:downremoves both the native app and any leftover legacy default-policy app (scripts/env/legacy-container-app.ts).- Open follow-ups that affect side-env ops: #235 (true digest reuse landed in #538, merged 2026-10-07, on top of #276's digest-pin guard), staging/prod cutover (#185, #187). Details: Conductor — Native durable_object containers.
Leftover native container apps (#324 / #329 / #337)
Landed in #337 (merged 2026-10-02; closes #324). A native app named conductor-<env>-workspacedo-native outlives its Worker and keeps holding quota. Teardowns that only warned used to leave these behind.
env:down deletes through the API. With a Cloudflare API token (CLOUDFLARE_API_TOKEN, or CF_DEPLOY_TOKEN in the dev vars), it calls DELETE /accounts/<id>/containers/applications/<listed id> (the undashed id containers list prints), re-lists, and exits non-zero if this env’s app is still listed — after Pulumi, database, and local state steps have already run. Without a token it still tries wrangler and warns.
Wrangler cannot delete the listed id. wrangler containers list prints an undashed id; wrangler containers delete only accepts a dashed UUID, which the API rejects (APPLICATION_NOT_FOUND). Manual cleanup (or a no-token teardown): delete with the API using the listed id. Zero-leftovers checks should include GET .../containers/applications.
Orphan blocks every conductor deploy. The app is bound to one Durable Object namespace. If the conductor Worker is deleted and recreated, WorkspaceDO gets a new namespace while the app keeps the old binding and the same name, so deploys fail with “could not finish applying its Durable Object-managed Container application settings” (candidate/ci hit this on 2026-10-02 — #329). Compare the app’s durable_objects.namespace_id (GET .../containers/applications/<id>) with the Worker’s WorkspaceDO namespace (GET .../workers/durable_objects/namespaces). If they differ, delete the app and deploy again. Repo notes: gotchas/side-envs.md, gotchas/containers.md.
Conductor image reuse (#193)
Landed in #193 (merged). Side envs share the staging Cloudflare account, so env:up and the conductor deploy reuse a pushed conductor-workspacedo tag instead of building — which agents without Docker need.
When it reuses: a registry tag whose commit exists locally and git diff <commit> HEAD -- IMAGE_INPUT_PATHS is empty. Staging-built bare <sha12> tags win over side-env <env>-<sha12> tags; then the newest commit. Dirty tags (…-dirty<ts>) and rootfs snapshots are never reused.
IMAGE_INPUT_PATHS (every build-context COPY/ADD in infra/agent-image/Dockerfile): infra/agent-image, packages/template, tsconfig.base.json, and services/conductor/src/coding-agent/workspace/AGENTS.md. Enforced by scripts/env/test/image-inputs.test.ts (#265): add a COPY without updating the list and CI fails. Root .dockerignore joins the list in #498 (on main since #490 merged 2026-10-05): changing context exclusions changes the image even when no COPY source changed, and the test now asserts it is listed.
Staging / prod deploy path (#252, merged; fixes #194): scripts/deploy/conductor.sh used to diff only infra/agent-image and packages/template, so a staging deploy that only changed in-workspace AGENTS.md (or tsconfig.base.json) skipped the rebuild and shipped a stale image. It now diffs its own IMAGE_INPUTS list — a superset of IMAGE_INPUT_PATHS that also includes .dockerignore, scripts/deploy/push-agent-image.sh, and scripts/deploy/conductor.sh (how the image is built/tagged). Side-env reuse and staging/prod selective rebuild therefore both cover every Dockerfile input.
Contract: IMAGE_INPUT_PATHS ⊆ IMAGE_INPUTS (#274, merged): every side-env image-input path must also appear in conductor.sh’s list. The same test file asserts the subset. Without it, a path only on the side-env list would rebuild side envs while staging reused a stale image. (.dockerignore in IMAGE_INPUT_PATHS was open as #266; #498 adds it, on main since #490 merged 2026-10-05. It changes the side-env image hash, so the first env:up after it needs a Docker push.)
Still builds when: nothing matches, HEAD’s image inputs are dirty, or --force-image is passed. env:up --allow-dirty tags dirty pushes -dirty<ts> so no other env treats them as a clean build of that commit.
Digest-pinned reuse (#276, merged)
Native side envs (#239) accept only digest-pinned agent image refs (@sha256:). Tag matching lives in findReusableTag; callers use findReusableImage, which returns a match only when the ref is digest-pinned (contract reused-image-must-be-digest-pinned). Landed in #276 (merged).
- Both
scripts/env/deploy.tsandscripts/env/lib/up-deploy.tsgo through that one guard (so the two copies cannot drift). - A tag-only match logs
image: … matches but is not digest-pinned; pushingand returns null; the caller pushes and pins instead of recording the tag. - Before #276,
env:upcould log reuse of e.g.:ci-<sha12>, write that tag into state, then throw inpatchConductorConfig:conductor agent image must be a digest-pinned registry.cloudflare.com ref(seen when a prior candidate push left a tag but failed later inwrangler deploy).
Was open after #276, fixed by #538: reuse could not produce a digest, so on native paths a tag match always pushed (candidate env:up ci paid rebuild + Cloudflare image prep, often ~15+ min). Separate: Cloudflare image-prep timeouts need a re-run, not this guard.
Tag → digest reuse (#538, merged)
Merged 2026-10-07 08:50 IDT (yoni-monday, merge d35a20a2). findReusableImage (scripts/env/lib/image-reuse.ts) now resolves the matching clean tag to a digest through scripts/deploy/push-agent-image.sh --resolve-image, using a Wrangler pull credential in a temporary Docker auth directory (removed on success and failure, so it never overwrites your own registry login), then runs the same manifest layer guard as a push before recording the @sha256: ref. Contract reused-image-must-be-digest-pinned now says: a failed credential, resolution, guard or malformed ref returns null (never a tag or an unchecked digest), and the caller pushes.
- Candidate (
ci) accepts only clean<sha12>/ci-<sha12>tags, the same trust policy as staging'sconductor.sh. Other side envs may still reuse clean developer<env>-<sha12>tags. Callers must pass their real target env. - State records whether this run pushed (
pushedThisRun); same-sha reuse is not a push. - Docker-free agents still need crane and registry access. If resolution fails, the log says
could not be resolved to a guarded digest; pushingand the normal push path then needs Docker. Never work around it by putting a tag into the native container config. - Corporate TLS inspection: Wrangler's registry list can fail its certificate check and fall back to a push. With Node 24,
NODE_USE_SYSTEM_CA=1makes it trust the installed system roots (normal verification, not a bypass).env:up --resolve-ipuses verified curl for health. Never setNODE_TLS_REJECT_UNAUTHORIZED=0.
Live evidence in the PR (owned side env cicdproof): a fresh-cache env:up resolved the image built at an earlier commit with only crane auth login, digest and manifest calls, no push; the manifest passed the guard (26 layers, largest 97.4 MB of the 110.0 MB limit). The candidate path itself is only proven after a real main deploy.
Warm vs cold env:up order (also #538). Warm runs upload dispatch and push its secrets before the control plane builds/uploads (matching canonical dispatch-first upgrades) and skip bootstrap/rebind. Cold envs bootstrap unbound only on Cloudflare 10143 (binding to a Worker that doesn't exist yet), then rebind dispatch after conductor/workflows and the control plane after its targets. Other upload or secret errors stop before the control plane.
Staging CD image reuse: do not use crane ls (#288, merged)
Landed in #288 (merged). Staging deploy’s conductor step (reuse_native_image in scripts/deploy/conductor.sh) was rebuilding and pushing the agent image on every run (2–3 min plus a container rollout), even when the candidate job had just pushed the same inputs as ci-<sha12>. Logs said Image reuse: cannot list …/conductor-workspacedo; pushing instead. Studio smoke right after often failed on “Waking your app's preview” / empty Code tab.
Cause: registry.cloudflare.com answers /v2/<repo>/tags/list with a pagination Link header that is not RFC 8288 (no <>, doubled query string). crane ls fails to parse it and exits non-zero; the page the header names is empty anyway.
Fix: list tags with curl + the pull token (first page, n=1000), not crane ls. Trust clean build tags <sha12> and ci-<sha12> (candidate env:up on the same commit); still reject <env>-<sha12> and -dirty*. Layer guard and image-inputs diff still apply. Healthy reuse logs Image reused: … (no build, no push) with image_pushed=false. Do not reintroduce crane ls against this registry — also in gotchas/deploying.md.
Branch routing removal (#606, merged)
Merged 2026-10-07 22:31 IDT by yoni-monday (merge f6628296, branch revert-branch-routing, head 6ee74588; +11/−2,878, 55 files; opened 22:22 IDT). Closed #586 (the gap inventory, moot now the feature is gone). #585 (header forwarding) was closed unmerged and #587 (post-CD branch smoke) was closed as not planned, both at 22:22 IDT.
Why it's going. Branch Workers answered browser requests with your code, but Durable Objects, queue consumers and named RPC always ran staging code against staging storage. Cloudflare has no per-request code selection for those surfaces, so every branch session silently read and wrote staging state through the back door. Closing the gaps (allowlists, "new objects only") was judged to cost more than the fast path is worth, so the feature is removed rather than patched.
What to use instead. A full side env with env:up. The planned speed-up is a warm pool of pre-built side envs (the PR measured about 6.3 minutes for a cold env:up without an image rebuild); it is tracked in a follow-up issue.
What it deleted. packages/branch-routing/; the withBranchRouting mounts on control-plane, dispatch and agents; the BRANCHES dispatch-namespace binding and BRANCH_ROUTING var from all three staging configs; branch:deploy, branch:down and branch:list; scripts/branch-switcher/ (the Chrome extension); the branch scripts and tests under scripts/env/; the brilliant-branches Pulumi namespace (infra/pulumi/src/branches.ts); repo docs/plans/branch-routing.md and its evidence folder; and the branch sections in gotchas, READMEs and docs. Dispatch, agents and control-plane go back to their pre-branch fetch shapes.
What it keeps. The brilliant-staging-agent key and all the staging-agent Pulumi and IAM work from #492 stay, since they don't depend on routing.
After merge (live follow-up, not yet confirmed done). At merge time the staging stack still held the brilliant-branches dispatch namespace, and the three staging Workers keep the BRANCHES binding until the next CD deploy from main. A pulumi up on staging then deletes the namespace. That is a deletes plan, so it needs the CI deletes-guard allowance or an admin session. The namespace is empty (branch:list was empty before the tooling was removed).
Evidence in the PR. bun run verify passes, and a repo-wide grep for the branch-routing names (withBranchRouting, BRANCH_ROUTING, brilliant-branches, x-brilliant-branch, branch:deploy and others) returns nothing.
Branch routing: deploy only changed Workers (#561, merged)
Removed by #606 (merged 2026-10-07 22:31 IDT): branch code can't reach Durable Objects, queues or named RPC, so branch sessions used staging state. This section is history;
branch:deploy|down|list, the header router and the switcher no longer exist onmain. Useenv:up.
Merged 2026-10-07 12:11 IDT by yoni-monday (merge d09e537d, branch fast-side-envs; closes #339, #341, #342). Design: repo docs/plans/branch-routing.md; runbook in repo scripts/env/README.md ("Branch envs") and AGENTS.md ("Verifying on your own environment"); traps in gotchas/side-envs.md. Routing is live only once staging has deployed from main with this merge; until the post-merge check below passes, treat it as unproven on staging.
Try this before env:up. If your change is code only in control-plane, dispatch or agents (no migration, new binding, queue consumer, Durable Object or Workflow class, template or conductor change), a branch env takes about 3 minutes instead of a ~10 minute stack with its own database. AGENTS.md now tells agents to try it first.
Why. A full side env is a Pulumi stack plus its own database, while most branches change one or two Workers. Branch routing uploads only the changed Workers into the staging account and lets you pick them per request. Everything else still gets staging. Staging data is not sensitive, so branch Workers run with staging's bindings, secrets and Durable Objects as they are. Branch writes are real staging writes.
How a request is routed. You send the header x-brilliant-branch: <name>. Router middleware (packages/branch-routing, withBranchRouting) runs first in the fetch of the three routed Workers: control-plane, dispatch and agents.
- Off unless all three hold:
BRILLIANT_ENV === "staging",BRANCH_ROUTING === "1", and aBRANCHESbinding to thebrilliant-branchesdispatch namespace (created in #492). When off, the header is never read. - On: it calls
BRANCHES.get("<branch>--<service>").fetch(req). If that Worker doesn't exist ("Worker not found"), the request falls through to staging code. Any other branch error is a 502, never a silent staging answer.get()never throws for a missing script, so the miss only shows at.fetch(). - Every response says who served it:
x-brilliant-served-by: stagingorbranch:<name>:<service>, exposed to CORS so cross-origin JS can read it.stagingmeans your code did not run.
Every Worker has a routing decision. scripts/env/branch-guard.ts lists ROUTED (control-plane, dispatch, agents) and NOT_ROUTED with a reason for each other Worker (conductor, workflows, admin, site, template-share, demo-data, evals). scripts/env/test/branch-coverage.test.ts fails verify when a Worker under apps/ or services/ is in neither list, when a routed Worker doesn't mount the router or lacks the binding, flag and BRILLIANT_ENV=staging, or when a list entry is stale. Adding a Worker means adding it to one of the two lists. (Agents was added late in the PR: before that, branch:deploy uploaded <branch>--agents but staging agents ignored the header.)
Prod stays off. Prod and side-env renders strip the binding and flag (stripBranchRouting in scripts/env/lib/config.ts), because they render from staging's wrangler.jsonc; side-env agents also get their own BRILLIANT_ENV. The runtime check requires exactly staging, and render.test.ts renders prod (and patches side envs) for every routed Worker and fails if either survives. Contracts: branch-routing-never-in-production, branch-routing-stripped-outside-staging.
Commands.
bun run branch:deploy <name> # diff vs origin/main (--base <ref>, --dry-run, --ids <file>) → services (+ callers/callees from scripts/env/service-graph.json) → guard → upload
bun run branch:list # what is deployed, and when
bun run branch:down <name> # delete every <name>--* scriptUploads use staging ids and staging secrets (via --secrets-file, a 0600 temp file), with the global_fetch_strictly_public compat flag and no consumers, crons, routes, migrations or the router's own binding. Durable Object and Workflow bindings point at staging's script (script_name), so a branch sees staging's app data and TEMPLATE_PUBLISH_WORKFLOW is defined, rather than empty branch-owned DOs. Credentials: the brilliant-staging-agent profile for the secret reads; the Cloudflare token comes from brilliant/cloudflare/staging. No wrangler.env-branch-* config or secrets file is left behind.
The guard sends you to env:up instead when the diff touches DB migrations, infra/pulumi, a binding / Durable Object / migration / queue / container / trigger section of any wrangler*.jsonc, queue consumers, a routed Worker source file that declares a DO or Workflow class the routed Workers bind (branch copies run staging's class code, so the edit would never run), packages/template, infra/agent-image, the conductor, or a Worker with no router. Use a full side env for those (and for anything destructive to data). The guard refused #561 itself (dispatch_namespaces changed … use bun run env:up), which is the intended behaviour.
Browser: branch switcher extension (scripts/branch-switcher/, load unpacked in Chrome). A declarativeNetRequest rule adds the header for the listed staging hosts only (studio app. and demo.brilliant.rocks, *.brilliant-app.rocks, and the workers.dev hosts of control-plane, conductor, dispatch and agents). Since #572 (merged 2026-10-07 13:20 IDT) the rule covers every resource type (navigation, iframes, fetch/XHR, WebSocket, scripts, styles, images, fonts, media and the rest). #561 alone covered only fetch, iframe, navigation and WebSocket, which made the studio render blank on a branch (see Traps). If Chrome rejects the rule, the icon shows a red ERR badge with the reason in its tooltip. The popup sets and clears the branch, and the badge shows the active one. Scripts and agents send the same header themselves (curl -H, Playwright extraHTTPHeaders).
Set up the switcher (once, about a minute; steps from scripts/branch-switcher/README.md, added in #572).
- Print the extension's path from a checkout that stays put (your main clone, not a
/tmpworktree, since Chrome reloads it from that path on every start):cd "$(git rev-parse --show-toplevel)/scripts/branch-switcher" && pwd. There is nothing to build. - In Chrome (or Arc, Brave, Edge) open
chrome://extensionsand switch on Developer mode. - Click Load unpacked and pick that directory. "Brilliant branch switcher" appears; a warning about developer-mode extensions is expected.
- Pin it from the puzzle-piece menu so the badge is visible.
- Click the icon: the popup should say "Active branch: none".
After a git pull that changes scripts/branch-switcher/, click the reload arrow on the extension card; Chrome doesn't pick up file changes itself.
Use it. bun run branch:deploy <name>, then type <name> in the popup and press Enter (lowercase letters, digits and single dashes, up to 31 characters; invalid names are refused). Reload the staging tab (https://app.brilliant.rocks). Clear turns it off. Reload after switching or clearing, because open pages keep what they already loaded.
Live check (from #572, real extension against real staging). With branch probe set, the studio, dispatch and agents each answered x-brilliant-served-by: branch:probe:<service> with the branch build's SHA, and the studio rendered its sign-in screen. After Clear, all three answered staging.
Traps (from the plan, the extension README and gotchas/side-envs.md).
served-by: stagingalthough you sent the header, in order of likelihood: that service isn't in your branch (bun run branch:list; fall-through is by design); a Worker-to-Worker hop didn't forward the header (only browser traffic gets it from the extension; with #585, open, Workers forward it only while serving a request, never from DO, alarm, queue or RPC calls); the extension lacks the host or itswss://twin, so sockets silently miss it; or the branch name has--, uppercase, or is over 31 characters and was ignored.- Edits to a Durable Object or Workflow never run on a branch: that code is staging's. The guard refuses a direct edit to such a class, but not a helper the class imports. Use
env:upfor DO or workflow work. - Error 1042 from a branch Worker means it lacks
global_fetch_strictly_public(branch:deployadds it, so a hand-uploaded script is the usual cause). Error 1019 is subrequest depth: a branch route calling back into its own host with the header loops. - Studio renders a blank page with the switcher on (
Failed to load module script … MIME type text/htmlin the console): the document came from the branch but its scripts and stylesheets came from staging. The branch HTML names its own asset hashes, so they 404 into the SPA fallback. Cause: themainrule from #561 doesn't coverscript,stylesheet,imageand other subresource types. Fixed in #572 (merged 2026-10-07):git pulland click reload on the extension inchrome://extensions.test/proof.tsnow also checks script, stylesheet and image requests, andtest/proof.test.tsruns that proof in CIverify(including thePROOF_DROP_WS=1case, which must exit 1). - Cached static files survive a branch switch. Hashed
/assets/*and HTML are safe, but non-hashed images and fonts (/landing/*, template images) are cached for a day with noVaryon the branch header, so the first copy the browser saw keeps showing. If your branch changes one of those, hard-reload (Cmd+Shift+R) or tick DevTools › Network › Disable cache. - Still served by the branch for minutes after
branch:down.branch:downdeletes the scripts at once andbun run branch:listis empty straight away, but the edge keeps dispatching to the deleted script for a few minutes (about four on 2026-10-07:x-brilliant-served-by: branch:<name>:<service>with the branch build's SHA, thenstaging). Our router has no lookup cache; the delete just takes that long to reach every edge. Wait it out before concluding the router falls through wrongly; to stop testing a branch immediately, clear the header instead (switcher Clear, or drop-H). Seen in the live check afterbranch:down probe; now ingotchas/side-envs.md(docs PR #576, merged 2026-10-07). - Red
ERRbadge on the extension icon: Chrome rejected the rule (the tooltip has the reason) and no request carries the header. - The extension needs
wss://host permission too, or WebSocket handshakes silently go to staging code.manifest.jsonlists both schemes andbun scripts/branch-switcher/test/proof.tsfails if a host is missing one. A new staging host means editing bothhosts.jsandhost_permissionsinmanifest.json(https and wss), then reloading the extension. - Worker-to-worker header forwarding (
withBranch) was not part of #561; it is in open PR #585. The conductor still has no router.
Post-merge check (from the PR). After the staging deploy from main: curl -H 'x-brilliant-branch: probe' to dispatch should return x-brilliant-served-by: branch:probe:dispatch; no header, or an unknown branch, should return staging. Then bun run branch:down probe. Staging DO and Workflow binding by script_name was accepted at upload but is unproven at runtime until this runs.
Worker-to-Worker branch forwarding (#585, open)
Moot. #585 was closed unmerged on 2026-10-07 and #606 (merged) removed branch routing entirely. Kept as history of the design.
Status: open PR, not merged. Opened 2026-10-07 15:17 IDT by yoni-monday (branch branch-routing-343, head b022b187, refs #343). This is slice 6 of the branch-routing plan. Until it merges, a Worker calling another Worker drops your branch and the second hop runs staging code. The design and call table below come from the PR's edits to repo docs/plans/branch-routing.md ("What forwards (as built)") and gotchas/side-envs.md.
Why. The browser (or curl -H) sends x-brilliant-branch, but a Worker that calls another Worker only passes it on if it copies the header. Without that, responses look healthy while the downstream hop quietly tests staging code.
How. withBranch(request, headers) in packages/branch-routing copies a valid incoming branch header onto an outgoing call without overwriting the caller's own headers. It is not gated itself; it is inert in prod because no prod Worker has the flag, binding and BRILLIANT_ENV=staging that make a router read the header. Forwarding only happens while a Worker is serving an inbound request and passes it on.
| Hop | Forwards? |
|---|---|
| control-plane → conductor | Yes, when an operation or route is serving a request (conductorFetch, routes/ai.ts) |
| control-plane → agents | Yes (agent draft, agent-grant wake-up) |
| control-plane → workflows | Only the synchronous step test (/run-step); schedule, event and delivery calls run outside a request |
| control-plane → template-share | No (credential-stripping allowlist; not a routed Worker) |
| dispatch → control-plane | Yes for published-app admission; no for collection consumer lookups (outbox, alarms) |
| dispatch → conductor | No (the conductor is not routed) |
| conductor → control-plane | Yes while serving a request (deploy and rollback script resolution, session deploy, container AI and members proxies); no from Durable Object, outbox and alarm work |
| workflows → control-plane | Yes for a step test; no for workflow runs, queue and alarm work |
| agents → conductor / control-plane | No: every call is made inside ThreadDO / RunDO, after the request that woke them |
anything → PlatformData, CollectionAdmin, AppRpc | Not possible (see below) |
Known gaps (deliberate). Anything a Durable Object, alarm, queue or cron calls later has no inbound request, so staging code answers. Threading a branch name through ThreadDO, RunDO and WorkspaceDO is not part of this PR.
RPC entrypoints never run on a branch. PLATFORM_DATA, COLLECTION_ADMIN and APP_RPC are service bindings to named WorkerEntrypoint classes on brilliant-dispatch. Those calls never pass through fetch, so no router sees them, and the branch namespace only hands back a plain Fetcher with no way to pick a named entrypoint. So a branch dispatch's copies of those three classes never run. branch:deploy now refuses a diff to a source file that declares one of them. It can't see the modules they delegate to (access/gateway.ts and its imports), so a change there deploys fine but is silently not exercised through RPC. Use env:up for that.
Admission cache per branch. Dispatch's published-app admission lease cache is keyed by branch, so a snapshot from a branch control plane is never reused for an ordinary request.
Check every hop with the smoke. bun scripts/e2e-smoke.ts --env staging --branch <name> sends the header on every request, records x-brilliant-served-by on each browser and Node HTTP response, and fails when a service that has a <name>--<service> script answered staging, when a normal response has no stamp, or on Cloudflare error 1019. It names the service and URL that answered staging. It can't see hidden server-to-server or RPC hops; unit tests cover those call sites.
New 1019 loop. Now that Workers forward the header, a route that calls another Worker which calls back into the first (control-plane to conductor to control-plane on the same path) hits subrequest depth error 1019; the smoke fails loudly on it.
Not yet proven (from the PR). A live probe on disposable forwardcheck--* scripts showed a branch dispatch reaching the branch control-plane with the header, and staging control-plane when the header was dropped. No conductor or workflows deploy from the branch was done, and no full smoke against the branch build has run, so those call sites need checking after merge.
Branch env still served after branch:down
branch:down deletes the scripts at once and branch:list is empty, but the edge keeps dispatching to the deleted script for a few minutes (about four on 2026-10-07: x-brilliant-served-by: branch:<name>:<svc> with the branch build's sha, then staging). Wait it out before deciding the router falls through wrongly; to stop testing a branch immediately, clear the header instead. Source: a gotchas/side-envs.md addition in an early revision of #620; the merged PR dropped it, and branch routing is gone since #606, so this is history.
Reproducing a usage reconciler rebuild, and tailing the side conductor (#653, merged)
To make the reconciler rebuild a step, abort a turn mid-generation (POST /w/<env>/agent/abort a few seconds after prompt). Pi commits a pi.assistant entry with stopReason: "aborted" and real usage that the live billing hook never records. The alarm rebuilds it about five minutes later and the result lands in turn_usage_receipts in the side DB.
The side conductor worker is conductor-<env>, not brilliant-conductor-<env>: wrangler tail brilliant-conductor-<env> fails with code 10007. Read the name from .brilliant-env/<env>.json (cloudflare.workers.conductor.name). Source: gotchas/side-envs.md addition in #653 (merged 2026-10-08).
Faster env:up (#628, merged) and its review fixes (#665, merged)
#628 (merged 2026-10-08 12:29 IDT, yoni-monday, part of #607) cut a cold env:up from 6m18s to 4m45s and a re-run on an existing env from 4m47s to 2m30s, measured live on env optfast. It changed four things:
- Migrations batch per file.
scripts/env/migrate.tssends each migration file in one round trip (one implicit transaction) instead of one statement at a time, which was 291 round trips across 39 files. It falls back to one statement at a time only on a duplicate-object error. The ledger and the destructive gate are unchanged. - A cold env skips the deploy that is sure to fail. With no prior state file (
isColdSideEnv), dispatch and the control plane go straight to their unbound bootstrap configs instead of first trying the full config and failing with 10143. A warm env keeps the try-full, catch 10143, then bootstrap path. - The five leaf deploys run together. Agents, workflows, template-share, demo-data and admin deploy in one batch (
scripts/env/lib/up-deploy-leaves.ts) because none of them binds another. The control plane is rebound only after the batch. env:downnow deletes dispatch's leftoverwrangler.env-<name>.bootstrap.jsoncas well as the control plane's.
What's left of the cold time is mostly the sequential bootstrap chain and the secrets fetch before phase 1 (about 70 to 80 seconds). The DB phase is expected to drop further with Neon branches (see Neon migration plan).
#665 (merged 2026-10-08 17:13 IDT, yoni-monday, merge 00478c64, branch env-cd-review-fixes) fixed three problems found in review of #628. They are on main now:
- The candidate env
ciis never treated as cold. A fresh release runner never has.brilliant-env/ci.json(scripts/deploy/candidate.ts prepareremoves it), so before #665 every release took the cold path and deployedci's control plane and dispatch without service bindings first, then rebound them.ciis long-lived and its bindings already exist, so #665 madeisColdSideEnv(state, envName)return false for it. The name lives in a new leaf module,scripts/env/lib/candidate-env-name.ts, so thatstate.tsdoesn't pull inaurora.tsand itspostgresimport. - Migration files with
CREATE INDEX CONCURRENTLYorALTER TYPE … ADD VALUErun one statement at a time. Postgres rejects the first inside a transaction (25001), and an enum value added by the second isn't usable later in the same transaction (55P04). Batching made any such file hard-fail with an error that doesn't point at the cause, including in the staging and prod migrate step ofdeploy.yml. #665 addedrequiresPerStatementExecution, which scans the file text, so new migrations need no special handling. - Leaf deploys wait for all five to finish. The batch uses
Promise.allSettledinstead ofPromise.all, so one failure no longer cuts off the other fourwranglersubprocesses mid-deploy. The first failure is still rethrown and still fails the run.
Two durable rules from the updated gotchas/side-envs.md in #665:
scripts/env/lib/state.tsandtargets.tsmust never importaurora.ts, even indirectly (and so nevercandidate-env.ts). The evals runner imports them, and its production-onlybun installleaves outpostgres, so it would crash at startup with “Cannot find package 'postgres'”.services/evals/test/image-files.test.tscatches this.- A batched migration file holds every lock it takes until the end of the file. A file that mixes a schema change such as
ALTER TABLEwith a large backfillUPDATEblocks live traffic on that table for the whole backfill, so put a big backfill in its own migration file.
Source: PR bodies and diffs of #628 and #665. Both PRs are merged.
Side-env DBs on Neon branches (#668, merged)
Merged 2026-10-08 19:10 IDT
#668 "Side envs on Neon branches of a CI-rebuilt golden; control plane next to Neon" (opened 18:48 IDT and merged 19:10 IDT on 2026-10-08 by yoni-monday, merge 079b27d6, branch neon-wave2-side-branches, head edd2d8f0) is wave 2 (#622). Everything below is from the PR's updated scripts/env/README.md and gotchas/side-envs.md.
How it works. An env's database is the Neon branch side-<name>, a copy-on-write child of golden in the staging Neon project. golden is declared in Pulumi (infra/pulumi/src/neon.ts) and rebuilt in place by .github/workflows/neon-golden.yml on every merge to main (scripts/neon/golden.ts: owner password reset, every migration from an empty database, the E2E seed, then a build record in golden.build, written last).
bun run env:up <name>branchesgoldenintoside-<name>(its own endpoint, owner password reset on the branch, read-only admin role created by SQL), applies any migrations newer than golden's, then runspulumi upwith Hyperdrive on the branch's direct host (never-pooler).bun run env:down <name>destroys the stack, then deletes the branch (its read-only role goes with it) and checks it is gone.bun scripts/neon/golden.tsrebuilds golden by hand.NEON_GOLDEN_BRANCH=<name>points bothenv:upand the rebuild at another branch, for testing the machinery without touchinggolden.
New prerequisite: the staging Neon project's API key as NEON_API_KEY_STAGING (or NEON_API_KEY). A key scoped to any other project is refused. It is never written to state, Pulumi config or logs, and because Neon's password-reset and branch-create responses echo role passwords, the tooling never prints a response body.
Staging Neon key from the secrets Worker (#703, merged)
#703 (merged 2026-10-09) removes the need to hold NEON_API_KEY_STAGING locally. It is now a side-env tooling catalog entry (staging project only, optional, no Worker consumes it). The secrets Worker serves it from GET /side-env-vars and binds it at deploy, but /sync never writes it into a Worker. env:up/env:down resolve it in order: an explicit env var wins (CI, golden job); otherwise, with BRILLIANT_SECRETS_SOURCE=store, it is read from the secrets Worker using your own Access login; otherwise you get a clear error. Closes the code half of #700.
When env:up stops at step 1 with "Neon branch golden does not exist, or has no finished build": that is fail-closed on purpose. The build record is checked on the new branch itself, so a branch cut mid-rebuild is refused and deleted. Run gh workflow run neon-golden.yml (or the script with the staging key), then rerun env:up.
Isolation. A branch inherits its parent's roles and passwords, so env:up resets neondb_owner on the branch itself, and the rebuild sets the inherited brilliant_admin_ro to NOLOGIN with no password on golden. To check an env, log in with its URL from .brilliant-env/<env>.json against staging's default endpoint and golden: both should answer 28P01. The read-only role keeps its per-env name brilliant_admin_ro_<env> so Hyperdrive and state need no special case.
Rules of thumb:
- Never delete
goldenby hand. Its children are live side envs, and Neon refuses anyway. - All side-env branches live in the staging Neon project, which is also staging's database. Don't hand-delete branches there; use
env:down. - Envs created before the move stay on Aurora until their next
env:up.state.neonin the env's state file says which backend it uses.env:upon an old env creates the branch, repoints its Hyperdrive configs and drops the Aurora database; side-env data is disposable, so nothing is copied. Withoutstate.neon,env:downdrops the Aurora database and role as before. - The candidate env
cimoves to a branch on its first release after merge. It keeps no state between runs, so everyenv:up citries the Aurora drop, which is a no-op after the first. - After the "everything disappeared" failure (#259), the env's Neon branch is not one of the things that vanish;
env:upfinds and reuses it.
The same PR moves the control plane's placement pin to aws:us-east-2, next to Neon, which fixed the dev-preview e2e timeouts. See the Neon plan for that and the PR's live evidence.
Agents starting side envs (#704, open)
Owner decision (2026-10-09): agents start side envs through the owner's own Cloudflare Access login, cached by cloudflared, never a separate key. When that login expires, the agent stops and asks the owner. The Neon key comes from the secrets Worker when BRILLIANT_SECRETS_SOURCE=store; an explicit env var still wins for CI (fallback lands in #703). Side envs are Neon branches of golden. Docs: #704 adds "Starting a side env" to docs/agent-workflow.md with the commands and a zero-leftovers check, and updates scripts/env/README.md and docs/getting-started.md. Merges after #703.
Related
Side envs from GitHub Actions (#715)
Merged to main 2026-10-09 13:51 IDT (PR #715, merge eb724901). You can now bring a side env up or down from GitHub Actions instead of from your own machine.
- Run it:
bun run env:ci up <name> [--ref <branch>]orbun run env:ci down <name>. It dispatches the workflow, finds the run, waits, and prints the env URLs or the step that failed. - Workflow:
.github/workflows/side-env.yml, dispatched from main with inputsaction,name,ref. Bad names or refs are refused before any checkout or credential. The branch is installed before the AWS role is assumed, and secrets reach only the env:up, env:down and leftovers steps. Actions are pinned by SHA. Runs are serialized per env name and never cancelled.downfails unless main's own leftovers check finds nothing left behind. - Who can run it: any repo writer, for any branch, with no reviewer gate. Branch code runs with side-env-scoped credentials only. The staging Cloudflare token is reused for now.
- AWS role:
brilliant-gha-side-env(Pulumi, staging stack, outputsideEnvWorkflowRoleArn) trusts only the GitHub OIDC subject for environmentside-envon DaPulse/brilliant-ai, using immutable owner and repo ids. It has the same managed policy as the side-env agent user, and that policy now denies access to theside-cistate, the candidate that gates staging. - GitHub environment:
side-env(main-only, secrets set).
Related: Secrets and envs.
Secret push order under the store (#721)
Merged 2026-10-09 14:16 IDT (PR #721). The first real env:ci up run showed that a side env's admin Worker (for example brilliant-admin-<name>) gets its secrets pushed before its first deploy. The Secrets Worker /sync can't write to a script that doesn't exist yet (it answers 404, surfaced as a 500 write_failed), while wrangler secret bulk quietly creates the missing script as a draft.
So in store mode, pushSideEnvSecrets now runs in this order:
- Push the direct keys with
wrangler secret bulk, which creates the draft script if needed. - Call
/syncfor the shared store values. - Re-push only the direct names that the sync also wrote, so local values still win.
A failed sync still throws before anything is recorded, and re-running converges. The rest of that first run worked end to end: OIDC role, Neon branch, migrations, every Worker deploy, and /sync through the side-env token. See also Secrets and envs.
Secrets Worker serves the side-stack passphrase and R2 state keys (#730)
Merged to main 2026-10-09 20:39 IDT (PR #730, merge 97741ad6). This is the broker half of moving side-env Pulumi state to R2 (wave 5 of #625).
/passphrase/sideexists on the staging Secrets Worker only. Callers allowed: people, the staging CI token, and the side-env token. The side-env token gets no other passphrase, and prod refusessideeven if a binding appeared.- New optional side-env tooling catalog entries
R2_STATE_ACCESS_KEY_IDandR2_STATE_SECRET_ACCESS_KEY, served by/side-env-varsfromSIDE_ENV_R2_STATE_*and never written by/sync. - Staging deploy binds
PASSPHRASE_SIDE(store secretpulumi-passphrase-side); prod binds only its own passphrase. - No live change yet: the store values are written before the state switch.
Update (#771, merged 2026-10-11)
BRILLIANT_SECRETS_SOURCE no longer exists; the Secrets Store is always used, so drop it from the setup steps above. Side stacks always use a passphrase. Details: Secrets and envs.
One canonical side-env guide (#765, merged)
Since PR #765, scripts/env/README.md in the repo is the single source for side environments. Agents run the env:ci path; people working on a laptop follow the prerequisites listed there. AGENTS.md, agent-workflow, and getting-started all link to it. There is no AWS in the path anymore; see Neon migration plan.
Side-env workflow hardening (#797, merged)
PR #797 (follow-up to #719) merged to main on 2026-10-12 00:57 IDT:
- Token: the side-env workflow keeps using the staging account's Cloudflare token. The owner accepted this; it's recorded in
scripts/env/README.md. - Independent leftovers job: after
env:down, a separateleftoversjob (needs: side-env,if: always()) runs on its own runner from main (github.sha) with its own install, so branch code can't change the verdict. - More leftovers checked (read-only): the env's nine Workers by exact name, its dispatch-namespace scripts, and its conductor container apps. A list that can't be read counts as still there.
- Shared wiki bucket: side envs no longer create
brilliant-wiki-<name>. They bind one shared R2 bucket,brilliant-wiki-side, declared once by the staging stack (prod unaffected).env:downnever deletes it. env:ciqueueing: prints "queued behind another run for <name>: <url>" instead of timing out silently.
Rollout: after merge, staging infra.yml creates brilliant-wiki-side, then live env:ci up/down is verified.
Side envs start with unlimited credits (#907, merged)
PR #907 (merged 2026-10-14 09:45 IDT by yoni-monday, merge e8b376f4) makes owner decision concrete: every side env starts with BILLING_UNLIMITED_CREDITS=true (the switch from #902).
What env:up does. After the Pulumi stack exists, it seeds the env's own CONFIG_KV once:
- Key unset (404) → writes
true - Key already set (
trueorfalse) → left alone, so an operator'sfalsesurvives a re-run - Any other KV error →
env:upfails loudly (no silent skip)
Staging and prod are untouched: env:up refuses those names before this step.
Gotcha: credit refusals do not reproduce on a fresh side env. With the switch on, the env never returns insufficient_credits / billing_suspended, and Trials never end into hosting grace. To reproduce those paths, set BILLING_UNLIMITED_CREDITS to false in that env's admin › Config (each isolate memos the value for up to 30s), then set it back to true when done. Repo note: gotchas/side-envs.md.
billing-live-check flips it for its own run. On a side env where the switch is true, the check turns it off through the audited admin Config API, waits past the 30s memo before asserting refusals at zero, then restores the recorded value (also on SIGINT/SIGTERM). A failed restore is a FAIL. It never writes the switch on shared envs (staging / stg / prod / production): if those are true, it refuses and tells you to flip by hand.
Also from the same PR: side envs use staging's sandbox Stripe key, so billing overview reports payments as available (Checkout is offered). Tech design: repo docs/plans/billing-tech-design.md. Related: Admin Config, Subscriptions, credits & access.
Side env admin Config not reaching its conductor (#905, merged)
Fixed in #905 (merged 2026-10-14). Symptom: a value saved on a side env's admin Config page (STUDIO_AUTO_TIERS, STUDIO_DEFAULT_MODEL, QUESTION_AUTO_ANSWER_SECONDS) is ignored and the conductor keeps the code default. Cause: env:up's reused-image path (image: reuse / image: skip in the log) re-rendered the conductor config without the env's CONFIG_KV id, so the conductor bound the base (staging) namespace while admin wrote the side one. scripts/env/lib/up-deploy.ts now passes the side env's id. An env deployed before the fix needs env:up again. See Admin Config: Studio model keys.