Skip to content

feat(core): log one line of font counts per compile - #9045

Merged
jrusso1020 merged 2 commits into
mainfrom
feat/font-compile-summary
Nov 29, 2026
Merged

jrusso1020 merged 2 commits into
mainfrom
feat/font-compile-summary

Conversation

@jrusso1020

@jrusso1020 jrusso1020 commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

What

A compile that resolves fonts now writes one info line with counts of what happened: families resolved, stylesheet lookups and font files served from the cache or fetched, and how many failed.

Why

Today a compile says which family it fetched and warns when a family has no mapping, but nothing adds it up, and one case writes nothing at all: a shipped family that kept only its shipped faces because the extra ones could not be fetched. One line per compile makes cache hit rate and fetch failures countable from logs.

Related work

None.

How

summarizeFontDiagnostics turns the record the resolver already keeps into name=value pairs, and injectDeterministicFontFaces logs it once after resolution, including when the compile stops on a font error. A page that asks for no font writes no line.

Test plan

  • Unit tests added/updated
  • Manual testing performed
  • Documentation updated (if applicable)
  • Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug

Run: the 9 new tests and the whole packages/core suite (364 files, 7,586 tests) pass locally. Not run: the producer and CLI suites, and no real render.

No visible change

Logging only. No studio or player file changes, and rendered output is the same.

Claude Fable 5.2

The line

[Compiler] font_resolution mode=open families=3 resolved=3 unresolved_required=0 unresolved_optional=0 bundled_faces_only=1 css_lookups=3 css_cache_hit=0 css_failed=1 files=6 files_cache_hit=0 files_fetched=6 files_failed=0 files_errored=0
  • mode: closed when the compile requires every font, else open.
  • bundled_faces_only: resolved shipped families where no extra-face lookup produced a usable file.
  • css_cache_hit: lookups answered from memory or disk. css_failed: lookups with no response or a non-2xx status.
  • files_*: font files named by those lookups, split by cache hit, fetched, and failed.

The line holds numbers and the mode only. It never carries a family name, an address or page text; a test asserts its exact shape.

Self-review

  1. Siblings: injectDeterministicFontFaces is the only entry that creates the record, so every caller gets the line. Existing log lines and the error contract are untouched; the existing diagnostics tests pass unchanged.
  2. Failure paths: the line is written in a finally, so it appears once when resolution throws (test: "is written once when a compile that requires every font stops on an unresolved one"). The summary is pure arithmetic over an in-memory record and cannot throw on its own input.
  3. Races: none added. Each compile owns its record; concurrent compiles sharing one lookup each count their own attempt, as the existing diagnostics tests cover.
  4. Trust: the record is typed enums, counts and statuses; no free-form field reaches the line. Test "holds numbers and a mode only" uses a sentinel family name and page text and checks neither appears.
  5. Tests prove it: with the two source files reverted, 8 of the 9 new tests fail (the other asserts that a page with no font writes no line). A file fetch that rejects is counted as files_errored, and the test helper asserts on every line that files equals the sum of its four outcome fields; a caller cancel is the one case with no outcome recorded. They run in the default core suite.
  6. Rollout: additive log line at info level. No stored data, config or API change. Anything parsing compiler logs by prefix sees one new prefix.
  7. Happy path: cold then warm compile of the same page in the test shows fetched files first, cache hits second. No real render was run.

🤖 Generated with Claude Code

A compile that resolves fonts now writes a single info line with how many
families it resolved, how many stylesheet lookups and font files came from
the cache or the network, and how many failed. It also counts a shipped
family that kept only its shipped faces because the extra ones could not
be fetched, which wrote nothing before. The line holds numbers and the
fetch mode only: no family name, address or page text.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@jrusso1020 jrusso1020 added the needs-jerrai-review Request a review from Jerrai. Removed after the review posts; re-add to request another. label Nov 28, 2026

@jerry-heygen jerry-heygen left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested at 2992b491. The new files_failed counter misses font-file fetches that throw. In packages/core/src/fonts/deterministicFonts.ts:1498, the WOFF2 lookup increments total up front, but only a returned non-OK response increments nonOk at line 1519. A network rejection in open mode returns null without incrementing a failure counter; in closed mode, an exhausted retry throws before that counter too. A compile with one such failed file can log files=1 files_failed=0, undercounting the outages this line is meant to make visible.

Count terminal lookup errors separately from HTTP statuses and include them in the summary. Preserve cancellation and retry behavior, and add a regression for a fetch that rejects rather than returning a 404. Hosted CI was still running when inspected; I did not run a live render.

— Jerrai (pr-review)

@jerry-heygen jerry-heygen removed the needs-jerrai-review Request a review from Jerrai. Removed after the review posts; re-add to request another. label Nov 28, 2026
A file fetch that rejected was counted in files but in no outcome
field. Count it per attempt and write it as files_errored, so files
always equals the sum of its outcome fields.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@jrusso1020 jrusso1020 added the needs-jerrai-review Request a review from Jerrai. Removed after the review posts; re-add to request another. label Nov 28, 2026

@jerry-heygen jerry-heygen left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at e4c93093. A font-file lookup that throws now increments files_errored, separately from the HTTP failures in files_failed. The new regressions cover a rejected fetch in open and closed mode, and the summary tests check that each file lookup has one counted outcome in the cases they exercise. The fix preserves the caller-abort check and the closed-mode error path.

To count file failures across both categories, use files_failed + files_errored. The hosted core suite had not completed when I checked; I did not run a live render.

— Jerrai (pr-review)

@jerry-heygen jerry-heygen removed the needs-jerrai-review Request a review from Jerrai. Removed after the review posts; re-add to request another. label Nov 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 275 (base branch 273), smooth 66 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Newly passing (2)

  • seqscaletwice-scale-px-r0-root-z100
  • seqscaletwice-scale-px-r0-nested-z100

Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)

  • seqscaletwice-scale-px-r0-root-z100
  • seqscaletwice-scale-px-r0-nested-z100

Quarantined, measured but not gated (0)

@jrusso1020
jrusso1020 enabled auto-merge November 28, 2026 23:45
@jrusso1020
jrusso1020 added this pull request to the merge queue Nov 28, 2026
Merged via the queue into main with commit 569be91 Nov 29, 2026
103 of 104 checks passed
@jrusso1020
jrusso1020 deleted the feat/font-compile-summary branch November 29, 2026 00:06
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.

2 participants