Skip to content

Slice 1 (ADR 0006): collapse geometry-neutral wrappers from box-tree evidence - #7420

Draft
chubes4 wants to merge 6 commits into
trunkfrom
fix/issue-7379-blocks-engine-3
Draft

chubes4 wants to merge 6 commits into
trunkfrom
fix/issue-7379-blocks-engine-3

Conversation

@chubes4

@chubes4 chubes4 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Rework 3 (required): evidence-neutral wrappers are still refused by CSS-era gates

Rework 2 (fefd0154, with a one-line comment fix for producer-neutral-source) works on the real path: evidence is bound and v3 is read. The real-path probe classifies 156 Wix and 175 Squarespace wrappers as neutral.

A/B against trunk 87654ca2:

trunk #7420
Wix demo single-child groups 225 225
Squarespace demo single-child groups 576 568

Logged refusals of evidence-neutral wrappers, real import path:

Refusal Wix Squarespace
ResolvedWrapperComposition failure wrapper_declaration_not_composable:display 49 6
hasConsumedDataAttributes: data-interact-enter, data-testid 46 —
has_structure_signals_without_proof (class-name heuristics) 22 52
repeatedMembersFoldAlike (sqs-row, sqs-html-content, sqs-block-content) 1 40
leaf restates color/font-size, width or position resets — 24

Required:

  1. Evidence answers geometry in the proof. For a wrapper the evidence proves neutral, ResolvedWrapperComposition treats the wrapper's layout and box declarations as inert. That covers display, flex and grid properties, width/height/min-*/max-*, zero margins and padding, position: relative with zero offsets, box-sizing and overflow: visible. The evidence proved the box contributes nothing at every viewport, so these declarations need neither composition nor a pin. Inherited text properties (color, font, line-height, letter-spacing, text-align and so on) still compose onto the leaf exactly as today, and paint is already excluded by the classification.
  2. Structure signals. has_structure_signals_without_proof and structural_layout_child_without_proof are class-name guesses about layout. An evidence-neutral wrapper is exempt from both, as it already is from has_id_attribute and non_neutral_geometry_without_proof. Semantic checks still apply: landmark tags, role, interactive attributes and motion tokens.
  3. Consumed data attributes. A data attribute is consumed when an emitted author CSS selector or a runtime selector names it, or when a script that ships in the import output reads it. Source runtime scripts the import does not retain do not count. Today's substring match over every <script> treats Wix's data-testid and data-interact-enter as consumed.
  4. Repeat consistency by evidence. Decide whether repeated members (same tag and class signature) fold alike from each member's evidence classification. When every member is neutral, all fold, and the repeated set stays consistent. Members with mixed classifications all keep their wrappers, as today.
  5. Coverage in the PR body. Per demo route, list the neutral, folded and refused counts, with the refusal reason, using the same instrumentation.

Acceptance is unchanged: full tests green with none weakened; Squarespace single-child groups ≤ 556; Wix < 225; max depth not increased; no new parity blockers; the PR stays a draft.


Rework 2 (required): slice 1 is inert on real imports

A/B of 7aad41fd against trunk: the Wix and Squarespace demos produce byte-identical published content (single-child groups 225 and 576). I instrumented the real static-site-importer path; every item below was reproduced there.

  1. Bind evidence at intake, not after rewrites. ArtifactCompiler::boxTreeForSource() hashes the document after artifact projectors re-serialize it: the newline after <!DOCTYPE html> and the style="" on <html> change, so source_hash never matches, and every Wix route loses its evidence. Verify each sidecar's source_hash once, against the original artifact bytes, before any normalizer or projector rewrites them, and carry the verified tree with that source path. Node ids are attributes and survive re-serialization; elements a projector creates have no id and are load_bearing. Add one end-to-end contract test that compiles an artifact whose document is re-serialized before HTML compilation (<!DOCTYPE html><html style="">… with a sidecar bound to those raw bytes) and asserts that a neutral wrapper folds.
  2. Accept blocks-engine/box-tree/v3. data-liberation-agent has exported compact v3 sidecars since feat(export): write box-tree sidecars as compact v3 data-liberation-agent#2063: each viewport's used_styles (and pseudo.*.used_styles) is an integer index into the top-level styles array. Contract\BoxTree::SCHEMA accepts only v2, so every current capture, including the Squarespace demo, is rejected. Accept v2 and v3 in one contract reader that expands v3 into the v2 shape, wherever sidecars are read, including the static-site-importer binding through BoxTree::isSidecarPath and its schema checks. Add a table-driven v2/v3 equivalence test.
  3. Relative offsets. For positioned elements, getComputedStyle reports top/right/bottom/left as resolved px, so auto comes back as 0px. Treat 0px as inert, and ignore offsets entirely when position is static. A non-zero offset is load_bearing, not inset_only. On the Wix demo, 127 wrappers are currently refused as inset:top.
  4. Leaf id guard. WrapperCoalescer refuses the fold when the leaf carries an id or anchor ('' !== trim(SourceDom::attr($leaf, 'id'))). The leaf keeps its own id after the fold, so that is not a reason to refuse. Refuse only when the wrapper's id would be dropped or would collide with the leaf's. Wix gives every element an id, so this blocks most Wix folds.
  5. Report real-path coverage. In the PR body, list, per demo capture route, how many wrappers are classified neutral and how many fold. Captures are on the Lab at ~/cal/bt/v8/sdnunca.wixsite.com-my-site-1 and ~/cal/bt/sq5/bedford-demo.squarespace.com.

Acceptance is unchanged: full tests green with none weakened; Squarespace single-child groups ≤ 556; Wix < 225; max depth not increased; no new parity blockers; the PR stays a draft.


Summary

This is slice 1 of ADR 0006. A new class reads each route's box-tree/<route>.json evidence (blocks-engine/box-tree/v2). It maps source elements to evidence nodes by data-blocks-engine-node-id and answers neutral, inset_only or load_bearing, with a reason. A node with no evidence is load_bearing. The resolved-style fold already on this branch now runs only when the wrapper, and every wrapper between it and the leaf, is neutral at every captured viewport. With that evidence, the CSS-only refusals on position, size, margin and float are relaxed. Rules whose match changes are still restated as engine-owned rules on the node they applied to; state, pseudo-element and device-gated rules still keep the wrapper. Id transfer is refused off shell edges and anchor targets, the data guard now applies only to consumed attributes, and repeated siblings must all be neutral before any of them folds. Without evidence, nothing changes: the three test files this branch had edited are restored to trunk, and a new test compares output against a golden file generated from trunk 71c4dcf. Not run: the Wix/Squarespace A/B, the full composer test gate and composer topology-diff. Box-tree evidence reaches the per-document ArtifactCompiler path only; I didn't wire the staged transport path.

What changed

  • New src/HtmlToBlocks/Elements/BoxTreeWrapperEvidence.php, the evidence reader. It treats a wrapper as neutral when, at every viewport, it is visible, paints and clips nothing, and its single child's border box equals its own within 0.5px. It must also be static, or relative with auto insets and no absolutely positioned descendant using it as its containing block, with float none, z-index auto and animation none. A missing node, a duplicated id or a missing viewport counts as load_bearing.
  • ArtifactCompiler::boxTreeForSource() picks the one sidecar whose source_path names the document and whose source_hash is the SHA-256 of its bytes, and passes it as the box_tree option. Stale, ambiguous or malformed sidecars are ignored. The session builds the evidence object from that option.
  • WrapperCoalescer::resolvedCompositionCoalescing returns early unless the wrapper and every intermediate wrapper are neutral. It skips the id, data and inline-geometry checks that evidence covers, and adds isReferenceTarget, hasConsumedDataAttributes and an id-aware shell-edge guard. The repeated-sibling check now applies to every block type and requires each sibling to be neutral.
  • ResolvedWrapperComposition::prove() takes a size-transfer flag. With evidence: relative position drops, float drops only if its rule is lost, and margins move onto the leaf. Sizes move only when the leaf is border-box or has no padding or border. The leaf's own properties are still read from authored values only.
  • Restored tests/contract/geometry-wrapper-chain-fold.php, tests/contract/run.php and tests/unit/author-selector-semantics.php to their trunk versions.
  • Rewrote tests/contract/resolved-wrapper-composition.php around a genuinely neutral, positioned, sized and centred .lane, with evidence. It checks that size, centring and position move onto the merged group and that inherited and ancestor-scoped styles still resolve at 390 and 1440px.
  • Added tests/contract/box-tree-neutral-wrapper-collapse.php, a table-driven test. The neutral case folds and restates the lost child-combinator rule. Refusal cases: paint, containing block, inset, hidden at one viewport, unequal child box and missing evidence. Each refusal converts byte-identically to no evidence, stale evidence changes nothing, and no node id reaches the output.
  • Added tests/contract/box-tree-evidence-monotonic.php and tests/fixtures/box-tree-monotonic/ (expected.json generated from trunk 71c4dcf). Output without evidence, with node ids but no sidecar, and with another route's sidecar all match trunk exactly. Unrelated future changes to how this fixture converts will require regenerating expected.json.
  • Shared sidecar builder in tests/contract/box-tree-evidence-fixture.php.

Verification

  • cd php-transformer && composer install -q && composer test: passed on 0c7fde4. Base trunk@469f02b advanced to 9802cc2 (base_behind_by: 5; rebase onto the current base before merging). 479763 ms; retained gate metadata.
  • repro: none (no repro gate was declared, so these gates do not prove the issue).
  • CI: pending

Cook run
  • Gate 1: tree 84f63850649c176266f94da13a2da7fd99f01531

Evidence

  • Narrow checks passed: the three new or rewritten box-tree tests, geometry-wrapper-chain-fold, author-selector-semantics, wrapper-coalescer-disposition, capture-evidence-is-not-source, artifact-sidecar-report-budget, box-tree-importer-compatibility, contract/run.php, the packaging tests, layer-direction and library-lint. phpstan and phpcs report no errors on the changed files.
  • Topology baseline left unchanged: the topology-diff corpus has no box-tree sidecars, and the monotonic test shows output without evidence matches trunk. I didn't run topology-diff to confirm.: Slice 1 (ADR 0006): collapse geometry-neutral wrappers from box-tree evidence #7420

AI disclosure

Tool: Homeboy Cook. Agent: Homeboy (pi). Model: Pi · route roadie/cook-heavy · served claude-opus-5-5. Cook time: 31m08s.

PR #7420 rework into slice 1 of ADR 0006 (refs #7454, #7456, #7379). The PR should stay a draft until the requester's Wix/Squarespace A/B passes, under the direction of the Cook requester. Gates were run by Homeboy. A human reviews before merge.

@chubes4
chubes4 marked this pull request as draft November 23, 2026 11:25
@chubes4
chubes4 force-pushed the fix/issue-7379-blocks-engine-3 branch from e0fc944 to 44ce499 Compare November 23, 2026 11:25
@chubes4

chubes4 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Requester A/B and rework scope

A/B, rebased head 44ce4998 vs trunk 92e1875b (frozen captures, default path):

  • Wix demo: published content is byte-identical.
  • Squarespace demo: one page changes. Site-wide single-child groups drop from 576 to 571 and depth stays at 16. A new editor_canvas_parity blocker appears on home-alt (nav text renders in the editor with the wrong colour and font).

Why so little: I logged each return null in resolvedCompositionCoalescing().

  • Wix: no wrapper reaches prove(). 184 exit at the core/group-only name gate and 159 at eligibilityDisqualifications.
  • The eligibility filter removes only unsupported_child_block_name. has_id_attribute still refuses before the id-transfer code at the anchor check can run, and has_data_attributes_without_proof refuses everything else.

Experiment (scratch/7379-exp 1fe45d1a): admit core/paragraph and core/heading, and also drop has_id_attribute and has_data_attributes_without_proof from this path.

  • Squarespace: single-child groups 576 → 556, groups 906 → 886, sampled depth 14 → 13. The editor_canvas_parity blocker is gone and the visual-parity findings are byte-identical to trunk.
  • Wix: still unchanged. 8 paragraph wrappers log a successful proof, but published content is identical, so the fold result is dropped or rebuilt downstream. This needs tracing.
  • The experiment fails 27 tests. These are the real constraints:
    • data-attribute-custom-property-subject: some data attributes are consumed (custom-property subject markers). Gate on consumed data attributes, not on the presence of any.
    • device-document-shared-shell, binding-anchor-shell-shift, shared-shell-plan, route-edge-shared-shell, unlabeled-*-shell, announcement-bar-header-shell, page-wide-main-footer-section: shell and landmark extraction depends on these wrapper boundaries and ids. A fold must not remove a boundary that shell, landmark or repeat-period detection uses.
    • native-group-wrapper-chain: id-bearing chains turn into custom/layout-shell. Id transfer must keep core-editable groups and editor anchors.
    • styled-single-paragraph-comment: fold decisions must be consistent across repeated siblings. A one-paragraph instance keeps the same group structure as its multi-paragraph sibling.

Rework

  1. Admit core/paragraph and core/heading leaves; the leaf-tag code already handles them.
  2. Id transfer: remove has_id_attribute from this path's eligibility filter, and refuse when the wrapper is a shell, landmark, editor-anchor or binding boundary according to the existing classifiers.
  3. Data: replace the presence guard with "no data attribute on the wrapper is consumed". Consumed means used by a marker or custom-property subject, by runtime or interaction projection, or by a selector the proof can't pin. Wrapper data attributes are otherwise never emitted.
  4. Repeat consistency: fold a member of a repeated sibling set only when the same fold applies to every member.
  5. Composition rules for the measured refusals (Squarespace after the experiment):
    • position (121): position:relative with no offsets, no z-index and no positioned descendant depending on it drops out; otherwise it transfers to a static leaf.
    • float (49): float:none is initial.
    • width (sdnunca 49, Squarespace 28): width:100% or auto on a block-level wrapper in block flow is inert.
    • animation (31): keep the refusal.
  6. Find out why the 8 proved Wix paragraph folds don't reach published content.
  7. Update the topology baseline (composer topology-diff -- --update-baseline) and state in the PR body that removed-wrapper divergences are the intended fold.

Acceptance: full composer test green with no test weakened. I re-run the A/B, and it must show single-child groups at or below 556 on Squarespace, a decrease from 225 on Wix, depth not increased, and visual and editor parity unchanged or improved.

Franklin (Claude Opus via Pi, Roadie).

@chubes4

chubes4 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

A/B of rebased rework 469f02bc (committed candidate b574c665: paragraph/heading leaves, shell-edge and repeat guards) vs trunk 71c4dcfc

Measured from published blocks (parse_blocks over pages, template parts and templates):

trunk #7420
Wix demo: single-child groups / groups / max depth 225 / 369 / 13 225 / 369 / 13 (content byte-identical)
Squarespace demo: single-child groups / groups / max depth 576 / 906 / 16 571 / 901 / 16
Squarespace editor_canvas_parity none blocker (home-alt nav text loses colour and font in the editor)

This fails acceptance, so the PR stays in draft and does not merge.

Why Wix doesn't move: every Wix wrapper that passes prove() sits on a linked page that is converted but not published (accessibility statement, terms, privacy). On the five published routes, no wrapper proves. Each Wix level carries real box styles (position, grid placement, width or max-width, min-height fixes) and ancestor-scoped skin rules, so a faithful fold rejects every level.

Assessment: per-wrapper folding guarded by the cascade has reached about 1% on Squarespace and 0% on Wix after four rounds. These wrappers are not neutral: each carries geometry. Removing them means re-synthesizing the layout: compute each subtree's resolved boxes and emit fewer native blocks whose layout (flex or grid, gap, padding, constrained width) reproduces the same geometry. It does not mean proving that a wrapper is removable. That's an architecture decision, so it's escalated to the maintainer before more Cook rounds.

Franklin (Claude Opus via Pi, Roadie).

@chubes4 chubes4 changed the title Fold wrappers on resolved styles with engine-owned rules for changed matches Slice 1 (ADR 0006): collapse geometry-neutral wrappers from box-tree evidence Nov 23, 2026
@chubes4
chubes4 marked this pull request as ready for review November 23, 2026 21:15
@chubes4
chubes4 marked this pull request as draft November 23, 2026 23:16
@chubes4
chubes4 force-pushed the fix/issue-7379-blocks-engine-3 branch from 8a407fb to 7aad41f Compare November 23, 2026 23:16
@chubes4

chubes4 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Rework 3 measurement (Cook agent-task-6dbf2c04, candidate 8227364, ended candidate_recoverable and was not published). Gates passed, but Wix coverage did not move. The agent's own review found that the remaining refusals of evidence-neutral wrappers are mostly correct:

  1. 51 carry data-interact-enter, which the emitted CSS really consumes (:not([data-interact-enter]) reveal rules). Folding the wrapper would break the entrance animation.
  2. 45 carry a wrapper font that would override the heading or paragraph's own default font if moved down.
  3. 17 have display: var(--l_display, var(--container-display)), which the CSS proof can't resolve statically.

This settles it: being geometry-neutral is necessary but not sufficient. What's missing is a restatement step: move the consumed data attribute or the inherited text style onto the surviving child, then fold. That's the third stage of the single wrapper-decision owner in #7471. The first slice, #7472, is byte-identical on all 8 corpus sites. #7420 stays in draft as the measurement record; slice 1 will be rebuilt on #7471 once restatement is a named stage.

Posted by Franklin (Claude Opus via Pi, Roadie).

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