Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions services/api/src/sandbox/orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3255,8 +3255,15 @@ function readOnlyRepositoryMode(mode: string) {
);
}

function githubPullRequestMode(mode: string) {
return ["review", "address_review", "ci_doctor"].includes(mode.replace(/-/g, "_"));
// Codex agents carry a `codex-` prefix by convention (see the seeded
// `codex-architect`/`codex-builder`), and `runs.mode` is the agent's name. Strip
// it here exactly as the sibling role predicates do, so a Codex-engine reviewer
// or repair agent resolves to the same governed role as its Claude counterpart
// and still receives the pull request's branch.
export function githubPullRequestMode(mode: string) {
return ["review", "address_review", "ci_doctor"].includes(
mode.replace(/^codex-/, "").replace(/-/g, "_"),
);
}

function receiptProvider(engine: string): FacilityReceipt["provider"] {
Expand Down
25 changes: 25 additions & 0 deletions services/api/test/sandbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import type { SandboxDriver } from "../src/sandbox/driver.js";
import {
dispatchRun,
finishRun,
githubPullRequestMode,
reconcileSandboxes,
repairExpectedHeadSha,
runDeliveryRefMismatch,
Expand Down Expand Up @@ -99,6 +100,30 @@ describe("run delivery integrity binding", () => {
);
expect(repairExpectedHeadSha("builder", { pullRequest: { headSha: webhook } })).toBeNull();
});

it("resolves pull-request roles identically for Claude and Codex agents", () => {
for (const role of ["review", "address-review", "ci-doctor"]) {
expect(githubPullRequestMode(role)).toBe(true);
expect(githubPullRequestMode(`codex-${role}`)).toBe(true);
}
expect(githubPullRequestMode("builder")).toBe(false);
expect(githubPullRequestMode("codex-builder")).toBe(false);
expect(githubPullRequestMode("codex-architect")).toBe(false);
});

it("keeps the checked-out branch and the pinned head in agreement for repair agents", () => {
// A repair agent that pins an admitted head must also be given the pull
// request's branch. Disagreement clones the default branch and then fails
// the runner's head verification with repository_head_sha_mismatch.
const admitted = "c".repeat(40);
for (const mode of ["address-review", "codex-address-review", "ci-doctor", "codex-ci-doctor"]) {
const pinsHead = Boolean(
repairExpectedHeadSha(mode, { ciDoctor: { admittedHeadSha: admitted } }),
);
expect(pinsHead).toBe(true);
expect(githubPullRequestMode(mode)).toBe(pinsHead);
}
});
});

async function canConnect() {
Expand Down
Loading