Skip to content

chore(build): add a package version and a changelog - #143

Merged
Ardnived merged 7 commits into
mainfrom
chore/versioned-embed-changelog
Aug 11, 2026
Merged

Ardnived merged 7 commits into
mainfrom
chore/versioned-embed-changelog

Conversation

@Ardnived

@Ardnived Ardnived commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

package.json was version: "0.1" — not valid semver, never bumped — and there was no changelog, so nothing recorded what an embedding site could observe changing under them.

This adds a real version and CHANGELOG.md. It deliberately does not add a versioned embed path or a release process.

Scope reduced after review

The first draft emitted v<major>/embed.js beside embed.js and shipped a docs/releasing.md. That was dropped on the owner's call, and the reasoning holds up: SahajAtlas deploys evergreen — main ships to sahajatlas.com almost daily, hosts embed from that server rather than consuming a package, and every channel would have served the current build regardless. So a versioned path buys no isolation; it only creates endpoints to keep alive and client sites to chase onto new markup.

Removed in 19916ea: scripts/emit-versioned-entry.{mjs,test.ts}, its vite.config.ts registration, docs/releasing.md, the public/_headers note, and the smoke and documentation coverage for a second entry. The build output is byte-for-byte what it was before this PR — dist/ contains embed.js and no v0/.

What lands

  • package.json 0.1 → 0.9.0 — valid semver, so the changelog has something to organise entries under.
  • CHANGELOG.md, seeded from git log rather than invented, covering the ~20 release-hardening tickets that just shipped — several host-visible: CSS scoping, the #anchor fix, noindex, the analytics/geolocation/error-reporting opt-out attributes, add-to-calendar, and a ~100 KiB payload reduction.

The changelog states the deployment model up front, so the version is not mistaken for a pin:

Deployment is evergreen and there is no release process. main deploys to sahajatlas.com, roughly daily, and every embed serves that build — hosts embed from our server rather than consuming a package, so there is nothing for them to upgrade and no version for them to pin. package.json carries a version so this file has something to organise entries under; it is a marker, not a contract.

Verification

Lint, typecheck, 991 tests, production build with the CSS-scope assertion (1,145 rules confined), and pnpm size at 370.0 / 371.8 KiB against the 395 budget. dist/v0/ confirmed absent.

Review coverage

/simplify completed on the original scope. /code-review and /security-review never ran — the implementing agent stalled while dispatching them. The scope reduction has since removed every non-documentation file from the diff, so what remains is CHANGELOG.md and a version string; the build config, scripts and smoke specs the reviews would have covered are no longer part of this change.

Closes #94

Ardnived and others added 5 commits August 7, 2026 21:13
`embed.js` is unhashed and mutable, so every deploy silently upgrades every
host and a breaking change cannot be staged. Emit the same entry to
`v<major>/embed.js` from the same build, with its `./assets/*` specifiers
rebased one directory up, so a host can install a path whose major cannot
change under them. `embed.js` is byte-identical and existing embeds are
untouched.

Not a shim importing `../embed.js`: that would execute the very mutable file
the host pinned away from. Not a second rolldown input: duplicate inputs
dedupe, which would turn `embed.js` into a thin re-export and cost every
existing host a round trip. A copy shares the hashed chunks, so the extra
deploy weight is one ~6 KB file.

Also adopts real semver — `0.1` was never valid and never bumped.

Refs #94

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Both halves fail invisibly. A wrong channel name publishes a path nobody
agreed to; a specifier wrong by one directory 404s the whole payload — and
`_redirects` answers that 404 with the SPA shell at 200, so it does not even
look like a failure. Neither moves a byte, so `pnpm size` and `pnpm build`
stay green through both.

Unit specs pin `channelFor` (including the historical `"0.1"`, which
`parseInt` would have turned into a confident `v0`) and `rebaseSpecifiers`
(only bundled files are rewritten; anything else is reported so the build
fails rather than shipping one dead import).

Smoke specs assert the deployed channel on content type and body, never
status, and pin that it names the same chunks as the mutable entry — one
build, two entry paths. The channel comes from the same `channelFor` the
build uses, so a version bump cannot leave the spec proving the old path.

