Refactor: extract semantic-parity report builders (slice 3 of #242)#246
Merged
Conversation
…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
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.phpinto a newsrc/HtmlToBlocks/Diagnostics/SemanticParityReporter.php. This is the code that builds thehtml_semantic_parity_*findings:landmark_count_mismatch— source vs block landmark count comparisonnavigation_menu_missing,navigation_core_block_missing,navigation_item_count_mismatch,navigation_item_mismatchreason_code/source_snippet/observed_block) and typography-parity mergeBuilders depend only on explicit parameters (parsed source
$body, generated$blocks,$sourceProvenance,$html,$staticCss) — no reach into transformer state. Shared DOM helpers come from the existingDomHelpersTrait(slice 2). The module carries aRuntime(required by trait helpers) mirroring the transformer's own.hasAncestorTag,hasSourceNavigationSignal, andsafeNavigationUrlare used by non-parity transformer code too, so they remain in HtmlTransformer and are duplicated in the reporter —DomHelpersTraitis untouched per the slice constraint (only HtmlTransformer + the new module changed).Behavior-preserving
No logic changes, no new/renamed findings, no changed parity counting.
composer testgreen.composer testgreen.HtmlTransformer line-count delta
6475 → 5706 (−769). New module: 857 lines.
DO NOT MERGE.