Skip to content

Restore five spaces Next drops on the home and expansion pages - #264

Merged
MaxGhenis merged 1 commit into
mainfrom
expand-space-src
Nov 14, 2026
Merged

MaxGhenis merged 1 commit into
mainfrom
expand-space-src

Conversation

@MaxGhenis

Copy link
Copy Markdown
Contributor

policybench.org renders five phrases with no space between two words:

Page Live text
/expand "tests 52 frontier modelson 100 households we drew"
/ "Claude Sonnet 5.5reject forced calls"
/ "Ten of the 52 modelsanswer the same facts"
/ "9,128of the snapshot's 9,128 exact-match misses"
/ "max(0, 1 − |pred − ref| / |ref|)when the reference is nonzero"

Next 16.2.6's compiler drops the leading space of a JSX text that spans more than one line and contains an HTML entity (', ’). It keeps the space when the same text sits on one line or has no entity. #262 added the entity to the /expand sentence; the four home-page phrases predate it.

This branch moves each of the five spaces into an explicit {" "}, which the compiler emits as its own child. No word of the copy changes.

This PR takes the page edits from #263, so the fix can go live before the guard test. An independent review of #263 at 782b38f found that the five edits keep every word and punctuation mark and restore one space at each boundary. Its three findings concern the tests, which stay on #263.

Lint, bun test tests and next build passed locally on #263's head, which has the same three source files, and a scan of the 73 built pages found no word running into the next.

🤖 Generated with Claude Code

Next 16.2.6's compiler drops the leading space of a JSX text that spans
more than one line and contains an HTML entity. Five phrases on the home
page and the expansion page lost the space between two words. Each space
moves into an explicit {" "}. No word of the copy changes.

The guard test for this defect is in #263.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
policybench-site Ready Ready Preview Nov 14, 2026 2:11pm UTC

Request Review

@MaxGhenis
MaxGhenis merged commit 4fa7751 into main Nov 14, 2026
5 checks passed
@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Merged at ca78e1d before the independent review, as a one-off, so the five spaces go live. Review pending after merge: the review of this head still runs as Subfleet job 20261114-091037-pb-264-space-src-review-r1, which is waiting for a review lane. A P0 or P1 finding means a revert or a fix within 24 hours. #263 and its guard test stay on the normal rule of review before merge.

@MaxGhenis

Copy link
Copy Markdown
Contributor Author

The independent review of ca78e1d returned no findings (Subfleet job 20261114-091037-pb-264-space-src-review-r1). The reviewer compiled the three changed files with Next 16.2.6 and found one space at each of the five repaired boundaries. None of the 73 built pages contains any of the five broken strings.

MaxGhenis added a commit that referenced this pull request Nov 14, 2026
The spacing guard predicted dropped whitespace from a hand-fitted model of
Next's compiler, and the round-2 review found a shape the model missed: an
encoded space after a line break at the end of a text (`a&apos;\n&#32;`),
which Next drops and TypeScript keeps. The guard now compiles each JSX text
under src/ with Next's SWC and with TypeScript and fails wherever Next shows
no whitespace at a place TypeScript does, or renders other characters, so it
no longer depends on the model. The rule cases gain the reviewer's shape and
still pin the compiler's behavior. SRC now goes through fileURLToPath, so a
checkout path with a space works. Each SWC test gets a 60-second limit.

Against src/ from before #264 the guard names exactly the five lines #264
fixed; on this head all 207 app tests pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis added a commit that referenced this pull request Nov 14, 2026
* Restore the spaces Next drops before multi-line text with an entity

Next 16.2.6's compiler drops the leading space of a JSX text that spans
more than one line and contains an HTML entity, so policybench.org renders
"52 frontier modelson 100 households" on /expand and four run-together
phrases on the home page. An explicit {" "} puts each space back. A new
test applies the compiler's trigger to every page component, and the
expansion-page test no longer reads React's text separators as spaces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Drop the no-op separator strip from the expand page test

