Secrets & environments
Planned: drop AWS (#620, plan merged)
A plan merged on 2026-10-08 (17:07 IDT) moves every database from Aurora to Neon (behind Hyperdrive), secrets to Cloudflare Secrets Store, and Pulumi state from S3 + KMS to R2, then deletes all AWS resources in five waves, moving Pulumi state before anything is deleted. Only wave 1 code has landed so far; this page still describes today. See Drop AWS: Neon migration plan.
Merged (not applied live): #681 (merged 2026-10-08 21:43 IDT) sets where the post-AWS Pulumi state passphrases live: a Worker behind Cloudflare Access serving each stack's passphrase from the account's Secrets Store, staging to developers via SSO plus CI, prod to CI only. Nothing is deployed yet. See Pulumi passphrase broker.
Merged (default still AWS until lead flips): #686 (merged 2026-10-09 00:46 IDT) adds a switchable path so worker secrets can come from the secrets Worker / Cloudflare Secrets Store instead of Secrets Manager. Flip is a lead action after migration; see Worker secrets from the secrets Worker.
Merged (staging bootstrap applied; deploy bind rule on main): #689 (merged 2026-10-09 01:14 IDT) is the Worker half of wave 4: renames services/pulumi-key → services/secrets and implements /sync, /dev-vars, and /side-env-vars. See Secrets Worker.
Merged (deploy rule): #695 (merged 2026-10-09 01:46 IDT) makes secrets Worker deploy bind only store secrets that exist (Cloudflare 10182). See Deploy binds only present store secrets.
Merged (optional Composio toolkit configs): #696 (merged 2026-10-09 02:06 IDT) makes each expanded COMPOSIO_AUTH_CONFIG_* name optional so a missing toolkit config is skipped, not a 409. See Composio toolkit configs optional.
Merged (ADR amendment on main): #697 (merged 2026-10-09 08:05 IDT) amends prod-infra ADR rows 9/10 so Secrets Store + secrets Worker are the source of truth, and admin writes move to the store API when the switch completes. Docs only. See ADR prod-infra rows 9/10.
Source of truth
Today (until the lead flips BRILLIANT_SECRETS_SOURCE=store): AWS Secrets Manager holds env JSON blobs (brilliant/dev, brilliant/staging, brilliant/prod, brilliant/side-env-base, …). Fan-out to Workers is defined by the checked-in catalog infra/secrets/catalog.ts and applied with:
bun run secrets:pull # laptop → .dev.vars
bun run secrets:push # ASM → wrangler secret bulk (CD / ops)
bun run secrets:verifyDo not store secret values in Outline, git, or chat. Test fixtures must look fake (fake-, test-, …).
Worker secrets from the secrets Worker (#686, merged)
#686 (merged 2026-10-09 00:46 IDT by yoni-monday, merge 9e4a6c0c; opened 2026-10-08 22:51 IDT, branch wave4-tooling, head 42c1168e, +2293/−141 in 24 files) is the tooling half of wave 4 (#624). BRILLIANT_SECRETS_SOURCE=aws|store chooses the source (default aws; unknown fails). No behaviour change until the lead sets the repo variable to store after the store is filled and verified. The Worker that serves the routes is on main as #689 (see Secrets Worker). Full wave context: Neon migration plan — Wave 4 tooling.
| Piece | Detail |
|---|---|
| Client | scripts/lib/secrets-worker.ts: Cloudflare Access (person: cloudflared; CI: service token). Never prints values. |
| Hosts | Staging / side / dev: https://secrets.brilliant.rocks. Prod: https://secrets.itsbrilliant.ai. |
| Store mode | secrets:push, env:up, deploy call /sync per worker. Minted / computed / local values still go via wrangler bulk. binding_in_use (CF 10053) defers that worker to a post-deploy pass. A worker with no non-computed catalog entries for that env (e.g. evals in prod) is skipped and its rendered wrangler config is never read (#724). |
| Pull | secrets:pull → GET /dev-vars; loadSideEnvBase → GET /side-env-vars. |
| Catalog | mintedPerSideEnv on the seven names env:up mints (never stored). |
| Migration | bun run secrets:to-store (dry-run, 100-cap check, refuses missing required) and bun run secrets:verify-store. Staging dry-run planned 79/100. |
Still ASM under store | Computed values, cloudflare-ids, admin-readonly, reviewed secrets-sync.yml (--expected-version fails under store). Rerun migration after Pulumi rotates generated keys. |
Lead flip (not automatic): migrate with secrets:to-store, set BRILLIANT_SECRETS_SOURCE=store plus Access service-token env secrets, verify with secrets:verify-store (names only). Staging/prod /sync refuses a person's login. See gotchas/aws-and-secrets.md on main.
Secrets Worker (#689, merged)
#689 (merged 2026-10-09 01:14 IDT by yoni-monday, merge c10dd438; opened 2026-10-09 00:47 IDT, branch wave4-secrets-worker, head b938772c, 4 commits, +2359/−369 in 42 files) is the Worker half of wave 4 (#624); tooling half is #686 (merged). Renames services/pulumi-key → services/secrets. Nothing applied live yet. Full design: Neon migration plan — Wave 4 secrets Worker; docs on main services/secrets/README.md.
| Piece | Detail |
|---|---|
| Hosts | Staging / side / dev: https://secrets.brilliant.rocks. Prod: https://secrets.itsbrilliant.ai. |
POST /sync | Catalog names only (never from the caller). People: side-env scripts only. CI token pinned by client id on every route. All values read before any write. CF 10053 → 409 binding_in_use. No Cloudflare body relayed. |
GET /dev-vars | People only, staging account — today's secrets:pull exposure. |
GET /side-env-vars | People + CI, staging account — today's loadSideEnvBase exposure. Also serves side-env tooling entries such as NEON_API_KEY_STAGING (#703), which /sync never writes to a Worker. |
| Side envs | Generated keys only from SIDE_ENV_ (never staging's). mintedPerSideEnv names never served. |
| Bootstrap | Imports each account's existing store (staging + prod already hold 4 AI Gateway secrets, never touched). Staging Access = Cloudflare login + OTP email allowlist; prod = CI only. |
| Store budget | 100-cap; worst case 130 by catalog; dry-run measured 79/100 on staging. |
| Live progress | Staging bootstrap applied (per #695 merged); first Worker deploy hit Cloudflare 10182 — bind-only-present fix is on main. Live staging then 409'd missing_required on GET /side-env-vars for absent Composio toolkit configs — #696 (merged) makes each expanded name optional. Still pending: green Worker deploy with the bind rule + optional Composio names, sync token, migration, verify-store, then BRILLIANT_SECRETS_SOURCE=store. Prod bootstrap still pending. |
Fresh Gemini review: no findings. 92 + 12 tests; all 8 Workers boot.
Secrets Worker deploy: bind only present store secrets (#695, merged)
#695 (merged 2026-10-09 01:46 IDT by yoni-monday, merge ae8b1ce8; opened 2026-10-09 01:34 IDT, branch secrets-deploy-bind-present, head 6b11ea198, 2 commits, +64/−18 in 3 files) is the fix from the first staging deploy of the secrets Worker. Full wave context: Neon migration plan — Deploy binds only present store secrets.
| Piece | Detail |
|---|---|
| Failure | Cloudflare 10182: a Secrets Store binding may not name a secret the store doesn't hold. The render had bound every catalog name (optional names and account-absent ones like TYPESAFE_API_KEY in staging). |
| Rule | services/secrets/scripts/deploy.ts lists the store's secret names (API never returns values) and binds only those; logs what it left unbound. |
| Fail-closed | An unbound name reads as absent, so /sync still fails closed (missing_required) on a missing required name. |
| Bootstrap yaml | Pulumi.staging.yaml records staging CI service token ids (public) from the first bootstrap up. |
| Live so far | Staging bootstrap applied (store imported, Access app + 2 policies; AI Gateway's 4 secrets untouched); CI service token secret in candidate/staging/infra-staging. |
Proven red: binding everything regardless of the store. services/secrets 95/95; tsc + biome clean.
Composio toolkit configs optional (#696, merged)
#696 (merged 2026-10-09 02:06 IDT by yoni-monday, merge 4c27e6b0; opened 2026-10-09 01:55 IDT, branch secrets-wildcard-optional, head 2c5c77c4, 1 commit, +26/−4 in 2 files) is the fix from live staging answering 409 missing_required on GET /side-env-vars. Full wave context: Neon migration plan — Composio toolkit configs optional.
| Piece | Detail |
|---|---|
| Finding | Worker expanded COMPOSIO_AUTH_CONFIG_* to every provider × profile and required all 12; staging holds only the toolkits it has (no Outlook, only some *_READ). |
| Rule | expandWildcard in services/secrets/src/lib/catalog-names.ts marks each expanded name optional: true. Absent toolkits land in skippedOptional; sync returns 200. |
| Why optional | Today's Secrets Manager push copies whichever of these names a blob holds — same semantics on the store path. |
| Without it | A staging /sync to the control plane would 409 and fail the release candidate on the store switch. |
Proven red then green: Outlook FULL/READ absent → skipped; Gmail FULL still pushed. services/secrets 96/96; tsc + biome clean.
ADR prod-infra rows 9/10: Secrets Store as source of truth (#697, merged)
#697 (merged 2026-10-09 08:05 IDT by yoni-monday, merge c798fe44; opened 2026-10-09 01:56 IDT, branch adr-secrets-store, head 04c5358a, 1 commit, +2/−2 in 1 file) is a docs-only amendment to the accepted prod-infra ADR, now on main. Closes #694. Full wave context: Neon migration plan — ADR prod-infra rows 9/10.
| Row | Amendment |
|---|---|
| 9 | Each account's Cloudflare Secrets Store + secrets Worker become the source of truth for worker secret values (was ASM). Store is write-only; Worker does one atomic secrets-bulk write per script from catalog names. Transitional BRILLIANT_SECRETS_SOURCE; Pulumi ASM add-ons stay until wave 5. |
| 10 | Admin write-only path moves from the AWS broker to the store's write API when the switch completes; broker deleted in wave 5. Worker application is /sync through reviewed CD. |
See also ADR index · Admin Secrets.
Pulumi secret add-ons
Some env values live in add-on Secrets Manager secrets that Pulumi owns and secretIdsFor merges over the base blob brilliant/<env> (same pattern as database):
| Add-on | Contents | Notes |
|---|---|---|
brilliant/<env>/database | {DATABASE_URL} | Deploy prefers this over the base key |
brilliant/<env>/admin-readonly | {ADMIN_READONLY_DATABASE_URL} | Admin’s brilliant_admin_ro URL; Hyperdrive origin (#248, merged); staging/prod only |
brilliant/<env>/turnstile | {TURNSTILE_SITE_KEY,TURNSTILE_SECRET} | Template demo “Try it” widget (#358 / #345 on main); site key is public to template-share |
Do not hand-edit those add-ons in the console; change them via Pulumi.
Environments
| Env | How it exists | Notes |
|---|---|---|
| Local Path 1 | Staging Worker URLs | No local secrets |
| Local Path 2 | .dev.vars from secrets:pull + per-dev DB URL | Hyperdrive local connection string |
| Side-env | env:up (Pulumi stack side-<name>) | Isolated workers + own Aurora DB + Hyperdrive; agents use brilliant-side-env-agent (no SSO) — see Side environments (#190, merged) |
ci (candidate) | Long-lived side env used by CD before staging | GitHub Environment candidate / role brilliant-gha-candidate; smoke + e2e must pass or staging is untouched (#222, merged) |
| Staging | CD on main after green verify → candidate (#241 removed STAGING_CD) | Shared; site https://brilliant.rocks, studio https://app.brilliant.rocks, admin https://admin.brilliant.rocks (#171 + #361); conductor deploys disrupt turns; see Verify & ship |
| Prod | Workflow dispatch + reviewers | Site https://itsbrilliant.ai, studio https://app.itsbrilliant.ai, admin https://admin.itsbrilliant.ai (#226 + #388, merged); gated by #222 (merged): needs staging running the sha + brilliant/staging-verified; Pulumi + Environment production approval |
Permissions refactor keys (#516, merged)
#516 (merged 2026-10-06 21:54 IDT, not deployed yet) adds five per-env keys, listed as generated for deployed envs in infra/secrets/catalog.ts. Side envs mint them automatically.
| Key | Consumers |
|---|---|
APP_ACCESS_AUTHORITY_KEY | control plane, dispatch, conductor |
APP_ACCESS_CONDUCTOR_REQUEST_KEY | control plane, conductor |
APP_ACCESS_DISPATCH_REQUEST_KEY | control plane, dispatch |
COLLECTION_PROOF_KEY | dispatch |
PLATFORM_DATA_IDENTITY_KEY | dispatch |
Staging and prod keys are minted by Pulumi (#541, merged)
#541 (merged 2026-10-06 23:55 IDT by yoni-monday, merge ab35dfcc) replaces the old manual step. No agent identity can write brilliant/<env>, so Pulumi now mints the five keys itself:
infra/pulumi/src/permission-keys.tscreates oneRandomPasswordper key (48 chars, no special characters) and writes them as one JSON secret,brilliant/<env>/permission-keys, for staging and prod only. Wired fromenvironment.ts.secretIdsFor(infra/secrets/aws.ts) merges that secret overbrilliant/<env>onsecrets:push, the same way theauth0andturnstileadd-ons work, and the deploy fans the values out to the workers.- Admin Secrets shows the five keys as Pulumi-owned and read-only (
source: brilliant/<env>/permission-keys, not editable). - Values exist only in Pulumi state and that secret, never in code or logs. Staging and prod never share a value (contract
permission-keys-are-pulumi-minted-per-env). - Rotation: replace the key's
RandomPassword. Workers fail closed untilsecrets:pushfans the new value out. infra.ymlcreates them along with the rest of the infra apply, so no human writes them. Check they exist by name only:aws secretsmanager get-secret-value --secret-id brilliant/staging/permission-keys --query SecretString --output text | jq -r 'keys[]'.
The staging preview showed 7 creates (5 passwords, the secret, its version) plus the Hyperdrive and cloudflare-ids changes already pending from #516.
The same PR (#516) turns Hyperdrive caching off and adds hyperdrive.AUTHORITY_HYPERDRIVE to brilliant/<env>/cloudflare-ids, so permission reads are never stale. See Permissions & app data.
Auth0
Nonprod tenant covers staging, side-envs, local. Staging Auth0 hosts / adminHosts include https://app.brilliant.rocks (studio callbacks), https://admin.brilliant.rocks, workers.dev wildcards and localhost (#171, #361). The marketing apex https://brilliant.rocks is a logout return only — in auth0.logoutOnlyHosts via #398 (merged; no sign-in callbacks or web origin). Prod tenant separate: Auth0 prod hosts / adminHosts include https://app.itsbrilliant.ai (studio callbacks), https://admin.itsbrilliant.ai, and production workers.dev origins (#226, #388, merged); https://itsbrilliant.ai is in logoutOnlyHosts the same way (#398). Apps/callbacks Pulumi-managed where possible. See Marketing site — Auth0 logout-only apex.
Auth0 management grant in Pulumi (#478, merged)
#478 (merged 2026-10-05, yoni-monday; related #464) puts the Auth0 management app's machine grant (the client-credentials grant the Pulumi Auth0 provider authenticates with) under Pulumi, with no permission change. Code: infra/pulumi/src/auth0-login-infra.ts, wired from src/auth0.ts; runbook in infra/pulumi/README.md § Auth0 management grant.
| What | Detail |
|---|---|
| Config key | brilliant-infra:auth0.managementGrant: {id, scopes, adopt?}. Absent means nothing is declared. adopt?: boolean (optional) came in #497 (merged). Since #497, prod sets managementGrant: {id, scopes, adopt: true} on main (see Prod step 1). |
| Resource | auth0.ClientGrant <name>-management-grant, subjectType: client, management secret's client_id, audience https://<canonical *.auth0.com domain>/api/v2/, protected. The import: <id> option used for adoption was removed by #483 (merged) now the grant is in state, so staging has no import. #497 (merged) brings it back behind config: adopt: true puts import: <id> on the grant resource, for a stack that has never managed the grant (prod); it's off unless set. Output managementGrantId. |
| Staging | Manages cgr_sHMpjFpJ0Tuvf8qa. Adopted by #478 at its existing 31 scopes, same order; since #483 (merged) the list is those 31 plus read:branding update:branding delete:branding read:prompts update:prompts (36). allowAllScopes never set; scopes are not ignored. |
| Prod | Declared on main since #497 (merged 2026-10-05): the prod management app's machine grant cgr_eoHcAn3mhvqB9BfK with adopt: true, keeping its existing 32 scopes in Auth0's order and appending read:branding update:branding delete:branding read:prompts update:prompts (37). The gated prod infra apply has run (run 37320346817: = 1 imported, ~ 2 updated), so the grant is in prod state with 37 scopes. #504 (merged) dropped adopt now that the import is done. Management secret brilliant/auth0/prod-mgmt. |
| Guards | Audience must be the canonical *.auth0.com tenant domain (the Management API never answers on a custom login domain, and an audience change replaces the protected grant). Scopes list must be non-empty, trimmed, no duplicates. up fails if the grant in state isn't the configured id. |
| Wrong grant | The non-prod tenant also has an empty user-subject grant for the same client and audience (cgr_9IWQjLSo6f7UKQ6j), and the prod tenant has one too (cgr_K0uMtFMFFoFaR6oe, left untouched by #497). Never adopt either; matching only client + audience is ambiguous, so adopt by grant id with subjectType: client. |
At adoption (#478) the import option was in code, so a fresh state adopted the grant on its first up with no CLI step. Since #483 (merged) there is no import option: a fresh stack must run pulumi import of the grant id first, otherwise up plans a create of a second client-subject grant, which Auth0 is expected to refuse as a conflict. Note that an in-code import never rejected a scope mismatch (scopes are mutable, so the run imports then updates them).
Widening scopes takes two merges. The Auth0 provider fetches its Management API token once per invocation, with the scopes the grant had at that moment. So: (1) adopt at current scopes (#478, done); (2) edit managementGrant.scopes in the stack config and remove the import option in the same change, and declare resources that need the new scopes only in a later merge so they run on a token that carries them. Step (2) is #483 (merged). Scope widening is tracked in #479.
Step 1 of the branded login: branding and prompt scopes (#483, merged). #483 (merged 2026-10-05, yoni-monday; step 1 of #480) is the "widen" merge. The non-prod management app got 403 on /api/v2/branding and /api/v2/prompts, so Pulumi couldn't set the login theme or copy. It also ships the logo file apps/site/public/brand/brilliant-logo.svg, so the site serves it before any theme points at it. It keeps staging's 31 scopes in order and appends read:branding update:branding delete:branding read:prompts update:prompts. It adds no custom-domain scopes (the custom domain is out of scope for now) and leaves prod untouched; the same pattern for prod is #497, merged (below). Because the grant is already in state from #478, the import option is removed and scopes are not ignored, so the configured list is exactly what the grant holds; a fresh stack would need a manual pulumi import of the grant id first. Staging preview: 1 update (the grant's scopes), 108 unchanged. The theme and prompt-copy resources come in a separate later PR (#484, below) once infra has applied this, since the provider mints its token before the grant update. It also supersedes the adoption-guard follow-up promised on #478. Per the PR's corrected gotchas/deploying.md, an in-code import does not reject a scope mismatch: scopes are mutable, so the same run imports and then updates them.
Step 2 of the branded login: theme and copy (#487, merged). #487 (merged to main 2026-10-05 14:46 IDT, yoni-monday, merge commit 58d16b40; closes the native-branding part of #480) is the "use the new scopes" merge. It re-lands the already-reviewed commits of #484, which GitHub shows as merged but which went into the leftover stack branch auth0-branding-scopes instead of main, so it never applied. Before it, sign-in showed Auth0's default black page and shield, with the copy "Log in to brilliant-prod to continue to brilliant-studio-prod" (the internal tenant and app names). The infra run for the merge commit (run 37305158088) was still in progress when this was written, and the PR's desktop and phone screenshots of the live Auth0 page are still to come. Once applied, the change replaces the old page on the non-prod tenant only:
| Piece | What it does |
|---|---|
| Config | New optional auth0.loginBranding: { logoUrl } in the stack config. Absent leaves the tenant's Universal Login theme and text alone. Staging sets logoUrl: https://brilliant.rocks/brand/brilliant-logo.svg. Prod sets logoUrl: https://itsbrilliant.ai/brand/brilliant-logo.svg on main since #504 (merged; Prod step 2). |
| Theme | auth0.BrandingTheme from infra/pulumi/src/auth0-branding.ts (loginTheme()): display name "Brilliant", every colour from packages/design-tokens, the Brilliant lockup as the centred widget logo, rounded inputs and buttons (8px), underlined links, centred layout on the canvas colour. The pre-merge read found no theme on the tenant (404 theme_not_found), so the first apply creates one; on a tenant that already has a theme, the resource takes it over in place (the code's docstring still says "adopts", a known nit). loginTheme() throws unless the logo URL is https://. |
| Copy | auth0.PromptCustomText (English) for login, login-id, login-password, signup, signup-id, signup-password, reset-password. Only the keys Auth0 puts the tenant or app name in are overridden (pageTitle, description, backToLoginLinkText, buttonText), e.g. "Log in to Brilliant to continue." and "Back to Brilliant". Every other form, error, MFA and reset text stays Auth0's. Each resource replaces that prompt's whole English custom text; before #487 the tenant's English custom text for all seven prompts was {}, so nothing was overwritten. |
| Logo | apps/site/public/brand/brilliant-logo.svg (the studio BrandMark lockup). It shipped in #483 (already on main) so the marketing site serves it on brilliant.rocks (later itsbrilliant.ai) before the theme references it. A site rollback past that file breaks the logo on every non-prod sign-in (and, once #504 applies, every prod sign-in too, since prod points at itsbrilliant.ai). |
| CI trigger | infra.yml also runs on changes to packages/design-tokens/src/**, so a palette change re-applies the login theme. |
| Tests | Fail if copy contains ${companyName} / ${clientName} or an internal name, if a theme colour isn't a design token, if contrast drops below 4.5:1 (text) or 3:1 (field borders, focus), if the logo URL isn't https, or if the configured logo file is missing from apps/site/public. |
Tenant-wide: staging, side environments and local dev all share the non-prod tenant, so all of them get the new look at once. No custom domain, no page template, no Google or SSO change.
How it was gated: #487 merged only after (1) #483's infra run applied the grant scopes (the provider's token only carries new scopes on a later invocation), (2) https://brilliant.rocks/brand/brilliant-logo.svg returned 200 image/svg+xml, byte-identical to main (it was 404 for a while because staging deploys were refusing while the conductor was busy, unblocked by #488), and (3) the tenant's existing theme and English prompt text were read (none and {}). Fresh staging preview on main d99cdf5f: + 8 to create (theme + 7 prompt texts), 109 unchanged, no updates, deletes or replaces. Infra tests ran locally (65/65); they aren't in CI yet (#485). Lesson from #484: once a stacked PR's parent merges, retarget the child to main before merging it, or it lands only on the leftover stack branch.
Not in this PR (split out during review): hosted branding and real-browser verification (#480), login-domain prep reusing the stack's Cloudflare provider (#481), and Google through Secrets Manager with a properly scoped options read and the callback prerequisite (#482). The current token lacks read:connections_options, so Google connection options aren't read or changed. No production apply, no new login domain, no sign-in behaviour change.
Step 3: Brilliant on every login screen (#493, merged) and the staging infra block (#499, merged; #500, merged). #493 (merged 2026-10-05 16:12 IDT, yoni-monday, merge 190b817f) moves all English prompt copy into infra/pulumi/src/auth0-prompt-texts.ts (PROMPT_TEXTS). It covers every key Auth0's text-element reference lists with ${companyName} or ${clientName}: 30 prompts and 145 keys. Every logoAltText becomes "Brilliant", so screen readers stop announcing "brilliant-nonprod", and titles end in "… | Brilliant". Two placeholders stay on purpose: ${clientName} on consent (it names the third-party app asking for access) and ${companyName} on invitation and organization copy (Auth0 fills in the organization name). Screens for features the tenant doesn't use yet (MFA, passkeys, passwordless, organizations) are included so turning one on later doesn't leak the internal names. device-flow, custom-form and status are skipped.
On apply, Auth0 rejected one key, and every infra run on main since #492 has been red (run 37315935564): 400 Bad Request: Invalid key "logoAltText" in screen "brute-force-protection-unblock-failure". Auth0's text-element reference lists that key on that screen, but the Management API refuses it. Pulumi applied 12 creates and 7 updates and stopped, so 19 of the 30 prompts are live. Not yet applied: brute-force-protection, mfa, mfa-email, mfa-push, mfa-recovery-code, mfa-sms, mfa-voice, mfa-webauthn, passkeys, phone-identifier-challenge, phone-identifier-enrollment. #499 (merged 2026-10-05 16:44 IDT, yoni-monday, merge 7e51c226) drops the brute-force-protection-unblock-failure entry (that screen keeps Auth0's default text) and adds a test that fails if it comes back. Its staging preview was + 10 creates and ~ 1 update (137 unchanged) with no deletes or replaces; 71/71 infra tests passed. The infra run for the merge commit applies the remaining prompts; check that run before assuming all 30 are live. Auth0 stops validating at the first bad key, and those 10 prompts have never been sent, so another rejected key may surface on the next run; the fix is the same, drop that key. The 19 live prompts aren't at risk.
That is what happened. The main runs after #499 (37319101162 and the re-run 37319370238) failed one screen later: 400 Bad Request: Invalid key "logoAltText" in screen "brute-force-protection-unblock-success". So Auth0 refuses logoAltText on both brute-force unblock-result screens, even though the reference lists it on both; it does accept it on brute-force-protection-unblock, which keeps it. #500 (merged 2026-10-05 16:50 IDT, yoni-monday, merge e6ebca9a, branch auth0-bfp-logo-alt-2) drops the unblock-success entry too and extends the test to cover both screens (71/71 infra tests pass). Under the ADR exception it was already applied to staging from the branch with the brilliant-staging-agent key and --continue-on-error (~ 1 updated, no rejections), and a full pulumi preview --stack staging from the branch now shows 148 unchanged, so all 30 prompts are live on staging. With #500 merged, main no longer carries the rejected key, so the infra run for its merge commit should be a no-op and turn main green again; check that run before assuming it did. Rule: the reference docs aren't proof a key is accepted; if the Management API rejects a key, remove it from PROMPT_TEXTS and pin that with a test.
Google prerequisite (still open, #482). Google returns to Auth0, not the studio, so a branded login on a custom domain needs https://brilliant-nonprod.us.auth0.com/login/callback and https://login.brilliant.rocks/login/callback on the Google OAuth client. That client is owned outside Pulumi and no manual change to it is approved yet.
Rules: all Auth0 config changes go through Pulumi; never PATCH the grant outside Pulumi. Gotcha written up in gotchas/deploying.md ("The Auth0 management app has two grants for the same audience").
Prod step 1: adopt grant and add branding scopes (#497, merged)
#497 (merged 2026-10-05 16:51 IDT, yoni-monday, merge 0a43a87f) is step 1 of 2 for prod, the same pattern as #478 + #483 on non-prod. Before it, prod login was Auth0's default, and it stays that way until step 2 (black page, Auth0 shield, "Log in to brilliant-prod to continue to brilliant-studio-prod"). A read-only check of the prod tenant found the management app's machine grant cgr_eoHcAn3mhvqB9BfK (subject client) with 32 scopes and no branding or prompts access (403 on /api/v2/branding and /api/v2/prompts). The tenant also has an empty user-subject grant cgr_K0uMtFMFFoFaR6oe, which the PR doesn't touch.
| Piece | What it does |
|---|---|
| Config | Pulumi.prod.yaml gets managementGrant with id cgr_eoHcAn3mhvqB9BfK, adopt: true, its 32 scopes in Auth0's order, plus read:branding update:branding delete:branding read:prompts update:prompts. |
adopt | New optional ManagementGrantConfig.adopt in auth0-login-infra.ts: when true, puts import: <id> on the grant resource. Real probes on non-prod: a scope difference imports then updates in one run; a client, audience or subject mismatch plans a replacement that protect refuses. So one prod run adopts and widens (unlike non-prod, which took two merges, #478 then #483). |
| Not yet | No theme or prompt copy on prod. That's step 2, in a later run, because the provider mints its token before the grant update. |
| Tests | 69/69 infra tests (auth0-login-infra.test.ts); they pin prod's exact scope list and that adopt sets import only when on. |
Preview: local preview on the prod stack shows the grant import (32 scopes) plus an update (adding branding and prompts scopes): ~2 to update, 1 to import, 95 unchanged, no deletes or replaces.
Rollout: prod applies only via infra → Run workflow → stack prod, behind the infra-production reviewer. After the apply, read prod's existing theme and custom text, then do step 2 (branding, with the logo on itsbrilliant.ai; that needs a prod site deploy first, since the logo 404s there today). A follow-up drops adopt once the grant is in state, as #483 did for staging (review asked for a tracking issue for that).
Applied. The gated prod run has since succeeded (run 37320346817: = 1 imported, ~ 2 updated), so the prod grant is in state with branding and prompts scopes. Dropping adopt landed in #504 (merged, below).
Merging didn't change prod. Prod has no apply on merge; before that run, the prod grant was still unmanaged with 32 scopes. Review flagged one risk for that run: the import-then-update plan for a scope difference only happens on newer Pulumi engines. Older ones refuse the import with "inputs to import do not match". So check that the CLI version used for the PR's local preview matches CI's PULUMI_VERSION (3.265.0) before spending a gated prod run. That failure is safe, it just wastes the run.
Prod step 2: brand the prod login (#504, merged)
#504 (merged 2026-10-05 19:23 IDT, yoni-monday, merge 0bc919cd, branch auth0-prod-branding) is step 2 for prod: the same theme, logo and English copy that are live on non-prod since #487, #493, #499 and #500. Before it, production sign-in at app.itsbrilliant.ai showed Auth0's default page (black, the Auth0 shield, "Log in to brilliant-prod to continue to brilliant-studio-prod").
Merging didn't change prod. Push only runs the staging stack, so the merge is a no-op there, and prod keeps Auth0's default login until someone runs infra → stack prod and approves it. Gate before that run: when #504 merged, https://itsbrilliant.ai/brand/brilliant-logo.svg still returned 404 (checked 19:24 IDT), because the prod site deploy that ships the file wasn't live yet. loginTheme() only checks that the URL is https://, not that it resolves, so running infra → prod before the logo serves would put a broken logo on every prod sign-in. Review asked to curl the URL for a 200 and diff it against apps/site/public/brand/brilliant-logo.svg before approving.
Prod tenant before the change (read-only, after #497 applied): prompts has universal_login_experience: "new", branding is {}, branding/themes/default is 404 theme_not_found, and English custom text is {} on all 30 prompts. Nothing was set by hand, so the change only creates.
| Piece | What it does |
|---|---|
| Config | Pulumi.prod.yaml gets loginBranding.logoUrl: https://itsbrilliant.ai/brand/brilliant-logo.svg. That turns on the same BrandingTheme and the 30 PromptCustomText resources staging has. |
adopt | Removed from prod's managementGrant, since the import already ran in run 37320346817. It changes nothing in the plan; left on, it would only re-import on a fresh state. |
| Tests | The stack-config logo test now covers both stacks: each logo host must be that stack's own marketing site (brilliant.rocks for staging, itsbrilliant.ai for prod) and the file must exist in apps/site/public. The "prod is not branded yet" test is gone. 72/72 infra tests pass. |
Preview: pulumi preview --stack prod from the branch shows + 1 BrandingTheme and + 30 PromptCustomText, 31 to create, with no updates, deletes or replaces.
Rollout order:
- The production site deploy (run 37333766619,
780f6441) has to servehttps://itsbrilliant.ai/brand/brilliant-logo.svgfirst. It returned 404 when the PR opened and still did right after the merge. - Merge #504 (done 2026-10-05). Push only runs the staging stack, so the merge is a no-op there.
- Run
infra→ stackprodand approve it behindinfra-production. - Check the production login in a browser at desktop and phone widths.
Steps 1, 3 and 4 were still pending when this was written; check the prod infra run before assuming the prod login is branded.
A prod site rollback past the logo file would break the logo on every prod sign-in, the same risk staging has.
Staging Auth0 test users for the E2E journey (#521, merged)
#521 (merged 2026-10-06 10:20 IDT, yoni-monday, merge 169e9b72; part of #440, the permissions final release gate) adds two real Auth0 users to the staging stack only. The permissions journey's invited runtime-only user and signed-in link visitor need real Universal Login sessions, which a minted studio session cookie can't stand in for, so those scenarios were always skipped before. Neither user is ever a member of a company, so they exercise the app-only paths.
| Identity | Used by the journey as |
|---|---|
e2e-runtime@e2e.brilliant.rocks | Invited runtime-only user |
e2e-link-visitor@e2e.brilliant.rocks | Signed-in link visitor |
| Piece | Detail |
|---|---|
| Config | brilliant-infra:auth0.e2eUsers: { labels: [runtime, link-visitor], emailDomain: e2e.brilliant.rocks } in Pulumi.staging.yaml. Each label becomes e2e-<label>@<emailDomain>. Absent means no users. |
| Code | infra/pulumi/src/auth0-e2e-users.ts (e2eUsers, e2eUserEmail), called from src/auth0.ts with the stack's database connection. |
| Users | auth0.User in Username-Password-Authentication, emailVerified: true (invitation acceptance and app sign-in both need a verified email), name E2E <label>. |
| Passwords | random.RandomPassword (32 chars) minted by Pulumi and written to Secrets Manager brilliant/staging/e2e-users as JSON { <label>: { email, password } }. They live only in Pulumi state and that secret: never in code or logs, and never pushed to Workers (secretIdsFor is an explicit list). |
| Domain | e2e.brilliant.rocks is a subdomain of our own Cloudflare zone with no MX record, so nobody can receive mail or reset passwords for these addresses, and no company signs in from it, so no join policy can match it. The first draft used brilliant-e2e.dev; review caught that it isn't registered to us, so whoever registered it could have reset these verified identities' passwords. |
| Prod guard | e2eUsers throws on the prod stack (a test covers the throw), and another test asserts Pulumi.prod.yaml never declares e2eUsers. |
| Contracts | e2e-users-are-nonprod-test-identities on e2eUsers; e2e-user-email-is-validated on e2eUserEmail (label must match [a-z0-9-]{1,32}, domain must have a TLD); management-client-enabled-only-for-e2e-users on databaseConnectionClients and management-client-cannot-sign-in on assertClientCredentialsOnly (#522). |
Rollout: before merge, GET /api/v2/users-by-email on the non-prod tenant returned 0 users for both addresses, so up wouldn't 409. Staging preview: +6 to create (2 users, 2 passwords, the secret and its version), 148 unchanged. Infra tests 75/75. infra.yml applies it from main on merge (run 37429022522 was in progress when this was written); check that run before assuming the users exist.
First apply failed; fixed by #522 (merged): the infra apply on merge 169e9b72 failed with 400 Bad Request: Connection must be enabled for this client to perform single user creation and signup operations (connection: Username-Password-Authentication). Auth0's Management API creates a database user only when the calling client is enabled on that connection, and only the studio client was. #522 (merged to main 2026-10-06 12:57 IDT by yoni-monday, merge commit afc5f920) enables the Pulumi management client on Username-Password-Authentication only when the stack declares e2eUsers (so staging only; prod never does). The pure helper databaseConnectionClients returns the studio client alone without test users and studio plus management with them (contract management-client-enabled-only-for-e2e-users, with a regression test). Sign-in guard: the management app is configured outside Pulumi, so before enabling it the stack reads its grant types back from the tenant (auth0.getClientOutput) and assertClientCredentialsOnly fails the plan if it allows anything besides client_credentials (password, authorization code, ...), since that would make it a sign-in path for every database user (contract management-client-cannot-sign-in, tested). The two connection associations are now two explicit auth0.ConnectionClients resources (<name>-google-clients, <name>-database-clients; same names as before, no replacement) instead of a loop, and the E2E users dependsOn the database one. Staging preview: 1 update (database ConnectionClients), 2 creates (the E2E users), 151 unchanged; infra tests 76/0. The staging infra apply for the merge (run 37446518555) was in progress when this was written; check that it succeeded before assuming the E2E users exist on staging.
Rules: never add e2eUsers to prod. Use only a domain we own with no MX. If a user with the same email already exists on the tenant (for example created by hand), up fails with a 409 conflict; delete or import it rather than renaming the label. Never enable the management client on any other connection, or on the database connection of a stack without e2eUsers. Never give the management app a grant type other than client_credentials; the plan fails if it has one while e2eUsers is declared.
CONTROL_PLANE_URL from studio origin (#387, merged)
Landed in #387 (merged 2026-10-04 by yoni-monday; prerequisite for prod cutover #304; closes blocking items of #370).
Symptom this fixed (staging after #361): preview and the Code tab failed while the studio worked. Conductor and workflows read CONTROL_PLANE_URL as a Worker secret; the copy stored in brilliant/staging still said https://brilliant.rocks, so the conductor's frame-ancestors refused app.brilliant.rocks.
| Piece | Behaviour |
|---|---|
Contract control-plane-url-from-studio-origin | secrets:push / withComputedUrls sets CONTROL_PLANE_URL for conductor and workflows from cloudflare-ids origins.studio. The stored key in brilliant/<env> is ignored. |
Missing origins.studio | Push fails (does not fall back to the stored value). |
| Kind | Stays a secret (no secret→var binding migration). |
| Base config | BASE_STUDIO_ORIGIN and the base wrangler CONTROL_PLANE_URL are https://app.brilliant.rocks (staging studio), not the apex the site owns. |
A host move still needs a secrets push (any CD deploy does one). Catalog note on the entry records the override. See Hosting — cutover hardening · Marketing site · Troubleshooting.
Conductor secrets-push idle wait (#217)
Removed. #488 (merged 2026-10-05) took this guard out; there is no idle wait any more. This section is kept as history. See Idle wait removed.
Landed in #217 (@cc conductor-secret-push-waits-for-idle, contract since deleted).
bun run secrets:push → wrangler secret bulk creates a new Worker version. On conductor, that resets every WorkspaceDO and kills in-flight turns (same eviction as a code deploy). From #217 until #488, before pushing conductor secrets, the push:
- Runs
scripts/deploy/wait-for-idle.sh(same LangSmith idle check asconductor.shbeforewrangler deploy). - Uses
LANGSMITH_API_KEY/LANGSMITH_PROJECT_IDfrom the bundle being pushed (target env), not a local.dev.vars. - Default wait budget
IDLE_WAIT_SECONDS(600 if unset). - Fails the push without writing secrets if idle exit ≠ 0.
Other workers never waited. Skipping an “unchanged” push is not safe (Cloudflare cannot read secret values back; CI has no cross-run hash). Admin Secrets sync still goes through this same secrets:push path — see Admin Secrets.
Idle wait removed (#488, merged)
#488 (merged 2026-10-05, yoni-monday; branch fix/secrets-push-no-idle-wait, merge commit d99cdf5f) removed this guard. Decision (owner): remove it. Conductor deploys and conductor secret pushes no longer wait for anything.
- Why: staging CD failed twice in a row at push secrets to workers with
[secrets:push] Unhandled error: conductor is not idle (wait-for-idle exit 2); secrets not pushed(runs 37298240599 on4a472e76, 37288979425 onb04b9518). The check aborts if any LangSmith run started in the last 4 minutes or is still pending from the last 15, and on a busy staging that never clears within the 10 minute budget, so merged changes didn't ship. It was blocking #487, whose logo is onmainbut undeployed. - What landed:
infra/secrets/push.tspushes conductor secrets with no wait (pushWorkerSecretsWhenIdleand its runner removed; the@cc conductor-secret-push-waits-for-idlecontract is deleted).scripts/deploy/conductor.shno longer waits beforewrangler deploy.scripts/deploy/wait-for-idle.shis deleted, along with itsBRILLIANT_DEPLOY_FORCE=1override.deploy.ymlno longer reads or passesLANGSMITH_API_KEY/LANGSMITH_PROJECT_IDto the conductor step (they are still pushed to conductor as ordinary secrets). - Tradeoff: a conductor deploy or conductor secret push now stops any running turn ("This script has been upgraded", socket close 1006). That was already true whenever the guard was bypassed.
gotchas/deploying.mdnow says the eviction is real and unguarded: avoid deploying conductor by hand while someone is mid-turn. - Checks in the PR:
bun test infra/secrets63 pass,scripts/deploy/deploy-workflow.test.ts7 pass, tsc / biome / cc-check / knip clean. - What to expect now: a burst of DO-reset / waking events right after a staging conductor deploy or secrets push is expected, not a regression. Clients see the waking
503+x-brilliant-waking: 1and reconnect; see Troubleshooting and Conductor — turn recovery.
Sentry auth token (CI-only)
SENTRY_AUTH_TOKEN in infra/secrets/catalog.ts: optional, consumers: [], staging+prod. Used only by the deploy workflow / scripts/env/lib/sourcemaps.ts to upload studio source maps to Sentry (org mondaycom-3j, project brilliant). Never pushed to Worker vars / .dev.vars.
Absent or rotated token → sourcemap upload is skipped; deploy still succeeds and .map files are deleted from dist/ before assets ship. See Control plane — studio source maps (#191, merged).
LangSmith (per env)
Staging and prod each get their own LangSmith project so traces do not mix. Catalog entries (computed, conductor, staging+prod):
LANGSMITH_PROJECT— project name traces land in (staging/production)LANGSMITH_PROJECT_ID— same project by id (staging evals runner; it no longer feeds a deploy idle check since #488, merged)
Org is EU (LANGSMITH_ENDPOINT=https://eu.api.smith.langchain.com). Values live in brilliant/staging and brilliant/prod ASM blobs; local: set both in services/conductor/.dev.vars (see .dev.vars.example).
scripts/deploy/wait-for-idle.sh used to read LANGSMITH_PROJECT_ID from env or .dev.vars (a hardcoded default once made it always look “idle”). #488 (merged) deleted the script; see Idle wait removed.
Landed in #134.
Evals never receives prod secrets (#406, merged)
Invariant evals-never-receives-prod-secrets on infra/secrets/catalog.ts: no catalog entry may list evals as a consumer in prod (helper or hand-written). infra/secrets/catalog.test.ts checks the full table via namesFor / fanOutSecrets.
Staging evals is a deliberate privileged peer: it receives SESSION_SECRET / PUBLIC_GUARD (no LangSmith ids after #959) so the runner can act as the fixture user and read traces. Compromising that Worker can mint a session for any staging user — EVALS_KEY protects the privileged HTTP surface. Production secrets are never fanned out. EVALS_KEY / optional TYPESAFE_API_KEY are DEPLOYED_OUTSIDE_PROD only.
See Agents & evals — staging-only.
Developer secret read policy (#178)
Pulumi manages IAM policy brilliant-developer-secrets-read (IT attaches it to the Apono BrilliantDeveloper permission set). Read-only: GetSecretValue + DescribeSecret on these exact non-prod names:
| Secret | Why developers need it |
|---|---|
brilliant/dev | Local secrets:pull |
brilliant/side-env-base | Side-env base / DB URLs |
brilliant/staging/auth0 | Non-prod Auth0 apps |
brilliant/staging/bedrock | Model config merged into side-env / secret pulls. Removed from the policy in code by #634 (merged 2026-10-08); the live grant stays until the approved stack apply. See Bedrock retirement. |
brilliant/cloudflare/staging | Side-stack provisioning (CF credentials) |
Not granted: brilliant/staging (full staging blob / CF deploy token), brilliant/staging/e2e-users (E2E test-user passwords, #521), production secrets, or any secret writes.
Agent key (separate): staging Pulumi also owns IAM user brilliant-side-env-agent and ASM secret brilliant/staging/side-env-agent for Sphera-style agents that cannot SSO. That secret is not on this developer policy. Scope and limits: Side environments (#190, merged). Neighboring names like brilliant/staging/bedrock-gateway and brilliant/cloudflare/staging-r2 stay excluded.
Staging agent key (separate, broader): for staging debugging, deploys and Pulumi, agents use IAM user brilliant-staging-agent instead — see Staging agent key below.
ARN Resource patterns end in -?????? (six-char Secrets Manager suffix), not -*. A -* suffix would also match those neighboring credential secrets.
Policy source: infra/pulumi/src/developer-secrets.ts (developerSecretsReadPolicy). Applying the Pulumi change needs Admin — BrilliantDeveloper cannot read the shared Pulumi backend. A successful SSO login that only offers ReadOnly / BrilliantDeveloper is not enough to pulumi up this policy.
loadSideEnvBase merges base + non-prod Auth0 + staging Bedrock as one operation. If Bedrock is denied, the already-read base is discarded and the failure often surfaces as BRILLIANT_AURORA_ADMIN_URL is not set — see Troubleshooting.
Staging agent key (#492, merged)
Merged #492 (yoni-monday, merge 409ee616, 2026-10-05). Resources were already applied to staging; main now matches.
What it is: a static IAM user brilliant-staging-agent (Pulumi: infra/pulumi/src/staging-agent.ts, created on the staging stack next to the side-env agent). Its key lives in ASM secret brilliant/staging/staging-agent (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, PULUMI_BACKEND_URL). AGENTS.md says agents use this profile for AWS instead of admin SSO: reading staging secrets, deploying, side envs, and pulumi preview on staging. It no longer runs pulumi up -s staging: since #557 staging up is CI-only, through infra.yml from main.
Setting up and using the key
This setup comes from #502 (merged 2026-10-05 16:59 IDT, yoni-monday, merge 6a6bab12, docs only, AGENTS.md), so it is now the documented procedure on main. The author ran the snippet verbatim from a clean shell on main: aws sts get-caller-identity returned user/brilliant-staging-agent and pulumi preview -s staging showed 148 unchanged.
One-time setup (done by someone who can already read the secret): copy AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY from brilliant/staging/staging-agent into a [brilliant-staging-agent] profile in ~/.aws/credentials, and set region = us-east-1 for it in ~/.aws/config. A sandboxed agent with no home profile exports all four values from the secret instead (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, PULUMI_BACKEND_URL).
Before every command: exported AWS_* session keys win over the profile, so strip them and check who you are first:
unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN AWS_CREDENTIAL_EXPIRATION
export AWS_PROFILE=brilliant-staging-agent AWS_REGION=us-east-1 \
PULUMI_BACKEND_URL=s3://brilliant-pulumi-state-029223413038
aws sts get-caller-identity # must end in user/brilliant-staging-agent
cd infra/pulumi && pulumi preview -s stagingAn AccessDenied on prod, IAM writes or rds:Modify* is the design, not a missing permission (gotchas/aws-and-secrets.md; see Troubleshooting). An up from a branch is drift until it merges, because main's next infra.yml run plans to delete what the branch added. Since #557 merged, staging up is CI-only: the agent can no longer write staging state, so land changes on main and let infra.yml apply them. The old "apply from the branch, then merge right after" exception is withdrawn.
| Scope | |
|---|---|
| Allowed | Read-only staging Pulumi state (lock path writable) and read/write side-* state; kms:Decrypt/DescribeKey on the staging stack key and full use of the side stack key (since #557); secretsmanager:* on brilliant/staging*, brilliant/side-env-base*, brilliant/dev*, brilliant/cloudflare/staging*; read on the non-prod Auth0 management secret; IAM, RDS and KMS metadata reads; staging Lambda logs (/aws/lambda/brilliant-staging-*) |
| Denied explicitly | Every IAM write (staging and prod share one AWS account, so an IAM write is prod admin); everything except DescribeKey on the shared alias/brilliant-pulumi key (it unwraps prod's stack key); prod Pulumi state; brilliant/prod* and brilliant/*/prod* secrets; writes to the staging checkpoint, history and backups (DenyStagingStateWrites) and encrypting with the staging stack key (DenyStagingStackKeyWrites) |
| Out of reach by design | Any pulumi up -s staging (CI-only since #557); IAM, Aurora, Lambda or KMS changes were already out of reach. Run those plans through infra.yml |
The Denies are pinned by contract @cc staging-agent-never-reaches-prod and test/staging-agent.test.ts, which checks the Denies (four original plus the two staging-state Denies from #557) and that no Allow writes IAM or reaches the shared key or prod.
Why staging has its own stack key: the agent can only run Pulumi on staging because the staging stack is encrypted with bootstrap key alias/brilliant-pulumi-staging (infra/bootstrap/aws.sh, BOOTSTRAP.md), not the shared alias/brilliant-pulumi. A stack must not own the key that decrypts it, so this key is bootstrap, not Pulumi. Moving staging back to the shared key breaks the agent. Pulumi.staging.yaml on main now names the staging key, so CI up staging from main can decrypt again.
Policy note: pulumi preview -s staging as the agent needs iam:GetRole and kms:DescribeKey on the shared key (both in this PR). The policy update needs one more admin up because the agent can't change IAM. Live checks as the agent worked for staging secret reads, staging state, describing the cluster and Lambda logs, and were refused for prod state and secrets, the shared key, iam:CreateUser, self-attaching AdministratorAccess and rds:ModifyDBCluster.
Staging state is read-only for the agent (#557, merged)
#557 (merged 2026-10-07 09:57 IDT by yoni-monday, merge cac22f13; opened by Brilliant Fixer; fixes #549, sev:medium) implements option A, which Yoni chose in Slack: the staging agent is read-only on staging Pulumi state, and CI is the only writer. infra.yml applies the new policy on the merge push (that run was still in progress when this page was updated).
Why: the key could write (s3:PutObject/DeleteObject) the staging checkpoint, its history and backups, and encrypt with the staging stack key. infra.yml applies that checkpoint as brilliant-gha-infra-staging, which has AdministratorAccess in the account prod also uses, and Pulumi updates whatever resource ids the checkpoint records. So anyone who could edit the checkpoint could point the admin role at prod resources (for example CreatePolicyVersion on a prod IAM policy), even though the agent's own Denies stop it from doing that directly.
What changed (infra/pulumi/src/staging-agent.ts):
- Staging checkpoint, history and backups are
s3:GetObjectonly (ReadStagingState). The lock path stays writable (SideStateAndStagingLock), becausepulumi previewtakes the lock and a lock file can't change what CI applies. Side stacks keep read/write. - The staging stack key allows only
kms:DecryptandDescribeKey(DecryptStagingStack). The side-stack key is unchanged. - Two new explicit Denies that hold even if a later Allow is broadened:
DenyStagingStateWrites(everything except Get/GetObjectVersion on checkpoint, history and backups) andDenyStagingStackKeyWrites(kms:Encrypt,GenerateDataKey*,ReEncrypt*on the staging key). - The contract
staging-agent-never-reaches-prodnow requires this.AGENTS.md, theprod-infra.mdADR row 8 andgotchas/aws-and-secrets.mdsay stagingupis CI-only, which withdraws the 2026-10-05 exception (dfdf7f07) that let agents apply to staging from a branch. - Tests in
infra/pulumi/test/staging-agent.test.tspin it: no Allow grants more thans3:GetObjecton staging state or more than Decrypt/DescribeKey on the staging key, both Denies exist, and the policy stays under the 6144-byte managed-policy limit.
What that means for agents now: keep using the key for pulumi preview -s staging, secrets and deploys, but don't run pulumi up -s staging; land the change on main and let infra.yml apply it. An AccessDenied on a staging state write or on kms:Encrypt/GenerateDataKey for alias/brilliant-pulumi-staging is the design (see Troubleshooting).
Post-merge check (not verified live at merge time), using the staging-agent key: pulumi preview -s staging still succeeds, and aws s3api put-object --bucket brilliant-pulumi-state-029223413038 --key .pulumi/backups/brilliant-infra/staging/probe-denied --body /dev/null returns AccessDenied. Probe that harmless path only; never probe staging.json itself. Expected preview is an in-place update of aws:iam/policy:Policy brilliant-staging-agent (policy document only), so the deletes gate passes.
Review notes left open at merge (non-blocking, merged as-is):
- The Deny test matches
/stacks/brilliant-infra/stagingwith a regex that also matchesstaging.json.*, so it would still pass if the exactstaging.jsonentry were dropped from the Deny. The reviewer suggested asserting the exact checkpoint ARN instead. - Because the agent keeps
PutObject/DeleteObjecton the staging lock path, it could hold a lock and makeinfra.ymlfail with "stack is currently locked", or delete CI's lock mid-up. That's an availability risk, not a way to steer what CI applies; the reviewer asked whether it's intended.
Left open: the side-env agent (and this agent) can still write side-ci state, which the candidate CI role applies. That role is narrow (side-ci resources and the staging Cloudflare token, with explicit Denies on staging/prod state and secrets), so it's the same kind of gap with a much smaller blast radius, and #557 didn't fix it.
Related: the narrower side-env agent (brilliant-side-env-agent, side stacks only) stays as it is. The same PR added the staging-only brilliant-branches dispatch namespace (removed again with branch routing in #606), see Hosting & Pulumi.
AWS CLI (secrets lookups)
infra/secrets/aws.ts wraps every aws CLI spawn via awsCliEnv:
- Sets
AWS_EC2_METADATA_DISABLED=trueunless the caller already set it (@cc aws-cli-no-instance-metadata). No caller gets credentials from instance metadata: laptops use SSO (AWS_PROFILE), CI uses OIDC env credentials. Without the flag, a missing-credentials CLI probes169.254.169.254and can stall past a unit-test timeout on CI. - With
AWS_PROFILEset, stale staticAWS_ACCESS_KEY_*/ session tokens in the shell are cleared so SSO wins. getSecretJsonuses a 20s spawn timeout so a hung CLI fails the lookup, not the caller.
Unit tests that only need config resolution must not call Secrets Manager. Example: resolveRunnerConfig in services/evals takes an injectable loadVars (default loadMergedDevVars); tests pass an empty loader. Landed in #135.
Admin
Secrets (write-only)
Staging/prod admin can replace external catalog secrets without reading existing values. Save updates AWS Secrets Manager; Workers apply via secrets-sync.yml (separate from save). Full behaviour, gates, broker, and rollout status: Admin Secrets (#184).
Earlier prod-infra “read-only health only” direction is superseded for external catalog entries; generated keys and Pulumi-owned settings stay read-only.
Config (KV overlay, #290 merged)
Non-secret settings that operators change often — today Composio auth-config ids — live in a Pulumi-owned brilliant-config KV (CONFIG_KV) and an admin Config page. Overlay is allowlisted and falls back to the Worker env var; audit succeeds before KV writes. Classic KV can lag ~1 minute. Full design: Admin Config. A dedicated production Composio project (separate key and auth-config ids from staging) is declared in Pulumi by #564 (merged 2026-10-07; two prod applies failed, the second after #568 creating six of ten configs, the custom-auth fix #569 let the third apply create all ten, and #579 repairs the four custom configs that got copied secret masks, so prod isn't switched yet); the key and config ids must be switched together, see Integrations. Prod: apply the infra workflow before the next prod deploy, or render fails closed on the missing binding id.
Auth0 login (apps/admin)
Admin uses its own Auth0 app (ADMIN_AUTH0_CLIENT_ID / secret) and session cookie, separate from studio. Login is Google via Universal Login (/auth/login → /auth/callback).
Staff gate: Auth0 can refuse a login when the account lacks the staff role. That comes back to GET /auth/callback as query params error + error_description (no code). The callback returns 403 { error, message } with Auth0's values (for example access_denied and a staff-only description). That is not a broken OAuth state cookie — ask for the staff role.
A real missing or expired __Host-admin_oauth_state still returns 400 { error: "invalid_state", … }.
Landed in #147.
No live brilliant.lighting fallbacks (#447, open)
Open #447 (closes #443): preview / studio / control-plane origins are required. Missing PREVIEW_URL, PREVIEW_HOST, CONTROL_PLANE_URL, or studio VITE_PREVIEW_URL fails instead of pointing at the dropped brilliant.lighting zone (or retired monday-vibe-stg). Full table and agent-id change: Hosting — no lighting fallbacks.
Neon API keys are environment-scoped (#709)
Merged 2026-10-09 in #709 (fixes #707, #708). NEON_API_KEY_STAGING and NEON_API_KEY_PRODUCTION used to be repo-level secrets, readable by any workflow on any branch, and infra.yml exported the prod key to every run.
NEON_API_KEY_STAGINGlives only on GitHub environmentsinfra-stagingandcandidate(main-only).NEON_API_KEY_PRODUCTIONlives only oninfra-production(main-only, required reviewer).- The
stagingenvironment now admits main only (also guardsCF_ACCESS_CLIENT_SECRET, see #284). infra.ymlgives a run only its own stack's key (empty otherwise);neon-golden.ymlruns withenvironment: infra-staging.- Follow-ups: delete the old repo-level secrets, prove golden + staging infra preview still work, then rotate both keys in the Neon console.
Side-env service token (#716, merged)
#716 (merged 2026-10-09 12:14 IDT by yoni-monday, merge 575144bf), companion to the side-env workflow (#715). That workflow runs branch code, so its Access token reaches no further than a person.
- New Secrets Worker caller role
side-env-token(client idSIDE_ENV_SERVICE_TOKEN_CLIENT_ID):/synconly forside-envand side-env scripts (neverci, staging or prod);/side-env-varsallowed;/dev-varsand/passphrase/*return 403. Honoured only on the account serving side envs. - CI token unchanged; any other service token is 403 everywhere.
- Bootstrap (staging only):
sideEnvServiceTokenId/sideEnvServiceClientId(both or neither), its own non-identity Access policy, output consumed bydeploy.ts. - Not yet live: config values, bootstrap up and Worker deploy still to be applied.
See also Side environments.
Related
- Getting started · Side environments · Verify & ship · Troubleshooting · Hosting & Pulumi · Marketing site · Admin Config · Admin Secrets · Admin Feature Flags · Control plane (Sentry / source maps)
AWS teardown B: Secrets Store and R2 state only (#771, merged)
#771 merged 2026-10-11 00:52 IDT (merge a4600082), together with slice C (workflows, from #764). No script, test, or admin route needs AWS any more.
BRILLIANT_SECRETS_SOURCEandBRILLIANT_PULUMI_BACKENDare gone. The Cloudflare Secrets Store and R2 Pulumi state are the only modes. Side stacks always use a passphrase, andside.cloudflareCredentialsSecretis gone.cloudflareIds,databaseUrl, ande2eUserscome from stack outputs (scripts/lib/stack-output.ts).secrets:pushtakesDATABASE_URLfrom the environment andCONTROL_PLANE_URLfromcloudflareIds.- Non-secret staging and prod values (gateway URL, feature flags, evals account id) are committed and rendered as wrangler
vars(scripts/env/lib/deployed-vars.ts). Side envs still compute theirs. - Staging smoke and e2e read seven names from the process env and fail naming any that are missing. Prod needs none.
- The admin secret editor is removed end to end (see Admin Secrets).
- Deleted:
infra/secrets/aws.ts,scripts/neon/cutover.tsand its libs,scripts/cutover/**,secrets:to-store, and the Aurora drops inenv:up/env:down.aurora.tsbecamereadonly-role.ts(live grant helpers only). - Still to do (phase 2): delete
infra/secrets/broker/{index,core}.tsandinfra/secrets/management.ts;infra/pulumi/src/secrets-broker.tsstill bundles the broker entry.
Related: Side environments, ADR index.
Transient /sync retries (#789, merged)
Merged 2026-10-11 (PR #789, fixes #774).
- Client
request(): up to 3 attempts (1s, then 3s backoff) on network errors and 5xx only. 4xx (401, 403, 409) stay terminal. Each retry logs one line with attempt, path, and status or error class, never the body or token. - Refusal hint: the Access login or service-token hint now shows only for 401, 403, and redirects. A 5xx says the Worker or Cloudflare failed after 3 tries.
- Secrets Worker
sync.ts: the secrets-bulk PATCH gets the same 3-attempt bound on 5xx or a thrown fetch. 4xx (including CF 10053binding_in_use) is never retried. Response shapes are unchanged. sideEnvVarsSyncreports the child's last stderr line (retry lines print first).- A Worker 500
write_failedis itself retried by the client, so a persistent Cloudflare 5xx can mean up to 9 PATCH attempts. Only failures repeat. - Deploy needed: the Worker side takes effect only after a secrets Worker deploy; since #790, run the
secrets-worker.ymlworkflow.
Deploying the secrets Worker from a workflow (#790, merged)
Merged 2026-10-11 12:55 IDT (PR #790, merge fa8668c7). Needed for the Worker-side retry in #789.
- Why: after the S3 state bucket was deleted (AWS teardown B),
services/secrets/scripts/deploy.tscouldn't read the bootstrap stack outputs, and the R2 keys for the bootstrap stacks live only in theinfra-*GitHub Environments. So the Worker couldn't be deployed from anywhere. - Outputs through the wrapper:
readOutputsnow runsscripts/pulumi.ts stack output --json -s <env>frominfra/pulumi-bootstrap(the wrapper sets the R2 state bucket and the empty bootstrap passphrase). - How to deploy: run the
secrets-worker.ymlworkflow by manual dispatch. It only deploys main's tip and uses theinfra-stagingorinfra-productionEnvironment (production needs a reviewer).CLOUDFLARE_API_TOKEN,R2_STATE_*, andCF_ACCESS_*go to the deploy step only. - The
services/secretsREADME deploy instructions were updated to match.
Pulumi owns the Secrets Store values it mints (#788, merged)
Merged 2026-10-11 by yoni-monday (PR #788, follow-up to #775).
- Pulumi now creates (never imports) the Secrets Store secrets it mints: 12 in prod and 21 in staging, scoped
["workers"], in the existing stores. - Runbook: right before the first
pulumi upwith this change, the lead must delete the hand-copied store entries, or the create will collide with them. - The BI pipeline sink now has
ignoreChanges: [schema, modifiedAt], so apulumi refreshno longer plans a false replace of the sink. - Tests:
infra/pulumibun testandtscclean.
Related: Neon migration plan, Hosting and infra.
Gotcha: /sync missing_required when the secrets Worker predates a store secret (#815, merged)
Merged 2026-10-12 08:50 IDT by yoni-monday (PR #815, merge 1d3f1da1). Records the gotcha in gotchas/secrets.md.
- Symptom: a deploy fails at
/syncwith 409missing_required, even though the Secrets Store lists every required name (seen in prod deploy run 38176972309). - Cause: the secrets Worker binds only store secrets that exist when it is deployed (under the 100-secret cap; see Deploy binds only present store secrets). A secret created after that deploy is invisible to it. Here the Worker deployed during the delete-and-recreate window from #775; the apply recreated the names a minute later, and the next prod deploy failed at its first
/sync. - Fix: run the
secrets-workerworkflow for that account after the names exist (Deploying the secrets Worker from a workflow). Here: secrets-worker run 38202600040 (version1c7b4d72). - Rule: whenever store secrets are deleted and recreated, deploy the secrets Worker after the recreate, never in the same window.
PostHog CLI API key / Sentry teardown (#953, merged)
#953 (merged 2026-10-15 12:45 IDT, merge b384d838) replaced studio/worker Sentry with PostHog error tracking:
| Before #953 | After #953 (on main) |
|---|---|
SENTRY_DSN on workers / VITE_SENTRY_DSN for the studio build | Gone; errors use POSTHOG_TOKEN / POSTHOG_HOST (dispatch gets them too) |
SENTRY_AUTH_TOKEN (CI-only, optional) for sentry-cli sourcemap upload | Replaced by optional POSTHOG_CLI_API_KEY (personal API key: scopes error tracking write + organization read) for posthog-cli sourcemap inject / upload |
Pending ops: add POSTHOG_CLI_API_KEY to the staging and production GitHub Environments so sourcemap upload runs; without it, deploys stay green, warn, skip upload, and still wipe .map files (minified frames until the secret is set). Later, after error tracking is confirmed, delete the Sentry project and the SENTRY_AUTH_TOKEN secret.
Catalog / workflow: infra/secrets/catalog.ts, scripts/env/lib/sourcemaps.ts, .github/workflows/deploy.yml. See PostHog — error tracking. The older Sentry auth token (CI-only) section is historical until that secret is deleted.
AUTH0_EMAIL_CONNECTION (#954, merged)
#954 (merged 2026-10-15 12:43 IDT by yoni-monday, merge e722b7bc) added a nonprod control-plane var:
AUTH0_EMAIL_CONNECTION=emailin the nonprod wrangler config. Prod render deletes it, as it doesAUTH0_DATABASE_CONNECTION.- Purpose: the passwordless (email-code) default for the Auth0 authorize request when the ACUL screens are on. Plain
/auth/loginand/auth/app/loginnameconnection=email, and signup usesext-screen=signup. - Pairs with
AUTH0_DATABASE_CONNECTION, which backs the e2e scripts' passwordconnection=hint. An explicit hint still wins.
See Control plane — email-code login defaults and Hosting & infra — #954.
AUTH0_EMAIL_SMTP_TOKEN (#967, merged)
#967 (merged 2026-10-15 16:01 IDT by yoni-monday, merge 2a866461, head c357d5ff, branch auth-code-email; opened 15:31 IDT) adds an infra Environment secret:
AUTH0_EMAIL_SMTP_TOKENoninfra-stagingandinfra-production: Cloudflare API token with Email Sending: Edit (account-owned). Set withgh secret set AUTH0_EMAIL_SMTP_TOKEN --env infra-staging(andinfra-production); per #972 theinfra-stagingone is set, and per #969 theinfra-productionone is set too. The sender domainmail.brilliant.rocksmust be onboarded for Email Sending. Used as the password of Auth0's SMTP email provider (smtp.mx.cloudflare.net:465, userapi_token).- Read only when
loginScreens.smtpProvideris set. Wired in.github/workflows/infra.yml; documented ininfra/pulumi/BOOTSTRAP.md. - Rotate: create a new Email Sending token, update the matching
infra-*Environment, apply (Pulumi pushes it to Auth0), then delete the old token.
smtpProvider was not set in any stack yaml when #967 merged, so the merge itself did not need the secret. Update: #972 (merged 2026-10-15 16:15 IDT) turned the flag on for staging. Prod sets it together with loginScreens.enabled: true in the #969 rollout. #974 (merged 2026-10-15 21:00 IDT) did that, so the prod infra run now reads AUTH0_EMAIL_SMTP_TOKEN from infra-production. Turning it on also needs the email_provider scopes #967 added to the management grant to be live from an earlier apply. See Hosting & infra — Auth0 login-code email for the owner steps.
LangSmith secrets removal (#959, merged)
#959 (merged 2026-10-15 14:48 IDT by yoni-monday, merge e2107120, head 28de255f, branch posthog-3-llm-analytics) removes LangSmith from the codebase. LANGSMITH_* values are gone from the secrets catalog and deployed vars; conductor LLM tracing gates on existing POSTHOG_TOKEN / POSTHOG_HOST only — no new secret.
Removed from the secrets catalog, deployed vars, side-env config, cloud-prep, wrangler and dev-vars:
LANGSMITH_API_KEYLANGSMITH_PROJECTLANGSMITH_PROJECT_IDLANGSMITH_ENDPOINT
The langsmith dependency is gone too. Wrangler vars no longer include LangSmith project/id.
Pending: delete the LangSmith projects and the LANGSMITH_API_KEY secret (after confirming PostHog LLM analytics on staging).
See PostHog — LLM analytics (#959, merged).
BI secrets removal (#971, merged)
#971 (merged 2026-10-15 16:41 IDT by yoni-monday, merge cb7500e1) replaces the BI pipeline with PostHog events (step 4 of the PostHog stack) and removes its secrets. Product events reuse the existing POSTHOG_TOKEN / POSTHOG_HOST, so there is no new secret.
Removed from the catalog and config:
R2_SQL_TOKENR2_CATALOG_TOKEN- the admin var
R2_BI_BUCKET
After the new code is deployed and infra has run on staging and prod: delete R2_SQL_TOKEN and R2_CATALOG_TOKEN from their stores and the GitHub Environments, and trim the Pipelines and Account API Tokens permissions from the Pulumi token. Don't do it earlier: the live stack uses them until the infra runs.
See PostHog — Step 4 (#971, merged).
Flagship token removal (#982, merged)
#982 (merged 2026-10-16 05:47 IDT by yoni-monday, merge 94410daa, PostHog 6/6) removes Flagship. Feature-flag evaluation reuses existing POSTHOG_TOKEN / POSTHOG_HOST — no new secret.
These leave the secrets catalog / verify / admin vars / env renderer (in the merge):
FLAGSHIP_TOKEN- admin vars
CF_ACCOUNT_ID/FLAGSHIP_APP_ID(Flagship app wiring)
Rollout order still pending: deploy the control plane (staging, then prod) before applying infra with allow-deletes (that destroys the Flagship apps). Only after the new worker is live, delete FLAGSHIP_TOKEN from each Secrets Store and drop the Flagship permission from the infra token (BOOTSTRAP.md). Do not delete the token earlier: an old worker still needs it until the PostHog-backed code is deployed.
See PostHog — Step 6 and Hosting — Flagship removal.
SLACK_BOT_TOKEN: Brilliant app in the brilliant.ai workspace (#993, merged)
Since PR #993 (merged 2026-10-17 08:23 IDT by yoni-monday, merge commit be1cd73a, final head c0e15b5f), prod SLACK_BOT_TOKEN is the bot token for the Brilliant Slack app (A0C9Z6HJ1L1) in the brilliant.ai workspace, and alerts post to #incoming (C0CA11H6XK6). It stays prod-only and optional, and it is never bound on dev, side envs, or staging. A missing or invalid token skips signup and app alerts without blocking a signup, but the marketing Contact form (POST /api/contact) fails with 502 until token and channel match.
Rotate it in the same control-plane deploy that changes the channel. Prod CD's secrets:push runs before the code deploy and deploys a Worker version at once, so expect a short gap; deploy at a quiet time. The new token is held off-repo by whoever created the Slack app (see the PR description), not in the repo.
Rollback: a Worker rollback restores that version's secret values, not the store. Roll back to the version from before this deploy's secrets push, and put the old token back in the store too, or the next deploy breaks alerts again.