@capybara-hq/kernel 0.1.0-rc.130 → 0.1.0-rc.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/account-erasures.d.ts +37 -0
- package/dist/admin/account-erasures.js +119 -0
- package/dist/admin/admin.controller.d.ts +35 -2
- package/dist/admin/admin.controller.js +75 -18
- package/dist/admin/admin.module.js +10 -0
- package/dist/admin/admin.schemas.d.ts +51 -0
- package/dist/admin/admin.schemas.js +20 -0
- package/dist/admin/erasure-dispositions.d.ts +23 -0
- package/dist/admin/erasure-dispositions.js +76 -0
- package/dist/admin/health.service.d.ts +6 -0
- package/dist/admin/health.service.js +27 -1
- package/dist/admin/usage.service.d.ts +5 -0
- package/dist/admin/usage.service.js +21 -2
- package/dist/agents/agents.service.d.ts +1 -1
- package/dist/channels/connections.service.d.ts +1 -1
- package/dist/client/client-reports.service.js +12 -0
- package/dist/config/schema.d.ts +8 -1
- package/dist/config/schema.js +43 -1
- package/dist/conversations/conversations.service.d.ts +9 -1
- package/dist/conversations/conversations.service.js +112 -15
- package/dist/conversations/event-log.d.ts +2 -0
- package/dist/conversations/event-log.js +77 -0
- package/dist/conversations/events.d.ts +11 -0
- package/dist/conversations/events.js +13 -1
- package/dist/conversations/prompt-suggestions.js +4 -0
- package/dist/conversations/titles.js +3 -2
- package/dist/db/kernel-schema.d.ts +71 -8
- package/dist/devices/devices.service.d.ts +13 -1
- package/dist/devices/devices.service.js +122 -9
- package/dist/erasure/account-batches.d.ts +9 -0
- package/dist/erasure/account-batches.js +567 -0
- package/dist/erasure/account-files.d.ts +34 -0
- package/dist/erasure/account-files.js +217 -0
- package/dist/erasure/account-residual.d.ts +15 -0
- package/dist/erasure/account-residual.js +149 -0
- package/dist/erasure/account-worker.d.ts +32 -0
- package/dist/erasure/account-worker.js +392 -0
- package/dist/erasure/device-cleanup.d.ts +23 -0
- package/dist/erasure/device-cleanup.js +221 -0
- package/dist/erasure/erasure.module.d.ts +2 -0
- package/dist/erasure/erasure.module.js +14 -0
- package/dist/erasure/external-evidence.d.ts +4 -0
- package/dist/erasure/external-evidence.js +28 -0
- package/dist/erasure/jobs.d.ts +5 -0
- package/dist/erasure/jobs.js +20 -0
- package/dist/erasure/org-batches.d.ts +11 -0
- package/dist/erasure/org-batches.js +159 -0
- package/dist/erasure/org-catalog.d.ts +2 -0
- package/dist/erasure/org-catalog.js +34 -0
- package/dist/erasure/org-rules.d.ts +14 -0
- package/dist/erasure/org-rules.js +227 -0
- package/dist/erasure/org-worker.d.ts +38 -0
- package/dist/erasure/org-worker.js +501 -0
- package/dist/erasure/requests.d.ts +61 -0
- package/dist/erasure/requests.js +180 -0
- package/dist/erasure/sweep.job.d.ts +19 -0
- package/dist/erasure/sweep.job.js +130 -0
- package/dist/erasure/worker.d.ts +17 -0
- package/dist/erasure/worker.js +110 -0
- package/dist/errors.d.ts +4 -0
- package/dist/errors.js +4 -0
- package/dist/evals/judge.d.ts +5 -0
- package/dist/evals/judge.js +16 -1
- package/dist/evals/run-replay.js +12 -1
- package/dist/evals/step-replay.d.ts +5 -3
- package/dist/evals/step-replay.js +9 -5
- package/dist/evals/worker.d.ts +2 -0
- package/dist/evals/worker.js +60 -16
- package/dist/files/blob-objects.d.ts +7 -3
- package/dist/files/blob-objects.js +39 -22
- package/dist/files/blob-sweep.job.d.ts +11 -0
- package/dist/files/blob-sweep.job.js +67 -6
- package/dist/http/api.module.js +5 -1
- package/dist/identity/accounts.js +3 -0
- package/dist/identity/api-tokens.js +5 -0
- package/dist/identity/auth.guard.d.ts +1 -0
- package/dist/identity/auth.guard.js +1 -0
- package/dist/identity/erasure-admission.d.ts +3 -0
- package/dist/identity/erasure-admission.js +14 -0
- package/dist/identity/external.js +5 -0
- package/dist/identity/sessions.js +5 -0
- package/dist/identity/settings.d.ts +86 -1
- package/dist/identity/settings.js +38 -4
- package/dist/infra/config/kernel-config.service.js +1 -0
- package/dist/infra/metrics/kernel-metrics.d.ts +18 -0
- package/dist/infra/metrics/kernel-metrics.js +54 -0
- package/dist/infra/metrics/operational-metrics.d.ts +31 -0
- package/dist/infra/metrics/operational-metrics.js +188 -0
- package/dist/infra/outbox/registry.d.ts +23 -0
- package/dist/infra/outbox/registry.js +12 -0
- package/dist/infra/throttler/credential-throttler.js +8 -1
- package/dist/infra/throttler/named-throttlers.d.ts +6 -0
- package/dist/infra/throttler/named-throttlers.js +6 -0
- package/dist/infra/throttler/principal-throttler.guard.d.ts +10 -0
- package/dist/infra/throttler/principal-throttler.guard.js +50 -0
- package/dist/infra/throttler/redis-throttler-storage.d.ts +1 -0
- package/dist/infra/throttler/redis-throttler-storage.js +27 -5
- package/dist/infra/throttler/throttler.guard.d.ts +2 -3
- package/dist/infra/throttler/throttler.guard.js +2 -3
- package/dist/infra/throttler/throttler.module.js +3 -2
- package/dist/models/budget-admission.d.ts +31 -0
- package/dist/models/budget-admission.js +149 -0
- package/dist/models/budget-counters.d.ts +28 -0
- package/dist/models/budget-counters.js +117 -0
- package/dist/models/budget-policy.d.ts +88 -0
- package/dist/models/budget-policy.js +78 -0
- package/dist/models/embeddings.js +13 -2
- package/dist/models/images.js +12 -2
- package/dist/models/purposes.d.ts +5 -2
- package/dist/models/purposes.js +9 -5
- package/dist/orgs/invitations.service.d.ts +1 -1
- package/dist/orgs/members.service.d.ts +28 -1
- package/dist/orgs/members.service.js +74 -11
- package/dist/orgs/offboarding.js +4 -6
- package/dist/orgs/org-owner.d.ts +2 -0
- package/dist/orgs/org-owner.js +21 -6
- package/dist/orgs/orgs.controller.d.ts +22 -0
- package/dist/orgs/orgs.controller.js +24 -0
- package/dist/orgs/orgs.module.js +4 -0
- package/dist/orgs/orgs.schemas.js +7 -0
- package/dist/orgs/orgs.service.d.ts +5 -1
- package/dist/orgs/orgs.service.js +28 -3
- package/dist/orgs/settings.controller.js +6 -1
- package/dist/orgs/settings.service.d.ts +58 -1
- package/dist/orgs/settings.service.js +74 -9
- package/dist/platform/exclusions.js +20 -1
- package/dist/platform/ops/accounts.ops.js +58 -1
- package/dist/platform/ops/admin.ops.js +13 -5
- package/dist/platform/ops/org-settings.ops.js +11 -4
- package/dist/platform/ops/orgs.ops.js +28 -0
- package/dist/platform/ops/retention.d.ts +16 -0
- package/dist/platform/ops/retention.js +21 -0
- package/dist/retention/jobs.d.ts +21 -0
- package/dist/retention/jobs.js +48 -0
- package/dist/retention/policy.d.ts +70 -0
- package/dist/retention/policy.js +103 -0
- package/dist/retention/purge-batch.d.ts +17 -0
- package/dist/retention/purge-batch.js +355 -0
- package/dist/retention/report-obligations.d.ts +12 -0
- package/dist/retention/report-obligations.js +71 -0
- package/dist/retention/sweep.job.d.ts +17 -0
- package/dist/retention/sweep.job.js +95 -0
- package/dist/retention/worker.d.ts +29 -0
- package/dist/retention/worker.js +306 -0
- package/dist/roles/worker.module.js +12 -2
- package/dist/runtime/maintenance.d.ts +5 -1
- package/dist/runtime/maintenance.js +20 -2
- package/dist/runtime/model-call.d.ts +3 -1
- package/dist/runtime/model-call.js +25 -3
- package/dist/runtime/providers.d.ts +7 -2
- package/dist/runtime/providers.js +76 -10
- package/dist/runtime/quota.d.ts +12 -12
- package/dist/runtime/quota.js +42 -37
- package/dist/runtime/run-finish.js +2 -0
- package/dist/runtime/run-principal.d.ts +9 -0
- package/dist/runtime/run-principal.js +18 -0
- package/dist/runtime/run-worker.js +48 -10
- package/dist/runtime/usage-report-jobs.d.ts +4 -1
- package/dist/runtime/usage-report-jobs.js +36 -13
- package/dist/runtime/usage-report.d.ts +5 -3
- package/dist/runtime/usage-report.js +37 -19
- package/dist/sandbox/review/classifier.d.ts +2 -2
- package/dist/sandbox/review/classifier.js +6 -2
- package/dist/sandbox/sandbox.service.js +18 -7
- package/dist/storage/purge.js +5 -1
- package/dist/storage/storage.service.d.ts +17 -1
- package/dist/storage/storage.service.js +75 -4
- package/dist/tools/builtins/vision/read-image.js +3 -0
- package/dist/tools/builtins/web/extract.js +3 -0
- package/dist/tools/pipeline.js +5 -1
- package/package.json +3 -1
- package/src/migrations/0216_model_budget_counters.sql +24 -0
- package/src/migrations/0217_retention.sql +44 -0
- package/src/migrations/0218_data_erasure.sql +41 -0
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
};
|
|
10
|
+
import { Inject, Injectable } from "@nestjs/common";
|
|
11
|
+
import { sql } from "kysely";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import { ConversationsService } from "../conversations/conversations.service.js";
|
|
14
|
+
import { BlobObjects } from "../files/blob-objects.js";
|
|
15
|
+
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
16
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
17
|
+
import { asPlatform, withOrgScope } from "../infra/database/org-scope.js";
|
|
18
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
19
|
+
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
20
|
+
import { OrgLock } from "../orgs/org-lock.js";
|
|
21
|
+
import { StorageService } from "../storage/storage.service.js";
|
|
22
|
+
import { accountErasureBatch, accountRootBatch } from "./account-batches.js";
|
|
23
|
+
import { accountFileBatch, accountFileIntentSchema, verifyAccountFileObjects, } from "./account-files.js";
|
|
24
|
+
import { accountHistoryPage, accountResidual } from "./account-residual.js";
|
|
25
|
+
import { AccountDeviceCleanup } from "./device-cleanup.js";
|
|
26
|
+
import { hasExternalDisposition, hasOpaqueExtensionHistory } from "./external-evidence.js";
|
|
27
|
+
import { ErasureRequests } from "./requests.js";
|
|
28
|
+
const RECHECK_MS = 5 * 60_000;
|
|
29
|
+
const DAY = 24 * 60 * 60_000;
|
|
30
|
+
const IN_FLIGHT_WINDOW_MS = DAY;
|
|
31
|
+
const HistoryKey = z.object({ conversationId: z.string(), seq: z.string().regex(/^\d+$/) });
|
|
32
|
+
const Progress = z.object({
|
|
33
|
+
inaccessibleSince: z.iso.datetime(),
|
|
34
|
+
storageIdentity: z.string(),
|
|
35
|
+
afterOrg: z.string().optional(),
|
|
36
|
+
file: accountFileIntentSchema.optional(),
|
|
37
|
+
historyComplete: z.boolean().optional(),
|
|
38
|
+
historyCursor: z.object({ end: HistoryKey, after: HistoryKey.optional() }).optional(),
|
|
39
|
+
});
|
|
40
|
+
let AccountErasure = class AccountErasure {
|
|
41
|
+
db;
|
|
42
|
+
txHost;
|
|
43
|
+
config;
|
|
44
|
+
lock;
|
|
45
|
+
requests;
|
|
46
|
+
conversations;
|
|
47
|
+
storage;
|
|
48
|
+
objects;
|
|
49
|
+
devices;
|
|
50
|
+
constructor(db, txHost, config, lock, requests, conversations, storage, objects, devices) {
|
|
51
|
+
this.db = db;
|
|
52
|
+
this.txHost = txHost;
|
|
53
|
+
this.config = config;
|
|
54
|
+
this.lock = lock;
|
|
55
|
+
this.requests = requests;
|
|
56
|
+
this.conversations = conversations;
|
|
57
|
+
this.storage = storage;
|
|
58
|
+
this.objects = objects;
|
|
59
|
+
this.devices = devices;
|
|
60
|
+
}
|
|
61
|
+
async run(id, generation) {
|
|
62
|
+
return asPlatform("worker entry for an opaque account erasure request", async () => {
|
|
63
|
+
const history = await this.prepareHistory(id, generation);
|
|
64
|
+
const action = await this.runStage(id, generation, history);
|
|
65
|
+
if (!action)
|
|
66
|
+
return;
|
|
67
|
+
if (action.kind === "final")
|
|
68
|
+
return this.finishAccount(id, generation);
|
|
69
|
+
if (action.kind === "file") {
|
|
70
|
+
try {
|
|
71
|
+
await withOrgScope(action.intent.orgId, () => this.storage.verifyErasureObjects(action.intent.orgId, action.storageIdentity, (store) => verifyAccountFileObjects(store, this.objects, action.intent)));
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
await this.fileResult(id, generation, action, false);
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
await this.fileResult(id, generation, action, true);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const { accountId } = action;
|
|
81
|
+
try {
|
|
82
|
+
await this.storage.deleteVerifiedAccountAvatars(accountId, action.storageIdentity);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
await this.avatarResult(id, generation, accountId, false);
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
await this.avatarResult(id, generation, accountId, true);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
enabled() {
|
|
92
|
+
const enabled = this.config.get().retention;
|
|
93
|
+
return enabled.erasureEnabled && enabled.destructiveEnabled;
|
|
94
|
+
}
|
|
95
|
+
defer(row, reason, dueAt = new Date(Date.now() + RECHECK_MS)) {
|
|
96
|
+
if (row.stage === "done")
|
|
97
|
+
throw new Error("Completed erasure work cannot be deferred");
|
|
98
|
+
return this.requests.advance(row, row.stage, reason, dueAt);
|
|
99
|
+
}
|
|
100
|
+
async prepareHistory(id, generation) {
|
|
101
|
+
if (!this.enabled())
|
|
102
|
+
return;
|
|
103
|
+
const work = await this.db
|
|
104
|
+
.selectFrom("data_erasure_requests")
|
|
105
|
+
.select(["target_id", "progress"])
|
|
106
|
+
.where("id", "=", id)
|
|
107
|
+
.where("org_id", "is", null)
|
|
108
|
+
.where("kind", "=", "account")
|
|
109
|
+
.where("generation", "=", generation)
|
|
110
|
+
.where("stage", "=", "account-final")
|
|
111
|
+
.where("due_at", "<=", sql `now()`)
|
|
112
|
+
.executeTakeFirst();
|
|
113
|
+
if (!work?.target_id)
|
|
114
|
+
return;
|
|
115
|
+
const progress = Progress.safeParse(work.progress);
|
|
116
|
+
if (!progress.success || progress.data.historyComplete)
|
|
117
|
+
return;
|
|
118
|
+
return accountHistoryPage(this.db.db, work.target_id, progress.data.historyCursor);
|
|
119
|
+
}
|
|
120
|
+
async runStage(id, generation, history) {
|
|
121
|
+
if (!this.enabled())
|
|
122
|
+
return;
|
|
123
|
+
const work = await this.requests.claim(id, generation);
|
|
124
|
+
if (work?.kind !== "account" || !work.target_id)
|
|
125
|
+
return;
|
|
126
|
+
const accountId = work.target_id;
|
|
127
|
+
const account = await this.db
|
|
128
|
+
.selectFrom("accounts")
|
|
129
|
+
.select(["id", "updated_at"])
|
|
130
|
+
.where("id", "=", accountId)
|
|
131
|
+
.where("status", "=", "disabled")
|
|
132
|
+
.where("erasure_requested", "=", true)
|
|
133
|
+
.executeTakeFirst();
|
|
134
|
+
if (!account) {
|
|
135
|
+
await this.defer(work, "account-fence");
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const observedStorage = this.storage.erasureIdentity();
|
|
139
|
+
const storedStorage = z
|
|
140
|
+
.object({ storageIdentity: z.string().nullable().optional() })
|
|
141
|
+
.safeParse(work.progress ?? {});
|
|
142
|
+
if (!storedStorage.success ||
|
|
143
|
+
!observedStorage ||
|
|
144
|
+
(storedStorage.data.storageIdentity != null &&
|
|
145
|
+
storedStorage.data.storageIdentity !== observedStorage)) {
|
|
146
|
+
await this.defer(work, "storage-provider-changed");
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
if (work.stage === "pending") {
|
|
150
|
+
const incomplete = new Date(account.updated_at.getTime() + IN_FLIGHT_WINDOW_MS);
|
|
151
|
+
if (incomplete.getTime() > Date.now()) {
|
|
152
|
+
await this.defer(work, "account-admission-drain", incomplete);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (!(await this.externalEvidence(work, accountId, storedStorage.data.storageIdentity == null))) {
|
|
156
|
+
await this.defer(work, "external-cleanup-unverified");
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
await this.requests.advance(work, "account-orgs", null, new Date(), {
|
|
160
|
+
inaccessibleSince: account.updated_at.toISOString(),
|
|
161
|
+
storageIdentity: observedStorage,
|
|
162
|
+
});
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const progress = Progress.safeParse(work.progress);
|
|
166
|
+
if (!progress.success || progress.data.storageIdentity !== observedStorage) {
|
|
167
|
+
await this.defer(work, "account-erasure-progress");
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (work.stage === "account-orgs") {
|
|
171
|
+
const org = await this.db
|
|
172
|
+
.selectFrom("orgs")
|
|
173
|
+
.select("id")
|
|
174
|
+
.$if(progress.data.afterOrg !== undefined, (q) => q.where("id", ">", progress.data.afterOrg))
|
|
175
|
+
.orderBy("id")
|
|
176
|
+
.limit(1)
|
|
177
|
+
.executeTakeFirst();
|
|
178
|
+
if (!org) {
|
|
179
|
+
await this.requests.advance(work, "account-external", null, new Date());
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const batch = await withOrgScope(org.id, () => this.orgBatch(org.id, accountId, new Date(progress.data.inaccessibleSince), progress.data.file));
|
|
183
|
+
if (batch.blocked) {
|
|
184
|
+
await this.defer(work, batch.blocked);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (batch.external && batch.intent && batch.intent.phase === progress.data.file?.phase)
|
|
188
|
+
return { kind: "file", accountId, intent: batch.intent, storageIdentity: observedStorage };
|
|
189
|
+
await this.requests.advance(work, "account-orgs", null, new Date(), {
|
|
190
|
+
...progress.data,
|
|
191
|
+
...(batch.intent && { file: batch.intent }),
|
|
192
|
+
...(batch.done && { afterOrg: org.id }),
|
|
193
|
+
});
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (work.stage === "account-external")
|
|
197
|
+
return { kind: "avatar", accountId, storageIdentity: observedStorage };
|
|
198
|
+
if (work.stage !== "account-final")
|
|
199
|
+
return;
|
|
200
|
+
if (!progress.data.historyComplete) {
|
|
201
|
+
if (!history)
|
|
202
|
+
return;
|
|
203
|
+
await this.requests.advance(work, "account-final", null, new Date(), {
|
|
204
|
+
...progress.data,
|
|
205
|
+
historyComplete: history.next === undefined,
|
|
206
|
+
historyCursor: history.next,
|
|
207
|
+
}, history.hit ? ["third-party-conversation-content"] : undefined);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (await this.clearFinalRows(work, accountId))
|
|
211
|
+
return { kind: "final" };
|
|
212
|
+
}
|
|
213
|
+
async externalEvidence(work, accountId, unknownStorage) {
|
|
214
|
+
if (await hasExternalDisposition(this.db.db, work.id, "external-cleanup-unverified"))
|
|
215
|
+
return true;
|
|
216
|
+
if (unknownStorage)
|
|
217
|
+
return false;
|
|
218
|
+
const [identity, extensions] = await Promise.all([
|
|
219
|
+
this.db
|
|
220
|
+
.selectFrom("identities")
|
|
221
|
+
.select("account_id")
|
|
222
|
+
.where("account_id", "=", accountId)
|
|
223
|
+
.where("source", "!=", "local")
|
|
224
|
+
.limit(1)
|
|
225
|
+
.executeTakeFirst(),
|
|
226
|
+
hasOpaqueExtensionHistory(this.db.db),
|
|
227
|
+
]);
|
|
228
|
+
return identity === undefined && !extensions;
|
|
229
|
+
}
|
|
230
|
+
async orgBatch(orgId, accountId, inaccessibleSince, priorFile) {
|
|
231
|
+
await this.lock.lockForRemoval(orgId);
|
|
232
|
+
const org = await this.db
|
|
233
|
+
.selectFrom("orgs")
|
|
234
|
+
.select("deleted_at")
|
|
235
|
+
.where("id", "=", orgId)
|
|
236
|
+
.forNoKeyUpdate()
|
|
237
|
+
.executeTakeFirst();
|
|
238
|
+
if (!org)
|
|
239
|
+
return { done: true };
|
|
240
|
+
const cutoff = new Date(Date.now() - this.config.get().files.deletedRetentionDays * DAY);
|
|
241
|
+
const file = await accountFileBatch(this.db.db, orgId, accountId, cutoff, priorFile);
|
|
242
|
+
if (!file.done && file.blocked !== "account-file-conversations")
|
|
243
|
+
return file;
|
|
244
|
+
const roots = await accountRootBatch(this.db.db, orgId, accountId);
|
|
245
|
+
if (roots.blocked)
|
|
246
|
+
return { blocked: roots.blocked };
|
|
247
|
+
if (roots.removed)
|
|
248
|
+
return { done: false };
|
|
249
|
+
const root = await this.db
|
|
250
|
+
.selectFrom("conversations")
|
|
251
|
+
.select(["id", "deleted_at"])
|
|
252
|
+
.where("org_id", "=", orgId)
|
|
253
|
+
.where("account_id", "=", accountId)
|
|
254
|
+
.where("parent_conversation_id", "is", null)
|
|
255
|
+
.orderBy("deleted_at", (o) => o.nullsFirst())
|
|
256
|
+
.orderBy("id")
|
|
257
|
+
.limit(1)
|
|
258
|
+
.executeTakeFirst();
|
|
259
|
+
if (root) {
|
|
260
|
+
if (root.deleted_at)
|
|
261
|
+
return { blocked: "conversation-purge" };
|
|
262
|
+
await this.conversations.tombstoneForErasure(orgId, root.id, accountId, inaccessibleSince);
|
|
263
|
+
return { done: false };
|
|
264
|
+
}
|
|
265
|
+
if (!file.done)
|
|
266
|
+
return file;
|
|
267
|
+
const batch = await accountErasureBatch(this.db.db, accountId, orgId);
|
|
268
|
+
if (batch.blocked)
|
|
269
|
+
return { blocked: batch.blocked };
|
|
270
|
+
if (batch.removed)
|
|
271
|
+
return { done: false };
|
|
272
|
+
return this.devices.batch(orgId, accountId);
|
|
273
|
+
}
|
|
274
|
+
async fileResult(id, generation, action, verified) {
|
|
275
|
+
const work = await this.requests.claim(id, generation);
|
|
276
|
+
if (work?.stage !== "account-orgs" || work.target_id !== action.accountId)
|
|
277
|
+
return;
|
|
278
|
+
const parsed = Progress.safeParse(work.progress);
|
|
279
|
+
if (!parsed.success ||
|
|
280
|
+
parsed.data.file?.id !== action.intent.id ||
|
|
281
|
+
parsed.data.file.phase !== action.intent.phase)
|
|
282
|
+
return;
|
|
283
|
+
if (!verified ||
|
|
284
|
+
!this.enabled() ||
|
|
285
|
+
parsed.data.storageIdentity !== this.storage.erasureIdentity()) {
|
|
286
|
+
await this.defer(work, "account-file-storage-unverified");
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const { file, ...progress } = parsed.data;
|
|
290
|
+
await this.requests.advance(work, work.stage, null, new Date(), file.phase === "staging" ? { ...progress, file: { ...file, phase: "release" } } : progress);
|
|
291
|
+
}
|
|
292
|
+
async avatarResult(id, generation, accountId, verified) {
|
|
293
|
+
const work = await this.requests.claim(id, generation);
|
|
294
|
+
if (work?.stage !== "account-external" || work.target_id !== accountId)
|
|
295
|
+
return;
|
|
296
|
+
const parsed = Progress.safeParse(work.progress);
|
|
297
|
+
if (verified &&
|
|
298
|
+
this.enabled() &&
|
|
299
|
+
parsed.success &&
|
|
300
|
+
parsed.data.storageIdentity === this.storage.erasureIdentity()) {
|
|
301
|
+
await this.requests.advance(work, "account-final", null, new Date());
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
await this.defer(work, "avatar-storage-unverified");
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
async clearFinalRows(work, accountId) {
|
|
308
|
+
const avatarBatch = await this.db
|
|
309
|
+
.deleteFrom("account_avatar_uploads")
|
|
310
|
+
.where("account_id", "=", accountId)
|
|
311
|
+
.where("id", "in", (query) => query
|
|
312
|
+
.selectFrom("account_avatar_uploads")
|
|
313
|
+
.select("id")
|
|
314
|
+
.where("account_id", "=", accountId)
|
|
315
|
+
.orderBy("id")
|
|
316
|
+
.limit(32)
|
|
317
|
+
.forUpdate())
|
|
318
|
+
.executeTakeFirst();
|
|
319
|
+
if (avatarBatch.numDeletedRows > 0n) {
|
|
320
|
+
await this.requests.advance(work, "account-final", null, new Date());
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
const batch = await accountErasureBatch(this.db.db, accountId, null);
|
|
324
|
+
if (batch.blocked) {
|
|
325
|
+
await this.defer(work, batch.blocked);
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
if (batch.removed) {
|
|
329
|
+
await this.requests.advance(work, "account-final", null, new Date());
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
return true;
|
|
333
|
+
}
|
|
334
|
+
// Check typed references before taking the account lock. PostgreSQL checks FK deltas during
|
|
335
|
+
// DELETE and aborts a serializable snapshot if a concurrent writer introduced a reference.
|
|
336
|
+
async finishAccount(id, generation) {
|
|
337
|
+
if (!this.enabled())
|
|
338
|
+
return;
|
|
339
|
+
const work = await this.requests.claim(id, generation);
|
|
340
|
+
if (work?.kind !== "account" || work.stage !== "account-final" || !work.target_id)
|
|
341
|
+
return;
|
|
342
|
+
const progress = Progress.safeParse(work.progress);
|
|
343
|
+
if (!progress.success ||
|
|
344
|
+
!progress.data.historyComplete ||
|
|
345
|
+
progress.data.storageIdentity !== this.storage.erasureIdentity())
|
|
346
|
+
return;
|
|
347
|
+
const accountId = work.target_id;
|
|
348
|
+
const residual = await accountResidual(this.db.db, accountId);
|
|
349
|
+
if (residual) {
|
|
350
|
+
await this.defer(work, residual);
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
const erased = await this.db
|
|
354
|
+
.deleteFrom("accounts")
|
|
355
|
+
.where("id", "=", accountId)
|
|
356
|
+
.where("status", "=", "disabled")
|
|
357
|
+
.where("erasure_requested", "=", true)
|
|
358
|
+
.returning("id")
|
|
359
|
+
.executeTakeFirst();
|
|
360
|
+
if (!erased) {
|
|
361
|
+
await this.defer(work, "account-fence");
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
if (!(await this.requests.complete(work)))
|
|
365
|
+
throw new Error("Account receipt changed during erasure");
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
__decorate([
|
|
369
|
+
Transactional()
|
|
370
|
+
], AccountErasure.prototype, "runStage", null);
|
|
371
|
+
__decorate([
|
|
372
|
+
Transactional()
|
|
373
|
+
], AccountErasure.prototype, "fileResult", null);
|
|
374
|
+
__decorate([
|
|
375
|
+
Transactional()
|
|
376
|
+
], AccountErasure.prototype, "avatarResult", null);
|
|
377
|
+
__decorate([
|
|
378
|
+
Transactional({ isolationLevel: "serializable" })
|
|
379
|
+
], AccountErasure.prototype, "finishAccount", null);
|
|
380
|
+
AccountErasure = __decorate([
|
|
381
|
+
Injectable(),
|
|
382
|
+
__param(0, Inject(KernelDb)),
|
|
383
|
+
__param(1, Inject(TransactionHost)),
|
|
384
|
+
__param(2, Inject(KernelConfigService)),
|
|
385
|
+
__param(3, Inject(OrgLock)),
|
|
386
|
+
__param(4, Inject(ErasureRequests)),
|
|
387
|
+
__param(5, Inject(ConversationsService)),
|
|
388
|
+
__param(6, Inject(StorageService)),
|
|
389
|
+
__param(7, Inject(BlobObjects)),
|
|
390
|
+
__param(8, Inject(AccountDeviceCleanup))
|
|
391
|
+
], AccountErasure);
|
|
392
|
+
export { AccountErasure };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
2
|
+
import { DevicesService } from "../devices/devices.service.js";
|
|
3
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
4
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
5
|
+
/** Recheck before bounded org row deletion while the admission fence is held. */
|
|
6
|
+
export declare function orgDeviceBlocker(db: KernelSchemaDb, orgId: string): Promise<string | undefined>;
|
|
7
|
+
export declare class AccountDeviceCleanup {
|
|
8
|
+
private readonly db;
|
|
9
|
+
readonly txHost: TransactionHost;
|
|
10
|
+
private readonly devices;
|
|
11
|
+
constructor(db: KernelDb, txHost: TransactionHost, devices: Pick<DevicesService, "retireForErasure" | "oweErasureVerification" | "eraseHistoricalMachine" | "revokeOrgMachine">);
|
|
12
|
+
/** The worker owns the request generation and org admission fence for this transaction. */
|
|
13
|
+
batch(orgId: string, accountId: string): Promise<{
|
|
14
|
+
done: boolean;
|
|
15
|
+
blocked?: string;
|
|
16
|
+
}>;
|
|
17
|
+
/** The org admission fence is held and the org cannot be restored during this batch. */
|
|
18
|
+
verifyOrgBatch(orgId: string): Promise<{
|
|
19
|
+
done: boolean;
|
|
20
|
+
blocked?: string;
|
|
21
|
+
}>;
|
|
22
|
+
private verifyDevice;
|
|
23
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
};
|
|
10
|
+
import { Inject, Injectable } from "@nestjs/common";
|
|
11
|
+
import { sql } from "kysely";
|
|
12
|
+
import { DevicesService } from "../devices/devices.service.js";
|
|
13
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
14
|
+
import { asPlatform, currentScope } from "../infra/database/org-scope.js";
|
|
15
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
16
|
+
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
17
|
+
import { PURGE_BATCH_SIZE } from "../retention/purge-batch.js";
|
|
18
|
+
import { orgCatalogDrift } from "./org-catalog.js";
|
|
19
|
+
const dependents = [
|
|
20
|
+
["device_defaults", "account_id"],
|
|
21
|
+
["device_machines", "id"],
|
|
22
|
+
["device_loopback_grants", "id"],
|
|
23
|
+
["device_site_grants", "id"],
|
|
24
|
+
["device_projects", "name"],
|
|
25
|
+
["device_permission_reports", "device_id"],
|
|
26
|
+
["device_instance_destructions", "provider, instance_generation"],
|
|
27
|
+
["permission_authority_epochs", "id"],
|
|
28
|
+
["device_generation_high_water", "device_id"],
|
|
29
|
+
];
|
|
30
|
+
const blocked = (reason) => ({ done: false, blocked: reason });
|
|
31
|
+
// Each relation names a device and an independent org. A foreign reference is a
|
|
32
|
+
// survivor, including non-FK runtime rows that could otherwise lose their lineage.
|
|
33
|
+
const scopedDeviceReferences = [
|
|
34
|
+
"automations",
|
|
35
|
+
"background_tasks",
|
|
36
|
+
"conversations",
|
|
37
|
+
"device_conversation_notices",
|
|
38
|
+
"device_defaults",
|
|
39
|
+
"device_instances",
|
|
40
|
+
"device_loopback_grants",
|
|
41
|
+
"device_machines",
|
|
42
|
+
"device_site_grants",
|
|
43
|
+
"permission_call_grants",
|
|
44
|
+
"sandbox_operation_intents",
|
|
45
|
+
];
|
|
46
|
+
async function foreignDeviceReference(db, orgId) {
|
|
47
|
+
// org-filter: deployment-wide read checks device ownership against each dependent's org.
|
|
48
|
+
return asPlatform("check device dependencies across org boundaries", async () => {
|
|
49
|
+
const checks = scopedDeviceReferences.map((table) => sql `EXISTS (
|
|
50
|
+
SELECT FROM ${sql.id("capybara", table)} r JOIN capybara.devices d ON d.id=r.device_id
|
|
51
|
+
WHERE (d.org_id=${orgId} OR r.org_id=${orgId}) AND d.org_id<>r.org_id
|
|
52
|
+
)`);
|
|
53
|
+
const result = await sql `SELECT ${sql.join(checks, sql ` OR `)} AS survivor`.execute(db);
|
|
54
|
+
return result.rows[0]?.survivor;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** Recheck before bounded org row deletion while the admission fence is held. */
|
|
58
|
+
export async function orgDeviceBlocker(db, orgId) {
|
|
59
|
+
const scope = currentScope();
|
|
60
|
+
if (scope?.kind !== "org" || scope.orgId !== orgId)
|
|
61
|
+
return "org-scope";
|
|
62
|
+
if (await foreignDeviceReference(db, orgId))
|
|
63
|
+
return "shared-device-reference";
|
|
64
|
+
const result = await sql `SELECT FROM capybara.devices WHERE org_id=${orgId} AND files_destroyed_at IS NULL
|
|
65
|
+
UNION ALL SELECT FROM capybara.device_instances WHERE org_id=${orgId}
|
|
66
|
+
UNION ALL SELECT FROM capybara.device_machines WHERE org_id=${orgId} AND revoked_at IS NULL
|
|
67
|
+
UNION ALL SELECT FROM capybara.device_conversation_notices WHERE org_id=${orgId} LIMIT 1`.execute(db);
|
|
68
|
+
return result.rows.length ? "device-destruction-unverified" : undefined;
|
|
69
|
+
}
|
|
70
|
+
let AccountDeviceCleanup = class AccountDeviceCleanup {
|
|
71
|
+
db;
|
|
72
|
+
txHost;
|
|
73
|
+
devices;
|
|
74
|
+
constructor(db, txHost, devices) {
|
|
75
|
+
this.db = db;
|
|
76
|
+
this.txHost = txHost;
|
|
77
|
+
this.devices = devices;
|
|
78
|
+
}
|
|
79
|
+
/** The worker owns the request generation and org admission fence for this transaction. */
|
|
80
|
+
async batch(orgId, accountId) {
|
|
81
|
+
const scope = currentScope();
|
|
82
|
+
if (scope?.kind !== "org" || scope.orgId !== orgId)
|
|
83
|
+
return blocked("account-scope");
|
|
84
|
+
const drift = await orgCatalogDrift(this.db.db);
|
|
85
|
+
if (drift)
|
|
86
|
+
return blocked(drift);
|
|
87
|
+
const account = await this.db
|
|
88
|
+
.selectFrom("accounts")
|
|
89
|
+
.select("id")
|
|
90
|
+
.where("id", "=", accountId)
|
|
91
|
+
.where("status", "=", "disabled")
|
|
92
|
+
.where("erasure_requested", "=", true)
|
|
93
|
+
.forUpdate()
|
|
94
|
+
.executeTakeFirst();
|
|
95
|
+
if (!account)
|
|
96
|
+
return blocked("account-fence");
|
|
97
|
+
const device = await this.db
|
|
98
|
+
.selectFrom("devices")
|
|
99
|
+
.select(["id", "deleted_at", "files_destroyed_at"])
|
|
100
|
+
.where("org_id", "=", orgId)
|
|
101
|
+
.where("owner_kind", "=", "personal")
|
|
102
|
+
.where("owner_account_id", "=", accountId)
|
|
103
|
+
.orderBy("id")
|
|
104
|
+
.limit(1)
|
|
105
|
+
.forUpdate()
|
|
106
|
+
.executeTakeFirst();
|
|
107
|
+
if (!device)
|
|
108
|
+
return { done: !(await this.devices.eraseHistoricalMachine(orgId, accountId)) };
|
|
109
|
+
// org-filter: deployment-wide read detects a surviving or inconsistent reference to the locked device.
|
|
110
|
+
const survivor = await asPlatform("check incoming references before retiring a personal device", () => sql `SELECT FROM capybara.conversations WHERE device_id=${device.id}
|
|
111
|
+
UNION ALL SELECT FROM capybara.automations WHERE device_id=${device.id}
|
|
112
|
+
UNION ALL SELECT FROM capybara.permission_call_grants WHERE device_id=${device.id}
|
|
113
|
+
UNION ALL SELECT FROM capybara.background_tasks WHERE device_id=${device.id}
|
|
114
|
+
UNION ALL SELECT FROM capybara.sandbox_operation_intents WHERE device_id=${device.id}
|
|
115
|
+
UNION ALL SELECT FROM capybara.device_conversation_notices WHERE device_id=${device.id}
|
|
116
|
+
UNION ALL SELECT FROM capybara.device_instances WHERE device_id=${device.id} AND org_id<>${orgId}
|
|
117
|
+
UNION ALL SELECT FROM capybara.device_defaults WHERE device_id=${device.id}
|
|
118
|
+
AND (org_id<>${orgId} OR account_id<>${accountId})
|
|
119
|
+
UNION ALL SELECT FROM capybara.device_machines WHERE device_id=${device.id}
|
|
120
|
+
AND (org_id<>${orgId} OR account_id<>${accountId})
|
|
121
|
+
UNION ALL SELECT FROM capybara.device_site_grants g JOIN capybara.conversations c ON c.id=g.conversation_id
|
|
122
|
+
WHERE g.device_id=${device.id} AND (g.org_id<>${orgId} OR c.org_id<>${orgId} OR c.account_id<>${accountId})
|
|
123
|
+
UNION ALL SELECT FROM capybara.device_loopback_grants g JOIN capybara.conversations c ON c.id=g.conversation_id
|
|
124
|
+
WHERE g.device_id=${device.id} AND (g.org_id<>${orgId} OR c.org_id<>${orgId} OR c.account_id<>${accountId})
|
|
125
|
+
LIMIT 1`.execute(this.db.db));
|
|
126
|
+
if (survivor.rows.length)
|
|
127
|
+
return blocked("personal-device-dependency");
|
|
128
|
+
if (!device.deleted_at) {
|
|
129
|
+
await this.devices.retireForErasure(orgId, accountId, device.id);
|
|
130
|
+
return { done: false };
|
|
131
|
+
}
|
|
132
|
+
const proof = await this.verifyDevice(orgId, device);
|
|
133
|
+
if (!proof.done)
|
|
134
|
+
return proof;
|
|
135
|
+
for (const [table, order] of dependents) {
|
|
136
|
+
const relation = sql.id("capybara", table);
|
|
137
|
+
const predicate = table === "permission_authority_epochs"
|
|
138
|
+
? sql `kind='device' AND id=${device.id}`
|
|
139
|
+
: table === "device_generation_high_water"
|
|
140
|
+
? sql `device_id::text=${device.id}`
|
|
141
|
+
: sql `device_id=${device.id}`;
|
|
142
|
+
const result = await sql `WITH page AS (
|
|
143
|
+
SELECT ctid FROM ${relation} WHERE ${predicate} ORDER BY ${sql.raw(order)}
|
|
144
|
+
LIMIT ${PURGE_BATCH_SIZE} FOR UPDATE
|
|
145
|
+
) DELETE FROM ${relation} USING page WHERE ${relation}.ctid=page.ctid`.execute(this.db.db);
|
|
146
|
+
if (Number(result.numAffectedRows))
|
|
147
|
+
return { done: false };
|
|
148
|
+
}
|
|
149
|
+
await this.db
|
|
150
|
+
.deleteFrom("devices")
|
|
151
|
+
.where("org_id", "=", orgId)
|
|
152
|
+
.where("owner_account_id", "=", accountId)
|
|
153
|
+
.where("id", "=", device.id)
|
|
154
|
+
.execute();
|
|
155
|
+
return { done: false };
|
|
156
|
+
}
|
|
157
|
+
/** The org admission fence is held and the org cannot be restored during this batch. */
|
|
158
|
+
async verifyOrgBatch(orgId) {
|
|
159
|
+
const scope = currentScope();
|
|
160
|
+
if (scope?.kind !== "org" || scope.orgId !== orgId)
|
|
161
|
+
return blocked("org-scope");
|
|
162
|
+
const org = await this.db
|
|
163
|
+
.selectFrom("orgs")
|
|
164
|
+
.select("deleted_at")
|
|
165
|
+
.where("id", "=", orgId)
|
|
166
|
+
.forNoKeyUpdate()
|
|
167
|
+
.executeTakeFirst();
|
|
168
|
+
if (!org?.deleted_at)
|
|
169
|
+
return blocked("org-tombstone");
|
|
170
|
+
if (await foreignDeviceReference(this.db.db, orgId))
|
|
171
|
+
return blocked("shared-device-reference");
|
|
172
|
+
if (await this.devices.revokeOrgMachine(orgId))
|
|
173
|
+
return { done: false };
|
|
174
|
+
const device = await this.db
|
|
175
|
+
.selectFrom("devices as d")
|
|
176
|
+
.select(["d.id", "d.files_destroyed_at"])
|
|
177
|
+
.where("d.org_id", "=", orgId)
|
|
178
|
+
.where((eb) => eb.or([
|
|
179
|
+
eb("d.files_destroyed_at", "is", null),
|
|
180
|
+
eb.exists(eb
|
|
181
|
+
.selectFrom("device_instances as i")
|
|
182
|
+
.select("i.device_id")
|
|
183
|
+
.where("i.org_id", "=", orgId)
|
|
184
|
+
.whereRef("i.device_id", "=", "d.id")),
|
|
185
|
+
]))
|
|
186
|
+
.orderBy("d.id")
|
|
187
|
+
.limit(1)
|
|
188
|
+
.forUpdate("d")
|
|
189
|
+
.executeTakeFirst();
|
|
190
|
+
return device ? this.verifyDevice(orgId, device) : { done: true };
|
|
191
|
+
}
|
|
192
|
+
async verifyDevice(orgId, device) {
|
|
193
|
+
const instance = await this.db
|
|
194
|
+
.selectFrom("device_instances")
|
|
195
|
+
.select("abandoned_at")
|
|
196
|
+
.where("org_id", "=", orgId)
|
|
197
|
+
.where("device_id", "=", device.id)
|
|
198
|
+
.executeTakeFirst();
|
|
199
|
+
if (instance?.abandoned_at)
|
|
200
|
+
return blocked("device-provider-unavailable");
|
|
201
|
+
if (instance)
|
|
202
|
+
return blocked("device-destruction-unverified");
|
|
203
|
+
if (device.files_destroyed_at)
|
|
204
|
+
return { done: true };
|
|
205
|
+
const reason = await this.devices.oweErasureVerification(orgId, device.id);
|
|
206
|
+
return reason ? blocked(reason) : { done: false };
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
__decorate([
|
|
210
|
+
Transactional({ propagation: "mandatory" })
|
|
211
|
+
], AccountDeviceCleanup.prototype, "batch", null);
|
|
212
|
+
__decorate([
|
|
213
|
+
Transactional({ propagation: "mandatory" })
|
|
214
|
+
], AccountDeviceCleanup.prototype, "verifyOrgBatch", null);
|
|
215
|
+
AccountDeviceCleanup = __decorate([
|
|
216
|
+
Injectable(),
|
|
217
|
+
__param(0, Inject(KernelDb)),
|
|
218
|
+
__param(1, Inject(TransactionHost)),
|
|
219
|
+
__param(2, Inject(DevicesService))
|
|
220
|
+
], AccountDeviceCleanup);
|
|
221
|
+
export { AccountDeviceCleanup };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Module } from "@nestjs/common";
|
|
8
|
+
import { ErasureRequests } from "./requests.js";
|
|
9
|
+
let ErasureModule = class ErasureModule {
|
|
10
|
+
};
|
|
11
|
+
ErasureModule = __decorate([
|
|
12
|
+
Module({ providers: [ErasureRequests], exports: [ErasureRequests] })
|
|
13
|
+
], ErasureModule);
|
|
14
|
+
export { ErasureModule };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
2
|
+
export declare const externalDispositionBlockers: readonly ["external-cleanup-unverified", "catalog-or-tool-ownership-unverified"];
|
|
3
|
+
export declare function hasOpaqueExtensionHistory(db: KernelSchemaDb): Promise<boolean>;
|
|
4
|
+
export declare function hasExternalDisposition(db: KernelSchemaDb, id: string, blocker: (typeof externalDispositionBlockers)[number]): Promise<boolean>;
|