Skip to content

chore(build): add audit gate, size budget, and embed smoke tests #99

Closed

Description

@Ardnived

Summary

CI (.github/workflows/ci.yml) gates lint + typecheck + test:run + build + ladle:build — but the release-readiness review found three blind spots that let real regressions accumulate silently, plus one EOL runtime:

  1. No dependency-vulnerability scan. pnpm audit --prod currently reports 64 vulnerabilities — 1 critical ([email protected] prototype pollution), 23 high ([email protected] ×7, [email protected] ×15 among them). This accumulated with every gate green, because nothing in CI ever ran an audit (.claude/reports/RELEASE_READINESS.md §3.6, §4, ship-blocker chore(claude): add Claude Code config + harmonize lint/format/typecheck #3).
  2. No bundle-size budget. The eager payload grew to 477 KiB gzipped (entry + all modulepreloads in dist/index.html), ~3–5× a reasonable third-party-embed budget, unnoticed — and embed.js emits zero modulepreload hints, so the embed's true graph is invisible to any check that only looks at index.html (§1.1, §1.6 item 6).
  3. The smoke lane never exercises the embed, and can silently no-op. Both existing specs (tests/smoke/root.smoke.test.ts, tests/smoke/spa-fallback.smoke.test.ts) fetch the standalone page only (asserting id="syatlas" and the <title>); embed.js and <sahaj-atlas> — the actual product a host installs — are never smoke-tested. And the smoke job skips silently: the run step is gated if: ${{ steps.preview.outputs.preview_url != '' }} and the specs use test.skipIf(skipWithoutPreview) (tests/smoke/_helpers/preview.ts), so a green "Smoke" check can mean "nothing ran" (§4; Appendix D "Smoke lane" row).

Separately, the two Accent translation workflows run an EOL runtime: actions/checkout@v3 + actions/setup-node@v3 + node-version: 16 (.github/workflows/sync-accent.yml:21-24, .github/workflows/push-accent.yml:12-15; Appendix D).

Proposed changes

  1. Audit gate. Add a dependency-vulnerability scan — e.g. pnpm audit --prod --audit-level high as a CI step, or a scheduled reporting workflow. The implementer weighs the tradeoff and writes it down in the workflow file: a hard PR gate flakes when a new upstream advisory lands mid-PR; a scheduled report can't block a regression. Sequencing note: the audit is red today — a hard gate can only land green after the sibling dependency-update ticket resolves the current findings (or with an explicit baseline/allowlist). Either way, the end state is: a new high/critical advisory becomes visible, never silent.
  2. Size-budget check. A script (new file under scripts/) that measures the eager payload from a production build, matching how the readiness report measured: (a) the entry + every modulepreload chunk referenced by dist/index.html, gzipped; and (b) embed.js + its static import graph, gzipped (it has no modulepreloads to enumerate — walk its imports). Fail CI when over a committed budget, set with headroom above the current ~477 KiB so this ticket doesn't block on the separate perf work — the budget's job is to catch unnoticed growth, and it gets ratcheted down as the lazy-loading ticket lands.
  3. Embed smoke spec. A new tests/smoke/embed.smoke.test.ts that fetches /embed.js from the preview and asserts: HTTP 200, non-empty body, and the body contains customElements.define (the widget registration — src/Widget.tsx). Fetch-level is the floor (the smoke lane is fetch-based by design — see .claude/rules/tests.md); a browser-level boot of <sahaj-atlas> is a stretch goal, noted but not required (the repo's Playwright MCP covers local verification, not CI).
  4. Loud smoke skip. When no preview URL is discovered, the smoke job must not read as a plain green pass: emit a workflow annotation (::warning::) + a $GITHUB_STEP_SUMMARY line at minimum, and consider failing outright when the PR is same-repo (secrets present, so a missing preview means the Cloudflare deploy itself failed). The invariant: a green Smoke check implies the specs actually ran. Keep the graceful skip for forked PRs and local runs.
  5. Accent workflow runtime bump. actions/checkout@v3 → v4, actions/setup-node@v3 → v4, node-version: 16 → 22 in sync-accent.yml + push-accent.yml — and nothing else. CLAUDE.md says to leave the accent workflows alone unless the task is about them; this task is exactly (and only) their runtime, so the diff is version lines only, no logic changes.
  6. Stretch (optional): an automated axe-core a11y pass over the Ladle stories (§5 / Appendix C note "No axe/automated a11y in CI or Ladle"). Skip if it balloons the ticket.

Acceptance criteria

  • A dependency-vulnerability scan exists (CI step or scheduled workflow); a new high/critical advisory produces a failed check, a neutral-but-visible outcome, or a report — never a silent green. The chosen hard-gate vs. scheduled tradeoff is documented in a comment in the workflow file.
  • A size-budget check runs in CI against the production build and fails over budget; it measures both (a) dist/index.html entry + all modulepreload chunks and (b) the embed.js static import graph — each gzipped; the budget value(s) are committed in-repo with headroom above the current eager payload.
  • A smoke spec fetches /embed.js: asserts 200, non-empty, contains customElements.define; guarded with test.skipIf(skipWithoutPreview) like its siblings.
  • The smoke job's no-preview path is loud: an annotation and/or step-summary entry (or a failure on same-repo PRs) — a green Smoke check now implies specs ran.
  • sync-accent.yml + push-accent.yml run checkout@v4 / setup-node@v4 / Node 22; the diff touches only those version lines.
  • Local behavior preserved: pnpm test:smoke without PREVIEW_URL still skips gracefully; pnpm lint && pnpm typecheck && pnpm test:run pass.
  • (Stretch, optional) axe-core pass over Ladle stories wired into CI.
  • Write an implementation report to .claude/reports/<issue-number>-<short-slug>.md — in the MAIN checkout at /Users/devindra/Documents/Projects/SahajAtlasWeb even when implementing from a worktree (the folder is gitignored) — covering what changed, what was deliberately NOT changed, and which readiness-report findings are resolved.

Files affected

  • .github/workflows/ci.yml — audit step (if gated), size-budget step, loud smoke skip
  • .github/workflows/audit.yml (new, only if the scheduled-report route is chosen)
  • .github/workflows/sync-accent.yml, .github/workflows/push-accent.yml — runtime versions only
  • tests/smoke/embed.smoke.test.ts (new); tests/smoke/_helpers/preview.ts if a helper is needed
  • scripts/check-bundle-size.mjs (new; name at implementer's discretion) + committed budget value(s)
  • package.json — additive script entries only

Parallel implementation: this ticket OWNS the files listed above (.github/workflows/*, tests/smoke/*, new scripts/ files for the size check); sibling release-hardening tickets run concurrently — avoid edits outside owned files except strictly additive ones (e.g. a new package.json script). In particular, the current audit findings themselves belong to the dependency-update sibling; this ticket only builds the gate, and must coordinate its landing order with that fix if hard-gating.

References

  • .claude/reports/RELEASE_READINESS.md §1.1, §1.6 (item 6), §3.6, §4, Appendix D (local, gitignored — main checkout only)
  • .github/workflows/ci.yml — smoke job gated on if: ${{ steps.preview.outputs.preview_url != '' }}
  • tests/smoke/_helpers/preview.ts — skipWithoutPreview
  • vite.config.ts — the widget entry emits embed.js (entryFileNames)
  • .claude/rules/tests.md — the two-lane test contract (smoke lane is fetch-based)
  • Prior art for measuring the eager payload: entry + every modulepreload in dist/index.html, gzipped, measured both ways around a change

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