@substrat-run/kernel 0.209.0 → 0.211.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/cost-rollup.d.ts +14 -1
- package/dist/cost-rollup.d.ts.map +1 -1
- package/dist/cost-rollup.js +37 -5
- package/dist/cost-rollup.js.map +1 -1
- package/dist/delegation-ceiling.d.ts +11 -0
- package/dist/delegation-ceiling.d.ts.map +1 -1
- package/dist/delegation-ceiling.js +13 -0
- package/dist/delegation-ceiling.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/invocation-line.d.ts +20 -0
- package/dist/invocation-line.d.ts.map +1 -1
- package/dist/invocation-line.js +15 -0
- package/dist/invocation-line.js.map +1 -1
- package/dist/module-erasure.d.ts +2 -0
- package/dist/module-erasure.d.ts.map +1 -1
- package/dist/module-erasure.js +4 -0
- package/dist/module-erasure.js.map +1 -1
- package/dist/platform-request-cap.d.ts +18 -0
- package/dist/platform-request-cap.d.ts.map +1 -1
- package/dist/platform-request-cap.js +18 -0
- package/dist/platform-request-cap.js.map +1 -1
- package/dist/platform-sweep.d.ts +38 -2
- package/dist/platform-sweep.d.ts.map +1 -1
- package/dist/platform-sweep.js +69 -0
- package/dist/platform-sweep.js.map +1 -1
- package/dist/scope-host.d.ts +44 -1
- package/dist/scope-host.d.ts.map +1 -1
- package/dist/scope-host.js.map +1 -1
- package/dist/stale-scopes.d.ts +135 -0
- package/dist/stale-scopes.d.ts.map +1 -0
- package/dist/stale-scopes.js +308 -0
- package/dist/stale-scopes.js.map +1 -0
- package/dist/subject-access.d.ts +6 -3
- package/dist/subject-access.d.ts.map +1 -1
- package/dist/subject-access.js +92 -18
- package/dist/subject-access.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { staleScope, staleScopeTake, } from '@substrat-run/contracts';
|
|
2
|
+
import { assertRowLimit } from './retention.js';
|
|
3
|
+
import { pushDayWindow, utcDayOf } from './billing-retention.js';
|
|
4
|
+
/**
|
|
5
|
+
* The daily stale-scopes report (#3313), as statements both adapters run against their directory:
|
|
6
|
+
* the SQLite host over better-sqlite3, the hosted one inside ControlPlaneDO. Written once so the
|
|
7
|
+
* two cannot report different things about the same fleet.
|
|
8
|
+
*
|
|
9
|
+
* It finds the scopes nothing will ever clean up: an active scope nobody uses, a fork with no
|
|
10
|
+
* expiry, a scope stuck half-made, one whose tenant or vertical is gone. It REPORTS and never moves
|
|
11
|
+
* a scope: a person archives through the doors that exist, and the retention reap deletes. Every
|
|
12
|
+
* finding but `idle` is decided from the directory's own rows, so no scope is woken (§5.4).
|
|
13
|
+
*
|
|
14
|
+
* `idle` reads the daily request rollup (`request-rollup.ts`): a scope's "last used" is the newest
|
|
15
|
+
* UTC day the rollup counted a routed request for it. That is the router's count of the requests it
|
|
16
|
+
* dispatched, so a scope reached only by peer calls or schedules has none, and a scope used once a
|
|
17
|
+
* year looks like a dead one. Nothing is stamped on the request path: a last-seen write there would
|
|
18
|
+
* be a write to the singleton directory on every request.
|
|
19
|
+
*
|
|
20
|
+
* `_substrat_stale_scopes` holds one row per (scope, finding) the latest report made, with the first
|
|
21
|
+
* and latest report that made it, so the list says how long each has been true rather than raising
|
|
22
|
+
* a fresh alert every day. A finding the latest report no longer makes is deleted.
|
|
23
|
+
* `_substrat_stale_scope_takes` holds one row per day a pass tried, with `meterDayTake`'s rules: a
|
|
24
|
+
* day is reported once, and a failed attempt carries the run of identical failures it belongs to.
|
|
25
|
+
*/
|
|
26
|
+
export const STALE_SCOPES_DDL = `
|
|
27
|
+
CREATE TABLE IF NOT EXISTS _substrat_stale_scopes (
|
|
28
|
+
scope_id TEXT NOT NULL,
|
|
29
|
+
finding TEXT NOT NULL,
|
|
30
|
+
tenant_id TEXT NOT NULL,
|
|
31
|
+
vertical TEXT,
|
|
32
|
+
kind TEXT,
|
|
33
|
+
status TEXT NOT NULL,
|
|
34
|
+
forked_from TEXT,
|
|
35
|
+
created_at TEXT NOT NULL,
|
|
36
|
+
last_request_day TEXT,
|
|
37
|
+
detail TEXT NOT NULL,
|
|
38
|
+
first_seen TEXT NOT NULL,
|
|
39
|
+
last_seen TEXT NOT NULL,
|
|
40
|
+
PRIMARY KEY (scope_id, finding)
|
|
41
|
+
);
|
|
42
|
+
CREATE INDEX IF NOT EXISTS _substrat_stale_scopes_tenant ON _substrat_stale_scopes (tenant_id, finding);
|
|
43
|
+
CREATE TABLE IF NOT EXISTS _substrat_stale_scope_takes (
|
|
44
|
+
day TEXT PRIMARY KEY,
|
|
45
|
+
attempted_at TEXT NOT NULL,
|
|
46
|
+
taken_at TEXT,
|
|
47
|
+
finding_count INTEGER,
|
|
48
|
+
idle_judged INTEGER,
|
|
49
|
+
error TEXT,
|
|
50
|
+
failing_since TEXT,
|
|
51
|
+
failing_count INTEGER
|
|
52
|
+
);
|
|
53
|
+
`;
|
|
54
|
+
/** How many days without a routed request make an active primary scope `idle`, by default. */
|
|
55
|
+
export const STALE_SCOPE_IDLE_DAYS = 30;
|
|
56
|
+
/**
|
|
57
|
+
* The shortest and longest idle windows. At least 3, because the two newest days may not be rolled
|
|
58
|
+
* up yet and a window must hold a day that is; at most 85, the request rollup's lookback, because a
|
|
59
|
+
* window it cannot cover is never judged.
|
|
60
|
+
*/
|
|
61
|
+
export const STALE_SCOPE_IDLE_DAYS_MIN = 3;
|
|
62
|
+
export const STALE_SCOPE_IDLE_DAYS_MAX = 85;
|
|
63
|
+
/** How long a scope may sit in `provisioning` before it is `stuck-provisioning`, by default. */
|
|
64
|
+
export const STALE_SCOPE_STUCK_MS = 86_400_000;
|
|
65
|
+
/**
|
|
66
|
+
* How long past its `expiresAt` a fork may stay before it is `expired-not-reaped`, by default. The
|
|
67
|
+
* GC runs every pass, so a day is many failed attempts, never one that is merely due.
|
|
68
|
+
*/
|
|
69
|
+
export const STALE_SCOPE_EXPIRED_GRACE_MS = 86_400_000;
|
|
70
|
+
/** How long one report may take before the pass counts the attempt failed, by default. */
|
|
71
|
+
export const STALE_SCOPES_TIMEOUT_MS = 30_000;
|
|
72
|
+
/** The most rows one `listStaleScopes` call returns, and its default. */
|
|
73
|
+
export const STALE_SCOPES_LIMIT_MAX = 10_000;
|
|
74
|
+
export const STALE_SCOPES_LIMIT_DEFAULT = 1_000;
|
|
75
|
+
const DAY_MS = 86_400_000;
|
|
76
|
+
/** The statuses a scope still holds data or a slot in: every one but archived and reaped. */
|
|
77
|
+
const LIVE = `('provisioning', 'active', 'suspended', 'archiving')`;
|
|
78
|
+
/** A fork or a clean-room preview: `isPrimaryScope`'s negation, over a directory row. */
|
|
79
|
+
const COPY = `(s.forked_from IS NOT NULL OR s.kind = 'preview')`;
|
|
80
|
+
const emptyCounts = () => ({
|
|
81
|
+
'tenant-not-active': 0,
|
|
82
|
+
'vertical-gone': 0,
|
|
83
|
+
unreachable: 0,
|
|
84
|
+
'stuck-provisioning': 0,
|
|
85
|
+
'no-expiry': 0,
|
|
86
|
+
'expired-not-reaped': 0,
|
|
87
|
+
'archived-undated': 0,
|
|
88
|
+
idle: 0,
|
|
89
|
+
});
|
|
90
|
+
const SCOPE_COLUMNS = 's.scope_id, s.tenant_id, s.vertical, s.kind, s.status, s.forked_from, s.created_at, s.expires_at';
|
|
91
|
+
function positiveMs(name, value) {
|
|
92
|
+
if (!(Number.isFinite(value) && value >= 0))
|
|
93
|
+
throw new Error(`${name} must be a non-negative number of ms, got ${String(value)}`);
|
|
94
|
+
return value;
|
|
95
|
+
}
|
|
96
|
+
/** Whether `idleAfterDays` is a whole number of days the report can judge. */
|
|
97
|
+
export function assertIdleDays(name, days) {
|
|
98
|
+
if (!(Number.isInteger(days) && days >= STALE_SCOPE_IDLE_DAYS_MIN && days <= STALE_SCOPE_IDLE_DAYS_MAX)) {
|
|
99
|
+
throw new Error(`${name} must be a whole number of days from ${STALE_SCOPE_IDLE_DAYS_MIN} to ${STALE_SCOPE_IDLE_DAYS_MAX}, got ${String(days)}`);
|
|
100
|
+
}
|
|
101
|
+
return days;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Every finding the directory supports at `at`. Pure reads, in the caller's transaction.
|
|
105
|
+
* `idleJudged` is false when the request rollup has not read every day of the idle window, which
|
|
106
|
+
* is a fleet without the rollup (a self-hosted directory) or one that started it recently.
|
|
107
|
+
*/
|
|
108
|
+
export function staleScopeFindingsAt(sql, at, thresholds = {}) {
|
|
109
|
+
const atMs = Date.parse(at);
|
|
110
|
+
const idleDays = assertIdleDays('idleAfterDays', thresholds.idleAfterDays ?? STALE_SCOPE_IDLE_DAYS);
|
|
111
|
+
const stuckBefore = new Date(atMs - positiveMs('stuckAfterMs', thresholds.stuckAfterMs ?? STALE_SCOPE_STUCK_MS)).toISOString();
|
|
112
|
+
const expiredBefore = new Date(atMs - positiveMs('expiredGraceMs', thresholds.expiredGraceMs ?? STALE_SCOPE_EXPIRED_GRACE_MS)).toISOString();
|
|
113
|
+
const findings = [];
|
|
114
|
+
const add = (rows, finding, detail) => {
|
|
115
|
+
for (const row of rows)
|
|
116
|
+
findings.push({ row, finding, detail: detail(row) });
|
|
117
|
+
};
|
|
118
|
+
add(sql(`SELECT ${SCOPE_COLUMNS}, t.status AS tenant_status FROM scopes s LEFT JOIN tenants t ON t.tenant_id = s.tenant_id
|
|
119
|
+
WHERE s.status IN ${LIVE} AND (t.status IS NULL OR t.status <> 'active')`, []), 'tenant-not-active', (r) => (r.tenant_status ? `its tenant is ${r.tenant_status}` : 'its tenant is gone from the directory'));
|
|
120
|
+
add(sql(`SELECT ${SCOPE_COLUMNS} FROM scopes s
|
|
121
|
+
WHERE s.status IN ${LIVE} AND s.vertical IS NOT NULL
|
|
122
|
+
AND NOT EXISTS (SELECT 1 FROM verticals v WHERE v.slug = s.vertical)`, []), 'vertical-gone', (r) => `its vertical ${r.vertical} is gone from the registry`);
|
|
123
|
+
add(sql(`SELECT ${SCOPE_COLUMNS} FROM scopes s
|
|
124
|
+
WHERE s.status = 'active' AND NOT ${COPY}
|
|
125
|
+
AND NOT EXISTS (SELECT 1 FROM hostnames h WHERE h.scope_id = s.scope_id)
|
|
126
|
+
AND NOT EXISTS (SELECT 1 FROM peer_bindings p WHERE p.target_scope_id = s.scope_id AND p.invalidated = 0)`, []), 'unreachable', () => 'no hostname and no peer binding reaches it');
|
|
127
|
+
add(sql(`SELECT ${SCOPE_COLUMNS} FROM scopes s WHERE s.status = 'provisioning' AND s.created_at <= ?`, [stuckBefore]), 'stuck-provisioning', (r) => `still provisioning since ${r.created_at}`);
|
|
128
|
+
add(sql(`SELECT ${SCOPE_COLUMNS} FROM scopes s WHERE ${COPY} AND s.expires_at IS NULL AND s.status IN ${LIVE}`, []), 'no-expiry', (r) => r.forked_from
|
|
129
|
+
? `a copy of ${r.forked_from} with no expiry: the snapshot GC never reaps it`
|
|
130
|
+
: 'a preview with no expiry: the snapshot GC never reaps it');
|
|
131
|
+
add(sql(`SELECT ${SCOPE_COLUMNS} FROM scopes s
|
|
132
|
+
WHERE ${COPY} AND s.expires_at IS NOT NULL AND s.expires_at <= ? AND s.status <> 'reaped'`, [expiredBefore]), 'expired-not-reaped', (r) => `expired at ${r.expires_at ?? ''} and the snapshot GC has not reaped it`);
|
|
133
|
+
add(sql(`SELECT ${SCOPE_COLUMNS} FROM scopes s WHERE s.status = 'archived' AND s.archived_at IS NULL`, []), 'archived-undated', () => 'archived with no archivedAt: the retention reap skips it');
|
|
134
|
+
const lastRequestDay = new Map(sql(`SELECT scope_id, MAX(day) AS day FROM _substrat_request_days WHERE requests > 0 GROUP BY scope_id`, []).map((r) => [r.scope_id, r.day]));
|
|
135
|
+
// Idle is judged only over a window the rollup has read: its first day, and every day after it
|
|
136
|
+
// that has ended and settled. A gap (a day whose read failed and waits its retry) holds the
|
|
137
|
+
// judgement back rather than reading as a day without traffic.
|
|
138
|
+
const windowStart = utcDayOf(atMs - idleDays * DAY_MS);
|
|
139
|
+
const lastDay = utcDayOf(atMs - 2 * DAY_MS);
|
|
140
|
+
const read = sql(`SELECT COUNT(*) AS n FROM _substrat_request_day_reads WHERE day >= ? AND day <= ? AND read_at IS NOT NULL`, [windowStart, lastDay]);
|
|
141
|
+
const windowDays = Math.round((Date.parse(`${lastDay}T00:00:00Z`) - Date.parse(`${windowStart}T00:00:00Z`)) / DAY_MS) + 1;
|
|
142
|
+
const idleJudged = (read[0]?.n ?? 0) >= windowDays;
|
|
143
|
+
if (idleJudged) {
|
|
144
|
+
const idleSince = new Date(atMs - idleDays * DAY_MS).toISOString();
|
|
145
|
+
const candidates = sql(`SELECT ${SCOPE_COLUMNS} FROM scopes s WHERE s.status = 'active' AND NOT ${COPY} AND s.created_at <= ?`, [idleSince]);
|
|
146
|
+
for (const row of candidates) {
|
|
147
|
+
const last = lastRequestDay.get(row.scope_id);
|
|
148
|
+
if (last !== undefined && last >= windowStart)
|
|
149
|
+
continue;
|
|
150
|
+
findings.push({
|
|
151
|
+
row,
|
|
152
|
+
finding: 'idle',
|
|
153
|
+
detail: last
|
|
154
|
+
? `no routed request in ${idleDays} days; the last was on ${last}`
|
|
155
|
+
: `no routed request in ${idleDays} days, and none on record`,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return { findings, lastRequestDay, idleJudged };
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Record one attempt at the report of the UTC day of `input.at`, in the caller's transaction.
|
|
163
|
+
*
|
|
164
|
+
* Without an error, it takes the report unless the day already has one: it reads the findings
|
|
165
|
+
* (`staleScopeFindingsAt`), upserts each (a new one gets `firstSeen`, every one gets `lastSeen` and
|
|
166
|
+
* its current detail), deletes every listed finding it did not make, and marks the day taken. When
|
|
167
|
+
* idle was not judged, the listed `idle` findings are left as they were. Every row is parsed before
|
|
168
|
+
* the first write, so a row that does not parse refuses the whole day.
|
|
169
|
+
*
|
|
170
|
+
* With an error, it records only the attempt and its run, and never over a day already taken.
|
|
171
|
+
*/
|
|
172
|
+
export function recordStaleScopeRows(sql, input) {
|
|
173
|
+
const at = new Date(input.at).toISOString();
|
|
174
|
+
const day = at.slice(0, 10);
|
|
175
|
+
const none = { day, taken: false, findings: emptyCounts(), opened: 0, resolved: 0, idleJudged: false };
|
|
176
|
+
if ('error' in input) {
|
|
177
|
+
const since = new Date(input.failingSince ?? at).toISOString();
|
|
178
|
+
const count = input.failingCount ?? 1;
|
|
179
|
+
if (!(Number.isInteger(count) && count >= 1)) {
|
|
180
|
+
throw new Error(`failingCount must be a whole number, at least one, got ${String(count)}`);
|
|
181
|
+
}
|
|
182
|
+
sql(`INSERT INTO _substrat_stale_scope_takes
|
|
183
|
+
(day, attempted_at, taken_at, finding_count, idle_judged, error, failing_since, failing_count)
|
|
184
|
+
VALUES (?, ?, NULL, NULL, NULL, ?, ?, ?)
|
|
185
|
+
ON CONFLICT (day) DO UPDATE SET
|
|
186
|
+
attempted_at = excluded.attempted_at, error = excluded.error,
|
|
187
|
+
failing_since = excluded.failing_since, failing_count = excluded.failing_count
|
|
188
|
+
WHERE _substrat_stale_scope_takes.taken_at IS NULL`, [day, at, input.error || 'the report failed', since, count]);
|
|
189
|
+
return none;
|
|
190
|
+
}
|
|
191
|
+
const prior = sql('SELECT taken_at FROM _substrat_stale_scope_takes WHERE day = ?', [day]);
|
|
192
|
+
if (prior[0]?.taken_at)
|
|
193
|
+
return none;
|
|
194
|
+
const { findings, lastRequestDay, idleJudged } = staleScopeFindingsAt(sql, at, input);
|
|
195
|
+
const tenantSlug = new Map(sql('SELECT tenant_id, slug FROM tenants', []).map((t) => [t.tenant_id, t.slug]));
|
|
196
|
+
const existing = new Map(sql('SELECT scope_id, finding, first_seen FROM _substrat_stale_scopes', []).map((r) => [`${r.scope_id} ${r.finding}`, r.first_seen]));
|
|
197
|
+
// Parsed before the first write: a row that does not read as a finding refuses the day.
|
|
198
|
+
const rows = findings.map((f) => staleScope.parse({
|
|
199
|
+
tenantId: f.row.tenant_id,
|
|
200
|
+
tenantSlug: tenantSlug.get(f.row.tenant_id) ?? null,
|
|
201
|
+
scopeId: f.row.scope_id,
|
|
202
|
+
finding: f.finding,
|
|
203
|
+
vertical: f.row.vertical,
|
|
204
|
+
kind: f.row.kind,
|
|
205
|
+
status: f.row.status,
|
|
206
|
+
forkedFrom: f.row.forked_from,
|
|
207
|
+
createdAt: f.row.created_at,
|
|
208
|
+
lastRequestDay: lastRequestDay.get(f.row.scope_id) ?? null,
|
|
209
|
+
detail: f.detail,
|
|
210
|
+
firstSeen: existing.get(`${f.row.scope_id} ${f.finding}`) ?? at,
|
|
211
|
+
lastSeen: at,
|
|
212
|
+
}));
|
|
213
|
+
const counts = emptyCounts();
|
|
214
|
+
let opened = 0;
|
|
215
|
+
for (const r of rows) {
|
|
216
|
+
counts[r.finding] += 1;
|
|
217
|
+
if (!existing.has(`${r.scopeId} ${r.finding}`))
|
|
218
|
+
opened += 1;
|
|
219
|
+
sql(`INSERT INTO _substrat_stale_scopes
|
|
220
|
+
(scope_id, finding, tenant_id, vertical, kind, status, forked_from, created_at, last_request_day, detail, first_seen, last_seen)
|
|
221
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
222
|
+
ON CONFLICT (scope_id, finding) DO UPDATE SET
|
|
223
|
+
tenant_id = excluded.tenant_id, vertical = excluded.vertical, kind = excluded.kind, status = excluded.status,
|
|
224
|
+
forked_from = excluded.forked_from, created_at = excluded.created_at,
|
|
225
|
+
last_request_day = excluded.last_request_day, detail = excluded.detail, last_seen = excluded.last_seen`, [
|
|
226
|
+
r.scopeId,
|
|
227
|
+
r.finding,
|
|
228
|
+
r.tenantId,
|
|
229
|
+
r.vertical,
|
|
230
|
+
r.kind,
|
|
231
|
+
r.status,
|
|
232
|
+
r.forkedFrom,
|
|
233
|
+
r.createdAt,
|
|
234
|
+
r.lastRequestDay,
|
|
235
|
+
r.detail,
|
|
236
|
+
r.firstSeen,
|
|
237
|
+
r.lastSeen,
|
|
238
|
+
]);
|
|
239
|
+
}
|
|
240
|
+
const keep = idleJudged ? '' : ` AND finding <> 'idle'`;
|
|
241
|
+
const resolved = sql(`SELECT COUNT(*) AS n FROM _substrat_stale_scopes WHERE last_seen <> ?${keep}`, [at])[0]?.n ?? 0;
|
|
242
|
+
sql(`DELETE FROM _substrat_stale_scopes WHERE last_seen <> ?${keep}`, [at]);
|
|
243
|
+
if (!idleJudged)
|
|
244
|
+
counts.idle = sql(`SELECT COUNT(*) AS n FROM _substrat_stale_scopes WHERE finding = 'idle'`, [])[0]?.n ?? 0;
|
|
245
|
+
const total = Object.values(counts).reduce((a, b) => a + b, 0);
|
|
246
|
+
sql(`INSERT INTO _substrat_stale_scope_takes
|
|
247
|
+
(day, attempted_at, taken_at, finding_count, idle_judged, error, failing_since, failing_count)
|
|
248
|
+
VALUES (?, ?, ?, ?, ?, NULL, NULL, NULL)
|
|
249
|
+
ON CONFLICT (day) DO UPDATE SET
|
|
250
|
+
attempted_at = excluded.attempted_at, taken_at = excluded.taken_at, finding_count = excluded.finding_count,
|
|
251
|
+
idle_judged = excluded.idle_judged, error = NULL, failing_since = NULL, failing_count = NULL`, [day, at, at, total, idleJudged ? 1 : 0]);
|
|
252
|
+
return { day, taken: true, findings: counts, opened, resolved, idleJudged };
|
|
253
|
+
}
|
|
254
|
+
/** The current findings — see `StaleScopeFilter`. Every row is parsed on the way out. */
|
|
255
|
+
export function listStaleScopeRows(sql, filter = {}) {
|
|
256
|
+
const where = [];
|
|
257
|
+
const params = [];
|
|
258
|
+
if (filter.tenantId !== undefined) {
|
|
259
|
+
where.push('f.tenant_id = ?');
|
|
260
|
+
params.push(filter.tenantId);
|
|
261
|
+
}
|
|
262
|
+
if (filter.finding !== undefined) {
|
|
263
|
+
where.push('f.finding = ?');
|
|
264
|
+
params.push(filter.finding);
|
|
265
|
+
}
|
|
266
|
+
params.push(Math.min(assertRowLimit('limit', filter.limit ?? STALE_SCOPES_LIMIT_DEFAULT), STALE_SCOPES_LIMIT_MAX));
|
|
267
|
+
const rows = sql(`SELECT f.scope_id, f.finding, f.tenant_id, t.slug AS tenant_slug, f.vertical, f.kind, f.status, f.forked_from,
|
|
268
|
+
f.created_at, f.last_request_day, f.detail, f.first_seen, f.last_seen
|
|
269
|
+
FROM _substrat_stale_scopes f LEFT JOIN tenants t ON t.tenant_id = f.tenant_id
|
|
270
|
+
${where.length ? `WHERE ${where.join(' AND ')}` : ''}
|
|
271
|
+
ORDER BY f.tenant_id, f.finding, f.first_seen, f.scope_id LIMIT ?`, params);
|
|
272
|
+
return rows.map((r) => staleScope.parse({
|
|
273
|
+
tenantId: r.tenant_id,
|
|
274
|
+
tenantSlug: r.tenant_slug,
|
|
275
|
+
scopeId: r.scope_id,
|
|
276
|
+
finding: r.finding,
|
|
277
|
+
vertical: r.vertical,
|
|
278
|
+
kind: r.kind,
|
|
279
|
+
status: r.status,
|
|
280
|
+
forkedFrom: r.forked_from,
|
|
281
|
+
createdAt: r.created_at,
|
|
282
|
+
lastRequestDay: r.last_request_day,
|
|
283
|
+
detail: r.detail,
|
|
284
|
+
firstSeen: r.first_seen,
|
|
285
|
+
lastSeen: r.last_seen,
|
|
286
|
+
}));
|
|
287
|
+
}
|
|
288
|
+
/** The report's record of each day it tried, in day order — see `StaleScopeTakeFilter`. */
|
|
289
|
+
export function listStaleScopeTakeRows(sql, filter = {}) {
|
|
290
|
+
const where = [];
|
|
291
|
+
const params = [];
|
|
292
|
+
pushDayWindow(filter, where, params);
|
|
293
|
+
const rows = sql(`SELECT day, attempted_at, taken_at, finding_count, idle_judged, error, failing_since, failing_count
|
|
294
|
+
FROM _substrat_stale_scope_takes
|
|
295
|
+
${where.length ? `WHERE ${where.join(' AND ')}` : ''}
|
|
296
|
+
ORDER BY day`, params);
|
|
297
|
+
return rows.map((r) => staleScopeTake.parse({
|
|
298
|
+
day: r.day,
|
|
299
|
+
attemptedAt: r.attempted_at,
|
|
300
|
+
takenAt: r.taken_at,
|
|
301
|
+
findings: r.finding_count,
|
|
302
|
+
idleJudged: r.idle_judged === null ? null : r.idle_judged === 1,
|
|
303
|
+
error: r.error,
|
|
304
|
+
failingSince: r.failing_since,
|
|
305
|
+
failingCount: r.failing_count,
|
|
306
|
+
}));
|
|
307
|
+
}
|
|
308
|
+
//# sourceMappingURL=stale-scopes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stale-scopes.js","sourceRoot":"","sources":["../src/stale-scopes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,cAAc,GAOf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2B/B,CAAC;AAEF,8FAA8F;AAC9F,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACxC;;;;GAIG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAC3C,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAC5C,gGAAgG;AAChG,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;AAC/C;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,UAAU,CAAC;AACvD,0FAA0F;AAC1F,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAE9C,yEAAyE;AACzE,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAC7C,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAEhD,MAAM,MAAM,GAAG,UAAU,CAAC;AAC1B,6FAA6F;AAC7F,MAAM,IAAI,GAAG,sDAAsD,CAAC;AACpE,yFAAyF;AACzF,MAAM,IAAI,GAAG,mDAAmD,CAAC;AA6CjE,MAAM,WAAW,GA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CAAC;AACJ,CAAC"}
|
package/dist/subject-access.d.ts
CHANGED
|
@@ -17,9 +17,12 @@
|
|
|
17
17
|
*
|
|
18
18
|
* Paging: each source is walked in turn, events first and then each declared entity in
|
|
19
19
|
* registration order, until the page's budget of events plus rows is spent. The cursor names the
|
|
20
|
-
* source and where in it to resume.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* source and where in it to resume. The pages of one request are separate reads (a separate RPC on
|
|
21
|
+
* a Durable Object), so the scope can change between them, and both sources resume by key: events
|
|
22
|
+
* after the last outbox id, an entity's rows after the last primary key in key order (#3303). A row
|
|
23
|
+
* written or deleted between two pages then repeats or skips no other row. A manifest derived
|
|
24
|
+
* before the erasure declaration carried the key has none to seek on; its rows are paged by offset
|
|
25
|
+
* in scan order, and each listing says which (`paging`), so the package can state it.
|
|
23
26
|
*/
|
|
24
27
|
import { type SubjectReadPage, type SubjectReadRequest } from '@substrat-run/contracts';
|
|
25
28
|
import { type ModuleErasurePlan } from './module-erasure.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subject-access.d.ts","sourceRoot":"","sources":["../src/subject-access.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"subject-access.d.ts","sourceRoot":"","sources":["../src/subject-access.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,kBAAkB,EAGxB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAmD,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC9G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AA0FjD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE;IACrC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC7C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,kBAAkB,CAAC;CACpC,GAAG,eAAe,CA2FlB"}
|
package/dist/subject-access.js
CHANGED
|
@@ -17,27 +17,68 @@
|
|
|
17
17
|
*
|
|
18
18
|
* Paging: each source is walked in turn, events first and then each declared entity in
|
|
19
19
|
* registration order, until the page's budget of events plus rows is spent. The cursor names the
|
|
20
|
-
* source and where in it to resume.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* source and where in it to resume. The pages of one request are separate reads (a separate RPC on
|
|
21
|
+
* a Durable Object), so the scope can change between them, and both sources resume by key: events
|
|
22
|
+
* after the last outbox id, an entity's rows after the last primary key in key order (#3303). A row
|
|
23
|
+
* written or deleted between two pages then repeats or skips no other row. A manifest derived
|
|
24
|
+
* before the erasure declaration carried the key has none to seek on; its rows are paged by offset
|
|
25
|
+
* in scan order, and each listing says which (`paging`), so the package can state it.
|
|
23
26
|
*/
|
|
24
27
|
import { SUBJECT_READ_PAGE_DEFAULT, SUBJECT_READ_PAGE_MAX, substratError, } from '@substrat-run/contracts';
|
|
25
|
-
import {
|
|
28
|
+
import { base64UrlToBytes, bytesToBase64Url } from '@substrat-run/contracts/scope-store-envelope';
|
|
29
|
+
import { erasureColumnOf, erasureTableOf, subjectMatchOf } from './module-erasure.js';
|
|
26
30
|
import { readSubjectEvents } from './timeline.js';
|
|
27
31
|
const EVENTS_CURSOR = /^e:(.+)$/;
|
|
28
|
-
const
|
|
32
|
+
const OFFSET_CURSOR = /^r:(\d{1,6}):(\d{1,9})$/;
|
|
33
|
+
const KEY_CURSOR = /^r:(\d{1,6}):k:([A-Za-z0-9_-]{1,4096})$/;
|
|
34
|
+
const notACursor = () => substratError('validation_failed', 'readSubject: not a cursor this read issued', { reason: 'subject_cursor' });
|
|
35
|
+
function parseKey(encoded) {
|
|
36
|
+
const bytes = base64UrlToBytes(encoded);
|
|
37
|
+
let key;
|
|
38
|
+
try {
|
|
39
|
+
key = bytes && JSON.parse(new TextDecoder().decode(bytes));
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
throw notACursor();
|
|
43
|
+
}
|
|
44
|
+
if (!Array.isArray(key) || key.length === 0 || !key.every((v) => typeof v === 'string' || Number.isFinite(v))) {
|
|
45
|
+
throw notACursor();
|
|
46
|
+
}
|
|
47
|
+
return key;
|
|
48
|
+
}
|
|
29
49
|
function parseCursor(cursor) {
|
|
30
50
|
if (cursor === undefined)
|
|
31
51
|
return { source: 'events' };
|
|
32
52
|
const events = EVENTS_CURSOR.exec(cursor);
|
|
33
53
|
if (events)
|
|
34
54
|
return { source: 'events', after: events[1] };
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
55
|
+
const offset = OFFSET_CURSOR.exec(cursor);
|
|
56
|
+
if (offset) {
|
|
57
|
+
// Offset 0 is the entity's start, whichever way the entity is then paged.
|
|
58
|
+
const n = Number(offset[2]);
|
|
59
|
+
return { source: 'records', entity: Number(offset[1]), ...(n > 0 ? { at: { offset: n } } : {}) };
|
|
60
|
+
}
|
|
61
|
+
const keyed = KEY_CURSOR.exec(cursor);
|
|
62
|
+
if (keyed)
|
|
63
|
+
return { source: 'records', entity: Number(keyed[1]), at: { key: parseKey(keyed[2]) } };
|
|
64
|
+
throw notACursor();
|
|
65
|
+
}
|
|
66
|
+
const recordsCursor = (entity, at) => 'offset' in at
|
|
67
|
+
? `r:${entity}:${at.offset}`
|
|
68
|
+
: `r:${entity}:k:${bytesToBase64Url(new TextEncoder().encode(JSON.stringify(at.key)))}`;
|
|
69
|
+
/**
|
|
70
|
+
* The key a cursor carries: the last row's primary key values. Only text and finite numbers round
|
|
71
|
+
* trip through the cursor's JSON exactly; any other key value (a blob, a NULL) is refused here rather
|
|
72
|
+
* than resumed from a different place.
|
|
73
|
+
*/
|
|
74
|
+
function keyOf(entityType, row, primaryKey) {
|
|
75
|
+
return primaryKey.map((column) => {
|
|
76
|
+
const v = row[column];
|
|
77
|
+
if (typeof v === 'string' || (typeof v === 'number' && Number.isFinite(v)))
|
|
78
|
+
return v;
|
|
79
|
+
throw substratError('internal', `readSubject: ${entityType}.${column} holds a primary key value a cursor cannot carry`);
|
|
80
|
+
});
|
|
39
81
|
}
|
|
40
|
-
const recordsCursor = (entity, offset) => `r:${entity}:${offset}`;
|
|
41
82
|
/** The declared entities access reads, in the order a cursor numbers them. */
|
|
42
83
|
function readableEntities(plans) {
|
|
43
84
|
return plans.flatMap((plan) => plan.declaration.entities
|
|
@@ -81,25 +122,55 @@ export function readSubjectPage(input) {
|
|
|
81
122
|
}
|
|
82
123
|
else {
|
|
83
124
|
budget -= read.length;
|
|
84
|
-
cursor = { source: 'records', entity: 0
|
|
125
|
+
cursor = { source: 'records', entity: 0 };
|
|
85
126
|
}
|
|
86
127
|
}
|
|
87
128
|
if (cursor.source === 'records' && nextCursor === null) {
|
|
88
|
-
let
|
|
129
|
+
let index = cursor.entity;
|
|
130
|
+
let at = cursor.at;
|
|
89
131
|
while (index < entities.length) {
|
|
90
132
|
if (budget === 0) {
|
|
91
|
-
nextCursor = recordsCursor(index, offset);
|
|
133
|
+
nextCursor = recordsCursor(index, at ?? { offset: 0 });
|
|
92
134
|
break;
|
|
93
135
|
}
|
|
94
136
|
const { moduleId, entity } = entities[index];
|
|
137
|
+
const primaryKey = entity.primaryKey;
|
|
138
|
+
// An offset cursor stays an offset walk to the entity's end, even where the key is now
|
|
139
|
+
// declared: it counts rows in scan order, which a key seek cannot resume.
|
|
140
|
+
const byKey = primaryKey !== undefined && !(at && 'offset' in at);
|
|
95
141
|
const { where, params } = subjectMatchOf(entity, subjectId);
|
|
96
|
-
const rows = sql.query(
|
|
97
142
|
// `main.`: a TEMP object named like the declared table would otherwise answer in its place.
|
|
98
|
-
`SELECT * FROM main.${erasureTableOf(entity)} WHERE ${where}
|
|
143
|
+
const from = `SELECT * FROM main.${erasureTableOf(entity)} WHERE ${where}`;
|
|
144
|
+
let rows;
|
|
145
|
+
if (byKey) {
|
|
146
|
+
const columns = primaryKey.map(erasureColumnOf);
|
|
147
|
+
const after = at && 'key' in at ? at.key : undefined;
|
|
148
|
+
if (after && after.length !== columns.length)
|
|
149
|
+
throw notACursor();
|
|
150
|
+
// A row value compares column by column in key order, each under its column's collation,
|
|
151
|
+
// which is the order ORDER BY walks: SQLite 3.15+, which both adapters run.
|
|
152
|
+
const seek = !after
|
|
153
|
+
? ''
|
|
154
|
+
: columns.length === 1
|
|
155
|
+
? ` AND ${columns[0]} > ?`
|
|
156
|
+
: ` AND (${columns.join(', ')}) > (${columns.map(() => '?').join(', ')})`;
|
|
157
|
+
rows = sql.query(`${from}${seek} ORDER BY ${columns.join(', ')} LIMIT ?`, [
|
|
158
|
+
...params,
|
|
159
|
+
...(after ?? []),
|
|
160
|
+
budget + 1,
|
|
161
|
+
]);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
// A key cursor for an entity with no key to seek on resumes nowhere it means.
|
|
165
|
+
if (at && 'key' in at)
|
|
166
|
+
throw notACursor();
|
|
167
|
+
const offset = at && 'offset' in at ? at.offset : 0;
|
|
168
|
+
rows = sql.query(`${from} LIMIT ? OFFSET ?`, [...params, budget + 1, offset]);
|
|
169
|
+
}
|
|
99
170
|
const taken = rows.slice(0, budget);
|
|
100
171
|
// An entity is listed on the page that reads its first rows, a zero included, so a reader
|
|
101
172
|
// can tell "looked at and held nothing" from "not looked at". Later pages add only rows.
|
|
102
|
-
if (
|
|
173
|
+
if (at === undefined || taken.length > 0) {
|
|
103
174
|
records.push({
|
|
104
175
|
module: moduleId,
|
|
105
176
|
entityType: entity.entityType,
|
|
@@ -107,15 +178,18 @@ export function readSubjectPage(input) {
|
|
|
107
178
|
subjects: [...(entity.subjects ?? [])],
|
|
108
179
|
erasable: entity.fields.map((f) => f.name),
|
|
109
180
|
rows: taken,
|
|
181
|
+
paging: byKey ? 'key' : 'offset',
|
|
110
182
|
});
|
|
111
183
|
}
|
|
112
184
|
budget -= taken.length;
|
|
113
185
|
if (rows.length > taken.length) {
|
|
114
|
-
nextCursor = recordsCursor(index,
|
|
186
|
+
nextCursor = recordsCursor(index, byKey
|
|
187
|
+
? { key: keyOf(entity.entityType, taken[taken.length - 1], primaryKey) }
|
|
188
|
+
: { offset: (at && 'offset' in at ? at.offset : 0) + taken.length });
|
|
115
189
|
break;
|
|
116
190
|
}
|
|
117
191
|
index += 1;
|
|
118
|
-
|
|
192
|
+
at = undefined;
|
|
119
193
|
}
|
|
120
194
|
}
|
|
121
195
|
return { events, records, ...unreachedOf(plans), nextCursor };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subject-access.js","sourceRoot":"","sources":["../src/subject-access.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"subject-access.js","sourceRoot":"","sources":["../src/subject-access.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,aAAa,GAMd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAClG,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAA0B,MAAM,qBAAqB,CAAC;AAE9G,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAalD,MAAM,aAAa,GAAG,UAAU,CAAC;AACjC,MAAM,aAAa,GAAG,yBAAyB,CAAC;AAChD,MAAM,UAAU,GAAG,yCAAyC,CAAC;AAE7D,MAAM,UAAU,GAAG,GAAG,EAAE,CACtB,aAAa,CAAC,mBAAmB,EAAE,4CAA4C,EAAE,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAC;AAEjH,SAAS,QAAQ,CAAC,OAAe;IAC/B,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACxC,IAAI,GAAY,CAAC;IACjB,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,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ;iBACjC,CAAC,CAAC;YACL,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;YACvB,IAAI,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;gBAC/B,UAAU,GAAG,aAAa,CACxB,KAAK,EACL,KAAK;oBACH,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAE,EAAE,UAAU,CAAC,EAAE;oBACzE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CACtE,CAAC;gBACF,MAAM;YACR,CAAC;YACD,KAAK,IAAI,CAAC,CAAC;YACX,EAAE,GAAG,SAAS,CAAC;QACjB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,WAAW,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;AAChE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@substrat-run/kernel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.211.0",
|
|
4
4
|
"description": "Substrat kernel contracts and services — pure TypeScript, no platform imports (D-14)",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@substrat-run/contracts": "^0.
|
|
37
|
+
"@substrat-run/contracts": "^0.211.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/node": "^22.20.5",
|