Skip to content

Preserve inline geometry in generated block assets#593

Merged
chubes4 merged 2 commits into
trunkfrom
cook/issue-591-geometry-drift-v2
Jul 13, 2026
Merged

Preserve inline geometry in generated block assets#593
chubes4 merged 2 commits into
trunkfrom
cook/issue-591-geometry-drift-v2

Conversation

@chubes4

@chubes4 chubes4 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Preserve inline geometry that core block supports cannot represent by emitting deterministic carrier classes and generated CSS assets.
  • Keep native block-owned geometry native, including spacer height and canonical button widths, while retaining unsupported min/max dimensions, aspect ratio, flex basis, and important declarations.
  • Add a separate geometry-v2 parity signal without changing the existing v1 score contract.

Fixes #591. Related to Automattic/static-site-importer#489.

Root cause

The transformer dropped inline geometry properties that were not mapped to native block supports. The first carrier implementation also exposed three correctness constraints that this PR now handles explicitly:

  • Artifact compilation must publish generated carrier CSS even when author stylesheet materialization is disabled.
  • Extracted declarations must preserve inline cascade behavior, including !important and element-local custom properties.
  • Carrier allocation and retention must remain deterministic across large documents without orphaned or colliding rules.

Implementation

  • Allocate collision-safe deterministic carrier classes from structural element identity and declaration signatures.
  • Retain only carrier rules referenced by final serialized block markup.
  • Emit generated geometry as a primary artifact asset before authored stylesheet assets.
  • Preserve source-important geometry inline and resolve local/transitive custom properties in geometry parity checks.
  • Keep native ownership boundaries narrow: spacer owns height; recognized core/button output owns canonical percentage widths.

The implementation is generic and contains no fixture-specific selectors or site overrides.

Evidence

Using the same static-style-parity-probes/geometry-v2 property set on a representative inline-geometry fixture:

Revision Geometry score
Baseline (a5b8b58) 0.3333
This PR 1.0000

The fixture covers width, max-width, and aspect ratio. A 200-element stress case produces 200 unique carrier classes and 200 matching rules with byte-identical output across repeated transforms.

The full transformer suite passes with 230 parity fixtures, 75 style/cascade assertions, 8 parity-runner assertions, and package-install proof.

How to test

  1. Run composer --working-dir=php-transformer install --no-interaction.
  2. Run composer --working-dir=php-transformer test.
  3. Run php php-transformer/tests/unit/block-style-support-conversion.php to exercise carrier allocation, cascade, spacer, button, custom-property, and stress regressions.
  4. Run php php-transformer/tests/unit/live-wp-parity-runner.php to verify the unchanged v1 contract and separate geometry-v2 signal.
  5. Compile an artifact containing style="width:30rem;max-width:20rem;aspect-ratio:2 / 1" and confirm its markup references a be-inline-geometry-* class and its materialization plan includes the matching generated CSS asset.

Compatibility

This intentionally changes generated markup and artifact assets for elements whose inline geometry was previously discarded. Consumers of ArtifactCompiler output may observe an additional generated CSS asset and deterministic carrier classes. Existing v1 parity scores and native block-owned geometry remain unchanged.

No extension-specific APIs or fixture-specific behavior are introduced.

Residual risk

Static parity and serialization tests do not replace browser raster validation. Reviewers should validate responsive layouts and complex custom-property fallback expressions on representative imported sites before merge.

AI assistance

  • AI assistance: Yes
  • Tool(s): GPT-5.6 Sol/OpenCode
  • Model: openai/gpt-5.6-sol and openai/gpt-5.6-terra
  • Used for: Drafted the implementation, corrections, regression tests, and independent reviews; Chris reviews and owns the change.

@chubes4 chubes4 merged commit fa23970 into trunk Jul 13, 2026
1 check passed
@chubes4 chubes4 deleted the cook/issue-591-geometry-drift-v2 branch July 13, 2026 21:14
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.

Reduce systemic visual geometry drift across imported fixture layouts

1 participant