From 79cc9c3cae8ed66cb01e18af8db26d4e3120e560 Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Sat, 18 Jul 2026 22:05:01 -0400 Subject: [PATCH] Omit publication error from successful verification --- .../execute-native-agent-task.mjs | 10 +++++----- ...execute-native-agent-task-lifecycle.test.mjs | 17 +++++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/scripts/run-agent-task/execute-native-agent-task.mjs b/.github/scripts/run-agent-task/execute-native-agent-task.mjs index f33e74dfb..155abd1e0 100644 --- a/.github/scripts/run-agent-task/execute-native-agent-task.mjs +++ b/.github/scripts/run-agent-task/execute-native-agent-task.mjs @@ -295,11 +295,11 @@ async function verifyPublishedPullRequest(publication, targetRepo, cwd) { if (response.code !== 0) return { valid: false, error: "Published pull request could not be resolved through GitHub.", stderr: response.stderr, stderr_truncated: response.stderr_truncated } try { const pullRequest = JSON.parse(response.stdout) - return { - valid: pullRequest?.html_url === record(publication).pull_request?.url - && string(pullRequest?.base?.repo?.full_name).toLowerCase() === targetRepo.toLowerCase(), - error: "Published pull request did not resolve to the target repository.", - } + const valid = pullRequest?.html_url === record(publication).pull_request?.url + && string(pullRequest?.base?.repo?.full_name).toLowerCase() === targetRepo.toLowerCase() + return valid + ? { valid: true } + : { valid: false, error: "Published pull request did not resolve to the target repository." } } catch { return { valid: false, error: "GitHub pull-request validation did not return JSON." } } diff --git a/tests/execute-native-agent-task-lifecycle.test.mjs b/tests/execute-native-agent-task-lifecycle.test.mjs index 082641ec5..28e9c208d 100644 --- a/tests/execute-native-agent-task-lifecycle.test.mjs +++ b/tests/execute-native-agent-task-lifecycle.test.mjs @@ -17,7 +17,8 @@ async function run(mode = "success") { const targetRepo = mode === "canonical-casing" ? "automattic/build-with-wordpress" : "owner/repo" const publicationRepo = mode === "canonical-casing" ? "Automattic/build-with-wordpress" - : mode === "different-repo" ? "other/repo" : targetRepo + : targetRepo + const resolvedRepo = mode === "different-repo" ? "other/repo" : publicationRepo await mkdir(join(workspace, ".codebox"), { recursive: true }) await writeFile(join(workspace, "README.md"), "OPENAI_API_KEY\nbefore\n") @@ -139,8 +140,8 @@ export async function publishRunnerWorkspace({ testHook }) { const gh = join(temp, "gh") await writeFile(gh, `#!/usr/bin/env node process.stdout.write(JSON.stringify({ - html_url: ${JSON.stringify(`https://github.com/${publicationRepo}/pull/1`)}, - base: { repo: { full_name: ${JSON.stringify(publicationRepo)} } }, + html_url: ${JSON.stringify(`https://github.com/${resolvedRepo}/pull/1`)}, + base: { repo: { full_name: ${JSON.stringify(resolvedRepo)} } }, })) `) await chmod(gh, 0o755) @@ -189,6 +190,7 @@ assert(!durablePatch.includes("OPENAI_API_KEY"), "durable patch artifacts redact assert.match(durablePatch, /\[REDACTED\]/) assert.match(success.order, /runtime\nvalidation\nverification\ndrift\npublish\n/) assert.equal(success.result.runtime_result.metadata.runner_workspace_publication.pull_request.url, "https://github.com/owner/repo/pull/1") +assert.deepEqual(success.result.publication_verification, { valid: true }) assert.equal(success.result.runtime_result.agent_runtime_diagnostics.prepared_paths.workspaces[0].target, "/workspace") assert.equal(success.result.runtime_result.agent_runtime_diagnostics.prepared_paths.workspaces[0].mode, "readwrite") assert.equal(success.result.runtime_result.agent_runtime_diagnostics.sandbox_workspace.mounts[0].target, "/workspace") @@ -196,12 +198,15 @@ assert.equal(success.result.runtime_result.agent_runtime_diagnostics.local_execu const canonicalCasing = await run("canonical-casing") assert.equal(canonicalCasing.code, 0, `${canonicalCasing.stderr}\n${JSON.stringify(canonicalCasing.result)}`) -assert.equal(canonicalCasing.result.publication_verification.valid, true) +assert.deepEqual(canonicalCasing.result.publication_verification, { valid: true }) const differentRepository = await run("different-repo") assert.equal(differentRepository.code, 1) -assert.equal(differentRepository.result.publication_verification.valid, false) -assert.match(differentRepository.result.failure.message, /valid canonical pull-request result/) +assert.deepEqual(differentRepository.result.publication_verification, { + valid: false, + error: "Published pull request did not resolve to the target repository.", +}) +assert.equal(differentRepository.result.failure.message, "Published pull request did not resolve to the target repository.") const failedVerification = await run("verify-fail") assert.equal(failedVerification.code, 1)