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
3 changes: 2 additions & 1 deletion test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ identities for a release already recorded on the base. Later upgrades must
retain prior records and revocations. Revoked hashes cannot authorize execution,
even when retained in a historical record.

This manifest cannot approve itself. A different human with current repository
The PR author may be a GitHub App bot on this repository. This manifest cannot
approve itself. A different human with current repository
`maintain` or `admin` permission must review the exact source and post one whole
comment: `NemoClaw-Upgrade-E2E: approve <head-sha> <base-sha>`. The corresponding
`revoke` command withdraws that decision. The latest eligible decision wins;
Expand Down
23 changes: 23 additions & 0 deletions test/e2e/support/candidate-upgrade-admission.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,29 @@ describe("candidate upgrade admission", () => {
expect(f.request.mock.calls.filter(([path]) => path.endsWith("/pulls/123"))).toHaveLength(2);
});

it("accepts a bot-authored PR only with an independent human maintainer's approval", async () => {
const f = fixture();
f.pr.user.login = "nvidia-nemopatch-writer[bot]";
await expect(readApprovedCandidateUpgrade(identity, [sourcePath], f.request)).resolves.toEqual({
sources: { [sourcePath]: f.source },
reviewer: "reviewer",
commentId: 50,
});
f.records.length = 0;
await expect(readApprovedCandidateUpgrade(identity, [sourcePath], f.request)).rejects.toThrow(
/independent maintainer/,
);
});

it("rejects a malformed bot author login before reading approval comments", async () => {
const f = fixture();
f.pr.user.login = "nvidia-nemopatch-writer[bot]suffix";
await expect(readApprovedCandidateUpgrade(identity, [sourcePath], f.request)).rejects.toThrow(
/open upstream PR/,
);
expect(f.request.mock.calls.some(([path]) => path.includes("/comments"))).toBe(false);
});

it.each([{ prNumber: 0 }, { candidateSha: "main" }, { baseSha: "main" }])(
"rejects invalid identity %j before any request",
async (change) => {
Expand Down
4 changes: 3 additions & 1 deletion tools/e2e/candidate-upgrade-admission.mts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const REPOSITORY = "NVIDIA/NemoClaw";
const PREFIX = `/repos/${REPOSITORY}`;
const SHA = /^[a-f0-9]{40}$/u;
const LOGIN = /^[a-zA-Z0-9][a-zA-Z0-9-]{0,38}$/u;
// GitHub adds [bot] to app authors; approval still requires a human LOGIN.
const PR_AUTHOR_LOGIN = /^[a-zA-Z0-9][a-zA-Z0-9-]{0,38}(?:\[bot\])?$/u;
const MAX_PAGES = 100;
const MAX_SOURCE_BYTES = 1024 * 1024;

Expand Down Expand Up @@ -54,7 +56,7 @@ function assertPullRequest(
record(head.repo).full_name !== REPOSITORY ||
record(base.repo).full_name !== REPOSITORY ||
typeof author.login !== "string" ||
!LOGIN.test(author.login)
!PR_AUTHOR_LOGIN.test(author.login)
)
throw new Error("Upgrade admission no longer matches the open upstream PR");
return author.login.toLowerCase();
Expand Down