Redact deleted issue comments

This commit is contained in:
Dotta
2026-06-03 17:32:25 +00:00
parent 78dc3625ac
commit 7f70759e61
27 changed files with 20722 additions and 83 deletions
@@ -107,4 +107,57 @@ describe("plugin SDK test harness", () => {
"missing required capability 'authorization.audit.read'",
);
});
it("returns tombstone-safe deleted comments from the in-memory issue helper", async () => {
const manifest: PaperclipPluginManifestV1 = {
id: "paperclip.test-comment-redaction",
apiVersion: 1,
version: "0.1.0",
displayName: "Comment Redaction",
description: "Test plugin",
author: "Paperclip",
categories: ["automation"],
capabilities: ["issue.comments.read"],
entrypoints: { worker: "./dist/worker.js" },
};
const harness = createTestHarness({ manifest });
harness.seed({
issues: [{
id: "issue-1",
companyId: "company-1",
title: "Comment redaction",
status: "todo",
priority: "medium",
}],
issueComments: [{
id: "comment-1",
companyId: "company-1",
issueId: "issue-1",
authorType: "user",
authorAgentId: null,
authorUserId: "user-1",
body: "secret plugin-visible body",
presentation: { kind: "system_notice", tone: "warning" },
metadata: { version: 1, sections: [{ rows: [{ type: "text", text: "secret plugin metadata" }] }] },
deletedAt: new Date("2026-06-03T12:00:00.000Z"),
deletedByType: "user",
deletedByUserId: "user-1",
createdAt: new Date("2026-06-03T11:00:00.000Z"),
updatedAt: new Date("2026-06-03T12:00:00.000Z"),
}],
});
const comments = await harness.ctx.issues.listComments("issue-1", "company-1");
expect(comments).toHaveLength(1);
expect(comments[0]).toMatchObject({
id: "comment-1",
body: "",
presentation: null,
metadata: null,
deletedByUserId: "user-1",
});
expect(JSON.stringify(comments)).not.toContain("secret plugin-visible body");
expect(JSON.stringify(comments)).not.toContain("secret plugin metadata");
});
});