Skip to content

chore(ci): nothing automated observes the production deploy, only a preview #244

Closed

Description

@sydevs-bot

Summary

Every automated check in this repo runs against a preview. .github/workflows/ci.yml:3-8
triggers only on pull_request and merge_group, and provenanceOf
(scripts/get-cloudflare-preview-url.mjs:570-575) demotes the bare project host to loose, which
pickPreview never selects — so discovery cannot name production even by accident. No job has ever
read the deploy that visitors and host sites actually get.

Found while implementing #232 (PR #245), which is what makes it concrete rather than tidy: that
ticket's whole finding was a build-time variable absent from the Production Pages environment
for seven weeks. Its fix adds a smoke assertion that the deployed bundle names a Sentry ingest host
— and that assertion can only ever see Preview. The exact recurrence (Production DSN blanked by a
dashboard edit, typo'd, or pointed at the wrong project) stays silent behind a green Smoke check.

Cost and value

What the PR gate cannot see is structural, not a coverage gap. VITE_* values are inlined at
build time, and Cloudflare Pages builds Preview and Production from separate dashboard
environments. The bundle CI reads is built from Preview's values, so it can never carry
Production's. tests/smoke/boot-origins.smoke.test.ts:11-17 records the inverse hole — VITE_HOST
set in Production, unset in Preview — costing every preview a blank page while all six smoke specs
stayed green. #232 is the same hole the other way round. Running the PR gate more often does not
close either one.

This is not an uptime monitor — but a daily cron makes it look like one. What the lane reads is
the content of deployed files, and that content changes only when a deploy happens. A daily
schedule re-reads an unchanged artifact about 364 times a year for one real signal per merge, and
is still up to 24 hours late. Availability stays out of scope and stays with the tools that own it.

So the trigger follows the deploy, not the clock. Measured costs:

daily schedule deployment_status
runs per year ~365 ~1 per merge to main
requests to production per run 13 13
Actions minutes billed 0 0
latency to a red signal up to 24 h minutes
cron disabled after 60 idle days (audit.yml:46-48) yes n/a

Actions quota is not a cost here. sydevs/SahajAtlasWeb is public, so standard-runner minutes
are free. The 13 requests are the whole production load — grep -c 'fetchPreview(' tests/smoke/*.test.ts
sums to 13 plain GETs, no spec issues a HEAD, and every one of them hits the CDN edge, not an
origin server.

Maintenance burden. One workflow file, permissions: contents: read, no credential and no
discovery step. The specs are the PR lane's own, so the two lanes cannot drift apart.

Approach

The per-spec triage this ticket assumed is unnecessary — measured, not reasoned. The whole lane
already passes against production:

PREVIEW_URL=https://sahajatlas.pages.dev pnpm test:smoke
# → 6 files, 16 tests, all passed (2026-10-02, on main)

Nothing in tests/smoke/ is preview-specific. _helpers/preview.ts:9 is process.env.PREVIEW_URL
plus fetch, and every assertion is about public/_headers, public/robots.txt,
public/_redirects, or a string in the shipped bundle — all identical across the two environments,
because both serve the same build output. So no spec is skipped by environment and none is
weakened.

  1. Add one workflow, on deployment_status plus workflow_dispatch only. Cloudflare Pages
    posts a GitHub deployment status carrying environment_url:
    scripts/get-cloudflare-preview-url.mjs:674-690 already reads exactly that, and ci.yml:18
    grants deployments: read for the same signal. Gate the job on the production environment and
    deployment_status.state == 'success', so it runs once per production deploy. ⚠ The
    environment name Cloudflare uses, and that a Cloudflare App status triggers a workflow at all,
    are both unverified — read them off a real deployment before writing the condition. A
    deployment_status workflow runs from the default branch.
  2. Take the origin from the event. Do not make it blank-able.
    github.event.deployment_status.environment_url names the deploy that just shipped, so the job
    needs no discovery step, no Cloudflare credential and no write permission. ⚠ This is also what
    keeps the job honest. skipWithoutPreview (tests/smoke/_helpers/preview.ts:12) makes every
    spec skip itself on an empty base URL, so a blank value would go green having run nothing —
    the chore(build): make preview discovery survive a slow cloudflare deploy #132 invariant, re-created one level up. Fail the job on an empty URL, before the specs run.
    The workflow_dispatch path carries https://sahajatlas.pages.dev as a literal default, under
    that same guard.
  3. Name the deploy in the step summary before the specs run. ci.yml:131-135 writes the URL
    only on the success path, so a failure names no host at all. Write it unconditionally, or with
    if: always(), so a red run says which deploy it read.
  4. Point the docs/environment.md Sentry runbook at the check. PR fix(report): detect a missing Sentry DSN, and tag the deploy #245 rewrites runbook step 1
    to tell a human to "fetch / from the deploy and grep the /assets/*.js it names for ingest"
    — that is this job, written out as an instruction because the lane cannot reach Production.
    Replace the instruction with the check. ⚠ That sentence exists only on PR fix(report): detect a missing Sentry DSN, and tag the deploy #245's branch, not on
    main
    — see Notes for the merge order.

Acceptance criteria

  • A run fires on each successful production deploy, reads the URL that deploy event names, and
    fails when an origin the bundle must request is absent from it.
  • A red run names the deploy it read, on the failure path as well as the success path.
  • The job cannot go green without running the specs: an empty base URL fails the job before
    skipWithoutPreview can hide it.
  • No schedule: trigger. The artifact changes only at deploy, so the run follows the deploy.
  • The PR lane is unchanged — ci.yml's on: block untouched, no spec skipped by environment,
    no assertion loosened.
  • docs/environment.md's Sentry runbook does not ask a human to grep a bundle for ingest.

Verification checklist

  • PREVIEW_URL=https://sahajatlas.pages.dev pnpm test:smoke passes on main today — 6 files,
    16 tests. It is the non-vacuous half: the lane reads https://cloud.sydevelopers.com/api out
    of assets/Spinner-*.js on production right now.
  • After PR fix(report): detect a missing Sentry DSN, and tag the deploy #245 merges, the same command fails on boot origins until Production carries
    VITE_SENTRY_DSN. Confirmed 2026-10-02: production's six eager /assets/*.js, embed.js and
    auto.js contain no ingest and no sentry literal, while cloud.sydevelopers.com is
    present — so that read is not vacuous either.
  • grep -n 'on:' -A 8 .github/workflows/*.yml shows the new workflow on deployment_status
    and workflow_dispatch only, and ci.yml:3-8 unchanged.
  • One workflow_dispatch run goes green against production as it stands today, and its step
    summary names https://sahajatlas.pages.dev.
  • One real merge to main produces exactly one run of this workflow, fired by the Cloudflare
    deployment status and naming the production URL from the event — not from a literal.
  • A run against a deliberately wrong origin goes red and names that origin in the summary.
  • pnpm lint && pnpm typecheck && pnpm test:run pass. No src/ file changes, so pnpm size is
    unaffected.

Open questions

  • Is a red Actions tab enough? Partly answered by the trigger change: an event-fired run
    attaches to the deploy that caused it, so the red run sits beside that deploy instead of in a
    cron list nobody opens. Decide whether that is enough, or whether the job should also open an
    issue on failure. Opening one needs issues: write — the only permission this design
    otherwise avoids.
  • Does any spec need skipping against production? No — all 16 pass, measured above.
  • Is CF_PAGES_BRANCH actually injected on both Pages environments? The Notes simplification
    rests on it, and no local build or file in this repo can answer it — only a real Pages build
    log can.

Notes

Merge order with #232 / PR #245, and why there is no Blocked by: line. This job is
non-vacuous on main today through the SahajCloud API origin, so it can land first and still catch
a real class of regression. Only the runbook criterion touches text #245 introduces, and it is
worded to hold either way. Whichever of the two lands second owns that sentence: if #245 merges
first, replace its grep instruction; if this merges first, #245's own doc edit should point at the
check instead of adding the instruction.

Why deployment_status and not push on main or a schedule. A push trigger fires before
the deploy exists, and nothing here can wait for it — discovery exists for exactly that wait and
refuses the production host by construction (scripts/get-cloudflare-preview-url.mjs:570-575). A
schedule fires when nothing has changed. The deployment status fires when the artifact under test
comes into existence, and carries its URL, which is why it needs neither the wait nor the literal.
audit.yml's scheduled shape is still the right precedent for a lane the PR gate cannot replace —
just not for its cadence, because an advisory arrives on its own schedule while a deploy announces
itself.

The adjacent CF_PAGES_BRANCH simplification belongs to #232, not here. It would replace
reportingEnvironment() (src/lib/report.ts:267 on PR #245's branch) and needs a define: entry
in vite.config.ts, which has none — CF_PAGES_BRANCH carries no VITE_ prefix, so Vite will not
inline it. This ticket changes no src/ file, and #245 is open on exactly that function, so
deciding it here would conflict with a live PR. The failure it prevents is real and unchanged:
VITE_SENTRY_ENVIRONMENT is a second variable a human types into the Preview dashboard, and unset,
reportingEnvironment() returns production, so preview events are indistinguishable from real
ones. ⚠ Confirm CF_PAGES_BRANCH is actually injected on both environments before relying on it —
this has not been verified against a real build, and deriving "is this production" from it also
means naming the production branch somewhere.

sahajatlas-design.pages.dev is out of scope. public/ is copied into both build outputs, so
robots.txt and _headers are policy for the playground too, and nothing observes it there
either. Covering it would need exactly the per-spec scoping this ticket just measured away — the
playground has no embed.js and no SPA shell. Healthy as of 2026-10-02: robots.txt serves and
/ carries x-robots-tag: noindex.

Found by the implement run for #232, 2026-10-02.

🤖 Written by the sydevs autonomous loop — see what this is

Activity

  1. added theissue type on Oct 2, 2026
  2. added
    proposal
    bot:working
    and removed on Oct 2, 2026
  3. sydevs-bot commented on Oct 2, 2026

    @sydevs-bot
    ContributorAuthor

    🤖 no session running

    recent dispatches
    • 21:34Z implement · attempt 1 · session · done
    • 21:34Z implement · attempt 1 · session
    • 18:50Z answer · attempt 1 · session · done
    • 18:50Z answer · attempt 1 · session
    • 02:22Z revise · attempt 1 · session · done

    Written by the sydevs dispatcher. Sessions never edit this comment.

  4. sydevs-bot commented on Oct 2, 2026

    @sydevs-bot
    ContributorAuthor

    Revised from the code. Three corrections.

    The per-spec triage is unnecessary. PREVIEW_URL=https://sahajatlas.pages.dev pnpm test:smoke passes on main today — 6 files, 16 tests. Nothing in tests/smoke/ is preview-specific, so no spec is skipped and none is weakened. Effort drops to Easy: one workflow file, one doc paragraph, no src/ change.

    A hole the approach now closes. skipWithoutPreview makes every spec skip on an empty base URL, so a blank-able input would make the new job go green having run nothing — the #132 invariant, re-created one level up. The origin stays a literal.

    AC 4 rested on text that is not on main. The "grep the bundle for ingest" runbook sentence lives only on PR #245's branch. Reworded to hold in either merge order. No Blocked by: — the job is non-vacuous today through the SahajCloud API origin.

    The CF_PAGES_BRANCH simplification moved out of scope: it rewrites reportingEnvironment(), which PR #245 adds, and needs a define: entry vite.config.ts lacks.

    @sydevs-bot implement starts work.

    🤖 Written by the sydevs autonomous loop — see what this is


    Generated by Claude Code

  5. added and removed
    bot:working
    on Oct 2, 2026
  6. Ardnived commented on Oct 2, 2026

    @Ardnived
    Contributor

    @sydevs-bot What would be the value of this? Does the CI check before every merge already cover enough? We don't want to implement an uptime monitor via GitHub Actions, we have other tools for that. Think more carefully and give a breakdown of the actual benefits of this and whether it outweighs the additional potential costs (by using up our Actions quota and increasing load on production) and maintenance burden

  7. added
    bot:working
    and removed
    proposal
    on Oct 2, 2026
  8. sydevs-bot commented on Oct 2, 2026

    @sydevs-bot
    ContributorAuthor

    Measured it. The value is real, the cadence was not — the trigger becomes deployment_status, not a daily cron.

    The PR gate cannot cover this. VITE_* values inline at build time, and Pages builds Preview and Production from separate dashboard environments, so the bundle CI reads can never carry Production's values. boot-origins.smoke.test.ts:11-17 is that hole inverted: VITE_HOST set in Production, unset in Preview, every preview blank, all six specs green.

    Agreed on the uptime monitor. The lane reads deployed file content, which changes only at deploy. A daily cron re-reads an unchanged artifact ~364 times a year and is still up to 24 h late. Cloudflare's deployment status carries the URL (get-cloudflare-preview-url.mjs:674-690), so the run follows the deploy.

    Costs. Actions quota: zero, the repo is public. Production load: 13 GETs per deploy, all CDN edge. Maintenance: one file, contents: read, no credential, shared specs.

    Body updated: cost section, trigger, criteria, checklist. @sydevs-bot implement starts it.

    🤖 Written by the sydevs autonomous loop — see what this is


    Generated by Claude Code

  9. added and removed
    bot:working
    on Oct 2, 2026
  10. Ardnived commented on Oct 3, 2026

    @Ardnived
    Contributor

    @sydevs-bot implement

  11. added
    bot:working
    and removed
    bot:working
    on Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    Medium

    Hold Until

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions