Repository navigation
chore(build): add audit gate, size budget, and embed smoke tests - #110
Merged
Merged
Conversation
The embed grew to ~477 KiB gzipped before anyone noticed, because nothing measured it. A per-chunk check would not have caught it either: this build re-chunks freely, so a chunk can shrink while the payload a visitor downloads is unchanged. So the script scores the two eager GRAPHS instead — the standalone shell's entry plus its modulepreload closure, and embed.js's static import graph, walked here because the embed entry emits no preload hints at all. The embed is the product a host installs, and a check that only read index.html would never see its cost. Budgets sit ~3% above today's 479.5 / 480.4 KiB: enough that a patch bump doesn't red an unrelated PR, tight enough that a newly-eager view does. They are one constant, meant to be ratcheted down as #96 lands. Refs #99 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Nothing in CI had ever run an audit, so the lockfile reached 64 advisories — 1 critical, 24 high — with every gate green the whole way. A plain `--audit-level high` cannot fix that from a standing start: it is red on day one and blocks every unrelated PR until the dependency tickets land, or it is loosened until it no longer catches anything. Neither is a gate. So today's findings are pinned in audit-baseline.json, each named with the ticket that owns it, and the check fails on a high/critical advisory that ISN'T pinned — green today, red the day a new one appears. Waiving one costs a reviewable line rather than a silent pass. Two softer states stay out of the PR gate, so a PR is never blocked by something it didn't cause: a baselined advisory since fixed but not pruned, and an audit that couldn't run at all. Both still matter — an unpruned baseline decays into a blanket allowlist, and a broken audit is a green check that checks nothing — so the weekly workflow enforces them with --strict, where a failure interrupts nobody. Refs #99 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Both existing specs fetch the standalone page. The product is the `<sahaj-atlas>` element in embed.js, and nothing exercised it — a deploy that broke the embed while leaving index.html healthy shipped past a green Smoke check. Asserting `customElements.define` and the tag name together, rather than a bare 200, is what distinguishes the real bundle from an SPA-fallback HTML page served with a 200. The second spec walks embed.js's imports and asserts each chunk resolves. embed.js is unhashed and mutable while its chunks are hashed, so a stale copy can request names the CDN no longer serves — a hard 404 with no fallback, and the widget never appears. This catches the deploy-side half of that skew. Refs #99 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…loud The size budget runs after the build; the audit runs as its own job so a dependency finding doesn't read as "Lint, Typecheck & Build" failing, and skips the install because `pnpm audit` resolves from the lockfile alone. The hard-gate-vs-scheduled tradeoff is written down beside the job. The smoke job's no-preview path was the quiet one: discovery exits 0 with an empty URL and the specs skip themselves, so a green "Smoke" check could equally mean nothing ran. Now green implies the specs executed. A same-repo PR has the secrets and the Cloudflare integration, so a missing preview is a failed deploy and fails the job; forks keep the graceful skip, annotated rather than silent. Refs #99 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
checkout@v3 and setup-node@v3 run on a Node 16 runtime GitHub has deprecated, and the jobs themselves ask for node-version 16. Version lines only — six of them. CLAUDE.md says to leave these workflows alone unless the task is about them, and this task is exactly and only their runtime, so the accent-cli invocations, triggers and PR settings are untouched. Refs #99 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Both new gates were writing the step summary and emitting annotations with their own copy of the same two functions, and had already drifted — the audit gate annotated on failure, the size gate only wrote to stderr, so one breach was visible on the run and the other only by unfolding the log. One `_ci-output.mjs` now owns both, and the size gate annotates. Also from the pass: dropped the never-invoked `--print` mode; collapsed the three-times-computed budget delta into one `spare`; replaced four singular/plural branches (one of which had already given up and printed "entr(y/ies)") with plain counts; and made both workflows call the same `pnpm audit:check` alias rather than one going through package.json and the other straight to node. Two guards the pass argued for, both against the same failure: a gate that passes because it measured nothing. The import walker is a regex over minified output, so it now fails when a graph comes back with fewer than two chunks instead of scoring a 2 KiB payload as comfortably under budget; and a graph running >10% under budget says so, since a budget far above the real payload is the green-check-that-checks-nothing this script exists to prevent. The smoke spec fetches embed.js once instead of per test, and HEADs the chunks rather than pulling ~440 KiB of bodies to read status codes — it also now checks every relative .js reference, not only static-import shapes, because a lazy chunk 404ing is the same broken deploy one interaction later. Refs #99 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Both reviews found the same class of defect this ticket was written to remove, in the new gates themselves. The chunk-existence assertion could not fail. `public/_redirects` is `/* /index.html 200`, so Cloudflare serves the SPA shell with a 200 for any path that isn't a built asset — verified against the live deploy, where a made-up chunk name returns 200 text/html. A status check therefore passed for exactly the missing-chunk deploy it was written to catch. It now requires a JavaScript content type. The size budget only caught a TOTAL walker failure. Half-breaking it — one import shape stops matching — shrinks the graph, collapses the total, and reports a comfortable pass on a payload it never measured; the embed graph is the exposed one, since standalone is cross-checked against the HTML's preload list. Running far UNDER budget is now a failure rather than a notice, which also makes the ratchet machine-enforced instead of a comment asking to be read. Simulated: the embed graph scoring 2.1 KiB now exits 1. Also: a rejected or non-200 embed fetch is no longer memoized, because caching it made all three of vitest's retries re-await the same failure instantly — defeating the retry the memo was meant to economise on. And the preview-URL discovery, which this PR turns into a signal CI hard- fails on: `pick()` matched the project by substring, so `evil-sahajatlas.pages.dev` qualified, and comment scanning had no author filter. On a public repo that let anyone who can comment aim the smoke lane at a host they control. Now a hostname match at a label boundary, bot authors only. Refs #99 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
CLAUDE.md and .claude/rules/tests.md described a CI gate that no longer matches, and pr-prep's `--full` claimed to mirror CI while omitting the one new step that needs a build — so the local gate could go green on exactly the change (a new eager import) the budget exists to catch. `--full` now runs `pnpm size` after the build. The tests rule also gains the two smoke-lane invariants, since both were learned by getting them wrong here: a green Smoke check must mean the specs ran, and a 200 proves nothing when `_redirects` serves the SPA shell for every unmatched path. Refs #99 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Deploying sahajatlas-design with
|
| Latest commit: |
a91cd2b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f883ffcf.sahajatlas-design.pages.dev |
| Branch Preview URL: | https://chore-ci-audit-size-smoke.sahajatlas-design.pages.dev |
Deploying sahajatlas with
|
| Latest commit: |
a91cd2b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e0ca79f4.sahajatlas.pages.dev |
| Branch Preview URL: | https://chore-ci-audit-size-smoke.sahajatlas.pages.dev |
Every run since 2026-06-22 failed on EOL Node 16, so the Accent sync was already dead. Bumping it to Node 22 would have re-armed a push-to-main job that inherits repo write access and runs an unpinned global install with ACCENT_API_KEY in scope — reviving unwatched automation to no benefit. Removed rather than upgraded, on the owner's call: the workflows are outdated and no longer in use. accent.json is left in place; it is now orphaned config and can go in a follow-up. Closes #99 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Ardnived
added a commit
that referenced
this pull request
Aug 7, 2026
Two conflicts, both keep-both: - CLAUDE.md — this branch rewrote the Routing row for the two-router mount, main rewrote Build tool + Data in the same table. Kept all three. - src/Widget.tsx — this branch restructured the wrapper (lang, role, the hash/memory branch), #113 added WIDGET_SCOPE_CLASS to its className. Kept the restructure and carried the scope class onto it: without that class the embed renders entirely unstyled. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This was referenced Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #99.
CI gated lint + typecheck + tests + build, and three real regressions accumulated behind that green check anyway: no dependency scan (64 advisories, 1 critical), no size budget (the eager payload reached ~477 KiB gz), and a smoke lane that never touched
embed.jsand could silently no-op. This adds the three missing gates, plus the accent workflows' runtime bump.The theme throughout is that a passing check has to mean something. Two of the gates I wrote initially did not, and the review caught both — see "Gates that didn't check anything" below.
What landed
pnpm sizein thegatejob, afterpnpm buildDependency Auditjob (pnpm audit:check)scripts/audit-baseline.json.github/workflows/audit.yml(--strict)tests/smoke/embed.smoke.test.tsembed.jsis missing, isn't the widget, or references chunks the deploy doesn't serveci.ymlThe size budget measures graphs, not chunks
Per-chunk numbers are meaningless here — the build re-chunks freely, so a chunk can shrink while the payload a visitor downloads is unchanged. It scores two eager graphs, gzipped: the standalone shell's entry + modulepreload closure, and
embed.js's static import graph (walked, because the embed entry emits zero preload hints — a check reading onlyindex.htmlwould never see the product's cost).Measured today: standalone 479.5 KiB, embed 480.4 KiB. Budget: 495 KiB each — one easily-edited constant, ~3% headroom.
Audit gate: hard, but scoped to what's new
The tradeoff, documented in
ci.ymlbeside the job. A plain--audit-level highis red on day one (1 critical + 24 high are already in the lockfile) and would block every unrelated PR until #101/#104 land; a purely scheduled report can't stop a regression and is exactly the check that goes unread — which is how 64 advisories accumulated.So known findings are pinned in
scripts/audit-baseline.json, each naming the ticket that owns it, and the gate fails on anything not pinned. Green today, red the day a new one appears. Waiving costs a reviewable line, not a silent pass.The softer states stay out of the PR gate so no PR is blocked by something it didn't cause — a fixed-but-unpruned entry, or an audit that couldn't run.
audit.yml --strictenforces those weekly, where a failure interrupts nobody.Gates that didn't check anything
Both found in review, both now covered by a reproduction:
public/_redirectsis/* /index.html 200, so Cloudflare returns 200text/htmlfor any path that isn't a built asset — verified live: a made-up chunk name returns 200. A status assertion passed for precisely the missing-chunk deploy it was written to catch. Now content-type checked.Also fixed: a memoized rejection made all three of vitest's smoke retries re-await the same failure instantly, and
pick()in the preview discovery matched the project by substring with no comment-author filter — soevil-sahajatlas.pages.devqualified, and on a public repo anyone who can comment could aim the smoke lane at a host they control. That mattered more once this PR made a missing preview hard-fail. Now a hostname match at a label boundary, bot authors only.Accent workflows — version lines only
checkout@v3→v4,setup-node@v3→v4,node-version: 16→22. Six lines across two files, no logic touched, per CLAUDE.md and the ticket's AC.Verification
pnpm lint,pnpm typecheck,pnpm test:run(577) — green.claude/skills/pr-prep/check.sh --full— green, including the new size steppnpm size→ exit 0; simulated half-broken walker → exit 1 with the diagnosticpnpm audit:check→ exit 0 (0 new, 0 stale); dropping the swiper entry → exit 1; adding a fake entry under--strict→ exit 1pnpm test:smokewith noPREVIEW_URL→ 4 skipped, no networkPREVIEW_URL=https://sahajatlas.pages.dev pnpm test:smoke→ 4 passed against a real deployEventRegister, a static import ofApp), and is unreachable only because every Swiper param inImageCarousel.tsxis a literalNot verifiable until this runs on a PR: the loud-skip path and the annotations, which need real Actions context.
Known gaps, recorded rather than hidden
--prod, matching the readiness report. A full audit reports 8 further high advisories, all in the build toolchain — noted inaudit.ymlwith what widening it would take.audit.yml.Readiness-report findings resolved
§3.6 / blocker #3 (no dependency scan), §1.1 + §1.6 item 6 (no size budget; embed's invisible graph), §4 + Appendix D (smoke lane never tests the embed; can self-skip; accent workflows on EOL Node 16).
🤖 Generated with Claude Code