mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-29 23:56:43 +01:00
fix(server): serialize review policy verdict authorization
Recheck terminal verdict and policy mutations under a row lock, and scope interaction verdict enforcement to the review confirmation itself. Co-Authored-By: Codex <noreply@openai.com>
This commit is contained in:
1 parent
373b675f94
commit
991f40bb2e
7 files changed
+205
-35
No files matched your search
@@ -81,7 +81,17 @@ export async function isIssueReviewVerdictInteraction(
|
||||
},
|
||||
): Promise<boolean> {
|
||||
const requester = await findReviewRequester(db, input.issue);
|
||||
if (!requester?.reviewInteractionId || requester.reviewInteractionId !== input.interaction.id) return false;
|
||||
if (!requester) return false;
|
||||
if (requester.reviewInteractionId && requester.reviewInteractionId !== input.interaction.id) return false;
|
||||
// Older review transitions did not persist the interaction binding. In that
|
||||
// case, an unattributed confirmation is ambiguous and must fail closed.
|
||||
// Confirmations attributed to an unrelated writer remain independently
|
||||
// resolvable, while requester-created confirmations inherit the issue policy.
|
||||
if (!requester.reviewInteractionId
|
||||
&& !input.interaction.createdByAgentId
|
||||
&& !input.interaction.createdByUserId) {
|
||||
return true;
|
||||
}
|
||||
return requester.type === "agent"
|
||||
? input.interaction.createdByAgentId === requester.id
|
||||
: input.interaction.createdByUserId === requester.id;
|
||||
|
||||
@@ -5893,6 +5893,15 @@ export function issueService(db: Db) {
|
||||
return getIssueByUuid(id);
|
||||
},
|
||||
|
||||
getByIdForUpdate: async (id: string, dbOrTx: any) => {
|
||||
return dbOrTx
|
||||
.select()
|
||||
.from(issues)
|
||||
.where(eq(issues.id, id))
|
||||
.for("update")
|
||||
.then((rows: Array<typeof issues.$inferSelect>) => rows[0] ?? null);
|
||||
},
|
||||
|
||||
getByIdentifier: async (identifier: string) => {
|
||||
return getIssueByIdentifier(identifier);
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user