Refs #94

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Seeds CHANGELOG.md from what has actually shipped — read off the commit
range, not invented — and writes down the release contract: what `embed.js`
and `v<major>/embed.js` each promise, the pin-vs-latest tradeoff, rollback,
and the cache-skew failure mode with the part that is genuinely not solved.

Three things it refuses to overclaim. No URL this repo publishes can pin a
BUILD — Pages serves one deployment at a time, so real immutability needs
artifact hosting, named as a future option rather than implied. `v0` carries
no compatibility promise, because semver 0.x does not, so hosts are told to
install `/embed.js` today. And the Cloudflare dashboard actions are listed as
an unchecked list, so merging this cannot be mistaken for doing them.

Refs #94

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
CLAUDE.md gains a Releasing section (the two URLs, the plugin's ordering
requirement, the LEGACY_CHANNELS rule, and that no path here pins a BUILD);
the tests rule records why the channel needs a smoke spec at all — the copy
differs from embed.js only by a rebase, so a wrong one is byte-for-byte
invisible to build and size and shows up only as a fetch nothing local makes.

README gets a strictly additive Versioning section. Its quickstart snippet is
still wrong on two counts predating this branch (`sahaj-atlas.js` should be
`embed.js`, `apikey` should be `api-key`); that is #93's integrator guide to
fix, and this section moves into it when it lands.

Refs #94

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Four findings applied, plus a documentation claim the review exposed as false.

- The ordering guard asked flattenEntryImports' own `flattenedImports().missing`
  instead of re-deriving it from `importClosure`. Two copies of "declares its
  whole closure" would drift the moment the flattener narrowed what it appends
  — and this copy's failure mode is erroring every build with a diagnosis
  pointing at plugin ordering that is already correct.
- Dropped `rebaseSpecifiers`' `depth` parameter. Nothing can vary it: channels
  are one segment and the smoke spec would fail a deeper one. Fixed `../`.
- Hoisted the rebase out of the channel loop — it is invariant, and the loop
  should read as "same bytes, N paths".
- Smoke lane: one shared specifier regex and one `new URL` resolver instead of
  two of each, and a memo over every URL. The new specs had bypassed the memo
  `fetchEmbed` documents, taking the file from 24 to 40 round trips for one URL
  it had never fetched. The 12-chunk loop is gone: it re-fetched a strict subset
  of the crawl above it, and normalized the path before fetching, so it could not
  test the rebase it was written for. The textual assertions can, and do.

LEGACY_CHANNELS became OLDEST_SUPPORTED_MAJOR, a floor. Every major from it to
the current one is emitted, so a release cannot drop a channel by forgetting —
the failure direction is ~5.6 KB of dead weight instead of a pinned host's
widget vanishing behind an SPA shell served at 200. The smoke lane asserts every
channel the floor implies, so it is a gate rather than a comment.

The doc fix: I had written that `v1/` "keeps serving code the v1 hosts can run".
It does not. Every channel serves the current build, so the versioned path is a
DECLARATION of the major a host integrated against, not a code freeze. Corrected
in releasing.md, CLAUDE.md, CHANGELOG.md and README.md, with the freeze named as
the deliberate ops act it would have to be.

Refs #94

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas with  Cloudflare Pages  Cloudflare Pages

Latest commit: 19916ea
Status: ✅  Deploy successful!
Preview URL: https://c21c7fcc.sahajatlas.pages.dev
Branch Preview URL: https://chore-versioned-embed-change.sahajatlas.pages.dev

View logs

Ardnived and others added 2 commits August 11, 2026 09:21
The owner's call, and the right one: SahajAtlas deploys evergreen. main
ships to sahajatlas.com almost daily, hosts embed from that server rather
than consuming a package, and every channel would have served the current
build anyway. So a v<major>/embed.js path buys no isolation — it only
creates endpoints to keep alive and clients to chase onto new markup.

Removed: scripts/emit-versioned-entry.{mjs,test.ts}, its vite.config
registration, docs/releasing.md, the _headers note about the versioned
path, and the smoke/doc coverage for a second entry.

