Studio Code: make validate_blocks a mandatory gate before applying block content - #3874
Merged
Merged
Conversation
…ock content Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collaborator
📊 Performance Test ResultsComparing 96bfa16 vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
1 task
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.
Related issues
single-page-build-turn-cadencecase inscripts/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-cadencebuild flow end-to-end multiple times viaapps/cli/ai/eval-runner.tsand inspected the recordedtoolCalls/toolResultsto confirmvalidate_blocksis 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>.htmlfile and then imports it withwp_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 callingvalidate_blocks— so a build could silently ship unvalidated blocks. In the eval suite this surfaced as thesingle-page-build-turn-cadencecase 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:
block-contentskill now has an explicit "validate before applying" step: the agent must callvalidate_blockson the scratch file and get a passing result before thewp_cli evalthat imports it.validate_blocksbefore it reaches the site — viawp 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
npm install --legacy-peer-depsandnpm run cli:build(Node ≥22 / npm ≥11).scripts/eval, run the case:npx promptfoo@0.121.4 eval -c promptfoo.config.yaml --filter-pattern "single-page" --no-cachesingle-page-build-turn-cadencecase should pass, withvalidate_blocksrecorded 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_blockscalled once withfilePath, immediately before the applyingwp_clicall, 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
npm run typecheckforapps/clipasses;eslint --fixrun on changed files)