@nodii/dsar 0.19.0 → 0.22.0

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.
Files changed (61) hide show
  1. package/dist/bind-pattern-a.d.ts +139 -2
  2. package/dist/bind-pattern-a.d.ts.map +1 -1
  3. package/dist/bind-pattern-a.js +571 -32
  4. package/dist/bind-pattern-a.js.map +1 -1
  5. package/dist/bind-pattern-b.d.ts.map +1 -1
  6. package/dist/bind-pattern-b.js +58 -3
  7. package/dist/bind-pattern-b.js.map +1 -1
  8. package/dist/grpc/dsar-service.d.ts +29 -0
  9. package/dist/grpc/dsar-service.d.ts.map +1 -1
  10. package/dist/grpc/dsar-service.js +34 -0
  11. package/dist/grpc/dsar-service.js.map +1 -1
  12. package/dist/grpc/proto-path.d.ts +33 -0
  13. package/dist/grpc/proto-path.d.ts.map +1 -0
  14. package/dist/grpc/proto-path.js +87 -0
  15. package/dist/grpc/proto-path.js.map +1 -0
  16. package/dist/hold-failure-mode.d.ts +24 -0
  17. package/dist/hold-failure-mode.d.ts.map +1 -1
  18. package/dist/hold-failure-mode.js +24 -0
  19. package/dist/hold-failure-mode.js.map +1 -1
  20. package/dist/hold-gate-probe.d.ts +61 -0
  21. package/dist/hold-gate-probe.d.ts.map +1 -0
  22. package/dist/hold-gate-probe.js +146 -0
  23. package/dist/hold-gate-probe.js.map +1 -0
  24. package/dist/holds.d.ts +60 -1
  25. package/dist/holds.d.ts.map +1 -1
  26. package/dist/holds.js +60 -3
  27. package/dist/holds.js.map +1 -1
  28. package/dist/index.d.ts +16 -6
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +28 -5
  31. package/dist/index.js.map +1 -1
  32. package/dist/migrations/index.d.ts.map +1 -1
  33. package/dist/migrations/index.js +10 -0
  34. package/dist/migrations/index.js.map +1 -1
  35. package/dist/orchestrator.d.ts +48 -0
  36. package/dist/orchestrator.d.ts.map +1 -1
  37. package/dist/orchestrator.js +297 -20
  38. package/dist/orchestrator.js.map +1 -1
  39. package/dist/register.d.ts +35 -1
  40. package/dist/register.d.ts.map +1 -1
  41. package/dist/register.js +26 -0
  42. package/dist/register.js.map +1 -1
  43. package/dist/retention-sweeper.d.ts +252 -0
  44. package/dist/retention-sweeper.d.ts.map +1 -0
  45. package/dist/retention-sweeper.js +356 -0
  46. package/dist/retention-sweeper.js.map +1 -0
  47. package/dist/retention.d.ts +109 -1
  48. package/dist/retention.d.ts.map +1 -1
  49. package/dist/retention.js +216 -3
  50. package/dist/retention.js.map +1 -1
  51. package/dist/subject-kinds.d.ts +74 -0
  52. package/dist/subject-kinds.d.ts.map +1 -0
  53. package/dist/subject-kinds.js +141 -0
  54. package/dist/subject-kinds.js.map +1 -0
  55. package/dist/types.d.ts +423 -7
  56. package/dist/types.d.ts.map +1 -1
  57. package/dist/types.js +164 -0
  58. package/dist/types.js.map +1 -1
  59. package/package.json +7 -4
  60. package/proto/nodii/dsar/v1/dsar.proto +202 -0
  61. package/src/migrations/001-lifecycle-requests.sql +422 -0
@@ -0,0 +1,356 @@
1
+ // D720 — the PURPOSE-SPENT SWEEPER: scheduled hard deletion once a retention
2
+ // window expires.
3
+ //
4
+ // WHY A SWEEPER AND NOT A DSAR HANDLER. DPDP s.8(7) owes erasure WITHOUT a
5
+ // request once the purpose is spent, and GDPR storage limitation says the same
6
+ // in different words. Neither obligation has a request to hang a handler on, so
7
+ // the engine is a scheduled job, not an RPC. It is also the half of the posture
8
+ // that makes crypto-shred defensible at all: encrypted personal data is still
9
+ // personal data (EDPB 02/2025 §51), so shredding a key does not complete "put
10
+ // beyond use" — the scheduled HARD DELETE does.
11
+ //
12
+ // THE STATUTORY BUCKET'S SECOND DEATH. A statutory record survives every
13
+ // per-subject erase by construction (it is under the tenant retention DEK, not
14
+ // the person's). This job is how it eventually dies: its `retention_schedules`
15
+ // window expires, no hold covers it, and `onPurge` deletes the row.
16
+ //
17
+ // SHAPE mirrors the lifecycle reaper (`state-store/reaper-job.ts`): a
18
+ // framework-agnostic `{ name, intervalMs, pool, handler }` the consumer hands to
19
+ // whatever scheduler it runs. The consumer owns the class→table mapping (only
20
+ // the service knows which of its tables holds which data class) and owns the
21
+ // DELETE (`onPurge`); the library owns schedule resolution, the hold gate, and
22
+ // the per-record purge event.
23
+ //
24
+ // AMENDS D593. D593 observed that the platform has "not a per-record purge log".
25
+ // That was a description of an absence, not a prohibition — D720 makes the
26
+ // Events surface gain a second, per-record source: `<svc>.retention.record_purged.v1`.
27
+ //
28
+ // Twins: python `nodii_dsar.retention_sweeper`, go `dsar.MakeRetentionSweeperJob`.
29
+ import { isHeld } from "./holds.js";
30
+ import { applyRetentionSchedules } from "./retention.js";
31
+ import { DEFAULT_ERASE_BLOCKING_HOLD_KINDS } from "./types.js";
32
+ const IDENT_RE = /^[a-z_][a-z0-9_]*$/;
33
+ /** Canonical sweeper job name, mirroring the reaper's metrics family. */
34
+ export const RETENTION_SWEEPER_JOB_NAME = "dsar.retention_sweeper";
35
+ /** Default sweep interval — 24h, same cadence as the lifecycle reaper. */
36
+ export const RETENTION_SWEEPER_INTERVAL_MS = 24 * 60 * 60 * 1000;
37
+ /** Default per-target row budget for one sweep. */
38
+ export const RETENTION_SWEEPER_BATCH_SIZE = 500;
39
+ /**
40
+ * D720 amendment to D593 — the per-record purge topic:
41
+ * `<serviceName>.retention.record_purged.v1`.
42
+ */
43
+ export function retentionPurgeTopic(serviceName) {
44
+ return `${serviceName}.retention.record_purged.v1`;
45
+ }
46
+ /**
47
+ * Raised when the hold consult fails during a sweep.
48
+ *
49
+ * FAIL-CLOSED, and it aborts the WHOLE sweep rather than skipping one record.
50
+ * The operator ruling the hold posture rests on is "if holds is inaccessible we
51
+ * deny the write — fail CLOSED" (2026-07-30), and a purge is the most
52
+ * irreversible write in the system. Skipping quietly would also be
53
+ * indistinguishable, in the run result, from "nothing was due" — so the sweep
54
+ * raises, the scheduler logs, and the next tick retries once holds is readable.
55
+ */
56
+ export class RetentionSweepHoldConsultFailed extends Error {
57
+ code = "RETENTION_SWEEP_HOLD_CONSULT_FAILED";
58
+ constructor(tableName, recordId, cause) {
59
+ const detail = cause instanceof Error ? cause.message : String(cause);
60
+ super(`RETENTION_SWEEP_HOLD_CONSULT_FAILED: the retention sweeper could not read the holds table while evaluating ${tableName}#${recordId}, so it CANNOT know whether a preservation hold covers this record. Fail-CLOSED per the 2026-07-30 operator ruling: the sweep aborts without purging anything, and the next tick retries. Underlying error: ${detail}`);
61
+ this.name = "RetentionSweepHoldConsultFailed";
62
+ }
63
+ }
64
+ function ensureIdent(value, what) {
65
+ if (!IDENT_RE.test(value)) {
66
+ throw new Error(`makeRetentionSweeperJob: ${what} ${JSON.stringify(value)} is not a bare SQL identifier (/^[a-z_][a-z0-9_]*$/). Table + column names are interpolated into the scan statement, so they are validated rather than parameterised.`);
67
+ }
68
+ return value;
69
+ }
70
+ function validateTarget(t) {
71
+ if (t.jurisdiction && t.jurisdictionColumn) {
72
+ throw new Error(`makeRetentionSweeperJob: target ${JSON.stringify(t.tableName)} declares BOTH \`jurisdiction\` and \`jurisdictionColumn\`. They answer the same question differently; pick one.`);
73
+ }
74
+ if (!t.jurisdiction && !t.jurisdictionColumn) {
75
+ throw new Error(`makeRetentionSweeperJob: target ${JSON.stringify(t.tableName)} declares neither \`jurisdiction\` nor \`jurisdictionColumn\`. A retention window is jurisdictional (the same document class has different periods in different countries) — the library will not assume one.`);
76
+ }
77
+ return {
78
+ dataClass: t.dataClass,
79
+ tableName: ensureIdent(t.tableName, "tableName"),
80
+ anchorColumn: ensureIdent(t.anchorColumn, "anchorColumn"),
81
+ anchor: t.anchor,
82
+ idColumn: ensureIdent(t.idColumn ?? "id", "idColumn"),
83
+ tenantColumn: ensureIdent(t.tenantColumn ?? "tenant_id", "tenantColumn"),
84
+ subjectColumn: t.subjectColumn
85
+ ? ensureIdent(t.subjectColumn, "subjectColumn")
86
+ : null,
87
+ jurisdiction: t.jurisdiction ?? null,
88
+ jurisdictionColumn: t.jurisdictionColumn
89
+ ? ensureIdent(t.jurisdictionColumn, "jurisdictionColumn")
90
+ : null,
91
+ documentClass: t.documentClass ?? t.dataClass,
92
+ entityKind: t.entityKind ?? t.dataClass,
93
+ };
94
+ }
95
+ /**
96
+ * D720 — build the schedulable purpose-spent sweeper.
97
+ *
98
+ * Per sweep, per target:
99
+ * 1. SELECT the batch (id, tenant, subject?, jurisdiction?, anchor);
100
+ * 2. resolve the governing schedule via {@link applyRetentionSchedules} —
101
+ * no schedule ⇒ SKIP (absence of a rule is never a licence to delete);
102
+ * 3. still inside its window ⇒ SKIP;
103
+ * 4. `extended_by_proceeding` ⇒ SKIP unless a hold consult says otherwise
104
+ * (an open proceeding rides the hold mechanism per D720);
105
+ * 5. hold consult (FAIL-CLOSED — a consult error aborts the sweep);
106
+ * 6. `onPurge(record, tx)` — the consumer's hard delete;
107
+ * 7. emit `<svc>.retention.record_purged.v1`.
108
+ *
109
+ * Steps 6+7 run in ONE transaction when `db` exposes `begin`, so the delete and
110
+ * its event commit together. Without a transaction runner the event is emitted
111
+ * after the delete resolves — a dropped event is recoverable, an
112
+ * announced-but-undeleted row is not.
113
+ */
114
+ export function makeRetentionSweeperJob(opts) {
115
+ if (!opts.db || typeof opts.db.unsafe !== "function") {
116
+ throw new Error("makeRetentionSweeperJob requires `db` — an OWNER-pool-backed SQL client (the scan SELECT + the purge DELETE are owner-granted per the RLS doctrine).");
117
+ }
118
+ if (typeof opts.onPurge !== "function") {
119
+ throw new Error("makeRetentionSweeperJob requires `onPurge` — the consumer's HARD DELETE. The library never deletes a service's rows itself, and a sweeper with no delete is a scheduled no-op that reports success.");
120
+ }
121
+ if (!Array.isArray(opts.targets) || opts.targets.length === 0) {
122
+ throw new Error("makeRetentionSweeperJob requires a non-empty `targets` — the service's data_class → table mapping. Only the service knows which of its tables holds which class.");
123
+ }
124
+ const targets = opts.targets.map(validateTarget);
125
+ const holdsTableName = opts.holdsTableName ?? "data_residency_holds";
126
+ const blockingKinds = opts.blockingHoldKinds ?? DEFAULT_ERASE_BLOCKING_HOLD_KINDS;
127
+ const batchSize = opts.batchSize ?? RETENTION_SWEEPER_BATCH_SIZE;
128
+ const maxScan = opts.maxScan ?? batchSize * 10;
129
+ if (maxScan < batchSize) {
130
+ throw new Error(`makeRetentionSweeperJob: maxScan (${maxScan}) is below batchSize (${batchSize}). The scan ceiling must allow at least one full actionable batch, or the sweep can never reach its budget.`);
131
+ }
132
+ const now = opts.now ?? (() => new Date());
133
+ const topic = retentionPurgeTopic(opts.serviceName);
134
+ const loadSchedules = async () => typeof opts.schedules === "function"
135
+ ? await opts.schedules()
136
+ : opts.schedules;
137
+ const handler = async () => {
138
+ const at = now();
139
+ const schedules = await loadSchedules();
140
+ const result = {
141
+ purged: 0,
142
+ inWindow: 0,
143
+ skippedHeld: 0,
144
+ skippedNoSchedule: 0,
145
+ scanned: 0,
146
+ exhausted: true,
147
+ errors: [],
148
+ ranAt: at.toISOString(),
149
+ };
150
+ for (const t of targets) {
151
+ const cols = [
152
+ `${t.idColumn}::text AS record_id`,
153
+ `${t.tenantColumn}::text AS tenant_id`,
154
+ t.subjectColumn
155
+ ? `${t.subjectColumn}::text AS subject_id`
156
+ : "NULL::text AS subject_id",
157
+ t.jurisdictionColumn
158
+ ? `${t.jurisdictionColumn}::text AS jurisdiction`
159
+ : "NULL::text AS jurisdiction",
160
+ `to_char(${t.anchorColumn} AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.US"Z"') AS anchored_at`,
161
+ ].join(",\n ");
162
+ // KEYSET CURSOR over `(anchor, id::text)`.
163
+ //
164
+ // The tiebreak is `id::text`, not the raw id, because the id column may be
165
+ // uuid, text or int and the cursor needs only a TOTAL order, not a
166
+ // semantically meaningful one. `ORDER BY` uses the identical expression so
167
+ // the comparison and the ordering can never disagree — an int column
168
+ // orders '10' before '9' under text collation, which is harmless while
169
+ // both sides agree and silently skips rows the moment they don't.
170
+ const stmt = `SELECT
171
+ ${cols}
172
+ FROM ${t.tableName}
173
+ WHERE ${t.anchorColumn} IS NOT NULL
174
+ AND (
175
+ $1::text IS NULL
176
+ OR ${t.anchorColumn} > $1::timestamptz
177
+ OR (${t.anchorColumn} = $1::timestamptz AND ${t.idColumn}::text > $2::text)
178
+ )
179
+ ORDER BY ${t.anchorColumn} ASC, ${t.idColumn}::text ASC
180
+ LIMIT $3`;
181
+ let cursorAnchor = null;
182
+ let cursorId = null;
183
+ let actionable = 0;
184
+ let scannedForTarget = 0;
185
+ let targetExhausted = false;
186
+ // Page until the ACTIONABLE budget fills, the ceiling is hit, or the
187
+ // table runs out. Skipped rows advance the cursor WITHOUT spending
188
+ // budget, so the next page starts beyond them inside this same tick —
189
+ // which is the whole fix: under the old fixed `LIMIT` with no cursor, a
190
+ // block of permanently-skipped rows at the head (oldest anchors) refilled
191
+ // every batch on every tick and nothing behind them was examined again,
192
+ // while the sweep still reported success.
193
+ while (actionable < batchSize && scannedForTarget < maxScan) {
194
+ const pageSize = Math.min(batchSize, maxScan - scannedForTarget);
195
+ const rows = (await opts.db.unsafe(stmt, [
196
+ cursorAnchor,
197
+ cursorId,
198
+ pageSize,
199
+ ]));
200
+ if (rows.length === 0) {
201
+ targetExhausted = true;
202
+ break;
203
+ }
204
+ scannedForTarget += rows.length;
205
+ result.scanned += rows.length;
206
+ for (const row of rows) {
207
+ // Advance the cursor for EVERY row, whatever its outcome. This line
208
+ // is the anti-starvation guarantee.
209
+ cursorAnchor = row.anchored_at;
210
+ cursorId = row.record_id;
211
+ const jurisdiction = t.jurisdiction ?? row.jurisdiction;
212
+ if (!jurisdiction) {
213
+ // No jurisdiction ⇒ no resolvable window ⇒ no purge.
214
+ result.skippedNoSchedule++;
215
+ continue;
216
+ }
217
+ const match = applyRetentionSchedules(schedules, {
218
+ jurisdiction,
219
+ documentClass: t.documentClass,
220
+ entityKind: t.entityKind,
221
+ anchorAt: row.anchored_at,
222
+ at,
223
+ });
224
+ // A schedule anchored on a DIFFERENT timestamp than this target's
225
+ // column is not this target's schedule — counting an 8-year window
226
+ // from the wrong instant is worse than not purging at all.
227
+ if (!match || match.schedule.anchor !== t.anchor) {
228
+ result.skippedNoSchedule++;
229
+ continue;
230
+ }
231
+ if (new Date(match.retainUntil).getTime() > at.getTime()) {
232
+ result.inWindow++;
233
+ actionable++;
234
+ continue;
235
+ }
236
+ // Hold gate — FAIL-CLOSED. `isHeld` throws on any SQL/connection
237
+ // error; we do NOT catch it into a skip, we abort the sweep (see
238
+ // RetentionSweepHoldConsultFailed).
239
+ let heldNow;
240
+ try {
241
+ const consult = await isHeld({
242
+ sql: opts.db,
243
+ tenantId: row.tenant_id,
244
+ ...(row.subject_id ? { subjectId: row.subject_id } : {}),
245
+ holdKind: blockingKinds,
246
+ dataClass: t.dataClass,
247
+ tableName: holdsTableName,
248
+ });
249
+ heldNow = consult.held;
250
+ }
251
+ catch (err) {
252
+ throw new RetentionSweepHoldConsultFailed(t.tableName, row.record_id, err);
253
+ }
254
+ if (heldNow) {
255
+ // Held rows do NOT spend the actionable budget — they are exactly
256
+ // the rows that used to starve everything behind them.
257
+ result.skippedHeld++;
258
+ continue;
259
+ }
260
+ if (match.extendedByProceeding) {
261
+ // The window has expired but the schedule says an open proceeding
262
+ // extends it. Proceedings ride the HOLD mechanism (D720:
263
+ // preservation holds are the exceptional-purpose surface), and the
264
+ // consult above found none — so there is no proceeding and the
265
+ // purge proceeds. The branch exists to make that reasoning explicit
266
+ // rather than implicit in the absence of a check.
267
+ }
268
+ const record = {
269
+ dataClass: t.dataClass,
270
+ tableName: t.tableName,
271
+ recordId: row.record_id,
272
+ tenantId: row.tenant_id,
273
+ subjectId: row.subject_id,
274
+ jurisdiction,
275
+ documentClass: t.documentClass,
276
+ entityKind: t.entityKind,
277
+ anchoredAt: row.anchored_at,
278
+ retainedUntil: match.retainUntil,
279
+ schedule: match.schedule,
280
+ };
281
+ const buildEvent = () => ({
282
+ topic,
283
+ serviceName: opts.serviceName,
284
+ dataClass: t.dataClass,
285
+ tableName: t.tableName,
286
+ recordId: row.record_id,
287
+ tenantId: row.tenant_id,
288
+ subjectId: row.subject_id,
289
+ jurisdiction,
290
+ documentClass: t.documentClass,
291
+ entityKind: t.entityKind,
292
+ retentionPeriod: match.schedule.retention_period,
293
+ anchor: match.schedule.anchor,
294
+ anchoredAt: row.anchored_at,
295
+ retainedUntil: match.retainUntil,
296
+ ...(match.schedule.statute_citation
297
+ ? { statuteCitation: match.schedule.statute_citation }
298
+ : {}),
299
+ purgedAt: new Date().toISOString(),
300
+ });
301
+ try {
302
+ if (opts.db.begin) {
303
+ // Atomic leg: the DELETE and its purge event commit together, so
304
+ // the feed can never diverge from what is actually gone.
305
+ await opts.db.begin(async (tx) => {
306
+ await opts.onPurge(record, tx);
307
+ if (opts.outboxEmitter) {
308
+ await opts.outboxEmitter(tx, buildEvent());
309
+ }
310
+ });
311
+ }
312
+ else {
313
+ // No transaction runner. Delete first, then announce — a dropped
314
+ // event is recoverable, an announced-but-undeleted row is not.
315
+ await opts.onPurge(record);
316
+ if (opts.outboxEmitter) {
317
+ await opts.outboxEmitter(opts.db, buildEvent());
318
+ }
319
+ }
320
+ }
321
+ catch (err) {
322
+ result.errors.push({
323
+ recordId: row.record_id,
324
+ tableName: t.tableName,
325
+ error: err instanceof Error ? err.message : String(err),
326
+ });
327
+ // A failed purge SPENDS budget: it was actionable, it was attempted,
328
+ // and it must not be retried forever inside one tick.
329
+ actionable++;
330
+ continue;
331
+ }
332
+ result.purged++;
333
+ actionable++;
334
+ }
335
+ if (rows.length < pageSize) {
336
+ targetExhausted = true;
337
+ break;
338
+ }
339
+ }
340
+ // Not reading a target to its end means rows beyond the cursor were never
341
+ // examined this tick. Say so rather than letting the tick look complete.
342
+ if (!targetExhausted)
343
+ result.exhausted = false;
344
+ }
345
+ if (opts.onRun)
346
+ await opts.onRun(result);
347
+ return result;
348
+ };
349
+ return {
350
+ name: RETENTION_SWEEPER_JOB_NAME,
351
+ intervalMs: opts.intervalMs ?? RETENTION_SWEEPER_INTERVAL_MS,
352
+ pool: "owner",
353
+ handler,
354
+ };
355
+ }
356
+ //# sourceMappingURL=retention-sweeper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retention-sweeper.js","sourceRoot":"","sources":["../src/retention-sweeper.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,kBAAkB;AAClB,EAAE;AACF,2EAA2E;AAC3E,+EAA+E;AAC/E,gFAAgF;AAChF,gFAAgF;AAChF,8EAA8E;AAC9E,8EAA8E;AAC9E,gDAAgD;AAChD,EAAE;AACF,yEAAyE;AACzE,+EAA+E;AAC/E,+EAA+E;AAC/E,oEAAoE;AACpE,EAAE;AACF,sEAAsE;AACtE,iFAAiF;AACjF,8EAA8E;AAC9E,6EAA6E;AAC7E,+EAA+E;AAC/E,8BAA8B;AAC9B,EAAE;AACF,iFAAiF;AACjF,2EAA2E;AAC3E,uFAAuF;AACvF,EAAE;AACF,mFAAmF;AAEnF,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAOzD,OAAO,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAC;AAe/D,MAAM,QAAQ,GAAG,oBAAoB,CAAC;AAEtC,yEAAyE;AACzE,MAAM,CAAC,MAAM,0BAA0B,GAAG,wBAAwB,CAAC;AAEnE,0EAA0E;AAC1E,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEjE,mDAAmD;AACnD,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAEhD;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,WAAmB;IACrD,OAAO,GAAG,WAAW,6BAA6B,CAAC;AACrD,CAAC;AA2MD;;;;;;;;;GASG;AACH,MAAM,OAAO,+BAAgC,SAAQ,KAAK;IAC/C,IAAI,GAAG,qCAAqC,CAAC;IACtD,YAAY,SAAiB,EAAE,QAAgB,EAAE,KAAc;QAC7D,MAAM,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AAO;KACR,CAAC;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { DsarRow, RetentionPolicy } from "./types.js";
1
+ import type { DsarRow, RetentionAnchor, RetentionPolicy, RetentionSchedule } from "./types.js";
2
2
  export interface RetentionMatch {
3
3
  policy: RetentionPolicy;
4
4
  retainUntil: string;
@@ -14,4 +14,112 @@ export interface RetentionMatch {
14
14
  * `lifecycle_requests` table.
15
15
  */
16
16
  export declare function applyRetention(policies: RetentionPolicy[], dsarRow: DsarRow, dataClass: string): RetentionMatch | null;
17
+ export interface ParsedDuration {
18
+ years: number;
19
+ months: number;
20
+ weeks: number;
21
+ days: number;
22
+ hours: number;
23
+ minutes: number;
24
+ seconds: number;
25
+ }
26
+ /**
27
+ * Parse an ISO-8601 duration (`P8Y`, `P10Y`, `P1Y6M`, `P90D`, `PT12H`).
28
+ *
29
+ * Throws on anything unparseable — a retention period is a legal obligation,
30
+ * and silently treating `"8Y"` (missing the `P`) as zero would purge a record
31
+ * eight years early. Negative durations are rejected for the same reason.
32
+ */
33
+ export declare function parseIsoDuration(period: string): ParsedDuration;
34
+ /**
35
+ * Add an ISO-8601 duration to an instant, calendar-correctly.
36
+ *
37
+ * Years and months go through the CALENDAR (UTC), not a fixed day count:
38
+ * "8 years from 2024-02-29" must land on 2032-02-29, and approximating a year
39
+ * as 365 days drifts two days over an 8-year statutory window — enough to purge
40
+ * on the wrong side of a filing deadline. Weeks/days/time are exact offsets.
41
+ */
42
+ export declare function addIsoDuration(at: Date, period: string): Date;
43
+ export interface RetentionScheduleQuery {
44
+ jurisdiction: string;
45
+ documentClass: string;
46
+ entityKind: string;
47
+ /**
48
+ * The record's ANCHOR timestamp — whichever of creation / last activity /
49
+ * relationship end / filing date the matched schedule counts from. The
50
+ * CALLER resolves it, because only the service knows which of its columns
51
+ * holds "relationship_end" for a given record.
52
+ */
53
+ anchorAt: string | Date;
54
+ /**
55
+ * Point in time the schedule is evaluated AT (effective-dating). Defaults to
56
+ * now. Pass the record's write time to answer "what window applied when this
57
+ * was filed?".
58
+ */
59
+ at?: string | Date;
60
+ }
61
+ export interface RetentionScheduleMatch {
62
+ schedule: RetentionSchedule;
63
+ /** ISO-8601 UTC instant the record may be hard-deleted. */
64
+ retainUntil: string;
65
+ /**
66
+ * True when the schedule is `extended_by_proceeding` — `retainUntil` is then
67
+ * the EARLIEST possible expiry, and the sweeper must additionally confirm no
68
+ * proceeding is open before purging.
69
+ */
70
+ extendedByProceeding: boolean;
71
+ }
72
+ /**
73
+ * D720 — resolve the governing retention schedule for a record and compute its
74
+ * hard-delete date.
75
+ *
76
+ * SELECTION, in order:
77
+ * 1. rows matching `(jurisdiction, document_class, entity_kind)` exactly;
78
+ * 2. narrowed to those IN FORCE at `at` (`effective_from <= at` and
79
+ * `effective_to` null or `> at`);
80
+ * 3. of those, the one with the LATEST `effective_from` — the most recent
81
+ * amendment wins, which is what "effective-dated" means;
82
+ * 4. ties (two rows with the same `effective_from`, e.g. a mid-migration
83
+ * double-insert) break toward the LONGER period. Retention floors are
84
+ * floors: when the registry is ambiguous the safe reading is the one that
85
+ * keeps the record, since a wrong purge is irreversible and a wrong keep
86
+ * is a row we delete next sweep.
87
+ *
88
+ * Returns `null` when nothing matches — the caller decides what that means. The
89
+ * sweeper treats it as "no schedule, no purge": absence of a rule is never a
90
+ * licence to delete.
91
+ */
92
+ export declare function applyRetentionSchedules(schedules: readonly RetentionSchedule[], query: RetentionScheduleQuery): RetentionScheduleMatch | null;
93
+ /**
94
+ * D720 — the anchor a schedule counts from, for a caller that needs to pick the
95
+ * right column before calling {@link applyRetentionSchedules}. Re-exported here
96
+ * so the sweeper + consumers import one symbol from one module.
97
+ */
98
+ export type { RetentionAnchor };
99
+ /** The canonical platform-global schedules table name. */
100
+ export declare const RETENTION_SCHEDULES_TABLE = "retention_schedules";
101
+ export interface RetentionSchedulesTable {
102
+ tableName: string;
103
+ /** Idempotent DDL — safe to re-run against an existing table (no-op). */
104
+ ddl: string;
105
+ }
106
+ /**
107
+ * D720 — the platform-global `retention_schedules` table.
108
+ *
109
+ * PLATFORM-GLOBAL, not per-service: it sits beside `retention_policies` and
110
+ * `data_residency_holds` in the orchestrator's schema, with no `<svc>_` prefix,
111
+ * because a jurisdiction's statutory period is a property of the LAW, not of
112
+ * whichever service happens to hold the record. `applyDsarMigrations` creates
113
+ * it; this function is for consumers running their own migration tool.
114
+ *
115
+ * The rows are DATA (operator/counsel-owned jurisdiction packs). This emits the
116
+ * shape only — no seed rows, no invented periods.
117
+ */
118
+ export declare function createRetentionSchedulesTable(tableName?: string): RetentionSchedulesTable;
119
+ /**
120
+ * The idempotent DDL body. Kept as a standalone function so the dsar migration
121
+ * template and `createRetentionSchedulesTable` emit BYTE-IDENTICAL SQL — one
122
+ * source of truth, no drift between the runner and the artifact.
123
+ */
124
+ export declare function retentionSchedulesDdl(tableName?: string): string;
17
125
  //# sourceMappingURL=retention.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"retention.d.ts","sourceRoot":"","sources":["../src/retention.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE3D,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,eAAe,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,eAAe,EAAE,EAC3B,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,GAChB,cAAc,GAAG,IAAI,CAoBvB"}
1
+ {"version":3,"file":"retention.d.ts","sourceRoot":"","sources":["../src/retention.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EACV,OAAO,EACP,eAAe,EACf,eAAe,EACf,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAGpB,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,eAAe,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;GASG;AACH,wBAAg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