Repository navigation
chore(build): serve the atlas app from a Cloudflare Worker - #297
Conversation
`wrangler.jsonc` is the `sahajatlas` app as a Workers static-assets Worker: assets-only out of `dist/`, `not_found_handling` in place of the `public/_redirects` splat the Worker never reads, previews on, and the `previews` block `cloudflare/wrangler-action` refuses to run without. `pnpm check:wrangler` named `wrangler.design.jsonc` alone, and nothing else in this repo reads either file — Workers Builds holds the dashboard's copy of the path. A config added without extending the gate is the exact drift #279 built the gate against, so the script now dry-runs both. Watched fail with `assets.directory` pointed at a directory `pnpm build` does not write: exit 1, naming the field. `scripts/wrangler-config.test.ts` covers the half the dry run cannot. A script that dry-runs one config exits 0, so the gate's own coverage has no second reader. Each of its nine assertions was watched fail against the defect it names. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GWfwsqh3etS8AgAGQRFp5s
`AGENTS.md` § Deployment stays the one authority, and `README.md` and `docs/architecture.md` stay pointers to it. What changed under it: the app is two targets, not one. The same `dist/` is served by the Pages project that answers `sahajatlas.com` and by a Worker at its own `workers.dev` host, so the `sahajatlas` bullet no longer claims the app has no `wrangler` config, and `_redirects` is now described as read by a platform rather than by a build — the app Worker ignores the very file the Pages app honours out of the same output. The variable docs follow from that: Pages keys its copies per environment, Workers Builds per trigger, and a preview trigger inherits nothing, so each `VITE_*` value is entered on every target. The Sentry runbook's step 3 said "the `sahajatlas` Pages project", which would now leave the Worker uploading nothing while deploying green. `docs/environment.md`'s `VITE_MAPBOX_ACCESSTOKEN` row said `.env.local` alone. The token is absent from the committed `.env` and inlined at build time, so Pages Production must already hold it or `sahajatlas.com` would draw no tiles. A variable list built from that table would have missed the map. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GWfwsqh3etS8AgAGQRFp5s
The spec enumerates the configs on disk instead of listing two, so a third target cannot arrive ungated, and applies the shared static-assets invariants to every config rather than the app's alone — flipping `preview_urls` off in `wrangler.design.jsonc` passed both the dry run and the first version of this spec, which is the hole it was written to close one file over. `ts.parseConfigFileTextToJson` replaces a hand-rolled comment strip: a trailing comma is legal JSONC that wrangler accepts and `JSON.parse` does not, so the strip could go red on a config that is fine. Measured: the `typescript` import leaves the lane's wall clock inside the band it already occupied, 30.08s against 28.9-31.2s. Dropped an assertion that proved nothing: `dist` is Vite's default `outDir`, and `vite.config.ts` sets none, so pinning `build` to contain `vite build` tied the config to nothing. Comment and doc compressions, no fact removed: the filename convention, the prefix hazard, the `previews` rationale and the `_redirects` behaviour were each stated twice over, once here and once in the file or authority that already owned them. `AGENTS.md` keeps the topology fact that generates the doubled variable entry and `docs/environment.md` keeps the per-variable consequence, so neither points at the other for a rule both state. `AGENTS.md`'s "run last" was wrong — `ci.yml` runs `pnpm build` again after the gate. Two claims corrected rather than compressed. Nothing else in this repo *deploys from* either wrangler config; `scripts/wrangler-config.test.ts` now reads both, so "nothing else reads" had become false. And `docs/testing.md` still credited the design Worker alone with `not_found_handling`, 90 lines under an edit that generalised it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GWfwsqh3etS8AgAGQRFp5s
This ticket's Approach 3 rests on a false premise, and the docs this branch already touched had copied it into the authority. `wrangler`'s `getAssetsOptions` reads `_redirects` and `_headers` through the same `maybeGetFile` pair and uploads each as a deployment module — which is precisely why `_headers` governs the playground Worker, as AGENTS.md already claimed. `createAssetsIgnoreFunction` keeps both out of the asset manifest, so neither is SERVED; #279 read that as "never read at all". `.assetsignore` cannot suppress either, because the read is unconditional. So `dist/`'s `/* /index.html 200` is in play on the app Worker, and what it does there is unmeasured. Cloudflare documents, for BOTH platforms, that "Redirects are always followed, regardless of whether or not an asset matches the incoming request" — and that sentence does not describe Pages. Measured against `sahajatlas.com` today, with the splat live: `/embed.js` and `/auto.js` answer `application/javascript`, `/robots.txt` answers `text/plain`, and only an unbuilt path falls through to the shell. An asset wins there. So the sentence predicts neither platform reliably, and the ticket's two predictions — that `robots.smoke.test.ts` passes and that no asset can be shadowed — are not evidence. Nothing here changes `public/_redirects`, and no fix is guessed at: the measurement comes first, on a Worker host, which is what the ticket's own acceptance criteria already ask a person to do. Two gate holes from the same review. Naming both configs was half a check: `;` or `|| true` between the dry runs kept the name list intact while a failing config exited 0. And the enumeration matched `.jsonc` alone, so a `wrangler.embed.toml` would have been invisible to "no target arrives ungated". Both now fail against their own defect. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GWfwsqh3etS8AgAGQRFp5s
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
sahajatlas-design | 4778bbe | Oct 14 2026, 12:52 AM |
Deploying sahajatlas-design with
|
| Latest commit: |
4778bbe
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0f532cf2.sahajatlas-design.pages.dev |
| Branch Preview URL: | https://claude-chore-280-app-worker.sahajatlas-design.pages.dev |
|
⚠ Behind
My lease on #280 is released; the push is the dispatcher's. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
This draft has had no CI activity for hours and no session holds it. Comment or push to wake me. 🤖 sydevs dispatcher |
`main` answered this branch's open question while it sat conflicted. #295 measured what I had only narrowed: a Worker reads `_redirects`, and the Workers API rejects `/* /index.html 200` as an infinite loop (100324), so the deploy fails outright rather than shadowing assets. #296 then measured the first build — the image honours `.node-version` and `packageManager`, and branch rules refuse prefix wildcards (12002). Conflicts, both in the half this branch and `main` each rewrote: - `package.json` — took `main`'s `ladle:build` with its `rm -f`, kept this branch's two-config `check:wrangler`. - `AGENTS.md` § Deployment — took `main`'s measured text wholesale and dropped my hedged version of the same facts, then added only what is the app's: that `dist/` cannot be cleaned by `pnpm build`. That last point is the one new thing here. `main` says the app's Worker move "must drop the line rather than ship it", and `ladle:build` shows the shape — but `dist/` is not `build/`: the Pages project serving sahajatlas.com deploys that same directory and needs the splat. So the deletion cannot live in `pnpm build`. `build:worker` is `build` plus the same `rm -f`, and it, not `build`, is the app Worker's Builds command. Verified: `pnpm build` leaves `dist/_redirects` in place, `pnpm build:worker` removes it. `check:wrangler` cannot catch a regression — the dry run never reaches the API that rejects the file — so the spec pins each config to the script that fills its directory, and pins `pnpm build` as free of the deletion. All three watched fail. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GWfwsqh3etS8AgAGQRFp5s
Deploying sahajatlas with
|
| Latest commit: |
a9e5cf2
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f51fb3e2.sahajatlas.pages.dev |
| Branch Preview URL: | https://claude-chore-280-app-worker.sahajatlas.pages.dev |
|
Unblocked and pushed Merged
New here: Gates green: lint, typecheck, 1734 tests, both builds, 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff matches #280's phase 1 and is no bigger than it: one config, a two-command gate, one build script, a doc sweep. build:worker is forced by #295, not invented here. The 158-line spec guards a two-command script, but its per-config block earns that — flipping preview_urls on one file alone passes the dry run. No contract surface moves: docs/embedding.md, public/_headers and public/_redirects are untouched.
One finding has teeth, and it is about the name, not the config.
Findings
- should-fix
wrangler.jsonc:7—Workers Builds: sahajatlasmatchesrunProject's exact-slug gate, so the app Worker's build can setfailureanddeploymentfor the Pages run. Red Smoke on healthy PRs from attended B onward, not from child 4. - should-fix
scripts/wrangler-config.test.ts:78— the gate's--dry-runis unpinned. - consider
AGENTS.md:105—pnpm build:workeris absent from Essential commands.
Named in the PR body, routed nowhere, not fixable on this branch:
- #280 attended B still says build command
pnpm build. That ticket is the runbook a person follows; this PR body is not. ci.yml:46-54— the gate comment still reads design-only, and the firstpnpm buildis now load-bearing for the gate with nothing saying so.
What was checked
#280 and #266 bodies; the whole diff; both wrangler configs whole; package.json scripts; the new spec against vitest.config.ts's **/*.test.ts include and eslint.config.js's readdirSync ban (scoped to src/, so scripts/ is clear); ci.yml order — build → size → ladle:build → gate, so both output directories exist; get-cloudflare-preview-url.mjs:244-254,700-770 and its spec; grep for any other wrangler invocation (none). No preview: the body is right that nothing here shows on one.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
`runProject` matched the trailing slug of a check run's name, so with the app Worker named `sahajatlas` — the Pages project's own name, which `wrangler.jsonc` gives it — `Workers Builds: sahajatlas` and `Cloudflare Pages: sahajatlas` were both read as this project's run. One Cloudflare App posts both, so the slug gate admitted the Worker's run to the conclusion block, where `failure` and `deployment` are last-write-wins. A failed Worker build would then report the Pages preview as `failed`, the one status whose advice is that re-running cannot help, on a PR whose preview deployed fine. The name-only evidence path is unchanged: a Worker run still counts as a Cloudflare deploy signal, as the `-design` sibling already did. It just cannot be concluded from. `CF_PROJECT` names a `pages.dev` host and `pick()` admits no other, so Pages is the only integration this script may conclude from today; #266's last child moves both together. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PgAVPfgGikcJastAwMwoUm
The spec is the gate's only reader and pinned `--config` and the `&&` joining, but not the flag that keeps `wrangler deploy` offline and credential-free. Dropped, every case still passed. Today that only makes a red gate noisy; once #266's child adds `cloudflare/wrangler-action` and a Cloudflare token to this repo, the same script would deploy from CI. Watched fail with the flag removed from one segment. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PgAVPfgGikcJastAwMwoUm
The block is the repo's command inventory, and `build:worker` is also the command a person types into Workers Builds for the app. It appeared only in § Deployment. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PgAVPfgGikcJastAwMwoUm
|
Three findings, three commits, all adopted. Pushed
Four new cases, each watched fail at the site that would cause it. Lean gate green: 1738 tests, 142 files. Body refreshed where this push made it false, that open-question note included. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Summary
wrangler.jsoncand abuild:workerscript, so the samedist/Pages serves also deploys as a Worker.check:wranglerand a new spec cover both configs;main's fix(build): drop _redirects from the Ladle build the design Worker deploys #295/docs(deploy): record the design Worker's first build and smoke measurement #296 findings are merged in.Change outline
The app becomes a second deploy target out of one build. Nothing a visitor reaches moves:
sahajatlas.comis still the Pages project, andpublic/_redirectsandpublic/_headersarebyte-identical to
main.Files
Contract — the app Worker's config
A new shape, under the config it was copied from. Every key is load-bearing; three are not
wrangler defaults.
{ "name": "sahajatlas", "compatibility_date": "2026-10-06", "assets": { "directory": "dist", "not_found_handling": "single-page-application" }, "preview_urls": true, "previews": {} }main— assets only, no Worker codenot_found_handlingis the Worker's only deep-link fallback — see the build split belowpreview_urlsdefaults tofalsein wrangler's own schemapreviewsis undocumented but schema-defined;cloudflare/wrangler-actionthrows without itBehaviour — one
dist/, two platforms that disagree about one fileThis is the substance of the change, and it is why the app needs its own build script where the
playground did not.
ladle:buildalready does this forbuild/(#295).dist/could not copy that shape, becausePages deploys the same directory and depends on the line — hence a separate script rather than a
change to
pnpm build.Behaviour — the name
sahajatlasnow belongs to two deploysThe Worker takes the Pages project's own name, and one Cloudflare App posts a check run for
each.
get-cloudflare-preview-url.mjsmatched a run to this project by the trailing slug of itsname, so both were this project's run:
failureanddeploymentare last-write-wins inside that loop, so a failed Worker build setfailedfor a Pages preview that deployed fine — the one status whose advice is that re-runningcannot help. The Worker's run still counts as evidence a deploy exists, exactly as the
-designsibling already did; it just cannot be concluded from.
CF_PROJECTnames apages.devhost andpick()admits no other, so Pages is the only integration this script may conclude from today,and #266's last child moves both together.
Behaviour — what the gate can and cannot see
The dry run validates a config against wrangler's schema and fails on a missing
assets.directory. Two things it cannot see, both now pinned byscripts/wrangler-config.test.ts:The second group exists because the dry run never reaches the API that rejects the file, and a
script that dry-runs one config exits 0.
Contract — the deploy docs
AGENTS.md§ Deployment stays the one authority;README.mdanddocs/architecture.mdstaypointers. The merge took
main's measured text wholesale and added only what is the app's.Preview
Nothing in this diff is observable on a preview: it adds a config and a script no CI job
deploys, extends a dry run, narrows a discovery gate, and edits prose.
Test results
pnpm lint && pnpm typecheck && pnpm test:run— 1738 tests, 142 filesscripts/wrangler-config.test.ts21,scripts/get-cloudflare-preview-url.test.ts40)pnpm build,pnpm build:worker,pnpm ladle:build,pnpm size(standalone 309.1/318, loader 2.8/3.5, embed 310.9/318 KiB)pnpm check:wranglerover both configspnpm build,dist/_redirectsexists; after
pnpm build:worker, it does not; afterpnpm ladle:build,build/_redirectsdoes not.
Every assertion was watched fail, against the defect it names
Each defect was reintroduced on its own, at the site that would cause it. Only the assertions
written for it went red:
--config wrangler.jsoncwrangler.embed.tomlarrives, ungated%s is JSON the shape assertions can read;|| true--dry-runfrom one segmentmainassets.directorydrifts tobuilddistassets.directoryremovedpreview_urlspreviewscompatibility_datereadConfigthrows, naming the file and the reasonbuild:workerstops droppingdist/_redirectswrangler.jsoncis filled by a script that drops itladle:buildstops droppingbuild/_redirectswrangler.design.jsoncpnpm buildstarts deleting itpnpm buildfree of the deletionrunProjectmatches the trailing slug alonerunProjectcasesThe four design-config rows are coverage the first version of this spec did not have: it
asserted the app's keys only, so flipping
preview_urlsoff one file over passed both the dryrun and the spec.
Two forms that are legal and must not go red were checked too:
--config=<file>, and atrailing comma in a config (legal JSONC that wrangler accepts and
JSON.parsedoes not).Separately, the dry run itself was watched fail with
assets.directorypointed atdist-nope:exit 1,
The directory specified by the "assets.directory" field in your configuration file does not exist.Manual verification
Phase 2 of #280 is attended Cloudflare work, and no cloud run can do any of it. The list is in
#280 under Attended, A → H. Three changes to it from
mainand from this PR:pnpm build:worker, notpnpm build.With
pnpm buildthe first deploy fails with 100324 before anything else can be checked..node-versionandpackageManager(
[email protected], [email protected]).name or a lone
*and refusegh-readonly-queue/*with12002. The merge-queue exclusionchore(build): serve the atlas app from a Cloudflare Worker #280 asks for cannot be configured as it is on Pages.
Still owed, and only a person can take them: the variable list written off the Pages project
before anything is entered, both trigger sets entered and read back name by name, the
source-map upload line in the first build log, the smoke count against the app's Worker host,
and whether Cloudflare accepts the Worker name
sahajatlas.Notes for reviewer
merge commit is the fix; CI can schedule from this push on.
## Open questionsis gone because both were answered, neither by me:and while this branch was behind: the API rejects it (100324) and the deploy fails outright
— not the "shadows assets" outcome I had reasoned to. My escalation to Our Cloudflare Pages sites move to Cloudflare Workers, at no extra cost #266 was raised an
hour after the answer landed and is withdrawn there. Root cause on my side: one
git fetchat the start of a long run, and a grounding read of chore(build): serve the atlas app from a Cloudflare Worker #280's body that still carried the old
claim.
and that is fixed here, not handed on. I had answered this "only in its evidence", which
was half the question:
PAGES_REandpick()do bound the URL to*.pages.dev, butrunProjectread a check run's trailing slug, whichWorkers Builds: sahajatlasshareswith the Pages run. See § the name
sahajatlasnow belongs to two deploys. What is stillOur Cloudflare Pages sites move to Cloudflare Workers, at no extra cost #266's child's is the preview lane for a Workers-hosted app, where
pick()and this anchormove together.
Worker's builds on this very PR: Workers Builds does post a GitHub check run, named
Workers Builds: sahajatlas-design, so the name identifies which Worker built (finding H);and a Worker may take a live Pages project's name —
Workers Builds: sahajatlas-designand
Cloudflare Pages: sahajatlas-designboth ran on the same commit. That secondobservation is what the discovery fix above rests on.
.github/, which chore(build): serve the atlas app from a Cloudflare Worker #280 forbids editing:ci.yml:46-50still calls the gate step "the design Worker's config" and claims nothing elsereads it; and
ci.yml:52-54justifies its position byladle:build/build/alone, though itnow also needs
pnpm build'sdist/. That second one has teeth:ci.ymlrunspnpm buildtwice, so deleting the first as a duplicate would make the gate fail cold.
.claude/workflow.jsonis a protected path, sodeployTargetandsecurityReview.triggerPattern(which matches nowrangler*path) stay stale — an attendededit at Our Cloudflare Pages sites move to Cloudflare Workers, at no extra cost #266's last child, per chore(build): serve the atlas app from a Cloudflare Worker #280's Notes.
serves publicly from the same build,
preview_urls: truewas alreadymain's posture, bothwrangler invocations are explicit
--dry-runwith no Cloudflare credential anywhere in CI,and no secret value entered the diff. The two gates this PR narrows — the check-run anchor and
the pinned
--dry-run— both move in the safe direction: strictly less is admitted, andnothing that was refused before is admitted now.
hand-rolled shell job control where a mis-written
waitexits 0 on failure); sharing oneconfig via
env(moves the selector into a dashboard command no spec can see).Detail
Why a spec and not just the dry run.
scripts/deploy-headers.test.tsexists for the samereason one level over:
public/_headersis inert text no local gate can execute. Here the inertthings are the gate's argument list and the config→script pairing. Nothing else in this repo
deploys from either wrangler config — Workers Builds holds the dashboard's copy of each path.
The parser.
ts.parseConfigFileTextToJsonreplaced a hand-rolled line-comment strip. Atrailing comma is legal JSONC that wrangler accepts (
allowTrailingCommasin its own schema)and
JSON.parserejects, so the strip could have gone red on a config that was fine.TypeScript is already a devDependency and
src/test-support/source-ast.tsalready imports it.Measured: the lane's wall clock stayed inside the band it already occupied.
The fixture pre-mortem. The spec reads the two real configs and the real
package.jsonrather than fixtures, so its only assumption is that a wrangler config is JSON-ish — asserted
rather than assumed, so a
.tomlfails by name instead of skipping the shape checks silently.--dry-runis pinned for a cost it does not yet carry. Nothing in this repo holds aCloudflare credential today, so dropping the flag would only make a red gate noisy. The spec
pins it because #266's child adds
cloudflare/wrangler-actionand a token, and the same scriptwould deploy from CI — the spec is the gate's only reader either way.
public/_redirectsandpublic/_headerscarry no change from this branch, and no⚠,#NNNbreadcrumb or cross-repo pointer was dropped by the sweep or the merge — checked bydiffing the counts per file in both directions against the new base.
Closes #280
🤖 Generated with Claude Code
https://claude.ai/code/session_01GWfwsqh3etS8AgAGQRFp5s