Skip to content

Refactor (slice 1, #242): extract diagnostics projection into DiagnosticsCollector#243

Merged
chubes4 merged 1 commit into
trunkfrom
refactor/htmltransformer-diagnostics-extract
Jun 27, 2026
Merged

Refactor (slice 1, #242): extract diagnostics projection into DiagnosticsCollector#243
chubes4 merged 1 commit into
trunkfrom
refactor/htmltransformer-diagnostics-extract

Conversation

@chubes4

@chubes4 chubes4 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

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 result diagnostics array is moved into a dedicated, cohesive module:

src/HtmlToBlocks/Diagnostics/DiagnosticsCollector.php

HtmlTransformer now delegates to DiagnosticsCollector::collect() with the data it already computed. What moved:

  • the html_to_blocks_core_slice base diagnostic
  • html_static_script_metadata projection (from scriptMetadata)
  • fallback → diagnostic projection (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_island projection (from runtimeIslands)
  • wp_block_validity_* findings projection (source Runtime::class)
  • html_semantic_parity_* findings projection

FallbackDiagnostic is untouched (the new module orchestrates the data it produces). No result schema/key changes. self::class attribution is preserved by passing the transformer source string into the collector; Runtime::class attribution is preserved by importing Runtime.

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*Fallback emitters were intentionally left in place for this slice: they are deeply interwoven with shared DOM/conversion helpers (attr, elementSelector, safeFallbackHtml, boundedFallbackHtml, and normalizedNavigationLabel which 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

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>
@chubes4 chubes4 merged commit e75bf1e into trunk Jun 27, 2026
1 check passed
@chubes4 chubes4 deleted the refactor/htmltransformer-diagnostics-extract branch June 27, 2026 23:38
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