Skip to content

Merge block HTML and editor validation into a single validate_blocks tool - #3753

Merged
youknowriad merged 2 commits into
trunkfrom
claude/ecstatic-lichterman-41813a
Jun 11, 2026
Merged

Merge block HTML and editor validation into a single validate_blocks tool#3753
youknowriad merged 2 commits into
trunkfrom
claude/ecstatic-lichterman-41813a

Conversation

@youknowriad

Copy link
Copy Markdown
Contributor

Related issues

  • Related to #

How AI was used in this PR

Authored end-to-end with Claude Code: consolidated the two validation tools, updated the system prompt and skills, migrated tests, and verified with lint, typecheck, and the tools test suite. Reviewers should sanity-check the gating logic in apps/cli/ai/tools/validate-blocks.ts and the updated agent guidance.

Proposed Changes

The agent previously had to call two separate tools to validate block content — validate_html_blocks (a fast static core/html policy check) followed by validate_and_fix_blocks (live-editor validation that needs a running site). Since the overwhelmingly common case is content that's already valid, this cost two agent turns where one would do.

This merges them into a single validate_blocks tool. The static HTML policy check runs first and acts as a short-circuit gate:

  • If it finds invalid core/html blocks, the tool returns only that report and skips live-editor validation entirely — so the agent rewrites those blocks before paying the expensive browser round-trip, exactly as before.
  • Once the policy check passes, live-editor validation/fix runs and both reports are concatenated into one result.

User impact: fewer agent turns (and less waiting) on the happy path when generating site content, with no change to the gating behavior that keeps invalid HTML blocks from reaching the editor. One trade-off: the static HTML check is now fused with editor validation, so it requires a running site — in practice it always preceded editor validation anyway.

Testing Instructions

  1. npm run cli:build
  2. In a studio code session, generate or edit page/post block content and observe that a single validate_blocks call replaces the previous two-call sequence.
  3. Provide content containing an invalid core/html block (e.g. a <form>); confirm the tool reports the invalid HTML blocks and does not run editor validation until they're rewritten.
  4. Provide valid content; confirm the combined report shows the HTML policy summary followed by editor validation, with auto-fix applied to the file when filePath is passed.

Automated: npm test -- apps/cli/ai/tests/tools.test.ts (48 passing), plus npm run typecheck and npx eslint.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
@wpmobilebot

wpmobilebot commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing fd7069f vs trunk

app-size

Metric trunk fd7069f Diff Change
App Size (Mac) 1358.10 MB 1358.10 MB 0.00 MB ⚪ 0.0%

site-editor

Metric trunk fd7069f Diff Change
load 1744 ms 1745 ms +1 ms ⚪ 0.0%

site-startup

Metric trunk fd7069f Diff Change
siteCreation 9523 ms 9039 ms 484 ms 🟢 -5.1%
siteStartup 4416 ms 4412 ms 4 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

@youknowriad
youknowriad requested a review from sejas June 10, 2026 10:22
@youknowriad
youknowriad force-pushed the claude/ecstatic-lichterman-41813a branch from 8bba9fd to 1756d65 Compare June 10, 2026 14:21
youknowriad and others added 2 commits June 11, 2026 11:58
…tool

Collapse validate_html_blocks and validate_and_fix_blocks into one tool so
the common "valid by default" path costs a single agent turn instead of two.
The static core/html policy check acts as a short-circuit gate: when it finds
invalid blocks it returns only those and skips the live-editor round-trip;
once it passes, editor validation runs and both reports are concatenated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The single-page-build-turn-cadence eval asserted on validate_html_blocks and
validate_and_fix_blocks tool results, which no longer exist after the merge.
Assert on the combined validate_blocks result instead: the core/html policy
gate passed (no "blocks invalid" marker) and live-editor validation succeeded.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@youknowriad
youknowriad force-pushed the claude/ecstatic-lichterman-41813a branch from 00bb783 to fd7069f Compare June 11, 2026 09:58
@youknowriad
youknowriad merged commit c34135a into trunk Jun 11, 2026
11 checks passed
@youknowriad
youknowriad deleted the claude/ecstatic-lichterman-41813a branch June 11, 2026 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants