Skip to content

Refactor: extract semantic-parity report builders (slice 3 of #242)#246

Merged
chubes4 merged 1 commit into
trunkfrom
refactor/htmltransformer-semantic-parity
Jun 28, 2026
Merged

Refactor: extract semantic-parity report builders (slice 3 of #242)#246
chubes4 merged 1 commit into
trunkfrom
refactor/htmltransformer-semantic-parity

Conversation

@chubes4

@chubes4 chubes4 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Refs #242 — slice 3: semantic-parity report builders.

What moved

Pure, behavior-preserving extraction of the semantic-parity report builders out of src/HtmlToBlocks/HtmlTransformer.php into a new src/HtmlToBlocks/Diagnostics/SemanticParityReporter.php. This is the code that builds the html_semantic_parity_* findings:

  • landmark_count_mismatch — source vs block landmark count comparison
  • navigation_menu_missing, navigation_core_block_missing, navigation_item_count_mismatch, navigation_item_mismatch
  • the source-side vs block-side nav/landmark parity counting (moved as a unit — the counters that must stay in sync were not restructured)
  • finding enrichment (reason_code / source_snippet / observed_block) and typography-parity merge

Builders depend only on explicit parameters (parsed source $body, generated $blocks, $sourceProvenance, $html, $staticCss) — no reach into transformer state. Shared DOM helpers come from the existing DomHelpersTrait (slice 2). The module carries a Runtime (required by trait helpers) mirroring the transformer's own.

hasAncestorTag, hasSourceNavigationSignal, and safeNavigationUrl are used by non-parity transformer code too, so they remain in HtmlTransformer and are duplicated in the reporter — DomHelpersTrait is untouched per the slice constraint (only HtmlTransformer + the new module changed).

Behavior-preserving

No logic changes, no new/renamed findings, no changed parity counting.

  • Baseline: canonical green, parity 128 fixtures pass, full composer test green.
  • After: canonical identical, parity 128 → 128 pass, full composer test green.
  • No fixtures touched.

HtmlTransformer line-count delta

6475 → 5706 (−769). New module: 857 lines.

DO NOT MERGE.

…dule

Slice 3 of decomposition epic #242. Pure behavior-preserving move of the
semantic-parity report builders (the html_semantic_parity_* findings:
landmark count comparison, navigation_menu_missing,
navigation_item_count_mismatch, and the source-vs-block nav/landmark parity
counting) out of HtmlTransformer into a dedicated
Diagnostics/SemanticParityReporter module.

The new module uses the shared DomHelpersTrait (slice 2) and receives the
parsed source body, generated blocks, and source provenance as explicit
parameters rather than reaching into transformer state. It carries a Runtime
(required by trait helpers) mirroring the transformer's own. The small
hasAncestorTag / hasSourceNavigationSignal / safeNavigationUrl helpers remain
in HtmlTransformer for non-parity callers and are duplicated in the reporter
so it needs no transformer reference (DomHelpersTrait is untouched per slice
constraints).

No logic changes, no new/renamed findings, no changed counting. Parity
128->128, canonical identical, full composer test green. HtmlTransformer
6475 -> 5706 lines (-769).

Refs #242

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@chubes4 chubes4 merged commit 2f3e64e into trunk Jun 28, 2026
1 check passed
@chubes4 chubes4 deleted the refactor/htmltransformer-semantic-parity branch June 28, 2026 00:00
chubes4 added a commit that referenced this pull request Jun 28, 2026
Refactor slices 3 (#246, SemanticParityReporter) and 4 (#249, FallbackEmitter)
were file-scoped, so they copied shared leaf helpers instead of promoting them.
Each of the following was byte-identical across its copies; consolidate the
single definition into Support/DomHelpersTrait (already used by all three
classes) and remove the duplicates:

- hasAncestorTag (HtmlTransformer + SemanticParityReporter)
- hasSourceNavigationSignal (HtmlTransformer + SemanticParityReporter)
- safeNavigationUrl (HtmlTransformer + SemanticParityReporter)
- runtimeIslandSelector (HtmlTransformer + FallbackEmitter)
- eventMetadata (HtmlTransformer + FallbackEmitter)
- isSafeSvgContent (HtmlTransformer + FallbackEmitter)
- dedupeArrayRows (HtmlTransformer + FallbackEmitter)

Behavior-preserving pure dedupe: no logic or signature changes. Canonical and
parity (144 fixtures) identical before and after; full composer test green.

Refs #242

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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