@nodii/dsar 0.20.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.
- package/dist/bind-pattern-a.d.ts +127 -13
- package/dist/bind-pattern-a.d.ts.map +1 -1
- package/dist/bind-pattern-a.js +553 -32
- package/dist/bind-pattern-a.js.map +1 -1
- package/dist/bind-pattern-b.d.ts.map +1 -1
- package/dist/bind-pattern-b.js +58 -3
- package/dist/bind-pattern-b.js.map +1 -1
- package/dist/grpc/dsar-service.d.ts +29 -0
- package/dist/grpc/dsar-service.d.ts.map +1 -1
- package/dist/grpc/dsar-service.js +34 -0
- package/dist/grpc/dsar-service.js.map +1 -1
- package/dist/grpc/proto-path.d.ts +33 -0
- package/dist/grpc/proto-path.d.ts.map +1 -0
- package/dist/grpc/proto-path.js +87 -0
- package/dist/grpc/proto-path.js.map +1 -0
- package/dist/hold-failure-mode.d.ts +24 -0
- package/dist/hold-failure-mode.d.ts.map +1 -1
- package/dist/hold-failure-mode.js +24 -0
- package/dist/hold-failure-mode.js.map +1 -1
- package/dist/hold-gate-probe.d.ts +61 -0
- package/dist/hold-gate-probe.d.ts.map +1 -0
- package/dist/hold-gate-probe.js +146 -0
- package/dist/hold-gate-probe.js.map +1 -0
- package/dist/holds.d.ts +60 -1
- package/dist/holds.d.ts.map +1 -1
- package/dist/holds.js +60 -3
- package/dist/holds.js.map +1 -1
- package/dist/index.d.ts +16 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -5
- package/dist/index.js.map +1 -1
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +10 -0
- package/dist/migrations/index.js.map +1 -1
- package/dist/orchestrator.d.ts +48 -0
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +297 -20
- package/dist/orchestrator.js.map +1 -1
- package/dist/register.d.ts +35 -1
- package/dist/register.d.ts.map +1 -1
- package/dist/register.js +26 -0
- package/dist/register.js.map +1 -1
- package/dist/retention-sweeper.d.ts +252 -0
- package/dist/retention-sweeper.d.ts.map +1 -0
- package/dist/retention-sweeper.js +356 -0
- package/dist/retention-sweeper.js.map +1 -0
- package/dist/retention.d.ts +109 -1
- package/dist/retention.d.ts.map +1 -1
- package/dist/retention.js +216 -3
- package/dist/retention.js.map +1 -1
- package/dist/subject-kinds.d.ts +74 -0
- package/dist/subject-kinds.d.ts.map +1 -0
- package/dist/subject-kinds.js +141 -0
- package/dist/subject-kinds.js.map +1 -0
- package/dist/types.d.ts +423 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +164 -0
- package/dist/types.js.map +1 -1
- package/package.json +7 -4
- package/proto/nodii/dsar/v1/dsar.proto +202 -0
- package/src/migrations/001-lifecycle-requests.sql +422 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { SqlTransaction } from "./types.js";
|
|
2
|
+
import { DsarError } from "./types.js";
|
|
3
|
+
/** The narrow client surface the probe needs. */
|
|
4
|
+
type ProbeSqlClient = Pick<SqlTransaction, "unsafe">;
|
|
5
|
+
/** Default probe budget. One round-trip; a boot must not hang on it. */
|
|
6
|
+
export declare const HOLD_GATE_PROBE_TIMEOUT_MS = 3000;
|
|
7
|
+
/**
|
|
8
|
+
* `hold_gate_error` detail when the probe could not reach the database at all
|
|
9
|
+
* (connection refused, DNS, auth, timeout).
|
|
10
|
+
*/
|
|
11
|
+
export declare const HOLD_GATE_PROBE_UNREACHABLE_DETAIL = "dsar hold gate: the configured sqlClient could not be reached at bind time \u2014 holds cannot be consulted, so erase/restrict are refused (fail-closed).";
|
|
12
|
+
/**
|
|
13
|
+
* `hold_gate_error` detail when the connection works but the holds relation is
|
|
14
|
+
* absent — an unmigrated database, or the right server and the wrong database.
|
|
15
|
+
*/
|
|
16
|
+
export declare const HOLD_GATE_PROBE_TABLE_MISSING_DETAIL = "dsar hold gate: the configured sqlClient is reachable but the holds table does not exist \u2014 run `applyDsarMigrations` against THIS database (a pool pointed at the wrong database satisfies every structural check and fails only at the first erase).";
|
|
17
|
+
/**
|
|
18
|
+
* Thrown by {@link bindPatternAAndVerify}, and used to reject
|
|
19
|
+
* `impl.holdGateReady`, when the hold-gate probe fails.
|
|
20
|
+
*
|
|
21
|
+
* There is no opt-out and no "warn and continue": a participant that cannot
|
|
22
|
+
* consult holds cannot serve `EraseData` or `RestrictProcessing`, and the
|
|
23
|
+
* operator ruling of 2026-07-30 makes that a refusal, not a degradation.
|
|
24
|
+
*/
|
|
25
|
+
export declare class HoldGateUnreachableError extends DsarError {
|
|
26
|
+
readonly code = "HOLD_GATE_UNREACHABLE";
|
|
27
|
+
/** The probe detail — one of the two exported constants above. */
|
|
28
|
+
readonly detail: string;
|
|
29
|
+
/** The underlying driver error text, when there was one. */
|
|
30
|
+
readonly cause: string | undefined;
|
|
31
|
+
constructor(serviceName: string, detail: string, cause?: string);
|
|
32
|
+
}
|
|
33
|
+
/** Outcome of one probe run. */
|
|
34
|
+
export type HoldGateProbeResult = {
|
|
35
|
+
ok: true;
|
|
36
|
+
} | {
|
|
37
|
+
ok: false;
|
|
38
|
+
detail: string;
|
|
39
|
+
cause: string | undefined;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Run the reachability probe ONCE, bounded by `timeoutMs`.
|
|
43
|
+
*
|
|
44
|
+
* Deliberately a SINGLE statement and a SINGLE attempt. It is a boot smoke test,
|
|
45
|
+
* not a health checker: retrying would delay every boot by the retry budget to
|
|
46
|
+
* tell us the same thing, and the running service already re-consults holds on
|
|
47
|
+
* every request. `to_regclass` returns NULL rather than raising for an absent
|
|
48
|
+
* relation, so one round-trip answers both questions — is the connection alive,
|
|
49
|
+
* and does the holds table exist.
|
|
50
|
+
*
|
|
51
|
+
* NEVER THROWS. A probe that threw would have to be caught at every call site,
|
|
52
|
+
* and one uncaught path would crash a boot on a transient blip. It returns the
|
|
53
|
+
* failure instead, and the caller decides how hard to fail.
|
|
54
|
+
*/
|
|
55
|
+
export declare function probeHoldGate(args: {
|
|
56
|
+
sql: ProbeSqlClient;
|
|
57
|
+
holdsTableName: string;
|
|
58
|
+
timeoutMs?: number;
|
|
59
|
+
}): Promise<HoldGateProbeResult>;
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=hold-gate-probe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hold-gate-probe.d.ts","sourceRoot":"","sources":["../src/hold-gate-probe.ts"],"names":[],"mappings":"AAoDA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,iDAAiD;AACjD,KAAK,cAAc,GAAG,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;AAErD,wEAAwE;AACxE,eAAO,MAAM,0BAA0B,OAAQ,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,kCAAkC,8JACyG,CAAC;AAEzJ;;;GAGG;AACH,eAAO,MAAM,oCAAoC,+PACwM,CAAC;AAE1P;;;;;;;GAOG;AACH,qBAAa,wBAAyB,SAAQ,SAAS;IACrD,QAAQ,CAAC,IAAI,2BAA2B;IACxC,kEAAkE;IAClE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,4DAA4D;IAC5D,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;gBACvB,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;CAUhE;AAED,gCAAgC;AAChC,MAAM,MAAM,mBAAmB,GAC3B;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GACZ;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAE7D;;;;;;;;;;;;;GAaG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE;IACxC,GAAG,EAAE,cAAc,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAsD/B"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// The hold-gate REACHABILITY probe.
|
|
2
|
+
//
|
|
3
|
+
// WHY A STRUCTURAL CHECK WAS NOT ENOUGH
|
|
4
|
+
// -------------------------------------
|
|
5
|
+
// `bindPatternA` refuses to bind without a `sqlClient`
|
|
6
|
+
// (`MissingSqlClientForHoldGateError`). That check is STRUCTURAL: it proves an
|
|
7
|
+
// object with an `unsafe` method was passed, and nothing else. A pool wired to a
|
|
8
|
+
// host that is down, to the WRONG database, or to a database that never had
|
|
9
|
+
// `applyDsarMigrations` run against it satisfies it completely and binds clean.
|
|
10
|
+
//
|
|
11
|
+
// The service then boots green, serves traffic, and refuses its first erase with
|
|
12
|
+
// `hold_consult_failed_fail_closed` — which is the correct fail-closed outcome,
|
|
13
|
+
// and is exactly as invisible at deploy time as the no-pool case was before the
|
|
14
|
+
// bind-time check existed. "There is a pool" and "holds can be consulted" are
|
|
15
|
+
// different claims, and only the second one is the one the gate depends on.
|
|
16
|
+
//
|
|
17
|
+
// The probe closes that gap: one bounded round-trip at bind that asserts the
|
|
18
|
+
// connection works AND the holds relation exists.
|
|
19
|
+
//
|
|
20
|
+
// WHY IT CANNOT THROW FROM `bindPatternA`
|
|
21
|
+
// ---------------------------------------
|
|
22
|
+
// `bindPatternA` is SYNCHRONOUS and returns a `DsarServiceImpl`. A database
|
|
23
|
+
// round-trip is not, and making the bind async would break every consumer's boot
|
|
24
|
+
// path — for a check whose whole purpose is to make boots safer. So the probe is
|
|
25
|
+
// FIRED at bind and its outcome is surfaced two ways:
|
|
26
|
+
//
|
|
27
|
+
// 1. `impl.holdGateReady` (via `holdGateReadyOf(impl)`) — the probe promise. A
|
|
28
|
+
// consumer that wants a HARD boot gate awaits it and lets a rejection abort
|
|
29
|
+
// the deploy. This is the recommended wiring.
|
|
30
|
+
// 2. `bindPatternAAndVerify(opts)` — the same thing pre-wired: awaits the probe
|
|
31
|
+
// and throws `HoldGateUnreachableError`. One call, no discipline required.
|
|
32
|
+
//
|
|
33
|
+
// WHAT DELIBERATELY IS NOT HERE: a third surface where the erase / restrict
|
|
34
|
+
// handlers await the verdict themselves.
|
|
35
|
+
//
|
|
36
|
+
// An earlier draft had exactly that, and called it "the floor". It is a bug. A
|
|
37
|
+
// service that booted during a five-second DB blip would then refuse every erase
|
|
38
|
+
// FOREVER, until redeployed — and the operator ruling the whole fail-closed
|
|
39
|
+
// posture rests on says the opposite: "it's just a matter of a retry when holds
|
|
40
|
+
// is accessible". A latched boot verdict is precisely the un-retryable refusal
|
|
41
|
+
// D650's non-memoization rule exists to prevent, relocated from the row cache
|
|
42
|
+
// into process memory. `ts/dsar/tests/hold-gate-probe.test.ts` pins the
|
|
43
|
+
// non-latching behaviour, and the pre-existing `RULING RETRY` integration test
|
|
44
|
+
// is what caught the draft.
|
|
45
|
+
//
|
|
46
|
+
// Nothing is lost. Every condition this probe detects — unreachable pool, wrong
|
|
47
|
+
// database, unmigrated schema — ALSO makes the per-request `isHeld` consult
|
|
48
|
+
// raise, and that already produces the branded, audited, non-memoizable refusal.
|
|
49
|
+
// The runtime floor was never the probe's job; the per-request consult is, and
|
|
50
|
+
// always was, the runtime authority. The probe's unique contribution is telling a
|
|
51
|
+
// DEPLOY, once, instead of telling the first production erase.
|
|
52
|
+
import { DsarError } from "./types.js";
|
|
53
|
+
/** Default probe budget. One round-trip; a boot must not hang on it. */
|
|
54
|
+
export const HOLD_GATE_PROBE_TIMEOUT_MS = 3_000;
|
|
55
|
+
/**
|
|
56
|
+
* `hold_gate_error` detail when the probe could not reach the database at all
|
|
57
|
+
* (connection refused, DNS, auth, timeout).
|
|
58
|
+
*/
|
|
59
|
+
export const HOLD_GATE_PROBE_UNREACHABLE_DETAIL = "dsar hold gate: the configured sqlClient could not be reached at bind time — holds cannot be consulted, so erase/restrict are refused (fail-closed).";
|
|
60
|
+
/**
|
|
61
|
+
* `hold_gate_error` detail when the connection works but the holds relation is
|
|
62
|
+
* absent — an unmigrated database, or the right server and the wrong database.
|
|
63
|
+
*/
|
|
64
|
+
export const HOLD_GATE_PROBE_TABLE_MISSING_DETAIL = "dsar hold gate: the configured sqlClient is reachable but the holds table does not exist — run `applyDsarMigrations` against THIS database (a pool pointed at the wrong database satisfies every structural check and fails only at the first erase).";
|
|
65
|
+
/**
|
|
66
|
+
* Thrown by {@link bindPatternAAndVerify}, and used to reject
|
|
67
|
+
* `impl.holdGateReady`, when the hold-gate probe fails.
|
|
68
|
+
*
|
|
69
|
+
* There is no opt-out and no "warn and continue": a participant that cannot
|
|
70
|
+
* consult holds cannot serve `EraseData` or `RestrictProcessing`, and the
|
|
71
|
+
* operator ruling of 2026-07-30 makes that a refusal, not a degradation.
|
|
72
|
+
*/
|
|
73
|
+
export class HoldGateUnreachableError extends DsarError {
|
|
74
|
+
code = "HOLD_GATE_UNREACHABLE";
|
|
75
|
+
/** The probe detail — one of the two exported constants above. */
|
|
76
|
+
detail;
|
|
77
|
+
/** The underlying driver error text, when there was one. */
|
|
78
|
+
cause;
|
|
79
|
+
constructor(serviceName, detail, cause) {
|
|
80
|
+
super(`HOLD_GATE_UNREACHABLE: bindPatternA(${JSON.stringify(serviceName)}) could not verify the hold gate at boot. ${detail}${cause ? ` Underlying error: ${cause}` : ""}`);
|
|
81
|
+
this.name = "HoldGateUnreachableError";
|
|
82
|
+
this.detail = detail;
|
|
83
|
+
this.cause = cause;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Run the reachability probe ONCE, bounded by `timeoutMs`.
|
|
88
|
+
*
|
|
89
|
+
* Deliberately a SINGLE statement and a SINGLE attempt. It is a boot smoke test,
|
|
90
|
+
* not a health checker: retrying would delay every boot by the retry budget to
|
|
91
|
+
* tell us the same thing, and the running service already re-consults holds on
|
|
92
|
+
* every request. `to_regclass` returns NULL rather than raising for an absent
|
|
93
|
+
* relation, so one round-trip answers both questions — is the connection alive,
|
|
94
|
+
* and does the holds table exist.
|
|
95
|
+
*
|
|
96
|
+
* NEVER THROWS. A probe that threw would have to be caught at every call site,
|
|
97
|
+
* and one uncaught path would crash a boot on a transient blip. It returns the
|
|
98
|
+
* failure instead, and the caller decides how hard to fail.
|
|
99
|
+
*/
|
|
100
|
+
export async function probeHoldGate(args) {
|
|
101
|
+
const budget = args.timeoutMs ?? HOLD_GATE_PROBE_TIMEOUT_MS;
|
|
102
|
+
let timer;
|
|
103
|
+
const timeout = new Promise((resolve) => {
|
|
104
|
+
timer = setTimeout(() => resolve({
|
|
105
|
+
ok: false,
|
|
106
|
+
detail: HOLD_GATE_PROBE_UNREACHABLE_DETAIL,
|
|
107
|
+
cause: `probe exceeded ${budget}ms`,
|
|
108
|
+
}), budget);
|
|
109
|
+
// A pending timer must not hold the process open — a boot probe should
|
|
110
|
+
// never be the reason a CLI or a short-lived job refuses to exit.
|
|
111
|
+
timer.unref?.();
|
|
112
|
+
});
|
|
113
|
+
const run = (async () => {
|
|
114
|
+
try {
|
|
115
|
+
// `to_regclass` is NULL-returning, not raising, so an absent relation is
|
|
116
|
+
// data rather than an exception — which is what lets one statement
|
|
117
|
+
// distinguish "cannot connect" from "connected, table missing".
|
|
118
|
+
const rows = (await args.sql.unsafe("SELECT to_regclass($1) IS NOT NULL AS holds_table_present", [args.holdsTableName]));
|
|
119
|
+
const raw = rows?.[0]?.holds_table_present;
|
|
120
|
+
const present = raw === true || raw === "t" || raw === "true" || raw === 1;
|
|
121
|
+
if (!present) {
|
|
122
|
+
return {
|
|
123
|
+
ok: false,
|
|
124
|
+
detail: HOLD_GATE_PROBE_TABLE_MISSING_DETAIL,
|
|
125
|
+
cause: `to_regclass(${args.holdsTableName}) returned ${rows?.length ? JSON.stringify(raw) : "no rows"}`,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return { ok: true };
|
|
129
|
+
}
|
|
130
|
+
catch (err) {
|
|
131
|
+
return {
|
|
132
|
+
ok: false,
|
|
133
|
+
detail: HOLD_GATE_PROBE_UNREACHABLE_DETAIL,
|
|
134
|
+
cause: err instanceof Error ? err.message : String(err),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
})();
|
|
138
|
+
try {
|
|
139
|
+
return await Promise.race([run, timeout]);
|
|
140
|
+
}
|
|
141
|
+
finally {
|
|
142
|
+
if (timer !== undefined)
|
|
143
|
+
clearTimeout(timer);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=hold-gate-probe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hold-gate-probe.js","sourceRoot":"","sources":["../src/hold-gate-probe.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,EAAE;AACF,wCAAwC;AACxC,wCAAwC;AACxC,uDAAuD;AACvD,+EAA+E;AAC/E,iFAAiF;AACjF,4EAA4E;AAC5E,gFAAgF;AAChF,EAAE;AACF,iFAAiF;AACjF,gFAAgF;AAChF,gFAAgF;AAChF,8EAA8E;AAC9E,4EAA4E;AAC5E,EAAE;AACF,6EAA6E;AAC7E,kDAAkD;AAClD,EAAE;AACF,0CAA0C;AAC1C,0CAA0C;AAC1C,4EAA4E;AAC5E,iFAAiF;AACjF,iFAAiF;AACjF,sDAAsD;AACtD,EAAE;AACF,iFAAiF;AACjF,iFAAiF;AACjF,mDAAmD;AACnD,kFAAkF;AAClF,gFAAgF;AAChF,EAAE;AACF,4EAA4E;AAC5E,yCAAyC;AACzC,EAAE;AACF,+EAA+E;AAC/E,iFAAiF;AACjF,4EAA4E;AAC5E,gFAAgF;AAChF,+EAA+E;AAC/E,8EAA8E;AAC9E,wEAAwE;AACxE,+EAA+E;AAC/E,4BAA4B;AAC5B,EAAE;AACF,gFAAgF;AAChF,4EAA4E;AAC5E,iFAAiF;AACjF,+EAA+E;AAC/E,kFAAkF;AAClF,+DAA+D;AAG/D,OAAO,EAAE,SAA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C,KAAK,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
|
package/dist/holds.d.ts
CHANGED
|
@@ -105,11 +105,70 @@ export interface LiftedHold {
|
|
|
105
105
|
* the `lifted` rows (`id`, `subject_id`, `hold_kind`, `data_class`) via
|
|
106
106
|
* `RETURNING`, so the caller (e.g. the tenant residency-holds outbox producer)
|
|
107
107
|
* emits ONE event per lifted row atomically — no pre-SELECT race window.
|
|
108
|
+
*
|
|
109
|
+
* ## Scope (drift `4a72cce1`) — three scopes, none of them guessed
|
|
110
|
+
*
|
|
111
|
+
* | call | lifts |
|
|
112
|
+
* |---|---|
|
|
113
|
+
* | `subjectId: 's1'` | ONLY `subject_id = 's1'`. Tenant-level rows SURVIVE. |
|
|
114
|
+
* | `subjectId: null` / omitted | ONLY the tenant-level rows (`subject_id IS NULL`). |
|
|
115
|
+
* | `subjectId: null` + `sweepAllSubjects: true` | EVERY unlifted row in the tenant, subject-scoped rows included. |
|
|
116
|
+
*
|
|
117
|
+
* A concrete `subjectId` together with `sweepAllSubjects: true` throws
|
|
118
|
+
* {@link AmbiguousLiftScope} — the two say opposite things.
|
|
119
|
+
*
|
|
120
|
+
* `sweepAllSubjects` is deliberately NOT called `tenantWide`. The participant
|
|
121
|
+
* bind layer hands its lift handler a `tenant_level` boolean meaning "the
|
|
122
|
+
* request named no subject, so act on the tenant-level ROW"; under the old name
|
|
123
|
+
* the two read as synonyms, and forwarding one into the other silently converted
|
|
124
|
+
* a one-row tenant lift into a whole-tenant sweep — this function's own bug,
|
|
125
|
+
* re-entered through its caller. There is no flag to forward: a lift request
|
|
126
|
+
* reaches this function through `subjectId` (`null` for the tenant-level row).
|
|
127
|
+
* `sweepAllSubjects` is an OPERATOR action with no request-level equivalent.
|
|
128
|
+
*
|
|
129
|
+
* ### What this fixes
|
|
130
|
+
*
|
|
131
|
+
* The predicate used to be
|
|
132
|
+
* `($3::text IS NULL OR subject_id = $3 OR subject_id IS NULL)`. That trailing
|
|
133
|
+
* `OR subject_id IS NULL` is unconditional: it applies on the `subjectId = 's1'`
|
|
134
|
+
* branch too. So a lift scoped to ONE data subject also lifted every
|
|
135
|
+
* TENANT-LEVEL hold of the matching kinds — including a statutory
|
|
136
|
+
* `legal` / `aml_regulatory` hold placed over the whole tenant. One subject
|
|
137
|
+
* exercising Art. 17 silently released the tenant's litigation hold, and the
|
|
138
|
+
* next erase for ANY subject then passed the gate. The `RETURNING` rows made it
|
|
139
|
+
* worse rather than louder: the caller emitted a `lifted.v1` event per
|
|
140
|
+
* collaterally-lifted row, so the release propagated across the fleet.
|
|
141
|
+
*
|
|
142
|
+
* `isHeld` / `listActiveHolds` keep their `OR subject_id IS NULL` arm — and
|
|
143
|
+
* must. On a READ that arm is the fail-SAFE direction (a tenant hold correctly
|
|
144
|
+
* blocks every subject's erase, and correctly surfaces in every subject's hold
|
|
145
|
+
* list). On this WRITE the same arm is the fail-DANGEROUS direction, because it
|
|
146
|
+
* RELEASES protection rather than applying it. Same clause, opposite sign.
|
|
108
147
|
*/
|
|
109
148
|
export declare function liftHold(opts: {
|
|
110
149
|
sql: SqlClient;
|
|
111
150
|
tenantId: string;
|
|
112
|
-
|
|
151
|
+
/**
|
|
152
|
+
* The subject whose holds are lifted. `null` / omitted = a scope that is NOT
|
|
153
|
+
* a subject: tenant-level holds only, unless `sweepAllSubjects` widens it.
|
|
154
|
+
*/
|
|
155
|
+
subjectId?: string | null;
|
|
156
|
+
/**
|
|
157
|
+
* Opt IN to the WHOLE-TENANT SWEEP: every unlifted row in the tenant,
|
|
158
|
+
* INCLUDING every subject's own holds. Requires `subjectId` to be `null` /
|
|
159
|
+
* omitted.
|
|
160
|
+
*
|
|
161
|
+
* This is the ONLY way to reach the pre-4a72cce1 `subjectId: null` behaviour.
|
|
162
|
+
* It is deliberately explicit and deliberately unattractive to type: releasing
|
|
163
|
+
* every subject's holds is a distinct, far higher-blast-radius operation than
|
|
164
|
+
* "release the tenant-level hold", and the old API spelled both of them
|
|
165
|
+
* `subjectId: null`.
|
|
166
|
+
*
|
|
167
|
+
* NEVER derive this from a `LiftRetentionHold` request. The bind layer's
|
|
168
|
+
* `tenant_level` flag is its OPPOSITE (one row vs. all rows) — see
|
|
169
|
+
* `RetentionHoldHandlers.lift`.
|
|
170
|
+
*/
|
|
171
|
+
sweepAllSubjects?: boolean;
|
|
113
172
|
holdKind: HoldKind | readonly HoldKind[];
|
|
114
173
|
liftedBy: string;
|
|
115
174
|
/** v0.4.0 — optional data-class narrowing. */
|
package/dist/holds.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"holds.d.ts","sourceRoot":"","sources":["../src/holds.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"holds.d.ts","sourceRoot":"","sources":["../src/holds.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAM1E,KAAK,SAAS,GAAG;IAEf,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACzD,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,SAAS,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,QAAQ,EAAE,CAAC;IAC1C;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AASD;;;;;;;;;;;;GAYG;AACH,wBAAsB,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAqCzE;AA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QAAQ,CAAC,IAAI,EAAE;IACnC,GAAG,EAAE,SAAS,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;;;;;;;;;;;;OAcG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,EAAE,QAAQ,GAAG,SAAS,QAAQ,EAAE,CAAC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,EAAE,CAAA;CAAE,CAAC,CAkDnD"}
|
package/dist/holds.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// - The consult can be invoked fail-closed by the caller (the consult
|
|
15
15
|
// itself throws on SQL error; the caller decides open-vs-closed). See
|
|
16
16
|
// `bind-pattern-a.ts` / `orchestrator.ts` (gap 3).
|
|
17
|
-
import { DEFAULT_ERASE_BLOCKING_HOLD_KINDS } from "./types.js";
|
|
17
|
+
import { AmbiguousLiftScope, DEFAULT_ERASE_BLOCKING_HOLD_KINDS, } from "./types.js";
|
|
18
18
|
function normalizeKinds(kind) {
|
|
19
19
|
if (kind === undefined)
|
|
20
20
|
return [...DEFAULT_ERASE_BLOCKING_HOLD_KINDS];
|
|
@@ -191,21 +191,78 @@ export async function listActiveHolds(opts) {
|
|
|
191
191
|
* the `lifted` rows (`id`, `subject_id`, `hold_kind`, `data_class`) via
|
|
192
192
|
* `RETURNING`, so the caller (e.g. the tenant residency-holds outbox producer)
|
|
193
193
|
* emits ONE event per lifted row atomically — no pre-SELECT race window.
|
|
194
|
+
*
|
|
195
|
+
* ## Scope (drift `4a72cce1`) — three scopes, none of them guessed
|
|
196
|
+
*
|
|
197
|
+
* | call | lifts |
|
|
198
|
+
* |---|---|
|
|
199
|
+
* | `subjectId: 's1'` | ONLY `subject_id = 's1'`. Tenant-level rows SURVIVE. |
|
|
200
|
+
* | `subjectId: null` / omitted | ONLY the tenant-level rows (`subject_id IS NULL`). |
|
|
201
|
+
* | `subjectId: null` + `sweepAllSubjects: true` | EVERY unlifted row in the tenant, subject-scoped rows included. |
|
|
202
|
+
*
|
|
203
|
+
* A concrete `subjectId` together with `sweepAllSubjects: true` throws
|
|
204
|
+
* {@link AmbiguousLiftScope} — the two say opposite things.
|
|
205
|
+
*
|
|
206
|
+
* `sweepAllSubjects` is deliberately NOT called `tenantWide`. The participant
|
|
207
|
+
* bind layer hands its lift handler a `tenant_level` boolean meaning "the
|
|
208
|
+
* request named no subject, so act on the tenant-level ROW"; under the old name
|
|
209
|
+
* the two read as synonyms, and forwarding one into the other silently converted
|
|
210
|
+
* a one-row tenant lift into a whole-tenant sweep — this function's own bug,
|
|
211
|
+
* re-entered through its caller. There is no flag to forward: a lift request
|
|
212
|
+
* reaches this function through `subjectId` (`null` for the tenant-level row).
|
|
213
|
+
* `sweepAllSubjects` is an OPERATOR action with no request-level equivalent.
|
|
214
|
+
*
|
|
215
|
+
* ### What this fixes
|
|
216
|
+
*
|
|
217
|
+
* The predicate used to be
|
|
218
|
+
* `($3::text IS NULL OR subject_id = $3 OR subject_id IS NULL)`. That trailing
|
|
219
|
+
* `OR subject_id IS NULL` is unconditional: it applies on the `subjectId = 's1'`
|
|
220
|
+
* branch too. So a lift scoped to ONE data subject also lifted every
|
|
221
|
+
* TENANT-LEVEL hold of the matching kinds — including a statutory
|
|
222
|
+
* `legal` / `aml_regulatory` hold placed over the whole tenant. One subject
|
|
223
|
+
* exercising Art. 17 silently released the tenant's litigation hold, and the
|
|
224
|
+
* next erase for ANY subject then passed the gate. The `RETURNING` rows made it
|
|
225
|
+
* worse rather than louder: the caller emitted a `lifted.v1` event per
|
|
226
|
+
* collaterally-lifted row, so the release propagated across the fleet.
|
|
227
|
+
*
|
|
228
|
+
* `isHeld` / `listActiveHolds` keep their `OR subject_id IS NULL` arm — and
|
|
229
|
+
* must. On a READ that arm is the fail-SAFE direction (a tenant hold correctly
|
|
230
|
+
* blocks every subject's erase, and correctly surfaces in every subject's hold
|
|
231
|
+
* list). On this WRITE the same arm is the fail-DANGEROUS direction, because it
|
|
232
|
+
* RELEASES protection rather than applying it. Same clause, opposite sign.
|
|
194
233
|
*/
|
|
195
234
|
export async function liftHold(opts) {
|
|
196
235
|
const table = opts.tableName ?? "data_residency_holds";
|
|
197
236
|
const kinds = normalizeKinds(opts.holdKind);
|
|
237
|
+
const subjectId = opts.subjectId ?? null;
|
|
238
|
+
if (opts.sweepAllSubjects === true && subjectId !== null) {
|
|
239
|
+
throw new AmbiguousLiftScope(subjectId);
|
|
240
|
+
}
|
|
241
|
+
// Every branch still REFERENCES $3 (bound to `subjectId`) so the parameter
|
|
242
|
+
// count matches the statement in all three scopes — postgres rejects a bind
|
|
243
|
+
// that supplies a parameter the statement never mentions.
|
|
244
|
+
const subjectScope = opts.sweepAllSubjects === true
|
|
245
|
+
? // Guarded above: `sweepAllSubjects` implies subjectId === null, so this
|
|
246
|
+
// is unconditionally TRUE — no subject predicate at all (the sweep).
|
|
247
|
+
"$3::text IS NULL"
|
|
248
|
+
: subjectId === null
|
|
249
|
+
? // Tenant-level holds ONLY. `$3::text IS NULL` is the guard that keeps
|
|
250
|
+
// this arm unreachable from the per-subject branch.
|
|
251
|
+
"(subject_id IS NULL AND $3::text IS NULL)"
|
|
252
|
+
: // Per-subject lift — STRICT. No `OR subject_id IS NULL`: a subject's
|
|
253
|
+
// lift must never release the tenant's hold (drift 4a72cce1).
|
|
254
|
+
"subject_id = $3";
|
|
198
255
|
const stmt = `UPDATE ${table}
|
|
199
256
|
SET lifted_at = now(), lifted_by = $4
|
|
200
257
|
WHERE tenant_id = $1 AND hold_kind = ANY($2::text[]) AND lifted_at IS NULL
|
|
201
|
-
AND
|
|
258
|
+
AND ${subjectScope}
|
|
202
259
|
AND ($5::text IS NULL OR data_class IS NULL OR data_class = $5)
|
|
203
260
|
AND ($6::text IS NULL OR hold_request_id = $6)
|
|
204
261
|
RETURNING id::text AS id, subject_id, hold_kind, data_class`;
|
|
205
262
|
const rows = (await opts.sql.unsafe(stmt, [
|
|
206
263
|
opts.tenantId,
|
|
207
264
|
kinds,
|
|
208
|
-
|
|
265
|
+
subjectId,
|
|
209
266
|
opts.liftedBy,
|
|
210
267
|
opts.dataClass ?? null,
|
|
211
268
|
opts.holdRequestId ?? null,
|
package/dist/holds.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"holds.js","sourceRoot":"","sources":["../src/holds.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,WAAW;AACX,EAAE;AACF,yCAAyC;AACzC,yEAAyE;AACzE,4EAA4E;AAC5E,6DAA6D;AAC7D,0CAA0C;AAC1C,8EAA8E;AAC9E,eAAe;AACf,wEAAwE;AACxE,0EAA0E;AAC1E,uDAAuD;AAGvD,OAAO,
|
|
1
|
+
{"version":3,"file":"holds.js","sourceRoot":"","sources":["../src/holds.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,WAAW;AACX,EAAE;AACF,yCAAyC;AACzC,yEAAyE;AACzE,4EAA4E;AAC5E,6DAA6D;AAC7D,0CAA0C;AAC1C,8EAA8E;AAC9E,eAAe;AACf,wEAAwE;AACxE,0EAA0E;AAC1E,uDAAuD;AAGvD,OAAO,EACL,kBAAkB,EAClB,iCAAiC,GAClC,MAAM,YAAY,CAAC;AA6BpB,SAAS,cAAc,CACrB,IAAgD;IAEhD,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,CAAC,GAAG,iCAAiC,CAAC,CAAC;IACtE,OAAO,KAAK,CAAC,OAAO,CAAC,I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AE,CAAC,CAAC,UAAU;QACxB,SAAS,EAAE,CAAC,CAAC,SAAS;QACtB,UAAU,EAAE,CAAC,CAAC,UAAU,IAAI,IAAI;KACjC,CAAC,CAAC,CAAC;IACJ,sEAAsE;IACtE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;AAC1C,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const LIB_NAME = "dsar";
|
|
2
|
-
export declare const VERSION = "0.
|
|
2
|
+
export declare const VERSION = "0.22.0";
|
|
3
3
|
export { initDsar, getDsarOrNull, requireDsar, _resetForTests, } from "./init.js";
|
|
4
4
|
export type { InitDsarConfig, ResolvedDsarConfig } from "./init.js";
|
|
5
5
|
export { InMemoryDsarStore } from "./store.js";
|
|
@@ -8,21 +8,31 @@ export { beginDsar, getDsar, listDsars, accessData, eraseData, portabilityExport
|
|
|
8
8
|
export type { BeginDsarArgs, BeginDsarResult, GetDsarArgs, ListDsarsArgs, AccessDataArgs, AccessDataResult, EraseDataArgs, EraseDataResult, PortabilityExportArgs, PortabilityExportResult, RectifyArgs, RectifyResult, MarkCompleteArgs, MarkCompleteResult, AppealRejectionArgs, AppealRejectionResult, } from "./handlers.js";
|
|
9
9
|
export { canonicalJson, CanonicalSerializationError, EventNonCanonical, } from "./canonical.js";
|
|
10
10
|
export type { CanonicalValue } from "./canonical.js";
|
|
11
|
-
export { AmbiguousHoldFailureMode, HELD_WRITE_FAILED_REASON, HOLD_CONSULT_FAILED_REASON, HOLD_GATE_INFRA_REFUSAL_REASONS, holdGateRefusalAuditPayload, isNonMemoizableOutcome, resolveFailClosedHolds, } from "./hold-failure-mode.js";
|
|
11
|
+
export { AmbiguousHoldFailureMode, HELD_WRITE_FAILED_REASON, HOLD_CONSULT_FAILED_REASON, HOLD_GATE_INFRA_REFUSAL_REASONS, HOLD_GATE_NO_SQL_CLIENT_DETAIL, holdGateRefusalAuditPayload, isNonMemoizableOutcome, resolveFailClosedHolds, } from "./hold-failure-mode.js";
|
|
12
12
|
export type { HoldFailureModeOpts } from "./hold-failure-mode.js";
|
|
13
|
+
export { SUBJECT_KINDS, UNKNOWN_SUBJECT_KIND_REASON, UnknownSubjectKindError, assertSubjectKind, isSubjectKind, unknownSubjectKindRefusal, } from "./subject-kinds.js";
|
|
14
|
+
export type { SubjectKind } from "./subject-kinds.js";
|
|
13
15
|
export { applyRetention } from "./retention.js";
|
|
14
16
|
export type { RetentionMatch } from "./retention.js";
|
|
15
|
-
export {
|
|
17
|
+
export { DEFAULT_PII_BUCKET, PII_BUCKETS, RETENTION_ANCHORS, RestrictedMarkerNotWritten, STATUTORY_ALREADY_TENANT_SHREDDED_REASON, STATUTORY_NOT_RETENTION_KEYED_REASON, STATUTORY_RETENTION_PARTIAL_REASON, StatutoryBucketNotRetentionKeyed, isPiiBucket, isRetentionAnchor, } from "./types.js";
|
|
18
|
+
export type { PiiBucket, RetainedClass, RetentionAnchor, RetentionDekState, RetentionSchedule, } from "./types.js";
|
|
19
|
+
export { RETENTION_SCHEDULES_TABLE, addIsoDuration, applyRetentionSchedules, createRetentionSchedulesTable, parseIsoDuration, retentionSchedulesDdl, } from "./retention.js";
|
|
20
|
+
export type { ParsedDuration, RetentionScheduleMatch, RetentionScheduleQuery, RetentionSchedulesTable, } from "./retention.js";
|
|
21
|
+
export { RETENTION_SWEEPER_BATCH_SIZE, RETENTION_SWEEPER_INTERVAL_MS, RETENTION_SWEEPER_JOB_NAME, RetentionSweepHoldConsultFailed, makeRetentionSweeperJob, retentionPurgeTopic, } from "./retention-sweeper.js";
|
|
22
|
+
export type { RetentionPurgeEvent, RetentionPurgeOutboxEmitter, RetentionPurgeRecord, RetentionSweepResult, RetentionSweepTarget, RetentionSweeperJobDefinition, RetentionSweeperOpts, } from "./retention-sweeper.js";
|
|
23
|
+
export { DsarError, DsarNotInitialized, DsarNotFound, DsarStoreRequired, JustificationRequired, SubjectKindNotRegistered, DsarTerminalStateViolation, ExportGatherFailed, EraseExecutionFailed, HandlerAlreadyRegistered, CmkAdapterNotConfigured, CmkResolutionFailed, MissingSqlClientForHoldGateError, AmbiguousLiftScope, tenantCmkAliasAdapter, } from "./types.js";
|
|
16
24
|
export type { ActiveHold, CompensationLogEntry, DsarRequestType, DsarRow, DsarStatus, DsarStore, DsarSubjectKind, EraseExecutorFn, ExportGatherFn, HoldKind, PortabilityFormat, RectifyHandlerFn, RetentionPolicy, LifecycleResponse, AggregatorStatus, SiblingState, PlatformLifecycleRequestRow, ListActiveHoldsRequest, ListActiveHoldsResponse, SubjectKindStr, PatternAEnvelope, PatternAHandlers, DecryptedExportBundle, RetentionHoldHandlers, HoldConsultResult, AuditEmitter, PiiAdapter, CmkRef, CmkLookupAdapter, DsarComplianceEvent, OutboxEmitter, SqlTransaction, } from "./types.js";
|
|
17
25
|
export { DEFAULT_ERASE_BLOCKING_HOLD_KINDS, STATUTORY_HOLD_KINDS, CITATION_REQUIRED_HOLD_KINDS, MissingOutboxEmitterError, RPC_TO_COMPLIANCE_VERB, complianceTopic, } from "./types.js";
|
|
18
26
|
export { type DsarServiceImpl, type DsarMethodHandler, type ListActiveHoldsMethodHandler, noDataServiceImpl, subjectKindFromProto, } from "./grpc/dsar-service.js";
|
|
19
|
-
export {
|
|
20
|
-
export
|
|
27
|
+
export { dataLifecycleProtoFor, dataLifecycleProtoPath, dataLifecycleProtoSource, } from "./grpc/proto-path.js";
|
|
28
|
+
export { bindPatternA, bindPatternAAndVerify, complianceStatusFor, holdGateReadyOf, } from "./bind-pattern-a.js";
|
|
29
|
+
export { HOLD_GATE_PROBE_TABLE_MISSING_DETAIL, HOLD_GATE_PROBE_TIMEOUT_MS, HOLD_GATE_PROBE_UNREACHABLE_DETAIL, HoldGateUnreachableError, probeHoldGate, type HoldGateProbeResult, } from "./hold-gate-probe.js";
|
|
30
|
+
export type { BindPatternAOpts, RetentionBucketDeclaration, RetentionScheduleLookup, } from "./bind-pattern-a.js";
|
|
21
31
|
export { bindPatternB } from "./bind-pattern-b.js";
|
|
22
32
|
export type { BindPatternBOpts } from "./bind-pattern-b.js";
|
|
23
33
|
export { bindPatternC } from "./bind-pattern-c.js";
|
|
24
34
|
export type { BindPatternCOpts } from "./bind-pattern-c.js";
|
|
25
|
-
export { bindOrchestrator, readAggregatorRow, dispatchModeFor, SYNC_RPCS, ASYNC_RPCS, } from "./orchestrator.js";
|
|
35
|
+
export { bindOrchestrator, readAggregatorRow, dispatchModeFor, SYNC_RPCS, ASYNC_RPCS, NO_SIBLING_REACHABLE_REASON, NO_SIBLING_REGISTERED_REASON, PARTIAL_SIBLING_FAILURE_REASON, PARTIAL_SIBLING_UNREACHABLE_REASON, } from "./orchestrator.js";
|
|
26
36
|
export type { BindOrchestratorOpts, SiblingClient, } from "./orchestrator.js";
|
|
27
37
|
export { registerWithOrchestrator } from "./register.js";
|
|
28
38
|
export type { RegisterWithOrchestratorOpts, RegisterWithOrchestratorResult, DataClassRegistration, } from "./register.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,QAAQ,SAAS,CAAC;AAC/B,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,QAAQ,SAAS,CAAC;AAC/B,eAAO,MAAM,OAAO,WAAW,CAAC;AAGhC,OAAO,EACL,QAAQ,EACR,aAAa,EACb,WAAW,EACX,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG/C,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,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B,GACtB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,8BAA8B,EAC9B,wBAAwB,GACzB,MAAM,qCAAqC,CAAC;AAC7C,YAAY,EACV,mBAAmB,EACnB,kCAAkC,GACnC,MAAM,qCAAqC,CAAC;AAG7C,OAAO,EACL,8BAA8B,EAC9B,aAAa,EACb,kCAAkC,EAClC,qCAAqC,GACtC,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC1E,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGzD,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,0BAA0B,EAC1B,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,GACf,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC7D,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGpD,OAAO,EACL,uBAAuB,EACvB,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
// - isHeld() / placeHold() / liftHold() for data_residency_holds.
|
|
19
19
|
// - Audit-action auto-naming via actionName() per 28-action family.
|
|
20
20
|
export const LIB_NAME = "dsar";
|
|
21
|
-
export const VERSION = "0.
|
|
21
|
+
export const VERSION = "0.22.0";
|
|
22
22
|
// ---- Bootstrap ----
|
|
23
23
|
export { initDsar, getDsarOrNull, requireDsar, _resetForTests, } from "./init.js";
|
|
24
24
|
export { InMemoryDsarStore } from "./store.js";
|
|
@@ -45,19 +45,42 @@ export { canonicalJson, CanonicalSerializationError, EventNonCanonical, } from "
|
|
|
45
45
|
// in `HOLD_GATE_INFRA_REFUSAL_REASONS`, and `isNonMemoizableOutcome` is the
|
|
46
46
|
// rule that keeps them out of the `lifecycle_requests` response cache so the
|
|
47
47
|
// ruling's "just a matter of a retry" is actually true.
|
|
48
|
-
export { AmbiguousHoldFailureMode, HELD_WRITE_FAILED_REASON, HOLD_CONSULT_FAILED_REASON, HOLD_GATE_INFRA_REFUSAL_REASONS, holdGateRefusalAuditPayload, isNonMemoizableOutcome, resolveFailClosedHolds, } from "./hold-failure-mode.js";
|
|
48
|
+
export { AmbiguousHoldFailureMode, HELD_WRITE_FAILED_REASON, HOLD_CONSULT_FAILED_REASON, HOLD_GATE_INFRA_REFUSAL_REASONS, HOLD_GATE_NO_SQL_CLIENT_DETAIL, holdGateRefusalAuditPayload, isNonMemoizableOutcome, resolveFailClosedHolds, } from "./hold-failure-mode.js";
|
|
49
|
+
// ---- D719: the CLOSED data-subject vocabulary ----
|
|
50
|
+
// `SUBJECT_KINDS` is the single source of truth for what a `subject_kind` may
|
|
51
|
+
// be, in this library and on the wire. `DsarSubjectKind` + `SubjectKindStr`
|
|
52
|
+
// (below) are now aliases of `SubjectKind`; they used to be two DIFFERENT
|
|
53
|
+
// hand-maintained lists in the same file.
|
|
54
|
+
export { SUBJECT_KINDS, UNKNOWN_SUBJECT_KIND_REASON, UnknownSubjectKindError, assertSubjectKind, isSubjectKind, unknownSubjectKindRefusal, } from "./subject-kinds.js";
|
|
49
55
|
export { applyRetention } from "./retention.js";
|
|
50
|
-
|
|
56
|
+
// ---- D720: three-bucket retention + schedules + the purpose-spent sweeper ----
|
|
57
|
+
export { DEFAULT_PII_BUCKET, PII_BUCKETS, RETENTION_ANCHORS, RestrictedMarkerNotWritten, STATUTORY_ALREADY_TENANT_SHREDDED_REASON, STATUTORY_NOT_RETENTION_KEYED_REASON, STATUTORY_RETENTION_PARTIAL_REASON, StatutoryBucketNotRetentionKeyed, isPiiBucket, isRetentionAnchor, } from "./types.js";
|
|
58
|
+
export { RETENTION_SCHEDULES_TABLE, addIsoDuration, applyRetentionSchedules, createRetentionSchedulesTable, parseIsoDuration, retentionSchedulesDdl, } from "./retention.js";
|
|
59
|
+
export { RETENTION_SWEEPER_BATCH_SIZE, RETENTION_SWEEPER_INTERVAL_MS, RETENTION_SWEEPER_JOB_NAME, RetentionSweepHoldConsultFailed, makeRetentionSweeperJob, retentionPurgeTopic, } from "./retention-sweeper.js";
|
|
60
|
+
export { DsarError, DsarNotInitialized, DsarNotFound, DsarStoreRequired, JustificationRequired, SubjectKindNotRegistered, DsarTerminalStateViolation, ExportGatherFailed, EraseExecutionFailed, HandlerAlreadyRegistered, CmkAdapterNotConfigured, CmkResolutionFailed,
|
|
61
|
+
// libs#612 (bind-time leg) — a Pattern A bind with no holds pool.
|
|
62
|
+
MissingSqlClientForHoldGateError,
|
|
63
|
+
// drift 4a72cce1 — `liftHold` refuses to guess between the two scopes.
|
|
64
|
+
AmbiguousLiftScope, tenantCmkAliasAdapter, } from "./types.js";
|
|
51
65
|
export { DEFAULT_ERASE_BLOCKING_HOLD_KINDS, STATUTORY_HOLD_KINDS, CITATION_REQUIRED_HOLD_KINDS,
|
|
52
66
|
// D239 — participant-side outbox seam.
|
|
53
67
|
MissingOutboxEmitterError, RPC_TO_COMPLIANCE_VERB, complianceTopic, } from "./types.js";
|
|
54
68
|
// ---- v0.1.1: gRPC service descriptor + Pattern A/B/C bindings ----
|
|
55
69
|
export { noDataServiceImpl, subjectKindFromProto, } from "./grpc/dsar-service.js";
|
|
56
|
-
|
|
70
|
+
// drift dc5640d1 — the SHIPPED DataLifecycleService .proto + its per-host
|
|
71
|
+
// materializer (D417). `package.json#files` carries `proto/` into the tarball.
|
|
72
|
+
export { dataLifecycleProtoFor, dataLifecycleProtoPath, dataLifecycleProtoSource, } from "./grpc/proto-path.js";
|
|
73
|
+
export { bindPatternA, bindPatternAAndVerify, complianceStatusFor, holdGateReadyOf, } from "./bind-pattern-a.js";
|
|
74
|
+
// The bind-time hold-gate reachability probe (the behavioural half of the
|
|
75
|
+
// no-pool guard — a structurally-valid pool aimed at a down/wrong/unmigrated DB).
|
|
76
|
+
export { HOLD_GATE_PROBE_TABLE_MISSING_DETAIL, HOLD_GATE_PROBE_TIMEOUT_MS, HOLD_GATE_PROBE_UNREACHABLE_DETAIL, HoldGateUnreachableError, probeHoldGate, } from "./hold-gate-probe.js";
|
|
57
77
|
export { bindPatternB } from "./bind-pattern-b.js";
|
|
58
78
|
export { bindPatternC } from "./bind-pattern-c.js";
|
|
59
79
|
// ---- v0.1.1: orchestrator + register ----
|
|
60
|
-
export { bindOrchestrator, readAggregatorRow, dispatchModeFor, SYNC_RPCS, ASYNC_RPCS,
|
|
80
|
+
export { bindOrchestrator, readAggregatorRow, dispatchModeFor, SYNC_RPCS, ASYNC_RPCS,
|
|
81
|
+
// Read-fan-out outcome vocabulary — a caller classifies a partial result by
|
|
82
|
+
// these tokens instead of string-matching prose.
|
|
83
|
+
NO_SIBLING_REACHABLE_REASON, NO_SIBLING_REGISTERED_REASON, PARTIAL_SIBLING_FAILURE_REASON, PARTIAL_SIBLING_UNREACHABLE_REASON, } from "./orchestrator.js";
|
|
61
84
|
export { registerWithOrchestrator } from "./register.js";
|
|
62
85
|
// ---- v0.1.1: lifecycle store + migrations ----
|
|
63
86
|
export { PostgresLifecycleRequestsStore, withLifecycleIdempotency, } from "./state-store/postgres-lifecycle.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,mEAAmE;AACnE,6CAA6C;AAC7C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,GACzB,MAAM,qCAAqC,CAAC;AAM7C,4EAA4E;AAC5E,OAAO,EACL,8BAA8B,EAC9B,aAAa,EACb,kCAAkC,EAClC,qCAAqC,GACtC,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAE/B,mDAAmD;AACnD,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG1E,yCAAyC;AACzC,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,0BAA0B,EAC1B,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAS1B,wCAAwC;AACxC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAG7D,gEAAgE;AAChE,OAAO,EACL,uBAAuB,EACvB,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAUA,KAAK,SAAS,GAAG;IAEf,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACzD,CAAC;AAiNF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAsC9C;AAaD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAoCzD;AAmDD,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,2BAA2B,kzaAkQvC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,iCAAiC,4hBAQ9B,CAAC;AAEjB;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CA4BrD"}
|
package/dist/migrations/index.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// `applySagaMigrations` in shape. The SQL source-of-truth lives at
|
|
6
6
|
// `src/migrations/001-lifecycle-requests.sql` for downstream services that
|
|
7
7
|
// prefer a different migration runner (Flyway, golang-migrate, alembic).
|
|
8
|
+
import { retentionSchedulesDdl } from "../retention.js";
|
|
8
9
|
/**
|
|
9
10
|
* The canonical CRUD verb set the A1 RLS policies cover (D412 § 2 — "SELECT /
|
|
10
11
|
* INSERT / UPDATE / DELETE scoped by the `app.tenant_id` GUC + the nodii_owner
|
|
@@ -151,6 +152,15 @@ CREATE TABLE IF NOT EXISTS retention_policies (
|
|
|
151
152
|
CREATE INDEX IF NOT EXISTS idx_retention_policies_active
|
|
152
153
|
ON retention_policies (data_class, subject_kind)
|
|
153
154
|
WHERE soft_deleted_at IS NULL;
|
|
155
|
+
-- D720 — retention_schedules: the platform-global, effective-dated statutory
|
|
156
|
+
-- window registry the purpose-spent sweeper consumes. Platform-global (no
|
|
157
|
+
-- <svc>_ prefix, beside retention_policies + data_residency_holds) because a
|
|
158
|
+
-- jurisdiction's statutory period is a property of the LAW, not of whichever
|
|
159
|
+
-- service holds the record. The ROWS are operator/counsel-owned data — this
|
|
160
|
+
-- migration ships the shape and seeds nothing.
|
|
161
|
+
-- Emitted from retentionSchedulesDdl() so the runner and the standalone
|
|
162
|
+
-- createRetentionSchedulesTable() artifact can never drift.
|
|
163
|
+
${retentionSchedulesDdl()}
|
|
154
164
|
CREATE TABLE IF NOT EXISTS data_residency_holds (
|
|
155
165
|
id UUID PRIMARY KEY,
|
|
156
166
|
tenant_id UUID NOT NULL,
|