Files
PaperClipAI/server/src/services/google-technical-information-work.ts
T
DottaandClaude Opus 5.5 12944919c6 feat(google): keep Google Technical Information at most 30 days and keep Google data out of training exports (#22842)
Adds a durable, sleep-aware 30-day sweep for Google Technical Information, keeps Google results out of decision training and shared feedback traces, and deletes the remaining copies of a cleaned run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 19:57:23 -06:00

42 lines
1.5 KiB
TypeScript

import type { Db } from "@paperclipai/db";
import { DELIVERY_QUEUES } from "./delivery-work-notifications.js";
import { registerDeadlineWork } from "./deadline-work.js";
import type { createDeliveryWorkCoordinator } from "./delivery-work-coordinator.js";
import { registerIdleLocalWorkProbe } from "./idle-local-work.js";
import { createGoogleTechnicalInformationRetention } from "./tool-access/connections/google-technical-information.js";
export function registerGoogleTechnicalInformationWork(
db: Db,
coordinator: ReturnType<typeof createDeliveryWorkCoordinator>,
canRun: () => boolean,
) {
const retention = createGoogleTechnicalInformationRetention(db);
let deadline: number | null | undefined;
const unregister = registerIdleLocalWorkProbe((options = {}) => {
if (deadline === undefined) return "unknown";
if (deadline === null) return "none";
return options.deadlineCapability?.deadlineCatalog === "domain_deadlines_v1" && deadline > Date.now()
? "none" : "present";
});
const worker = registerDeadlineWork(coordinator, DELIVERY_QUEUES.googleTechnicalInformation, {
canRun,
retryMs: 60_000,
notificationCoalesceMs: 5_000,
onSettled: () => {
deadline = undefined;
},
run: (signal) => signal.aborted ? Promise.resolve() : retention.sweep(signal),
next: async () => {
deadline = await retention.nextDeadline();
return deadline;
},
});
return {
...worker,
stop: async () => {
unregister();
await worker.stop();
},
};
}