Refactor (slice 1, #242): extract diagnostics projection into DiagnosticsCollector#243
Merged
Merged
Conversation
Slice 1 of #242. Behavior-preserving pure extraction: move the inline projection of computed conversion signals (static script metadata, fallback diagnostics, runtime islands, wp_block_validity_* findings, and html_semantic_parity_* findings) into the result diagnostics array out of HtmlTransformer::transform() and into a dedicated HtmlToBlocks\Diagnostics\DiagnosticsCollector. No logic changes, no new findings, no renamed codes. The transformer now delegates to DiagnosticsCollector::collect() with the data it already computed. Diagnostics output is byte-identical. 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 1 of the HtmlTransformer decomposition epic: extract the diagnostics projection concern.
What this does
Pure extraction/move. The inline block in
HtmlTransformer::transform()that projected already-computed conversion signals into the flat resultdiagnosticsarray is moved into a dedicated, cohesive module:src/HtmlToBlocks/Diagnostics/DiagnosticsCollector.phpHtmlTransformernow delegates toDiagnosticsCollector::collect()with the data it already computed. What moved:html_to_blocks_core_slicebase diagnostichtml_static_script_metadataprojection (fromscriptMetadata)html_*_fallback,interactive_control_behavior_lost, etc., with full finding enrichment fields: pattern_family, source_selector, parent/ancestor_reason, suggested_generic_repair_class, …)preserved_runtime_islandprojection (fromruntimeIslands)wp_block_validity_*findings projection (sourceRuntime::class)html_semantic_parity_*findings projectionFallbackDiagnosticis untouched (the new module orchestrates the data it produces). No result schema/key changes.self::classattribution is preserved by passing the transformer source string into the collector;Runtime::classattribution is preserved by importingRuntime.Behavior-preserving — parity identical 128→128
Captured a baseline before refactoring and re-ran after:
composer test:canonical: 5 contracts pass (no-WP runtime, WP-stub runtime, plugin bootstrap, HTML-to-blocks, format bridge scaffold) — identical before/after.composer parity: 128 fixtures pass → 128 fixtures pass — identical.composer test(canonical + parity + packaging): green.No logic changes, no new findings, no renamed codes, no fixture changes. Output is byte-identical.
Line-count reduction
HtmlTransformer.php: 6816 → 6723 lines (−93), with the projection logic now isolated in a 148-line single-responsibility module that diagnostics work can target without touching transformer core.Scope notes
The semantic-parity report builders and the interactive-control behavior-loss /
capture*Fallbackemitters were intentionally left in place for this slice: they are deeply interwoven with shared DOM/conversion helpers (attr,elementSelector,safeFallbackHtml,boundedFallbackHtml, andnormalizedNavigationLabelwhich is also used by navigation de-duplication), so moving them would not be a clean pure move. This slice extracts the largest provably-safe cohesive unit — the projection seam — leaving those emitters for a later slice once their shared helpers are factored out.Do not merge without review.
🤖 Generated with Claude Code