Kept: a real semver version in package.json (0.1 was not valid semver)
and CHANGELOG.md, rewritten for an evergreen embed — the version is a
marker to organise entries under, not a contract a host can pin to.

Closes #94

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@Ardnived Ardnived changed the title chore(build): version the embed bundle and add a changelog chore(build): add a package version and a changelog Aug 11, 2026
@Ardnived
Ardnived merged commit 64ddacf into main Aug 11, 2026
5 checks passed
@Ardnived
Ardnived deleted the chore/versioned-embed-changelog branch August 11, 2026 16:27
Ardnived added a commit that referenced this pull request Aug 11, 2026
* chore(build): upload sentry source maps, then delete them before deploy

`vite.config.ts` set no `build.sourcemap`, so the default (`false`) applied and
the build emitted no maps at all — every production frame from #108's telemetry
pointed into a minified chunk. This is not "maps that weren't uploaded".

Maps are now emitted as `'hidden'` (written, but no `sourceMappingURL` comment
advertises them), uploaded by `@sentry/vite-plugin`, and deleted before the
output is deployed. They must never reach `dist/`: `public/_headers` serves
`/assets/*` CORS-open with a one-year immutable cache, so a shipped `.map` is an
irrevocable publication of this repo's source from a host page we don't own.

Both halves are gated on `SENTRY_AUTH_TOKEN`, the plugin AND `build.sourcemap`,
so a build that cannot upload does not write maps at all. Local builds, CI, forks
and `pnpm ladle:build` (which uses its own vite config) are byte-identical to
before — measured: 370.0/371.8 KiB on both graphs, unchanged.

`pnpm assert:maps` is the guarantee rather than the intention, per the
`assert:css` precedent. It fails on a surviving `.map` AND on any
`sourceMappingURL`, because `sourcemap: 'inline'` would embed every original
source in the shipped JS while emitting no `.map` file for the first check to
find. Verified against a real dist: it catches all 24 maps and exits 1.

Two plugin defaults are overridden because they reach out of the widget.
`release.inject` would write `window.SENTRY_RELEASE` onto the HOST page — the
exact hazard #108 refused in the other direction — and `telemetry` posts build
data from inside the deploy's critical path. `create`/`finalize`/`setCommits` are
all off too: `create: false` alone still ran `sentry-cli releases finalize`,
which needs scope we don't want to grant and whose failure would be reported as
a failed map upload.

An upload failure is loud but non-fatal. This widget deploys evergreen, and a
bug fix should not be blocked by a telemetry outage — availability may degrade
the diagnostics, never the safety, which is why `assert:maps` still fails the
build if the maps are the thing left behind.

Refs #130

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* test(report): pin debug_meta through the event scrub

Symbolication needs a release OR a debug ID to match a frame to a map. `release`
stays `undefined` — #108 pinned it because the SDK's default reads the HOST
page's `window.SENTRY_RELEASE`, and #143 settled that this repo's version is "a
marker, not a contract" for an evergreen deploy, so it is the wrong identity
anyway. Debug IDs are per-build and need no release, which keeps that hazard
shut; `vite.config.ts` blocks the plugin from injecting the global in reverse.

That makes `debug_meta` load-bearing, and it sits one deletion away from gone.
`prepareEvent` fills it from the injected debug IDs BEFORE `beforeSend` runs
(verified in @sentry/core 10.69.0: `applyDebugIds` then `applyDebugMeta`, then
`processBeforeSend`), and our hook survives only because it is a delete-list —
the docblock beside it says "allowlist", and making that literally true would
un-symbolicate every frame with the upload, the deletion gate and every other
check still green.

So it is a spec, not a comment. Mutation-tested: adding `delete event.debug_meta`
turns it red.

Refs #130

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* docs: record the source-map upload and its dashboard runbook

The repo half and the dashboard half are documented separately on purpose, so
merging this cannot be mistaken for completing it — the same care #143 took with
its own unchecked list. Until the three variables are set on the `sahajatlas`
Pages project, the build behaves exactly as it did before.

