mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-20 09:50:48 +01:00
Validate PR artifacts and preserve file-level review completion
Explicit PR artifacts with unreadable identities could be dropped by the reference extractor, leaving completion with nothing to verify. Review comments linked through PR file views were also mistaken for delivery of the implementation PR itself. Refuse unreadable declared PR artifacts in both feedback and locked commit validation. Exclude review-comment outputs and recognize file-level comment links while still checking explicitly declared PR delivery artifacts. Verified the regressions fail before the fix. Server typecheck and 220 focused feedback, finalization, and configured-review tests pass afterward. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
88249dc41d
commit
7f259b7047
2 files changed
+43
-1
No files matched your search
@@ -95,6 +95,44 @@ describe("native final-response feedback", () => {
|
||||
} finally { resolve.mockRestore(); }
|
||||
});
|
||||
|
||||
it.each([
|
||||
"https://github.com/example/project/pull/not-a-number",
|
||||
"https://github.com/example/project/pull/0",
|
||||
"https://github.com/example/project/pull/9007199254740992",
|
||||
"https://example.test/example/project/pull/42",
|
||||
])("rejects an explicitly declared PR artifact with an unreadable identity: %s", async ref => {
|
||||
const value = await fixture();
|
||||
const lookup = vi.fn();
|
||||
const resolve = vi.spyOn(pullRequestMerge, "createPullRequestMergeStateResolver").mockReturnValue(lookup);
|
||||
const report = { ...done, artifacts: [{ kind: "pull_request", ref }] };
|
||||
try {
|
||||
await expect(nativeCompletionFeedback(db, value.runId, report)).rejects.toThrow("PR artifact has no verifiable GitHub identity");
|
||||
await expect(db.transaction(tx => validateNativeDeliverableEvidence(tx as unknown as typeof db,
|
||||
{ ...value, objective: "Deliver the implementation.", semanticToolReceipts: {}, lockSources: true,
|
||||
authoritativeDone: true, verifiedMergedPullRequests: new Set<string>() }, report)))
|
||||
.rejects.toThrow("PR artifact has no verifiable GitHub identity");
|
||||
expect(lookup).not.toHaveBeenCalled();
|
||||
} finally { resolve.mockRestore(); }
|
||||
});
|
||||
|
||||
it.each([
|
||||
"https://github.com/example/project/pull/42/files#r123",
|
||||
"https://github.com/example/project/pull/42/files?diff=split#r123",
|
||||
"https://github.com/example/project/pull/42/changes#r123",
|
||||
"https://github.com/example/project/pull/42#discussion_r123",
|
||||
])("does not treat a file-level review comment as delivery of the reviewed PR: %s", async ref => {
|
||||
const value = await fixture();
|
||||
const lookup = vi.fn().mockResolvedValue("open");
|
||||
const resolve = vi.spyOn(pullRequestMerge, "createPullRequestMergeStateResolver").mockReturnValue(lookup);
|
||||
try {
|
||||
await expect(nativeCompletionFeedback(db, value.runId, { ...done,
|
||||
artifacts: [{ kind: "review_comment", ref }] })).resolves.toContain("Completion report accepted");
|
||||
expect(lookup).not.toHaveBeenCalled();
|
||||
await expect(nativeCompletionFeedback(db, value.runId, { ...done,
|
||||
artifacts: [{ kind: "pull_request", ref }] })).rejects.toThrow("not been verified as merged");
|
||||
} finally { resolve.mockRestore(); }
|
||||
});
|
||||
|
||||
it("rechecks current deliverables under the commit lock without making network calls", async () => {
|
||||
const value = await fixture();
|
||||
const lookup = vi.fn().mockResolvedValue("merged");
|
||||
|
||||
@@ -34,7 +34,11 @@ export async function nativePullRequestCompletionReferences(db: Db, binding: Bin
|
||||
...(Array.isArray(artifacts) ? artifacts.flatMap(value => {
|
||||
const artifact = record(value);
|
||||
const ref = typeof value === "string" ? value : artifact.ref;
|
||||
if (artifact.kind !== "pull_request" && typeof ref === "string" && /\/pull\/[1-9][0-9]*#[^\s]+/u.test(ref)) return [];
|
||||
if (artifact.kind === "pull_request" && extractGitHubPullRequestReferences([ref]).length !== 1) {
|
||||
throw new NativePullRequestCompletionError("A declared PR artifact has no verifiable GitHub identity. Register its canonical PR URL before completing the task.");
|
||||
}
|
||||
if (artifact.kind !== "pull_request" && (artifact.kind === "review_comment" ||
|
||||
(typeof ref === "string" && /\/pull\/[1-9][0-9]*(?:[/?][^#\s]*)?#[^\s]+/u.test(ref)))) return [];
|
||||
return [ref];
|
||||
}) : []),
|
||||
...products.flatMap(product => {
|
||||
|
||||
Reference in new issue
Block a user