Skip to content

Studio Code: make validate_blocks a mandatory gate before applying block content - #3874

Merged
youknowriad merged 1 commit into
trunkfrom
make-block-validation-mandatory-gate
Jun 18, 2026
Merged

Studio Code: make validate_blocks a mandatory gate before applying block content#3874
youknowriad merged 1 commit into
trunkfrom
make-block-validation-mandatory-gate

Conversation

@youknowriad

Copy link
Copy Markdown
Contributor

Related issues

  • Related to the Studio Code agent eval suite (single-page-build-turn-cadence case in scripts/eval/promptfoo.config.yaml)

How AI was used in this PR

The change itself is prompt/skill text for the Studio Code agent. I used the agent's own eval harness to reproduce the non-determinism and verify the fix: ran the single-page-build-turn-cadence build flow end-to-end multiple times via apps/cli/ai/eval-runner.ts and inspected the recorded toolCalls/toolResults to confirm validate_blocks is now invoked — and passes — on every run, before the page content is applied.

Proposed Changes

When the Studio Code agent builds a page, it writes the block markup into a scratch tmp/page-<slug>.html file and then imports it with wp_cli eval. Because validation was framed as a separate, after-the-fact step, the agent would sometimes apply that content to the site without ever calling validate_blocks — so a build could silently ship unvalidated blocks. In the eval suite this surfaced as the single-page-build-turn-cadence case intermittently failing with "validate_blocks was not called for block content."

This makes block validation a mandatory gate that runs before content is applied, rather than an easy-to-skip cleanup step:

  • The Page Content recipe in the block-content skill now has an explicit "validate before applying" step: the agent must call validate_blocks on the scratch file and get a passing result before the wp_cli eval that imports it.
  • The skill's Validation section and the agent's main workflow are reworded to state that any generated block content must pass validate_blocks before it reaches the site — via wp post create/update, wp_cli eval, or file import — and that a build which skips validation is incomplete.

User impact: site builds are more reliably correct — the agent no longer applies block content it hasn't validated and auto-fixed, which prevents subtly broken/invalid blocks from landing on the page. No tool internals or eval assertions were changed; only the agent's guidance.

Testing Instructions

  1. npm install --legacy-peer-deps and npm run cli:build (Node ≥22 / npm ≥11).
  2. From scripts/eval, run the case:
    npx promptfoo@0.121.4 eval -c promptfoo.config.yaml --filter-pattern "single-page" --no-cache
  3. The single-page-build-turn-cadence case should pass, with validate_blocks recorded for the page content.

Verified here by driving the exact eval prompt through eval-runner (10-min budget, matching the case) across 3 consecutive runs. Every run: validate_blocks called once with filePath, immediately before the applying wp_cli call, and passing (e.g. "HTML block policy: no core/html blocks found. / Validation: 27/27 blocks valid"). All three eval assertions (validation, turn timing < 60s, no --post_content-file=) passed on every run.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors? (npm run typecheck for apps/cli passes; eslint --fix run on changed files)
…ock content

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@wpmobilebot

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 96bfa16 vs trunk

app-size

Metric trunk 96bfa16 Diff Change
App Size (Mac) 2355.89 MB 2355.89 MB +0.00 MB ⚪ 0.0%

site-editor

Metric trunk 96bfa16 Diff Change
load 1711 ms 1752 ms +41 ms ⚪ 0.0%

site-startup

Metric trunk 96bfa16 Diff Change
siteCreation 8013 ms 8490 ms +477 ms 🔴 6.0%
siteStartup 3890 ms 3866 ms 24 ms ⚪ 0.0%

Results are median values from multiple test runs.

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

@youknowriad
youknowriad merged commit 3aa8c5a into trunk Jun 18, 2026
12 checks passed
@youknowriad
youknowriad deleted the make-block-validation-mandatory-gate branch June 18, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants