@@ -2,7 +2,7 @@ import { stripUndefined } from "./object-utils.js"
22import { planBrowserRandomWalk } from "./browser-interaction.js"
33import { FUZZ_RUNNER_CAPABILITIES_SCHEMA , RUNTIME_BACKED_FUZZ_SUITE_RUNNER_CAPABILITIES , fuzzRunnerCapabilitiesContract , fuzzSuiteCaseResetPolicy , fuzzSuiteRequiredRunnerCapabilities , fuzzSuiteResetPolicyDiagnostics , fuzzSuiteResultEnvelope , unsupportedRequiredFuzzRunnerCapabilities , type FuzzSuiteArtifactRef , type FuzzSuiteCase , type FuzzSuiteCaseResetResult , type FuzzSuiteCaseResult , type FuzzSuiteContract , type FuzzSuiteDiagnostic , type FuzzSuiteResetPolicy , type FuzzSuiteRunnerCapabilities , type FuzzSuiteTargetRef } from "./fuzz-suite-contracts.js"
44import { DELETE_BOUNDARY_ARTIFACT_KIND , DELETE_BOUNDARY_ARTIFACT_SCHEMA , MUTATION_ISOLATION_ARTIFACT_KIND , MUTATION_ISOLATION_ARTIFACT_SCHEMA , isRestMutationMethod } from "./mutation-isolation-contracts.js"
5- import type { RuntimeAction , RuntimeActionObservation } from "./runtime-action-adapter.js"
5+ import { RuntimeActionExecutionError , type RuntimeAction , type RuntimeActionObservation } from "./runtime-action-adapter.js"
66import type { ExecutionResult , ExecutionSpec , RuntimeCommandDiagnosticsCaptureSpec , RuntimeEpisodeTraceRef , WorkspaceRecipeStep } from "./runtime-contracts.js"
77import { WORDPRESS_CRUD_OPERATION_SCHEMA , normalizeWordPressCrudOperation } from "./wordpress-crud-contracts.js"
88import { WORDPRESS_DB_OPERATION_SCHEMA , normalizeWordPressDbOperation } from "./wordpress-db-contracts.js"
@@ -249,7 +249,7 @@ export async function runFuzzSuite(suite: FuzzSuiteContract, options: FuzzSuiteR
249249 } catch ( error ) {
250250 const diagnostic : FuzzSuiteDiagnostic = { severity : "error" , code : "fuzz_suite_runtime_action_sequence_execution_error" , caseId : fuzzCase . id , target, message : error instanceof Error ? error . message : String ( error ) }
251251 diagnostics . push ( diagnostic )
252- cases . push ( { id : fuzzCase . id , status : "error" , success : false , target, reset, diagnostics : [ diagnostic ] , metadata : stripUndefined ( { replay : replayMetadata , adapter : { ...plan . metadata , adapterKind : "runtime-action" , actionType : "sequence" , executorKind : "episode" } } ) } )
252+ cases . push ( { id : fuzzCase . id , status : "error" , success : false , target, reset, diagnostics : [ diagnostic ] , artifactRefs : fuzzSuiteRuntimeActionErrorArtifactRefs ( error ) , metadata : stripUndefined ( { replay : replayMetadata , adapter : { ...plan . metadata , adapterKind : "runtime-action" , actionType : "sequence" , executorKind : "episode" } } ) } )
253253 }
254254 continue
255255 }
@@ -304,6 +304,7 @@ export async function runFuzzSuite(suite: FuzzSuiteContract, options: FuzzSuiteR
304304 target,
305305 reset,
306306 diagnostics : [ diagnostic ] ,
307+ artifactRefs : fuzzSuiteRuntimeActionErrorArtifactRefs ( error ) ,
307308 metadata : stripUndefined ( { replay : replayMetadata , adapter : { ...plan . metadata , adapterKind : "runtime-action" , actionType : runtimeAction . action . type , executorKind : "episode" } } ) ,
308309 } )
309310 }
@@ -965,6 +966,25 @@ function runtimeActionFuzzSuiteTargetAdapter(): FuzzSuiteTargetAdapter {
965966 }
966967 }
967968
969+ if ( input . payload . type === "editor_actions" ) {
970+ if ( ! Array . isArray ( input . payload . steps ) ) {
971+ return unsupportedInputAdapterResolution ( fuzzCase , target , "Expected editor_actions runtime-action input steps array." , { adapterKind : "runtime-action" , actionType : input . payload . type } )
972+ }
973+ return {
974+ status : "supported" ,
975+ spec : stripUndefined ( { command : "wordpress.editor-actions" , args : runtimeEditorActionsArgs ( input . payload ) , timeoutMs : runtimeActionTimeoutMs ( input . payload , input . timeoutMs ) } ) as ExecutionSpec ,
976+ metadata : { adapterKind : "runtime-action" , actionType : input . payload . type , mappedCommand : "wordpress.editor-actions" } ,
977+ }
978+ }
979+
980+ if ( input . payload . type === "editor_validate_blocks" ) {
981+ return {
982+ status : "supported" ,
983+ spec : stripUndefined ( { command : "wordpress.editor-validate-blocks" , args : runtimeEditorValidateBlocksArgs ( input . payload ) , timeoutMs : runtimeActionTimeoutMs ( input . payload , input . timeoutMs ) } ) as ExecutionSpec ,
984+ metadata : { adapterKind : "runtime-action" , actionType : input . payload . type , mappedCommand : "wordpress.editor-validate-blocks" } ,
985+ }
986+ }
987+
968988 if ( input . payload . type === "admin_page" || input . payload . type === "page" ) {
969989 const command = input . payload . type === "admin_page" ? "wordpress.simulated-admin-page-load" : "wordpress.simulated-frontend-page-load"
970990 return {
@@ -1168,6 +1188,8 @@ function fuzzSuiteRuntimeActionMutationClassification(action: RuntimeAction): {
11681188 if ( action . type === "browser" ) return { mutates : [ "click" , "fill" , "press" , "select" ] . includes ( action . operation ) , metadata : { actionType : action . type , operation : action . operation } }
11691189 if ( action . type === "admin_page" || action . type === "page" ) return { mutates : false , metadata : { actionType : action . type } }
11701190 if ( action . type === "editor_open" ) return { mutates : false , metadata : { actionType : action . type } }
1191+ if ( action . type === "editor_actions" ) return { mutates : action . steps . some ( ( step ) => step . kind === "savePost" ) , metadata : { actionType : action . type , steps : action . steps . length } }
1192+ if ( action . type === "editor_validate_blocks" ) return { mutates : false , metadata : { actionType : action . type } }
11711193 return { mutates : false , metadata : { actionType : action . type } }
11721194}
11731195
@@ -1357,6 +1379,24 @@ function runtimeEditorOpenArgs(input: Record<string, unknown>): string[] {
13571379 ] . filter ( ( arg ) : arg is string => Boolean ( arg ) )
13581380}
13591381
1382+ function runtimeEditorActionsArgs ( input : Record < string , unknown > ) : string [ ] {
1383+ return [
1384+ ...runtimeEditorOpenArgs ( input ) ,
1385+ `steps-json=${ JSON . stringify ( input . steps ) } ` ,
1386+ durationMsArg ( "wait-timeout" , input . wait_timeout_ms ?? input . waitTimeoutMs ) ,
1387+ durationMsArg ( "step-timeout" , input . step_timeout_ms ?? input . stepTimeoutMs ) ,
1388+ ] . filter ( ( arg ) : arg is string => Boolean ( arg ) )
1389+ }
1390+
1391+ function runtimeEditorValidateBlocksArgs ( input : Record < string , unknown > ) : string [ ] {
1392+ return [
1393+ optionalStringArg ( "content" , input . content ) ,
1394+ optionalStringArg ( "content-file" , input . content_file ?? input . contentFile ) ,
1395+ ...runtimeEditorOpenArgs ( input ) ,
1396+ optionalStringArg ( "validation-provider" , input . validation_provider ?? input . validationProvider ) ,
1397+ ] . filter ( ( arg ) : arg is string => Boolean ( arg ) )
1398+ }
1399+
13601400function durationMsArg ( name : string , value : unknown ) : string | undefined {
13611401 return typeof value === "number" && Number . isFinite ( value ) ? `${ name } =${ value } ms` : undefined
13621402}
@@ -1401,7 +1441,13 @@ function fuzzSuiteExecutionArtifactRefs(execution: ExecutionResult): FuzzSuiteAr
14011441}
14021442
14031443function fuzzSuiteRuntimeActionArtifactRefs ( observation : RuntimeActionObservation ) : FuzzSuiteArtifactRef [ ] | undefined {
1404- const refs = ( observation . artifactRefs ?? [ ] ) . map ( fuzzSuiteArtifactRefFromTrace ) . filter ( ( ref ) : ref is FuzzSuiteArtifactRef => Boolean ( ref ) )
1444+ const refs = [ ...( observation . artifactRefs ?? [ ] ) , ...( observation . step ?. execution . artifactRefs ?? [ ] ) , ...( observation . step ?. execution . result ?. artifactRefs ?? [ ] ) ] . map ( fuzzSuiteArtifactRefFromTrace ) . filter ( ( ref ) : ref is FuzzSuiteArtifactRef => Boolean ( ref ) )
1445+ return refs . length > 0 ? refs : undefined
1446+ }
1447+
1448+ function fuzzSuiteRuntimeActionErrorArtifactRefs ( error : unknown ) : FuzzSuiteArtifactRef [ ] | undefined {
1449+ if ( ! ( error instanceof RuntimeActionExecutionError ) ) return undefined
1450+ const refs = error . artifactRefs . map ( fuzzSuiteArtifactRefFromTrace ) . filter ( ( ref ) : ref is FuzzSuiteArtifactRef => Boolean ( ref ) )
14051451 return refs . length > 0 ? refs : undefined
14061452}
14071453
@@ -1459,8 +1505,9 @@ function fuzzSuiteArtifactRefFromTrace(ref: RuntimeEpisodeTraceRef): FuzzSuiteAr
14591505 return stripUndefined ( {
14601506 path,
14611507 kind : ref . kind ,
1508+ contentType : ref . contentType ,
14621509 sha256 : ref . digest ?. algorithm === "sha256" ? ref . digest . value : undefined ,
1463- metadata : stripUndefined ( { id : ref . id , artifactId : ref . artifactId , digest : ref . digest } ) ,
1510+ metadata : stripUndefined ( { id : ref . id , artifactId : ref . artifactId , digest : ref . digest , sourcePath : ref . sourcePath } ) ,
14641511 } )
14651512}
14661513
0 commit comments