fix: make break-glass evidence atomic

Write the owner-visible system notice and issue.break_glass_read audit entry in one transaction so an emergency read cannot persist only half of its evidence.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-08-01 22:56:08 +00:00
1 parent 71e7799bc1
commit 571851faf5
1 file changed
+32 -29
+32 -29
View File
@@ -3507,37 +3507,40 @@ export function issueRoutes(
) {
const actor = getActorInfo(req);
const occurredAt = new Date().toISOString();
await svc.addComment(
issue.id,
`A company administrator used audited break-glass access to read this private task at ${occurredAt}.`,
{},
{
authorType: "system",
presentation: {
kind: "system_notice",
tone: "warning",
title: "Break-glass access used",
detailsDefaultOpen: false,
density: "compact",
await db.transaction(async (tx) => {
const txDb = tx as unknown as Db;
await issueService(txDb).addComment(
issue.id,
`A company administrator used audited break-glass access to read this private task at ${occurredAt}.`,
{},
{
authorType: "system",
presentation: {
kind: "system_notice",
tone: "warning",
title: "Break-glass access used",
detailsDefaultOpen: false,
density: "compact",
},
},
},
);
await logActivity(db, {
companyId: issue.companyId,
actorType: "user",
actorId: actor.actorId,
agentId: null,
runId: actor.runId,
agentApiKeyId: actor.agentApiKeyId,
action: "issue.break_glass_read",
entityType: "issue",
entityId: issue.id,
issueId: issue.id,
details: {
);
await logActivity(txDb, {
companyId: issue.companyId,
actorType: "user",
actorId: actor.actorId,
agentId: null,
runId: actor.runId,
agentApiKeyId: actor.agentApiKeyId,
action: "issue.break_glass_read",
entityType: "issue",
entityId: issue.id,
issueId: issue.id,
occurredAt,
acknowledgement: "breakGlass=true",
},
details: {
issueId: issue.id,
occurredAt,
acknowledgement: "breakGlass=true",
},
});
});
}