fix: preserve import job wipe ownership

Keep durable actor attribution from deleting record-owned jobs.

Align provider and idempotency coverage with fail-closed behavior.
This commit is contained in:
Marc-André Bombeck committed 2026-08-06 02:11:01 +02:00
1 parent f5ca810643
commit d404d8275a
3 files changed
+10 -2

No files matched your search

+2 -1
View File
@@ -643,7 +643,8 @@ describe("withIdempotency — record-scoped cells", () => {
await run();
expect(claimed().key).toBe(CLIENT_KEY);
expect(prisma.idempotencyKey.findUnique).not.toHaveBeenCalled();
expect(prisma.idempotencyKey.create).not.toHaveBeenCalled();
});
it("refuses a client key that carries the separator", async () => {
@@ -25,7 +25,10 @@ vi.mock("@/lib/ai/codex-oauth", () => ({
encryptCodexCreds: vi.fn(),
decryptCodexCreds: vi.fn(),
}));
vi.mock("@/lib/logging/context", () => ({ annotate: vi.fn() }));
vi.mock("@/lib/logging/context", () => ({
annotate: vi.fn(),
getEvent: vi.fn(() => undefined),
}));
vi.mock("undici", async (importOriginal) => {
const actual = await importOriginal<typeof import("undici")>();
return {
+4
View File
@@ -417,6 +417,10 @@ export const USER_KEPT_FIELDS: Readonly<Record<string, string>> = {
* {@link resolveWipeDelegate} translates; the route is unaware.
*/
export const WIPE_OWNER_FIELDS: Readonly<Record<string, readonly string[]>> = {
// The record owner owns the import payload. The actor is durable audit
// attribution and must not let deleting a manager erase another record's
// import history.
MedicationIntakeImportJob: ["recordUserId"],
// Both sides. Wiping only the grantor side would leave the account still
// holding read access to other people's records after it asked for
// everything of its own to be deleted.