environment.md gains the three build-time variables and the runbook: which Pages
project (not `sahajatlas-design`, which builds through .ladle/vite.config.ts and
cannot run the plugin — verified, not assumed), which environments, why all three
or none, and the one criterion the repo cannot check for itself.

CLAUDE.md records why the `_headers` rule it already documents is what makes a
shipped map irrecoverable, and the size gate's new blind spot: the plugin only
runs on a credentialed build, so CI measures ~2.1 KiB less than production ships.

Refs #130

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(build): stop the sentry config guard from bricking dev and preview

H2, plus the vite.config comments review found asserting things the code does
not do.

**H2.** `vite.config.ts` is evaluated for EVERY Vite command, not just builds, so
the half-config throw fired on `vite dev` and `vite preview` too — both died with
"failed to load config". A contributor with an ambient SENTRY_AUTH_TOKEN from any
other Sentry-instrumented project could not start the dev server, and the error
talked about uploading source maps on a command that uploads nothing. The
justification for that throw — a deploy going green with every frame minified —
exists only for `command === 'build'`, so the config is now a function of
`{ command }`. Verified three ways: dev starts, preview starts, and a build with
a token but no org still fails loudly.

**M1.** The `errorHandler` comment named the wrong hazard and understated what
passing the handler disarms. `handleRecoverableError` only rethrows in the branch
where no handler was supplied, so supplying one also downgrades a failed
`deleteArtifacts()` — called with `throwByDefault: true` — from "fail the build"
to "log and exit 0, maps still on disk". THAT is the one path by which a map
could reach dist, and the real reason `assert:maps` exists. The converse is now
stated too: the gate cannot backstop a failed UPLOAD, because deletion runs in
`writeBundle`'s `finally` regardless.

**M2.** The docblock refused `release.inject` on the grounds that it writes a
host-page global while silently accepting two of our own. Debug-ID injection
writes `window._sentryDebugIds` and `_sentryDebugIdIdentifier` at module
evaluation. Recorded, with why they are accepted where SENTRY_RELEASE is not:
there is no option keeping debug-ID upload without injection, the map is additive
and stack-keyed so it cannot displace a host's entries, and nothing reads the
identifier at runtime.

**L1.** "Last:" described the array position, not the behaviour — the plugin
returns `enforce: 'pre'`, so Vite hoists it ahead of everything above regardless.
What makes it safe is the phase: it reads off disk in `writeBundle`.

**L2.** `/assets/*` is not the whole story — `embed.js.map` sits at the dist root,
outside that CORS+immutable rule. Still a disclosure, just a recallable one.

**L3.** Notes that the absolute delete glob is exposed to glob metacharacters in
the checkout path, and that `assert:maps` is the mitigation rather than escaping.

Refs #130

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(build): gate the ladle output too, and grep it for the auth token

H1 said the gate's docblock claimed "CI and both Cloudflare Pages builds gate on
it" when `sahajatlas-design` builds `pnpm ladle:build`, which never runs
`pnpm build`. The security review independently reached the same file from the
other direction: the gate is `dist`-only while `public/_headers` is copied into
BOTH outputs, so a map in `build/` would be served under the same CORS-open,
year-immutable rule.

So the claim is made TRUE rather than deleted. The output directory is now an
argument and `ladle:build` passes `../build` — 146 files scanned there. Latent
today (Ladle builds through `.ladle/vite.config.ts`, which loads neither our
`build.sourcemap` nor the plugin), but Ladle stories import the app's real `src/`
tree, so anyone adding `sourcemap: true` to debug a story would have shipped it
with no gate anywhere in the pipeline.

Also from the security review: `assert:maps` now greps every emitted file for the
value of SENTRY_AUTH_TOKEN when one is set. Vite cannot inline a variable without
a `VITE_` prefix so this should be unreachable, but "should be" is what this file
exists to replace, and it makes environment.md's claim that the output is grepped
a gate rather than a habit. Costs nothing uncredentialed; an empty-string token
(a declared-but-blank Cloudflare variable) is specced not to match every file.

L4: the sourceMappingURL failure text said `build.sourcemap` must change, which is
the wrong instruction when the cause is a dependency embedding the literal string
— ordinary content in stack-trace libraries. It now names both causes and says to
exempt the file by name rather than weaken the check.

Refs #130

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* docs(report): describe the event scrub as the delete-list it is

M3. The `beforeSend` docblock opened "An allowlist, not a blocklist — the event is
rebuilt from what we know we put on it" four lines above
`delete event.user / extra / contexts / breadcrumbs`. My previous commit annotated
the discrepancy and left it standing, which is not a fix: a false claim that has
been noticed is still the claim a future reader acts on. It also matters more than
usual here, because that delete-list IS the only reason `debug_meta` survives to
symbolicate anything.

Rewritten to say what the code does, name a true allowlist as the stronger form
still worth having, and say why it is not attempted here — enumerating the fields
an event legitimately needs is a change to the seam deserving its own ticket, not
a drive-by on a build-plumbing PR. Whoever does it is told to carry `debug_meta`
across.

The spec is strengthened the way review asked, as far as the SDK allows. Driving
the real `applyDebugIds`/`applyDebugMeta` is not possible without a deep import
into `build/esm/utils/` — `@sentry/core`'s exports map offers only `.`, `./server`
and `./browser` — which is the library-internals coupling the tests rule forbids.
So the fixture is typed as `NonNullable<Event['debug_meta']>` instead: a delete-
list returns any key you hand it, so an invented fixture would pass even for a
misspelled field, and binding it to the SDK's own type means a rename fails
typecheck.

Refs #130

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* ci(build): prove the credentialed map chain offline, and ignore the token file

Two findings that both amount to "the dangerous path is the untested one".

**L5.** Every CI step runs the UNcredentialed path, because CI has no token — so
the first machine ever to execute map emission, deletion and the gate together
was Cloudflare, on a production deploy. The new step builds with a dummy token
against a closed port: the upload fails immediately and nothing leaves the
runner, while everything around it is asserted — maps are emitted under a token,
`errorHandler` keeps the failure non-fatal, deletion still runs in `writeBundle`'s
`finally`, and `assert:maps` proves dist is clean. The token is a literal rather
than a secret so this keeps working on forked PRs.

**Security review, medium.** `.env.sentry-build-plugin` is where Sentry's own
wizard and docs write SENTRY_AUTH_TOKEN, and `@sentry/vite-plugin` reads it at
build time and Object.assign's it over `process.env`. It does not match `*.local`,
so the default filename for a real secret was tracked in a public repo. The
security-scan hook carries a SENTRY_AUTH_TOKEN pattern but only fires on
agent-run git commands, not a human's terminal.

Running that dry run locally also confirmed the runbook correction in the next
commit: the upload really is `sourcemaps upload -p <project> --release <sha>`,
release-scoped, even with all four release actions off.

Refs #130

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* docs: correct the token scopes and name the budget ratchet hazard

**Security review, medium — the runbook was wrong in a way that fails silently.**
It said the token "does not need release-write scope" because the plugin sets
`create`/`finalize`/`setCommits` to false. Those switch off the extra release
CALLS, but the upload command itself is still release-scoped — observed in a real
build log as `sourcemaps upload -p <project> --release <sha>`, because the plugin
infers a release name from git regardless. An under-scoped token 403s,
`errorHandler` logs it, the deploy goes green and production ships minified
forever: the exact state #130 exists to end, reached through its own runbook. Now
names `project:releases` + `org:read`, says to confirm against Sentry's docs, and
says to read the first credentialed build log rather than assume.

**M2, second half.** The ~2.1 KiB under-measurement was reported but its
consequence was not: CLAUDE.md treats the size budget as a ratchet to lower
whenever the payload shrinks, and lowering `BUDGET_KIB` to within 2.1 KiB of the
CI number would make the PRODUCTION build fail a gate CI cannot reproduce. Stated
as a constraint on that ratchet.

CLAUDE.md also gains the corrected errorHandler story (deletion, not upload, is
the path the gate closes) and the new offline dry-run step.

Refs #130

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(build): version the embed bundle and add a changelog

1 participant