Repository navigation
ci: deploy through the Cloudflare Deploy Broker instead of the static CLOUDFLARE_API_TOKEN - #111
Conversation
… CLOUDFLARE_API_TOKEN
There was a problem hiding this comment.
I reviewed this PR and didn't find any bugs. It rewrites how production is deployed, which changes who holds credentials, how D1 migrations get applied, and how Durable Object classes are declared, so a human should still look at it before merge.
What was reviewed:
- production.yml: the job graph (authorize -> settings/check -> build -> deploy -> update_slack_app), the non-cancelling concurrency group, the SLACK_APP_ID regex check before it reaches
build-command, and the health-check loop. - scripts/broker-build.ts: how DO migrations become exports (the rename keeps the storage type, and unsupported migration fields throw), the relative migrations_dir, the ASSETS binding, and the .assetsignore check.
- The 0020_telegram_provider.sql placeholder (a no-op
WHERE 0update), the preview sed that handles both the old and new placeholder names, and the matching Env additions in src/env.d.ts. - Not checked, because reading the code can't settle them: whether the pinned tempoxyz broker workflow and action behave as described, and whether production's d1_migrations ledger and live secrets match what the PR says.
Extended reasoning...
The PR changes the production deploy workflow, adds a build script that rewrites the generated wrangler.json, bumps wrangler from 4.91.0 to 4.151.0 (which regenerates about 3.7k lines of types), and adds a placeholder D1 migration. It touches security-sensitive surface: Cloudflare credentials leave production CI, deploy authorization moves to an external broker, and Worker secrets are no longer uploaded from GitHub. Whether it works depends on external state this review can't see: the broker policy PR it must merge after, the production migration ledger, and the RPC_CREDENTIALS value the description flags as stale. Those, plus the critical deploy path, are why this is a defer rather than an approve.
…clear audit failures
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
| '@hono/node-server@<2.1.6': 2.1.9 | ||
| 'hono@<4.13.16': 4.13.19 |
There was a problem hiding this comment.
🟡 (optional) Future hono upgrades will fail to install or leave dependencies stuck on 4.13.19, so later advisories cannot be cleared by bumping hono. pnpm applies 'hono@<4.13.16': 4.13.19 to every spec that overlaps the range, including peer ranges. The lockfile already rewrites ^4, >=3.9.0 and >=4.10.0 to an exact hono: 4.13.19. Fix: make the override track the direct dependency, e.g. hono: $hono, so dependents and peers follow package.json's hono on the next bump. The same applies to the @ hono/node-server@<2.1.6 entry if it gains dependents.
Why this was flagged
pnpm checks an override selector like hono@<4.13.16 by range intersection, not by the version that would resolve. The lockfile shows the effect: the peer ranges of @ hono/node-server (^4, pnpm-lock.yaml:745), @ hono/standard-validator (>=3.9.0), @ hono/zod-validator (>=4.10.0), hono-openapi (^4.11.2) and mppx (>=4.12.25) all became hono: 4.13.19. Suppose a maintainer, or pnpm deps (taze), bumps package.json's hono to 4.13.20 or 4.14.x for the next advisory. The root spec no longer overlaps <4.13.16, so the root moves but every transitive copy stays on 4.13.19. Peers such as @ hono/zod-validator now require exactly 4.13.19, so with strictPeerDependencies: true (pnpm-workspace.yaml) the install fails on an unmet peer. On the base branch no hono override existed, so hono peers and dependents followed the root version. The older '@ hono/node-server@<2.1.3' override caused no such pin because nothing declares @ hono/node-server as a peer, so it is no safeguard here.
Verification: Trigger: a later hono bump in package.json that leaves the 'hono@<4.13.16': 4.13.19 override in place. The root specifier 4.13.19 (package.json:41) does not overlap <4.13.16, so the override does not touch it. @ hono/zod-validator is a direct root dependency (package.json:34) whose peer now reads exactly 4.13.19. With strictPeerDependencies: true (pnpm-workspace.yaml), that unmet peer fails the install.
| timeout-minutes: 20 | ||
| environment: production | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| steps: | ||
| - name: Secure runner | ||
| uses: tempoxyz/gh-actions/actions/secure-runner@35019557465e3c38ee3468be171771fd73577584 # 2026-10-20T06-22-38Z-35019557 | ||
|
|
||
| # The broker applies pending D1 migrations to DB, then uploads and | ||
| # promotes the version, and stops before promotion if a migration fails. | ||
| # The Worker keeps its secrets; change them in the broker dashboard | ||
| # (https://cf.tehq.net/, Workers tab). | ||
| - name: Migrate D1 and deploy through the broker | ||
| uses: tempoxyz/gh-actions/actions/cloudflare-deploy-broker@1a535d662a51f211d750307541069cb849535414 # 2026-11-19T07-33-38Z-1a535d66 | ||
| with: | ||
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
| command: deploy --env production | ||
| environment: production | ||
| secrets: | | ||
| FEE_PAYER_PRIVATE_KEY_MAINNET | ||
| FEE_PAYER_PRIVATE_KEY_TESTNET | ||
| RPC_CREDENTIALS | ||
| SECRET_KEY | ||
| SLACK_CLIENT_ID | ||
| SLACK_CLIENT_SECRET | ||
| SLACK_SIGNING_SECRET | ||
| TEMPO_API_KEY | ||
| TWITTER_ACCESS_TOKEN | ||
| TWITTER_ACCESS_TOKEN_SECRET | ||
| TWITTER_BEARER_TOKEN | ||
| TWITTER_CONSUMER_KEY | ||
| TWITTER_CONSUMER_SECRET | ||
| TWITTER_OAUTH_CLIENT_ID | ||
| TWITTER_OAUTH_CLIENT_SECRET | ||
| env: | ||
| FEE_PAYER_PRIVATE_KEY_MAINNET: ${{ secrets.FEE_PAYER_PRIVATE_KEY_MAINNET }} | ||
| FEE_PAYER_PRIVATE_KEY_TESTNET: ${{ secrets.FEE_PAYER_PRIVATE_KEY_TESTNET }} | ||
| RPC_CREDENTIALS: ${{ secrets.RPC_CREDENTIALS }} | ||
| SECRET_KEY: ${{ secrets.SECRET_KEY }} | ||
| SLACK_APP_ID: ${{ vars.SLACK_APP_ID }} | ||
| SLACK_CLIENT_ID: ${{ secrets.SLACK_CLIENT_ID }} | ||
| SLACK_CLIENT_SECRET: ${{ secrets.SLACK_CLIENT_SECRET }} | ||
| SLACK_SIGNING_SECRET: ${{ secrets.SLACK_SIGNING_SECRET }} | ||
| TEMPO_API_KEY: ${{ secrets.TEMPO_API_KEY }} | ||
| TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }} | ||
| TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} | ||
| TWITTER_BEARER_TOKEN: ${{ secrets.TWITTER_BEARER_TOKEN }} | ||
| TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }} | ||
| TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }} | ||
| TWITTER_OAUTH_CLIENT_ID: ${{ secrets.TWITTER_OAUTH_CLIENT_ID }} | ||
| TWITTER_OAUTH_CLIENT_SECRET: ${{ secrets.TWITTER_OAUTH_CLIENT_SECRET }} | ||
| deployment-id: tipbot | ||
| artifact-id: ${{ needs.build.outputs.artifact-id }} | ||
| archive-digest: ${{ needs.build.outputs.archive-digest }} | ||
| module-digest: ${{ needs.build.outputs.module-digest }} | ||
|
|
||
| # /api/health queries D1. | ||
| - name: Check https://tip.bot | ||
| run: | | ||
| for _ in $(seq 1 10); do | ||
| if curl -fsS --max-time 10 https://tip.bot/api/health; then exit 0; fi |
There was a problem hiding this comment.
🟡 nit (optional): Two new time durations have no human-readable comment, which AGENTS.md requires. They are timeout-minutes: 20 at production.yml:101 and curl --max-time 10 at production.yml:126. The neighbouring sleep 6 # 6 seconds follows the rule. Fix: add trailing comments such as # 20 minutes and # 10 seconds.
Why this was flagged
AGENTS.md:52 says every added time duration or amount needs a comment next to it giving the human-readable time. The diff adds timeout-minutes: 20 to the deploy job at .github/workflows/production.yml:101 and curl -fsS --max-time 10 in the health-check loop at line 126, and neither has a comment. The sleep 6 # 6 seconds two lines below shows the convention the author was following. This is a convention slip only and changes no behaviour. Nothing in CI enforces the rule, so nothing catches it.
Verification: Severity: nit. This is a convention slip that breaks nothing at runtime. AGENTS.md:52 says: "whenever you add a time duration/amount, make sure it has comment next to it with the human-readable time". The diff adds timeout-minutes: 20 at .github/workflows/production.yml:101 and curl -fsS --max-time 10 at line 126, and neither has a comment. Behavior is unaffected.
…ad of the static CLOUDFLARE_API_TOKEN (#112) **Merge after** tempoxyz/cloudflare-sts#197 has merged and STS has deployed it. Before that, the first preview fails at "Fetch a Cloudflare token". See "Merge after" below. Pull request previews stop running the pull request's code next to the `preview` environment's long-lived `CLOUDFLARE_API_TOKEN`. Production already deploys through the broker (#111). After this PR, no workflow on `main` reads the `preview` environment's `CLOUDFLARE_API_TOKEN` or `CLOUDFLARE_ACCOUNT_ID`. - **`pull_request.yml` gets a Preview Build job.** It builds the pull request with `CLOUDFLARE_ENV=preview` and no secrets. It uploads the Worker, static assets, D1 migrations and both Slack manifests as the `preview` artifact. - **`preview.yml` → `preview_deploy.yml` now run only main's code.** They check out main, check the artifact, configure the Slack app, and only then fetch a 10-minute Cloudflare STS token (`preview-deploy`). With it they create the D1 database and queues, apply the pull request's migration SQL, and deploy the build unbundled with main's `wrangler.jsonc` and the preview secrets. A fresh D1-only token (`preview-seed`, 15 minutes) then seeds the database with main's `scripts/preview-seed.ts`. - **`preview_destroy.yml` and `preview_sweep.yml`** fetch their own STS tokens (`preview-destroy`, `preview-sweep`) in place of the secret. ## Before / after | | Before | After | | --- | --- | --- | | Pull request's code | Checked out in `preview_deploy.yml`'s Deploy job. Its `setup-pnpm` action, lockfile, `src/lib`, `scripts/slack.ts`, Wrangler, build and `scripts/preview-seed.ts` ran there, with the Cloudflare token, the fee payer keys, `SECRET_KEY` and the Slack config token (which can mint a `secrets: write` GitHub token) | Runs only in Preview Build, under the `pull_request` identity, with no secrets | | Cloudflare token | Static `CLOUDFLARE_API_TOKEN`: no expiry or IP binding, and `.github/TODO.md` lists it on all accounts | STS tokens pinned to main's three workflows in the `preview` environment (deploy 10 min, seed 15 min with D1 only, destroy 10, sweep 15), this runner's IP only, revoked when the job ends | | Wrangler, config, seed, reaction emoji | The pull request's | Main's. Wrangler uploads the artifact as data (`no_bundle`, `upload_source_maps: false`) | | D1 migrations, Worker bundle, assets, Slack manifests | The pull request's | Still the pull request's, as checked data | | Preview D1 database | ID from the preview comment | Found by name (`tipbot-pr<n>`) | | Fork pull requests | Previewed if an organization member started or re-ran the run | No preview | ## Why STS, not the broker Each preview creates a Worker, a D1 database and two queues, attaches `pr<n>.tip.bot`, and uploads per-preview secrets, including its Slack app's credentials. The broker's policy-free previews bind only static assets and version metadata, and the broker creates no D1 database or queue for an unpublished Worker. It also never deletes any of these. The seed also reads the production database. tempoxyz/cloudflare-sts#197 has the full reasoning. ## How the trusted job treats the pull request's build - **It checks out and runs only main.** It installs main's lockfile with `--ignore-scripts`, as `setup-pnpm` already did. Main's code computes the reaction emoji and runs the seed. - **The artifact stays outside the workspace.** `scripts/preview-artifact.ts check` runs before any token is fetched. It refuses symbolic links and special files, any top-level entry beyond `client`, `migrations`, `server` and the two manifests, migration names other than `NNNN_name.sql`, and a manifest whose app name isn't `Tipbot PR <n>` or that holds a URL off `https://pr<n>.tip.bot/`. - **`preview-artifact.ts config` writes the deploy config from main's `wrangler.jsonc`.** That config sets the Worker name, bindings, D1 database, queues, custom domain and vars. Only `main`/`base_dir`, the assets directory and `migrations_dir` point at the artifact. It sets `upload_source_maps: false`, because Wrangler otherwise follows `sourceMappingURL` comments to any file. The build writes no source maps, so nothing is lost. The script also asserts the name, D1 binding, route and `HOST` before writing. - **Only the workflow's own comments count.** Every read of the preview comment now requires `github-actions[bot]` as the author. Before, any comment containing `tipbot-preview` counted, and this repository is public. Destroy and sweep then took `d1_id` and Slack app IDs from it, so a crafted comment could point a deletion at another D1 database or Slack app. D1 databases are now always found by name. ## Behavior to review - **The STS token is broad.** Cloudflare can't scope D1, Queues or Workers Scripts write to one resource. For 10 minutes the deploy token can rewrite every Worker in tempo-prd, `tipbot` included, and read and write every D1 database, the production `tipbot` database included. STS reserves `d1_read` for tempoxyz/cloudflare, so the seed reads production with a D1 Write token of its own (15 minutes, no Workers or Queues). That's why the job must never run pull request code (comment at the top of `preview_deploy.yml`). - **A preview still runs the pull request's code with real secrets and data, as before.** That means `FEE_PAYER_PRIVATE_KEY_MAINNET`/`_TESTNET`, `SECRET_KEY`, `TEMPO_API_KEY`, its Slack app's credentials, and a seeded copy of one production Slack workspace's linked members (addresses, Slack IDs and names). The org-membership gate and the new same-repository rule are what stand in front of that. - **Some pull request changes reach the preview only after they merge.** That covers changes to `wrangler.jsonc` (bindings, vars, compatibility date), the Wrangler version, `scripts/preview-seed.ts`, the reaction emoji code and `public/tipbot-preview.png`. Code, assets, migrations and Slack scopes and events still preview. If a pull request changes the seeded tables' schema, main's seed may fail on its preview until it merges. - **The `slack-app-id` meta tag on a pull request's first preview is empty.** The build now runs before the Slack app exists, so it reads the ID from the preview comment, and the next push fills it in. - **Fork pull requests get no preview.** Before, an organization member's re-run would preview a fork's code with all of the above. - **This PR shows no preview.** Its own Preview Build runs, but `preview.yml` runs from main, where the old flow still is. I keep this PR a draft except while the Claude review starts, so main's old flow never deploys it with the static token. Mark it ready just before merging, as with #111. - **Open branches without this change get no preview until they merge main.** Their Pull Request run uploads no `preview` artifact, so the Gate job skips the deploy with a notice. The same happens for a run whose push was a draft's, or whose artifact (kept 3 days) has expired. A run for a commit the pull request has already moved past also ends without deploying, and the newer commit's run deploys. - **Previews haven't deployed since 2026-11-01.** On 11-08 and 11-14 the static token got 401 at "Setup preview D1". After it was replaced on 11-17, no ready pull request has run one, and production's runs with the same token were refused D1 writes (#111). So the first run after merge is also the first test of the whole path. ## Validation - `pnpm check` (format, lint, type-aware) and `pnpm check:types` pass. actionlint 1.7.12 passes. zizmor 1.30.1 (offline) reports no findings, as on main. - I built the preview locally as Preview Build does (`CLOUDFLARE_ENV=preview`, substituted `wrangler.jsonc`) and packaged the artifact. - `preview-artifact.ts check` accepts it. It refuses: a symlink to a file, a symlink to a directory, a FIFO, a `.SQL` migration, an extra top-level file, a directory named `server/index.js`, a manifest redirect to another host, `https://pr999.tip.bot.evil.example/`, `https://tip.bot/...`, and an app named `Tipbot`. - `preview-artifact.ts config` refuses a malformed D1 ID. - With main's Wrangler 4.151.0 in the job's layout (config in its own directory, artifact elsewhere), `wrangler deploy --config wrangler.json --env preview --dry-run --secrets-file` accepts the generated config. It uploads 48 ES modules (6,749 KiB), reads 34 asset files, and binds `CHAT_STATE`, `AUTH_NONCE`, `PENDING_TIP_QUEUE` → `tipbot-pending-tip-pr999`, `DB` → `tipbot-pr999`, `AI`, `CF_VERSION_METADATA`, the vars and the seven secrets. That matches what the old flow deployed in run 41330856120. `wrangler d1 migrations list --local` with the generated config reads the artifact's 30 migrations. - I confirmed in Wrangler 4.151.0's source that `--secrets-file` uploads `secret_text` bindings, and that a first deploy without them fails because of `secrets.required`. Source maps load unless `upload_source_maps === false`. Custom domains go through account-level `/workers/scripts/<name>/domains/changeset` and `/workers/domains/records` calls, with no `/zones` lookup. ## Merge after 1. tempoxyz/cloudflare-sts#197 merges and STS deploys it. 2. Mark this PR ready and merge it right away. ## After merge 1. On the next ready pull request from a branch of this repository, check that Preview Build uploads `preview`, and that **Preview / Deploy** fetches a token and passes "Deploy preview" and "Seed preview workspace". Also check that `https://pr<n>.tip.bot` answers and the comment shows Ready. 2. Close or draft that pull request and check that **Preview Destroy** fetches a token and deletes the Worker, D1 database and queues. The next midnight **Preview Sweep** should also fetch one. 3. Then delete the `preview` environment's `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` in tempoxyz/tip.bot. Nothing on main reads them. 4. Revoke the Cloudflare token behind them. It was set at the same second as production's (2026-11-17 22:23:40 UTC), and production's copy is already deleted, so it is probably the same token.
Merge after tempoxyz/cloudflare-deploy-policies#293 has merged and its Publish policies run has succeeded. See "Merge after" below.
Draft on purpose. A ready pull request gets a preview:
preview.ymlonmainruns this branch's code with thepreviewenvironment's token.main'spreview_deploy.ymldoes not yet replace this branch's newtipbot-preview-nameplaceholder, so that preview would create a D1 database, Queues and a Slack app and then fail at Run migrations. Mark it ready just before merging. Previews of pull requests opened after it merges work.Summary
A push to
mainnow deploys thetipbotWorker (https://tip.bot) through the Cloudflare Deploy Broker. No job ofproduction.ymlholds a Cloudflare credential any more, so theproductionenvironment'sCLOUDFLARE_API_TOKENandCLOUDFLARE_ACCOUNT_IDbecome unused. The Worker keeps its name, D1 database, Durable Objects, Queue, AI binding, cron, custom domain and secrets. Previews are unchanged and still use thepreviewenvironment's token; see "Previews" below.Why production.yml has been failing
Every Production run since 2026-11-04 (#95's merge) fails at Run migrations, so nothing after #107 has deployed.
tipbotstill serves version54437c81, which run 41477298036 deployed on 2026-11-02 with this workflow (authortom@tempo.xyz, the owner of the API token).wrangler d1 migrations apply tipbot --env production --remote. Wrangler reads the ledger and lists0026_tempo_workspace_ousd.sql, feat: default to OUSD #95's oneUPDATE, as pending. Then D1 refuses to run it:You do not have permission to perform this operation. [code: 7500](runs 41924847485 and 42512225697).CLOUDFLARE_API_TOKENin both environments on 2026-11-17 22:23 UTC and re-ran 42512225697 a minute later. It failed the same way, so the new token cannot write D1 either. It is probably a user token whose owner's tempo-prd role lacks D1 write, or a token without D1 Edit. I could not check which, because I can't read either.The broker applies 0026 with its own credential, so this PR also fixes the failure, provided the database accepts the statement.
Before / after
wrangler d1 migrations applywith the static tokendb/migrationsbefore it uploads, and stops before promotion if one failspnpm buildin the deploy job, with the token in the jobcloudflare-deploy-broker-build.yml(gh-actions1a535d66) runspnpm build:brokerand attests the Worker, its 48 chunks,dist/server/wrangler.json,dist/clientand the migrations. No credentialdeploy --env production, pluswrangler secret bulkof 15 secretscloudflare-deploy-brokerwith deployment IDtipbot, then a check thathttps://tip.bot/api/health(which queries D1) returns 200productionenvironment on every deployvars.SLACK_APP_IDin the deploy jobSettingsjob in theproductionenvironment reads it and passes it to the build. It is public: tip.bot serves it in a meta tagChanges needed for the broker build
migrationsand needsexports, which Wrangler 4.91 does not understand. 4.151.0 is already in the lockfile through@cloudflare/vitest-plugin, so the lockfile only switches the importer; no new package is added.@cloudflare/vite-plugin1.37.0 accepts it (^4.91.0).src/worker-configuration.d.tsis regenerated bypnpm gen:types. Wrangler now declaresEnvandCloudflare.Envas extensions of a generated__BaseEnv_Env, sosrc/env.d.tsadds its stronger types to both.tipbot-preview-nameinstead of__PREVIEW_NAME__, because Wrangler 4.151'swrangler typesrejects a Worker name with capitals or underscores.preview_deploy.ymlreplaces both, so branches from before this PR still preview.scripts/broker-build.ts(pnpm build:broker) runspnpm buildfor production, then adjusts the generateddist/server/wrangler.json:wrangler.jsonc's migrations:TipbotChatStateDOas SQLite (created asChatStateDO, renamed intipbot_chat_state_v2) andNonceStorageaslegacy-kv. The broker never replays migrations.wrangler.jsonckeeps them for previews and local development.migrations_dirrelative to the generated file, adds theASSETSbinding the broker requires (nothing reads it), and deletes the Vite plugin's.assetsignore, which the broker rejects and which lists only files the client build does not write.wrangler.jsoncsetsaccount_id(tempo-prd) inenv.production, which the builder requires.db/migrations/0020_telegram_provider.sqlis a no-op placeholder. Production run 26782816327 applied an earlier file of that name (327ef06) before 954bf9b reverted it, so the production ledger still records it. Wrangler ignores applied names it has no file for; the broker requires every recorded name to be one of the attested manifest's first ones, and otherwise fails withd1_migration_history_mismatch. On a fresh database (local, tests, previews) the placeholder runs oneUPDATE … WHERE 0. It sorts before0020_tip_ask.sql, after 0019.Also:
pnpm auditc34b6d2 is separate from the migration.
main's Verify job now failspnpm auditon seven advisories published since #109: hono below 4.13.16 (GHSA-4m76-xfj5-7975, GHSA-h7mg-cq63-vhpq and five others) and@hono/node-serverbelow 2.1.6 (GHSA-qv5m-9pm6-hqp3, GHSA-jpvv-r467-5p4w). This PR fails the same way without a fix, so it pins hono 4.13.19 and overrides@hono/node-serverto 2.1.9 (both older than the one-day release-age policy). These are patch releases.Secrets
The broker keeps the live Worker's secrets.
wrangler secret list --name tipbot(names only) shows all 14 thatwrangler.jsoncrequires (FEE_PAYER_PRIVATE_KEY_MAINNET,FEE_PAYER_PRIVATE_KEY_TESTNET,SECRET_KEY,SLACK_CLIENT_ID,SLACK_CLIENT_SECRET,SLACK_SIGNING_SECRET,TEMPO_API_KEY, and the sevenTWITTER_*), plusRPC_CREDENTIALS, whichsrc/lib/tempo.tsreads, andTELEGRAM_BOT_TOKENandTELEGRAM_WEBHOOK_SECRET_TOKEN, which nothing reads since the Telegram revert.Important
The
productionenvironment'sRPC_CREDENTIALSwas updated on 2026-11-12, after the last successful deploy (11-02). Every deploy since has failed, so the Worker still has the earlier value, and this workflow no longer uploads secrets. If the new value should be live, setRPC_CREDENTIALSin the broker dashboard. No other production secret changed after 11-02.Behavior to review
upload_source_mapsstays inwrangler.jsonc, but the broker never uploads source maps, so production stack traces will not be source-mapped.ASSETS. Assets are still served directly, before the Worker, as now.Settingsjob records a deployment to theproductionenvironment before the build, because it reads that environment'sSLACK_APP_ID.main. I replayed it (see Validation).Previews
PR code runs while the
previewenvironment's token is in the job.preview.ymlloads frommain, butpreview_deploy.yml's deploy job checks out the pull request's commit and then runs its code in the same job as the token: itssetup-pnpmcomposite action and lockfile,src/lib/*.ts,scripts/slack.ts, itswranglerforqueues create,d1 migrations applyanddeploy,vite.config.tsduring the build, andscripts/preview-seed.tswithCLOUDFLARE_API_TOKENin its environment. The token can edit every Worker and every D1 database in tempo-prd.preview-seed.tsalso reads the productiontipbotdatabase. Both environments' tokens were replaced in the same second on 11-17, so they are probably the same token.The broker's isolated previews cannot do this: each preview creates its own Worker, D1 database and Queues, attaches
pr<n>.tip.bot, and binds secrets. Moving previews to STS safely means splittingpreview_deploy.ymlso the pull request's code only builds, without credentials, and code frommaindoes every privileged step. That is a larger change of the Slack and seeding steps too, and it cannot run before it merges, so this PR leaves previews as they are. It is listed as a decision for the owner.Validation
pnpm auditreports no known vulnerabilities, andpnpm check,pnpm check:typesandpnpm test --project unitpass locally.pnpm db:migrateandpnpm db:codegenon a fresh local database apply all 30 migrations and leavedb/types.gen.tsanddb/schemas.gen.tsunchanged.main.pnpm build:brokerbuild command and every packaging step, on macOS and in anode:24.22.1Linux container. Every builder check passes. It attestsindex.jsplus 48esmmodules (6.9 MB), 32 assets (6.3 MB, all with known media types) and 30 migrations.BROKER_REFand at brokermain, and rejects drifted ones (preview URLs on, another D1 database, another Worker, an extra route, a KV namespace,NonceStorageas SQLite).Merge after
wrangler d1 execute tipbot --remote --env production --command "SELECT name FROM d1_migrations ORDER BY id"should list0020_telegram_provider.sql. If it does not, deletedb/migrations/0020_telegram_provider.sqlfrom this PR.After merge
tipbotpromoted.policies/tempoxyz/tip.bot.yamlfrom tempoxyz/cloudflare-deploy-policies. Later deploys use the remembered grant.RPC_CREDENTIALSin the broker dashboard if the 11-12 value should be live (see Secrets).productionenvironment'sCLOUDFLARE_API_TOKENandCLOUDFLARE_ACCOUNT_ID. Nothing reads them after this PR. The environment's Worker secrets (FEE_PAYER_*,RPC_CREDENTIALS,SECRET_KEY,SLACK_CLIENT_*,SLACK_SIGNING_SECRET,TEMPO_API_KEY,TWITTER_*,TELEGRAM_*) are unread too; delete them only if no one needs them as the copy of record. Keepvars.SLACK_APP_ID.previewenvironment'sCLOUDFLARE_API_TOKENis probably the same token, and previews still use it.If the bootstrap deploy fails before promotion, the current version keeps serving. Reverting this PR restores the Wrangler workflow, which still fails at the D1 migration.