Uh oh!
There was an error while loading. Please reload this page.
test(scripts): pin the published stylesheet banner per subject (#7044) - #7285
Merged
Conversation
Export `defaultHeader` from `scripts/build-plugin-stylesheet.mjs` (previously module-private) and add one per-subject assertion in `plugin-published-stylesheet.test.ts` that the emitted sheet starts with the package's own declared header (`fields`, via `buildOptions.header`) or the shared `defaultHeader(PACKAGE_NAME)` (`plugin-grid`, `plugin-kanban`) when it declares none — reading the expected value from each subject's own build script export, never a second hand-spelled copy. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BGMDbrVa8JjZcCQ7DWYH1b
#7044) The original per-subject assertion recomputed "expected" by calling the same function (defaultHeader, or buildOptions.header) that produced "actual" — so it could never be surprised by a mutation to that function's wording; both sides move together. Add two checks that break that symmetry without a second hand-spelled copy of any wording: - the banner must actually name the subject's own package (mod.PACKAGE_NAME, a plain constant each build script declares independently of defaultHeader) — gives the assembly check teeth against a broken interpolation inside defaultHeader for the two packages that inherit it; - fields' emitted sheet must NOT match the shared default banner — the control for the scenario objectui#7044 named directly: an accidental drop of fields' own header override, which the first check alone cannot see because dropping it moves fields' "expected" and "actual" to the shared default in lockstep. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BGMDbrVa8JjZcCQ7DWYH1b
yinlianghui
marked this pull request as ready for review
September 2, 2026 03:33
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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.
Fixes#7044
What
Three packages ship a supplement stylesheet whose emitted bytes open with a
banner comment that is part of the published artifact (
@object-ui/fields,@object-ui/plugin-grid,@object-ui/plugin-kanban). Nothing in the suiteread that banner, so a change to the shared
defaultHeader, or an accidentaldrop of fields' own per-package
headeroverride, would ship silently — thesecond case being a diff in a published file that #6405's acceptance gate
(byte-identity of the emitted sheet) was explicitly meant to prevent.
This PR:
defaultHeaderfromscripts/build-plugin-stylesheet.mjs(wasmodule-private; one-line change, function body untouched, plus a doc-comment
note on why it's exported now).
scripts/__tests__/plugin-published-stylesheet.test.tsthat the emittedsheet opens with the header the subject is actually configured to use —
its own declared
buildOptions.headerforfields, else the shareddefaultHeader(PACKAGE_NAME)this module now exports forplugin-grid/plugin-kanban— never a second, hand-spelled copy of either wording (theroute ruled out on the issue as the "assertion that inspects nothing"
shape).
Why two checks, not one
The obvious single assertion — recompute "expected" by calling the very
function (
defaultHeader, orbuildOptions.header) that also produced"actual" — is vacuous: since both sides call the same pure function on the
same input, no mutation to that function's own wording can ever make it
disagree with itself. Ablating confirmed this (see Testing below), so the
assertion adds two independent checks that don't have that shape:
expectedHeader, whereexpectedHeaderis read from the subject's ownbuild script export. Catches the header not being prepended at all, or
some unrelated value being used.
subject's own
PACKAGE_NAME— a plain string constant each build scriptdeclares independently, never derived from
defaultHeader. This is whatgives check 1 teeth against a broken interpolation inside
defaultHeaderitself, for the two packages that inherit it.
shared default banner. This is the check that actually catches "an
accidental drop of fields'
headeroverride" — the scenario named in theissue — because dropping it moves fields' "expected" (check 1's fallback)
and "actual" to the shared default in lockstep, so check 1 alone can't see
it.
Testing
Ablation 1 — mutated
defaultHeader()inscripts/build-plugin-stylesheet.mjsto hardcode a wrong package name(breaking its package-name interpolation), confirmed the mutation landed on
disk (
git diff, byte count), reran the suite:Restored the mutated file from
HEAD(git checkout HEADon that one path);git hash-objecton the restored file matched the pre-mutation blob exactly.Ablation 2 — mutated
packages/fields/scripts/build-css.mjsto drop itsheader: HEADER,line frombuildOptions(simulating the exact "accidentaldrop" defect named in the issue), confirmed on disk, reran the suite:
Restored the mutated file from
HEADthe same way;git hash-objectmatchedthe pre-mutation blob exactly.
Byte-identity of the published artifact (objectui#6405's acceptance
gate): built all three subjects' emitted sheets against this branch's
scripts/build-plugin-stylesheet.mjsand, separately, against the pre-PRversion at
64d624ded(temporarily checked out, restored by blob hashafterward). SHA-256 of all three emitted sheets is identical before/after —
the
exportkeyword and doc-comment addition change zero published bytes.Scope
Touches only
scripts/build-plugin-stylesheet.mjs(the one-lineexport+a doc-comment) and
scripts/__tests__/plugin-published-stylesheet.test.ts.The three
build-css.mjsconsumers are untouched in the committed diff (theywere only mutated transiently, on disk, during the two ablations above, and
restored by verified blob hash — never part of any commit).
No changeset: scripts-only diff, nothing published moves.
🤖 Generated with Claude Code
https://claude.ai/code/session_01BGMDbrVa8JjZcCQ7DWYH1b