Skip to content

fix(build): pin smoke discovery to the head commit's deploy #138

Closed

Description

@Ardnived

Summary

The smoke lane can pass having tested a different commit than the one under review. pick() accepts any hostname that is, or ends with, the configured project host — which matches both the per-deploy alias (cad41df8.sahajatlas.pages.dev) and Cloudflare's stable branch alias (fix-i18n-hygiene.sahajatlas.pages.dev). The branch alias points at whatever deployed to that branch most recently, which on a re-push or a queued build is not the PR's head commit.

Found by the security review on #132 and rated High there. It is pre-existing and was an explicit non-goal of that ticket (a timeout fix should not quietly change which URL is trusted), so it was recorded rather than patched.

Why it matters more than it used to

Three gates now lean on this lane meaning something:

All three are weakened by a URL that may not correspond to the commit. A stale-but-healthy preview turns the lane into a check that passes for the wrong artifact — the same class of defect as #99's "status is not a result", one level up.

Current behaviour

  • scripts/get-cloudflare-preview-url.mjs — shortSha (line ~122) is used only to corroborate a Cloudflare bot comment (~line 435). It never constrains which harvested URL pick() returns.
  • pick() (~line 309) matches on hostname suffix alone.
  • The check-run source added in fix(build): find the preview URL on the check run, not just a comment #122 is fetched per-SHA (/commits/<sha>/check-runs), so URLs from that source are already commit-correct — the exposure is the comment and any other source that can surface a branch-scoped URL.

Proposed changes

Verify each point against the current file first; #132 rewrote much of it.

  • Prefer a deploy-specific URL over a branch alias, rather than taking the first match. The per-deploy alias is the one that corresponds to a commit.
  • Where a URL's provenance is already per-SHA (the check run), keep it; where it isn't, either corroborate it against the head SHA or rank it below one that is.
  • Consider asserting the served build actually is the head commit — the smoke lane could check a build-stamped asset rather than trusting the URL's provenance at all. That would close the class rather than this instance, and is worth weighing against its cost.
  • Do not regress chore(build): make preview discovery survive a slow cloudflare deploy #132's status taxonomy or chore(build): add audit gate, size budget, and embed smoke tests #99's hard-fail: a correct URL that is merely slow must still read as pending, not absent.

Acceptance criteria

Files affected

  • scripts/get-cloudflare-preview-url.mjs
  • .claude/rules/tests.md (smoke section)
  • possibly tests/smoke/ and .github/workflows/ci.yml

Parallel implementation: this ticket owns those files. Sibling release-hardening tickets run concurrently; avoid edits outside them.

References

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

    No type

    Fields

    Hold Until

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions