Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ Blocks Engine is a collection of tools for generating, transforming, and materia
- [`php-transformer`](php-transformer/) - PHP primitives for converting HTML, Markdown, and generated website artifacts into WordPress-native block outputs.
- [`figma-transformer`](figma-transformer/) - PHP primitives for converting Figma `.fig` archives and Figma-derived scenegraphs into static HTML website artifacts with parity diagnostics.

Artifact compilation also emits the self-contained [`wordpress-site-plan/v2`](docs/contracts/wordpress-site-plan-v2.md) block-theme materialization contract.
Artifact compilation also emits the self-contained [`wordpress-site-plan/v3`](php-transformer/docs/contracts/wordpress-site-plan-v3.md) block-theme materialization contract. See the [contract directory](php-transformer/docs/contracts/) for the current schemas and archived versions.

The [Figma-to-WordPress acceptance matrix](docs/contracts/figma-wordpress-acceptance-matrix-v2.md) consumes that handoff through generic, configurable materialization providers and attributes parity independently across Figma-to-HTML, HTML-to-WordPress, and end-to-end boundaries.
The [Figma-to-WordPress acceptance matrix](php-transformer/docs/contracts/figma-wordpress-acceptance-matrix-v2.md) consumes that handoff through generic, configurable materialization providers and attributes parity independently across Figma-to-HTML, HTML-to-WordPress, and end-to-end boundaries.
14 changes: 7 additions & 7 deletions docs/adr/0005-box-tree-reduction-engine-owned-styles.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Reduce source structure from the captured box tree; ship only engine-owned styles

**Status: Superseded by [#7370](https://github.com/Automattic/blocks-engine/issues/7370).** On eight frozen corpus sites, enabling one box-tree decision family at a time produced no additional passing cells beyond run-to-run noise. With all families enabled, agency, bizcasual, bolt-lumen, replit-zach, sdnunca and base44 fell to zero passing cells (without box trees: 2, 12, 1, 3, 11 and 18–21); dropping author stylesheets alone caused the same collapse. Box-tree consumption is therefore removed entirely; sidecars remain capture-only evidence and capture identity is stripped from output.
**Status: Superseded by [#7370](https://github.com/Automattic/blocks-engine/issues/7370).** On eight frozen corpus sites, enabling one box-tree decision family at a time produced no additional passing cells beyond run-to-run noise. With all families enabled, agency, bizcasual, bolt-lumen, replit-zach, sdnunca and base44 fell to zero passing cells (without box trees: 2, 12, 1, 3, 11 and 18–21); dropping author stylesheets alone caused the same collapse. The decision below is historical: the broad box-tree reduction and engine-only stylesheet pipeline were removed.

**Current behavior:** The compiler reads optional, source-path- and hash-bound `box-tree/**.json` sidecars (v2 and compact v3) on the default path. [ADR 0006](0006-box-tree-evidence-for-wrapper-folding.md) defines the limited wrapper use: per-viewport border boxes and used styles are evidence for guarded wrapper folds, not instructions to reconstruct layout or replace author stylesheets. Separately, the purchase-affordance scan uses the same reader to ignore elements with `display: none` at every captured viewport. Sidecars and capture node IDs are not emitted as theme assets or block identity.

Captured sites become block trees shaped by what the browser rendered, not by the
source markup's nesting. Every wrapper that renders nothing of its own collapses, and
Expand Down Expand Up @@ -98,11 +100,9 @@ the selectors, is the ground truth for what each element contributes.
Slice 3 accepts pixel values at the captured viewports; lifting fluid intent
and interaction selectors follows separately in slice 3b.

## Status update: intake is opt-in (#7352)
## Historical status update: intake was opt-in (#7352)

Applied box-tree decisions made every frozen corpus import worse than the
same capture without box-tree evidence. Intake is therefore withheld unless
`BLOCKS_ENGINE_BOX_TREE_INTAKE=1`. The default import equals the import
without sidecars and reports `box_tree_withheld`. Tests that exercise these
decisions opt in explicitly. Per #7345, each decision returns to the default
path only when the corpus replay shows it is no worse than authored styling.
same capture without box-tree evidence. At that point, intake was withheld unless
`BLOCKS_ENGINE_BOX_TREE_INTAKE=1`; the default import reported `box_tree_withheld`.
That gate described the old pipeline, not the current evidence reader.
27 changes: 27 additions & 0 deletions docs/adr/0006-box-tree-evidence-for-wrapper-folding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use captured box-tree evidence for wrapper folding; keep author CSS

**Status: Implemented as described below.** Supersedes the reduction and stylesheet strategy in [ADR 0005](0005-box-tree-reduction-engine-owned-styles.md). See [#7454](https://github.com/Automattic/blocks-engine/issues/7454), [#7505](https://github.com/Automattic/blocks-engine/issues/7505), and [#7517](https://github.com/Automattic/blocks-engine/issues/7517) for the design history; this record describes what shipped, not every proposed fold.

## Context

Selector survival alone retains wrappers whose class or ID is consumed even when the wrapper contributes no independent box. Conversely, stripping author CSS and reconstructing the whole site from captured styles regressed visual parity. Use captured geometry to support a specific fold, and prove that the author rules still work after that fold.

## Evidence binding

- `ArtifactCompiler` looks for JSON under a `box-tree/` directory in the artifact. It accepts exactly one supported sidecar matching the document's normalized `source_path` and SHA-256 `source_hash`, subject to the 32 MiB sidecar limit. The digest describes original intake bytes, not HTML reserialized by a normalizer or projector. Missing, stale, ambiguous or unreadable sidecars supply no evidence. No intake flag is required.
- `Contract\BoxTree::read()` accepts `blocks-engine/box-tree/v2` (inline used styles) and `blocks-engine/box-tree/v3` (style-table indices expanded to the v2 shape). The wrapper proof reads the captured viewport names and the per-node `border_box` and `used_styles` for each viewport. It does not use captured pseudo-element observations or interaction states as proof; selector state and generated boxes are checked from author CSS.
- `BoxTreeWrapperEvidence` binds observations to DOM elements by unique `data-blocks-engine-node-id` and removes the carrier when binding the document. Missing, invalid, unknown or duplicated IDs, or elements created without a captured ID, cannot prove a fold. Sidecars are not theme assets and capture node IDs are not emitted as block identity.

## Wrapper decision

`WrapperCoalescer` tries the evidence-backed restatement path when the existing coalescing paths have not removed the wrapper and the wrapper passes preflight. `WrapperDecision::restatedWrapperFold()` is limited to eligible single-element-child `div` wrappers without own non-whitespace text; the surviving block may come from deeper in an already-folded sole-child chain. Missing or insufficient evidence preserves the wrapper **on this path**, without changing the eligibility of the existing CSS and layout-geometry proofs.

1. **Prove geometry and paint at every captured viewport.** The wrapper must not be `display: none`, must have positive width, and the fold requires `display: block`. The classifier checks background, borders, shadow, outline, opacity, transforms, filters, masking, clipping and overflow, as well as stacking (`z-index`), animation and positioning. The wrapper must be static or relative with inert offsets (`auto` or zero); an absolute descendant relying on that relative containing block, or one without sufficient position evidence, blocks the neutral case. A float is allowed only if the wrapper fills its parent's content box. The wrapper and child border boxes must agree within 0.5 CSS px on each of x, y, width and height, unless the inset proof below applies.
2. **Allow only proven transfers.** The inset proof expands the child's border box by the wrapper's padding and checks it against the wrapper box at every viewport. The child must be paint-free, static, non-floating and block-level, with zero margins, padding and borders. Relative positioning can transfer with that same box proof, inert offsets and observed descendant positions. Wrapper opacity can transfer when the child has unit opacity throughout and does not contest the declaration. Width, max-width and margins can be restated only if the declaration proof allows them (including the child's box-sizing or lack of padding and borders for size declarations); width/centering and min-height mismatch labels are diagnostics, not separate licenses to fold unequal boxes.
3. **Prove identity and the cascade.** Saved boundaries, runtime and motion targets, binding anchors, document-edge IDs and unsupported attributes can all refuse the fold. The child must be able to carry the wrapper's classes and any transferred anchor. An unused ID or inert `data-*` attribute can be dropped; consumed attributes must move safely or be projected to an engine-owned class. `RestatedWrapperFold` checks selector matches and declaration precedence before and after the move, including inherited text, competing child declarations and values that depend on the old containing block. It adds selector arms where needed to keep targeting the surviving elements. Unverifiable selectors, changed matches or unsafe declarations keep the wrapper with a named reason and detail. Author CSS still ships through the existing projection path.

For the guard inventory see [Wrapper decisions](../../php-transformer/docs/wrapper-decisions.md). This is not general box-tree layout synthesis, a replay of captured interaction states, or a guarantee of equivalence outside the observed viewports. Producers may omit sidecars to avoid per-route capture cost, but an import without them cannot take these evidence-backed folds or apply the captured visibility check below.

## Separate use of the same evidence

The compiler also passes the bound sidecar to `CommerceStructureRecognizer` when looking for source purchase affordances. That scan excludes elements (and their subtrees) proven `display: none` at every captured viewport; it does not remove them from the document being compiled. It does not use this evidence to prove a store exists. There is no general-purpose restyle or source-pruning pass driven by box trees.
64 changes: 0 additions & 64 deletions docs/bedford-visible-text-audit.md

This file was deleted.

110 changes: 0 additions & 110 deletions docs/contracts/php-transformer-visual-parity-fixture.schema.json

This file was deleted.

Loading
Loading