The test renders with renderToStaticMarkup, which emits no <!-- -->
separators, so the added .replace(/<!-- -->/g, "") changed nothing and
its comment named the wrong cause. The test never saw the /expand defect
because Bun's transpiler keeps the leading space that Next's compiler
drops. The line returns to what main has; a compiler-backed check for the
five fixed spaces follows in the spacing guard test.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* Check the spacing guard's cases and the five fixed spaces with Next's SWC

The guard's rule cases were checked against Next's compiler only by hand.
The test now loads Next's own SWC binding, compiles each case with it and
with TypeScript, and requires the case to record what Next renders and
whether that drops a space TypeScript keeps. A second check compiles
ExpandCoverageCopy, ModelLeaderboard and Methodology with Next's SWC and
requires whitespace before each of the five phrases policybench.org ran
together. Run against main's three files, it fails on all five and the
guard names the five lines.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* Count only the entities Next's compiler decodes in the spacing guard

The guard's /&(#\d+|#x[0-9a-f]+|[a-z][a-z0-9]*);/i matched any &name;,
so `{x} after\n one&notAnEntity;s` failed it although Next keeps that
space: the compiler leaves unknown names as written and only a decoded
entity triggers the drop. Probing Next 16.2.6's SWC with 2,425 candidate
names (TypeScript's JSX table, the HTML5 names, case variants) showed it
decodes exactly TypeScript's 253 names, case-sensitively, plus decimal
and lowercase-x hex references with at most nine characters between &
and ;. The guard now reads entities that way. A new test compiles every
listed name and a set of near misses and requires the guard to agree with
the compiler on each; rule cases add an unknown name and a miscased one
(space kept, not flagged) and a named, decimal and hex entity (flagged).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* Flag every JSX text whose edge whitespace Next's compiler drops

The guard required a previous sibling and a literal LF, and looked only
at leading spaces, so it passed three shapes Next 16.2.6's SWC mangles:
a text that opens an element (`before<span> after\n one&apos;s</span>`
renders "beforeafter one's"), a lone CR or U+2028 as the line break, and
an encoded line break at a text's edge (`{x}&#10;word\n next` renders
"{x}word next"). Probing the compiler showed two mechanisms. Next deletes
the leading spaces and tabs of a text that has a decoded entity and any
line break, literal or encoded; @swc/core 1.16.22 keeps them. Every SWC
probed also reads an encoded line break as a source line break, so at
either end of a text it vanishes with the whitespace around it, where
TypeScript and Bun keep it. Whitespace the compiler never trims (&#32;,
&nbsp;, a literal no-break space) keeps the words apart in both.

The guard now reads each text as the compiler does and applies both
rules, stated in the test's header. New rule cases cover each shape and
the kept-whitespace exceptions, each compiled with Next's SWC and checked
against TypeScript's output. No text under src/ matches the wider rule,
and against main's files the guard still names exactly the five lines.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* Compare Next's compiler with TypeScript on every JSX text in the guard

The spacing guard predicted dropped whitespace from a hand-fitted model of
Next's compiler, and the round-2 review found a shape the model missed: an
encoded space after a line break at the end of a text (`a&apos;\n&#32;`),
which Next drops and TypeScript keeps. The guard now compiles each JSX text
under src/ with Next's SWC and with TypeScript and fails wherever Next shows
no whitespace at a place TypeScript does, or renders other characters, so it
no longer depends on the model. The rule cases gain the reviewer's shape and
still pin the compiler's behavior. SRC now goes through fileURLToPath, so a
checkout path with a space works. Each SWC test gets a 60-second limit.

Against src/ from before #264 the guard names exactly the five lines #264
fixed; on this head all 207 app tests pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
Preview — ca78e1d9 Deployed Nov 14, 2026 by vercel[bot]
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.

1 participant