@@ -17,6 +17,10 @@ const uploadLayoutRegression = JSON.parse(await readFile(new URL("../fixtures/ag
1717assert . equal ( uploadLayoutRegression . run_id , "29306539573" )
1818assert . equal ( uploadLayoutRegression . observed . upload_preparation , "failed-on-runtime-source" )
1919assert . match ( uploadLayoutRegression . raw_layout . runtime_source , / p r e p a r e d - p l u g i n s \/ a g e n t s - a p i \/ a g e n t s - a p i \. p h p $ / )
20+ const diagnosticRegression = JSON . parse ( await readFile ( new URL ( "../fixtures/agent-task-upload-run-29307978522.json" , import . meta. url ) , "utf8" ) )
21+ assert . equal ( diagnosticRegression . run_id , "29307978522" )
22+ assert . match ( diagnosticRegression . result . diagnostics [ 0 ] . message , / O p e n A i P r o v i d e r / )
23+ assert . match ( diagnosticRegression . result . diagnostics [ 0 ] . stack , / W P _ A g e n t s _ R e g i s t r y / )
2024const hostedPathRegression = JSON . parse ( await readFile ( new URL ( "../fixtures/agent-task-runtime-paths-run-29305012941.json" , import . meta. url ) , "utf8" ) )
2125for ( const result of [ hostedPathRegression . success , hostedPathRegression . failure ] ) {
2226 const sanitized = sanitizeRuntimeSourceValue ( result , hostedPathRegression . runtime_root )
@@ -151,6 +155,15 @@ await withTempDir("wp-codebox-runtime-source-upload-", async (directory) => {
151155 assert . doesNotMatch ( stagedInput , / c o m p o n e n t _ c o n t r a c t s | s o u r c e _ p a c k a g e _ r o o t / )
152156 const stagedResult = await readFile ( join ( upload , ".codebox" , "agent-task-workflow-result.json" ) , "utf8" )
153157 assert . doesNotMatch ( stagedResult , / p r i v a t e - r u n t i m e - s o u r c e / )
158+ await writeFile ( join ( workspace , ".codebox" , "agent-task-workflow-result.json" ) , `${ JSON . stringify ( diagnosticRegression . result , null , 2 ) } \n` )
159+ await execFileAsync ( process . execPath , [ script . pathname ] , { env : { ...process . env , AGENT_TASK_WORKSPACE : workspace , AGENT_TASK_UPLOAD_PATH : upload , WP_CODEBOX_RUNTIME_SOURCE_ROOT : privateRoot } } )
160+ const stagedDiagnostic = await readFile ( join ( upload , ".codebox" , "agent-task-workflow-result.json" ) , "utf8" )
161+ assert . match ( stagedDiagnostic , / O p e n A i P r o v i d e r / )
162+ assert . match ( stagedDiagnostic , / W P _ A g e n t s _ R e g i s t r y / )
163+ await writeFile ( join ( artifacts , "safe.json" ) , "Diagnostic snippet: <?php OpenAiProvider function was unavailable in WP_Agents_Registry." )
164+ await writeFile ( join ( workspace , ".codebox" , "agent-task-workflow-result.json" ) , JSON . stringify ( { typed_artifacts : [ { name : "reviewer-report" , type : "report" , artifact : { path : "safe.json" } } ] } ) )
165+ await execFileAsync ( process . execPath , [ script . pathname ] , { env : { ...process . env , AGENT_TASK_WORKSPACE : workspace , AGENT_TASK_UPLOAD_PATH : upload , WP_CODEBOX_RUNTIME_SOURCE_ROOT : privateRoot } } )
166+ assert . match ( await readFile ( join ( upload , ".codebox" , "agent-task-artifacts" , "safe.json" ) , "utf8" ) , / O p e n A i P r o v i d e r / )
154167 await writeFile ( join ( artifacts , "leak.json" ) , `runtime log ${ privateRoot } /source.php` )
155168 await writeFile ( join ( workspace , ".codebox" , "agent-task-workflow-result.json" ) , JSON . stringify ( { status : "failed" , success : false , typed_artifacts : [ { name : "reviewer-report" , type : "report" , artifact : { path : "leak.json" } } ] } ) )
156169 await execFileAsync ( process . execPath , [ script . pathname ] , { env : { ...process . env , AGENT_TASK_WORKSPACE : workspace , AGENT_TASK_UPLOAD_PATH : upload , WP_CODEBOX_RUNTIME_SOURCE_ROOT : privateRoot } } )
@@ -167,7 +180,15 @@ await withTempDir("wp-codebox-runtime-source-upload-", async (directory) => {
167180 assert . doesNotMatch ( exclusionManifest , / p r e p a r e d - p l u g i n s | a g e n t s - a p i | p r i v a t e - r u n t i m e - s o u r c e / )
168181 await writeFile ( join ( workspace , ".codebox" , "agent-task-workflow-result.json" ) , JSON . stringify ( { typed_artifacts : [ { name : "reviewer-report" , type : "report" , artifact : { path : "prepared-plugins/agents-api/agents-api.php" } } ] } ) )
169182 await assert . rejects ( execFileAsync ( process . execPath , [ script . pathname ] , { env : { ...process . env , AGENT_TASK_WORKSPACE : workspace , AGENT_TASK_UPLOAD_PATH : upload , WP_CODEBOX_RUNTIME_SOURCE_ROOT : privateRoot } } ) , / D e c l a r e d r e v i e w e r a r t i f a c t s / )
183+ assert . ok ( await readFile ( join ( upload , ".codebox" , "agent-task-workflow-result.json" ) , "utf8" ) , "Declared artifact rejection preserves the normalized control result" )
170184 await rm ( join ( artifacts , "prepared-plugins" ) , { recursive : true , force : true } )
185+ for ( const path of [ "runtime-source-disguised.json" , "runtime-source-disguised.txt" ] ) {
186+ await writeFile ( join ( artifacts , path ) , await readFile ( new URL ( `../fixtures/agent-task-upload/${ path } ` , import . meta. url ) , "utf8" ) )
187+ await writeFile ( join ( workspace , ".codebox" , "agent-task-workflow-result.json" ) , JSON . stringify ( { typed_artifacts : [ { name : "reviewer-report" , type : "report" , artifact : { path } } ] } ) )
188+ await assert . rejects ( execFileAsync ( process . execPath , [ script . pathname ] , { env : { ...process . env , AGENT_TASK_WORKSPACE : workspace , AGENT_TASK_UPLOAD_PATH : upload , WP_CODEBOX_RUNTIME_SOURCE_ROOT : privateRoot } } ) , / s o u r c e c o n t e n t s / )
189+ assert . ok ( await readFile ( join ( upload , ".codebox" , "agent-task-workflow-result.json" ) , "utf8" ) , "Disguised source rejection preserves the normalized control result" )
190+ await rm ( join ( artifacts , path ) )
191+ }
171192 await mkdir ( suffixedPrivateRoot , { recursive : true } )
172193 await writeFile ( join ( artifacts , "suffixed-root-leak.json" ) , suffixedPrivateRoot )
173194 await writeFile ( join ( workspace , ".codebox" , "agent-task-workflow-result.json" ) , JSON . stringify ( { typed_artifacts : [ { name : "reviewer-report" , type : "report" , artifact : { path : "suffixed-root-leak.json" } } ] } ) )
0 commit comments