@@ -15,7 +15,7 @@ async function run(mode = "success") {
1515 const temp = await mkdtemp ( join ( tmpdir ( ) , "wp-codebox-native-lifecycle-" ) )
1616 const workspace = join ( temp , "workspace" )
1717 await mkdir ( join ( workspace , ".codebox" ) , { recursive : true } )
18- await writeFile ( join ( workspace , "README.md" ) , "before \n" )
18+ await writeFile ( join ( workspace , "README.md" ) , "OPENAI_API_KEY\nbefore \n" )
1919
2020 const request = {
2121 schema : "wp-codebox/agent-task-workflow-request/v1" ,
@@ -74,7 +74,7 @@ const output = process.argv[process.argv.indexOf("--result-file") + 1]
7474const input = JSON.parse(await readFile(process.argv[process.argv.indexOf("--input-file") + 1], "utf8"))
7575const root = join(process.cwd(), ".codebox", "agent-task-artifacts", "files")
7676await mkdir(root, { recursive: true })
77- const patch = ${ JSON . stringify ( noOp ? "" : applyReject ? "--- a/README.md\n+++ b/README.md\n@@ -1 +1 @@\n-not-before\n+after\n" : "--- a/README.md\n+++ b/README.md\n@@ -1 +1 @@\n-before\n+after\n" ) }
77+ const patch = ${ JSON . stringify ( noOp ? "" : applyReject ? "--- a/README.md\n+++ b/README.md\n@@ -1,2 +1,2 @@\n OPENAI_API_KEY\n -not-before\n+after\n" : "--- a/README.md\n+++ b/README.md\n@@ -1,2 +1,2 @@\n OPENAI_API_KEY \n-before\n+after\n" ) }
7878await writeFile(join(root, "patch.diff"), patch)
7979await writeFile(join(root, "changed-files.json"), JSON.stringify({
8080 schema: "wp-codebox/changed-files/v1",
@@ -146,6 +146,7 @@ process.stdout.write(JSON.stringify({
146146 WP_CODEBOX_TEST_PUBLISHER_MODULE : publisher ,
147147 WP_CODEBOX_TEST_PUBLISHER_HOOK : JSON . stringify ( { orderPath : publisherOrderPath } ) ,
148148 GITHUB_TOKEN : "token" ,
149+ MODEL_PROVIDER_SECRET_1 : "OPENAI_API_KEY" ,
149150 EXPLICIT_ACCESS_TOKEN_CONFIGURED : "true" ,
150151 EXTERNAL_PACKAGE_SOURCE_POLICY : JSON . stringify ( {
151152 version : 1 ,
@@ -169,7 +170,10 @@ process.stdout.write(JSON.stringify({
169170
170171const success = await run ( )
171172assert . equal ( success . code , 0 , success . stderr )
172- assert . equal ( await readFile ( join ( success . workspace , "README.md" ) , "utf8" ) , "after\n" )
173+ assert . equal ( await readFile ( join ( success . workspace , "README.md" ) , "utf8" ) , "OPENAI_API_KEY\nafter\n" )
174+ const durablePatch = await readFile ( join ( success . workspace , ".codebox" , "agent-task-artifacts" , "files" , "patch.diff" ) , "utf8" )
175+ assert ( ! durablePatch . includes ( "OPENAI_API_KEY" ) , "durable patch artifacts redact configured secret values" )
176+ assert . match ( durablePatch , / \[ R E D A C T E D \] / )
173177assert . match ( success . order , / r u n t i m e \n v a l i d a t i o n \n v e r i f i c a t i o n \n d r i f t \n p u b l i s h \n / )
174178assert . equal ( success . result . runtime_result . metadata . runner_workspace_publication . pull_request . url , "https://github.com/owner/repo/pull/1" )
175179assert . equal ( success . result . runtime_result . agent_runtime_diagnostics . prepared_paths . workspaces [ 0 ] . target , "/workspace" )
@@ -214,12 +218,12 @@ await execFileAsync(process.execPath, [uploader], {
214218 AGENT_TASK_UPLOAD_PATH : join ( mismatch . workspace , ".codebox" , "agent-task-upload" ) ,
215219 } ,
216220} )
217- assert . equal ( await readFile ( join ( mismatch . workspace , ".codebox" , "agent-task-upload" , ".codebox" , "agent-task-artifacts" , "apply-failure" , "rejected.patch" ) , "utf8" ) , "--- a/README.md\n+++ b/README.md\n@@ -1 +1 @@\n-before\n+after\n" )
221+ assert . equal ( await readFile ( join ( mismatch . workspace , ".codebox" , "agent-task-upload" , ".codebox" , "agent-task-artifacts" , "apply-failure" , "rejected.patch" ) , "utf8" ) , "--- a/README.md\n+++ b/README.md\n@@ -1,2 +1,2 @@\n [REDACTED] \n-before\n+after\n" )
218222assert . match ( await readFile ( join ( mismatch . workspace , ".codebox" , "agent-task-upload" , ".codebox" , "agent-task-artifacts" , "apply-failure" , "changed-files.json" ) , "utf8" ) , / R E A D M E \. m d / )
219223
220224const applyReject = await run ( "apply-reject" )
221225assert . equal ( applyReject . code , 1 )
222- assert . equal ( await readFile ( join ( applyReject . workspace , "README.md" ) , "utf8" ) , "before \n" , "a rejected patch does not partially mutate the matching host workspace" )
226+ assert . equal ( await readFile ( join ( applyReject . workspace , "README.md" ) , "utf8" ) , "OPENAI_API_KEY\nbefore \n" , "a rejected patch does not partially mutate the matching host workspace" )
223227assert . equal ( applyReject . result . failure . stage , "apply" )
224228assert . match ( applyReject . result . failure . message , / H o s t g i t a p p l y f a i l e d / )
225229assert . deepEqual ( applyReject . result . failure . evidence . expected_identity , applyReject . result . failure . evidence . actual_identity , "the failure records the matching seed and host identities" )
0 commit comments