Design-system CSS metrics count engine-generated CSS as source CSS
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 28/100
Research direction
Start in WordPressSitePlan::uniqueSourceCssBytes(), which currently dedupes compiled CSS assets by source_hash and skips only source: engine-support. The fix moves measurement to the input artifact: sum unique author CSS files and unique inline style blocks, then carry the total in the compiled-site envelope as source_css_bytes. Done means a fixture with per-page copies, shared chrome and editor static state reports the input artifact's unique author CSS bytes, and the Modus ratio falls within 5% of the on-disk measurement. The tagging of generated assets needs a design decision first, so check with the maintainers before starting.
Written by the indexing model from the issue text.
Description
Problem
design_system.metrics.unique_source_css_bytes is supposed to measure the author's captured CSS, with each stylesheet counted once. It currently counts engine-generated CSS as source, so generated_to_source_css_ratio understates how much CSS the theme adds by about 16x.
Evidence (Modus Digital, built from #2966 at 0a89e9f4d)
| Metric | Measured | |
|---|---|---|
| Theme CSS | theme_css_bytes 2,909,287 |
2,762,159 bytes across 123 .css files on disk |
| Author source CSS | unique_source_css_bytes 2,316,551 |
about 134 KB: 128,264 bytes in 4 unique captured stylesheets plus 6,250 bytes in 3 unique inline <style> blocks |
| Ratio | generated_to_source_css_ratio 1.26 |
about 20 |
Root cause
WordPressSitePlan::uniqueSourceCssBytes() adds up the compiled CSS assets, deduplicated by source_hash, and excludes only source: engine-support. Several engine-generated outputs have no engine-support tag and carry their own hash, so each one counts as source:
shared-chrome-*.css(12 files);editor-static-state-*.cssandengine-support-after-author-*.css(27 files);- per-route inline extractions (
blog/*.inline-N.css, 66 files); - per-page stylesheet projections (
styles-*.page-*.css, up to 773 KB each).
Proposal
Measure source CSS from the input artifact before compilation, rather than from compiled assets:
- add up the CSS files, deduplicated by content hash;
- add the inline
<style>blocks, deduplicated by content hash; - carry the total in the compiled-site envelope (for example
source_css_bytes) for the site plan to report.
Engine CSS then becomes theme_css_bytes minus the bytes projected from author CSS. That needs one tag on every generated asset, saying whether it is author-derived or engine-owned.
Acceptance
- On a fixture with per-page copies, shared chrome and editor static state,
unique_source_css_bytesequals the input artifact's unique author CSS bytes. - The Modus import reports a ratio within 5% of the on-disk measurement.
AI disclosure: Claude (Opus) in the Pi coding agent, via Roadie, measured the import and drafted this issue at Chris Huber's direction.
- Dominant language
- PHP
- Stars
- 21
- Forks
- 2
- Avg merge
- 8h 35m
- Merged PRs (30d)
- 659
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Automattic/blocks-engine
-
Solved site promotion gate fails on runner PHP patch drift (expects 8.2.33, runner installs 8.2.34)Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Automattic/blocks-engine#2161 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Automattic/blocks-engine#2061 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Automattic/blocks-engine#1701 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Automattic/blocks-engine#775 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
Automattic/blocks-engine#3024 · 1 comment ·
Maintainers usually reply within 1 day
All issues in Automattic/blocks-engine
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
opnsense/core#11052 · 1 comment ·
Maintainers usually reply within 1 day
-
needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
grokability/snipe-it#19857 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
Maintainers usually reply within 1 day