@substrat-run/kernel 0.163.0 → 0.164.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/attachment-bytes.d.ts +121 -0
- package/dist/attachment-bytes.d.ts.map +1 -0
- package/dist/attachment-bytes.js +94 -0
- package/dist/attachment-bytes.js.map +1 -0
- package/dist/attachment-sweep.d.ts +2 -1
- package/dist/attachment-sweep.d.ts.map +1 -1
- package/dist/attachment-sweep.js +1 -1
- package/dist/attachment-sweep.js.map +1 -1
- package/dist/attachment-text.d.ts +1 -1
- package/dist/attachment-text.d.ts.map +1 -1
- package/dist/attachment-text.js +1 -1
- package/dist/attachment-text.js.map +1 -1
- package/dist/billing-retention.js +1 -1
- package/dist/billing-retention.js.map +1 -1
- package/dist/connection-context.d.ts +69 -0
- package/dist/connection-context.d.ts.map +1 -0
- package/dist/connection-context.js +19 -0
- package/dist/connection-context.js.map +1 -0
- package/dist/connection-landings.d.ts +8 -0
- package/dist/connection-landings.d.ts.map +1 -1
- package/dist/connection-landings.js +5 -1
- package/dist/connection-landings.js.map +1 -1
- package/dist/connector-transport.d.ts +313 -0
- package/dist/connector-transport.d.ts.map +1 -0
- package/dist/connector-transport.js +66 -0
- package/dist/connector-transport.js.map +1 -0
- package/dist/deadline-fetch.d.ts +1 -1
- package/dist/deadline-fetch.d.ts.map +1 -1
- package/dist/findings.js +1 -1
- package/dist/findings.js.map +1 -1
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/job-run.d.ts +2 -1
- package/dist/job-run.d.ts.map +1 -1
- package/dist/job-run.js +2 -1
- package/dist/job-run.js.map +1 -1
- package/dist/live-read.d.ts +258 -0
- package/dist/live-read.d.ts.map +1 -0
- package/dist/live-read.js +101 -0
- package/dist/live-read.js.map +1 -0
- package/dist/membership-executor.d.ts +2 -1
- package/dist/membership-executor.d.ts.map +1 -1
- package/dist/membership-executor.js.map +1 -1
- package/dist/meter-days.js +1 -1
- package/dist/meter-days.js.map +1 -1
- package/dist/migration-digest.d.ts +1 -1
- package/dist/migration-digest.d.ts.map +1 -1
- package/dist/migration-digest.js +1 -1
- package/dist/migration-digest.js.map +1 -1
- package/dist/platform-sweep.d.ts +22 -4
- package/dist/platform-sweep.d.ts.map +1 -1
- package/dist/platform-sweep.js +69 -26
- package/dist/platform-sweep.js.map +1 -1
- package/dist/promote-review.d.ts +35 -4
- package/dist/promote-review.d.ts.map +1 -1
- package/dist/promote-review.js +31 -15
- package/dist/promote-review.js.map +1 -1
- package/dist/request-rollup.js +1 -1
- package/dist/request-rollup.js.map +1 -1
- package/dist/retention.d.ts +106 -0
- package/dist/retention.d.ts.map +1 -0
- package/dist/retention.js +131 -0
- package/dist/retention.js.map +1 -0
- package/dist/scope-host.d.ts +16 -789
- package/dist/scope-host.d.ts.map +1 -1
- package/dist/scope-host.js +1 -385
- package/dist/scope-host.js.map +1 -1
- package/dist/storage-gauge.js +1 -1
- package/dist/storage-gauge.js.map +1 -1
- package/dist/upload-link.d.ts +1 -1
- package/dist/upload-link.d.ts.map +1 -1
- package/dist/upload-link.js +1 -1
- package/dist/upload-link.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-rollup.js","sourceRoot":"","sources":["../src/request-rollup.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,gBAAgB,GAKjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"request-rollup.js","sourceRoot":"","sources":["../src/request-rollup.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,gBAAgB,GAKjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,QAAQ,E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IAAI,IAAI,EAAE,SAAS;YAAE,SAAS;QAC9B,IAAI,IAAI,IAAI,IAAI,CAAC,WAAW,GAAG,WAAW;YAAE,SAAS;QACrD,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How long a recorded operational failure is kept (#559). Telemetry, not evidence:
|
|
3
|
+
* unlike the never-swept admin log, the ops-failures table self-prunes on write in
|
|
4
|
+
* every adapter, so it can never grow without bound and needs no cron wiring or
|
|
5
|
+
* operator decision. 90 days comfortably outlives any incident follow-up (a
|
|
6
|
+
* Cloudflare ticket round-trip) while keeping directory storage flat.
|
|
7
|
+
*/
|
|
8
|
+
export declare const OPS_FAILURE_RETENTION_DAYS = 90;
|
|
9
|
+
/**
|
|
10
|
+
* How long a sweep-run row is kept (#1232). Much shorter than ops failures: this
|
|
11
|
+
* is high-frequency telemetry (a pass every few minutes times every connection
|
|
12
|
+
* and schedule), and its job is the recent-runs strip plus an incident window —
|
|
13
|
+
* 14 days covers both. Pruned on write in every adapter, like ops failures and
|
|
14
|
+
* for the same reason: the table stays bounded even where no scheduled pass runs.
|
|
15
|
+
*/
|
|
16
|
+
export declare const SWEEP_RUN_RETENTION_DAYS = 14;
|
|
17
|
+
/**
|
|
18
|
+
* The drained batch's dedupe key on the directory's `_substrat_sweep_runs` (#1232), as
|
|
19
|
+
* both adapters build it: `recordSweepRun` is an `INSERT OR IGNORE` against this index,
|
|
20
|
+
* which is what makes a replayed drain write nothing twice.
|
|
21
|
+
*
|
|
22
|
+
* `kind` is in it since #1572, and that is the fix rather than a tidy-up. Every entry of
|
|
23
|
+
* one drained batch shares its `request_id`, and `unit` is built from two namespaces that
|
|
24
|
+
* nothing keeps apart — `<scopeId>:<operation>` for a schedule, `<scopeId>:<eventType>`
|
|
25
|
+
* for a freshness verdict — while `scheduleSpec.operation` is `z.string().min(1)`. A
|
|
26
|
+
* schedule named exactly like an event type its scope expects freshness on collided on
|
|
27
|
+
* `(request_id, unit)`, and the ignore-on-conflict write discarded the second row with no
|
|
28
|
+
* error anywhere. Both rows are signals by their absence (a stopped evaluator, a missed
|
|
29
|
+
* run), so losing one read as the very thing it was meant to rule out. It is #1288's
|
|
30
|
+
* collision, in the record table beside the state table.
|
|
31
|
+
*
|
|
32
|
+
* Shared rather than spelled in each adapter because a directory that predates it
|
|
33
|
+
* re-creates it (`ensureSweepRunsIntentKind`, in both), and `lint:spine-ddl` sees only
|
|
34
|
+
* the created copy. One definition keeps the re-created shape and the created shape the
|
|
35
|
+
* same shape; the gate then holds each adapter's DDL to including it.
|
|
36
|
+
*/
|
|
37
|
+
export declare const SWEEP_RUNS_INTENT_INDEX = "CREATE UNIQUE INDEX IF NOT EXISTS _substrat_sweep_runs_intent ON _substrat_sweep_runs (request_id, kind, unit);";
|
|
38
|
+
/**
|
|
39
|
+
* Whether a directory's `_substrat_sweep_runs_intent` already has `kind` among its
|
|
40
|
+
* columns, read off the index's `sql` in `sqlite_master` — which DO SQLite serves and
|
|
41
|
+
* `PRAGMA` does not, so both adapters detect by one strategy. `false` means the index
|
|
42
|
+
* must be DROPPED and created again: `CREATE … IF NOT EXISTS` matches on the name alone,
|
|
43
|
+
* so on every existing directory the old `(request_id, unit)` index would otherwise
|
|
44
|
+
* stand for good, while a fresh one — and any test that starts from one — gets the new.
|
|
45
|
+
*/
|
|
46
|
+
export declare function sweepRunsIntentHasKind(indexSql: string): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* How long an issue row outlives its last occurrence (#1233). Deliberately longer
|
|
49
|
+
* than the 90-day evidence beneath it: an issue is the compressed memory of a
|
|
50
|
+
* failure class, and "we saw this five months ago" is exactly what a regression
|
|
51
|
+
* needs to be recognizable. Pruned on write like everything else here, and on the
|
|
52
|
+
* scheduled pass (`pruneTelemetry`, #1632), so a quiet directory sheds it on time too.
|
|
53
|
+
*/
|
|
54
|
+
export declare const ISSUE_RETENTION_DAYS = 180;
|
|
55
|
+
/** What one `pruneTelemetry` call deleted, per table. */
|
|
56
|
+
export interface TelemetryPruneReport {
|
|
57
|
+
opsFailures: number;
|
|
58
|
+
issues: number;
|
|
59
|
+
sweepRuns: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A caller-supplied row bound, checked before it reaches a SQL `LIMIT` (#1632). SQLite reads a
|
|
63
|
+
* negative `LIMIT` as no limit at all, so `-1` turns a bounded batch into an unbounded one; a
|
|
64
|
+
* fractional or non-finite value is refused by SQLite itself, as a failure every later call
|
|
65
|
+
* repeats. Neither is a value anyone means, so it is a configuration error, refused here with the
|
|
66
|
+
* option's name, and never silently normalized into something the caller did not ask for.
|
|
67
|
+
* Returns the value, so a call site can bind it in place.
|
|
68
|
+
*/
|
|
69
|
+
export declare function assertRowLimit(name: string, value: number): number;
|
|
70
|
+
/**
|
|
71
|
+
* A caller-supplied row offset, checked before it reaches a SQL `OFFSET` — `assertRowLimit`'s
|
|
72
|
+
* sibling. Zero is a valid offset; a negative, fractional or non-finite one is refused rather
|
|
73
|
+
* than passed to SQLite, which fails the statement on it.
|
|
74
|
+
*/
|
|
75
|
+
export declare function assertRowOffset(name: string, value: number): number;
|
|
76
|
+
/** How many rows of EACH telemetry table one `pruneTelemetry` call deletes, by default. */
|
|
77
|
+
export declare const TELEMETRY_PRUNE_BATCH = 500;
|
|
78
|
+
/**
|
|
79
|
+
* The three telemetry retentions as statements, for `pruneTelemetry` on both adapters (#1632).
|
|
80
|
+
*
|
|
81
|
+
* Each table already prunes on write, and that bound holds only while something is written:
|
|
82
|
+
* a quiet directory keeps a row past its retention for as long as nothing new arrives in
|
|
83
|
+
* that table. An issue is the case that matters. Erasure skips an issue whose exemplar owner
|
|
84
|
+
* is unknown, on the promise that it ages out within `ISSUE_RETENTION_DAYS`, and on a
|
|
85
|
+
* directory with no new failures nothing ever deleted it. The scheduled pass runs these
|
|
86
|
+
* statements, which makes the stated retention a bound in time rather than in traffic.
|
|
87
|
+
*
|
|
88
|
+
* **Bounded per call, oldest first.** After a long pause or a restore the backlog can be a
|
|
89
|
+
* year of sweep runs, and one unbounded DELETE over it is a pass that fails on the Durable
|
|
90
|
+
* Object every tick. Each statement deletes at most `limit` rows, chosen through the table's
|
|
91
|
+
* own retention index (`… WHERE rowid IN (SELECT rowid … ORDER BY <ts> LIMIT ?)`), so the
|
|
92
|
+
* backlog drains over passes. `RETURNING` makes the count what was actually deleted on both
|
|
93
|
+
* adapters, rather than a rows-written figure that would also count index writes.
|
|
94
|
+
*/
|
|
95
|
+
export declare function telemetryRetentionStatements(nowMs: number, limit: number): {
|
|
96
|
+
table: keyof TelemetryPruneReport;
|
|
97
|
+
sql: string;
|
|
98
|
+
params: [string, number];
|
|
99
|
+
}[];
|
|
100
|
+
/**
|
|
101
|
+
* One bounded retention DELETE: at most `LIMIT ?` rows whose `column` is before `?`, oldest
|
|
102
|
+
* first through the column's own index, `RETURNING 1` so the count is what was deleted. Takes
|
|
103
|
+
* `(horizon, limit)`. The statement `telemetryRetentionStatements` and `pruneFindings` share.
|
|
104
|
+
*/
|
|
105
|
+
export declare function boundedRetentionDelete(table: string, column: string): string;
|
|
106
|
+
//# sourceMappingURL=retention.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retention.d.ts","sourceRoot":"","sources":["../src/retention.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,uBAAuB,oHAC+E,CAAC;AAEpH;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAGhE;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,yDAAyD;AACzD,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAGlE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAGnE;AAED,2FAA2F;AAC3F,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ;IAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,EAAE,CAoBhF;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAK5E"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { substratError } from '@substrat-run/contracts';
|
|
2
|
+
/**
|
|
3
|
+
* How long a recorded operational failure is kept (#559). Telemetry, not evidence:
|
|
4
|
+
* unlike the never-swept admin log, the ops-failures table self-prunes on write in
|
|
5
|
+
* every adapter, so it can never grow without bound and needs no cron wiring or
|
|
6
|
+
* operator decision. 90 days comfortably outlives any incident follow-up (a
|
|
7
|
+
* Cloudflare ticket round-trip) while keeping directory storage flat.
|
|
8
|
+
*/
|
|
9
|
+
export const OPS_FAILURE_RETENTION_DAYS = 90;
|
|
10
|
+
/**
|
|
11
|
+
* How long a sweep-run row is kept (#1232). Much shorter than ops failures: this
|
|
12
|
+
* is high-frequency telemetry (a pass every few minutes times every connection
|
|
13
|
+
* and schedule), and its job is the recent-runs strip plus an incident window —
|
|
14
|
+
* 14 days covers both. Pruned on write in every adapter, like ops failures and
|
|
15
|
+
* for the same reason: the table stays bounded even where no scheduled pass runs.
|
|
16
|
+
*/
|
|
17
|
+
export const SWEEP_RUN_RETENTION_DAYS = 14;
|
|
18
|
+
/**
|
|
19
|
+
* The drained batch's dedupe key on the directory's `_substrat_sweep_runs` (#1232), as
|
|
20
|
+
* both adapters build it: `recordSweepRun` is an `INSERT OR IGNORE` against this index,
|
|
21
|
+
* which is what makes a replayed drain write nothing twice.
|
|
22
|
+
*
|
|
23
|
+
* `kind` is in it since #1572, and that is the fix rather than a tidy-up. Every entry of
|
|
24
|
+
* one drained batch shares its `request_id`, and `unit` is built from two namespaces that
|
|
25
|
+
* nothing keeps apart — `<scopeId>:<operation>` for a schedule, `<scopeId>:<eventType>`
|
|
26
|
+
* for a freshness verdict — while `scheduleSpec.operation` is `z.string().min(1)`. A
|
|
27
|
+
* schedule named exactly like an event type its scope expects freshness on collided on
|
|
28
|
+
* `(request_id, unit)`, and the ignore-on-conflict write discarded the second row with no
|
|
29
|
+
* error anywhere. Both rows are signals by their absence (a stopped evaluator, a missed
|
|
30
|
+
* run), so losing one read as the very thing it was meant to rule out. It is #1288's
|
|
31
|
+
* collision, in the record table beside the state table.
|
|
32
|
+
*
|
|
33
|
+
* Shared rather than spelled in each adapter because a directory that predates it
|
|
34
|
+
* re-creates it (`ensureSweepRunsIntentKind`, in both), and `lint:spine-ddl` sees only
|
|
35
|
+
* the created copy. One definition keeps the re-created shape and the created shape the
|
|
36
|
+
* same shape; the gate then holds each adapter's DDL to including it.
|
|
37
|
+
*/
|
|
38
|
+
export const SWEEP_RUNS_INTENT_INDEX = 'CREATE UNIQUE INDEX IF NOT EXISTS _substrat_sweep_runs_intent ON _substrat_sweep_runs (request_id, kind, unit);';
|
|
39
|
+
/**
|
|
40
|
+
* Whether a directory's `_substrat_sweep_runs_intent` already has `kind` among its
|
|
41
|
+
* columns, read off the index's `sql` in `sqlite_master` — which DO SQLite serves and
|
|
42
|
+
* `PRAGMA` does not, so both adapters detect by one strategy. `false` means the index
|
|
43
|
+
* must be DROPPED and created again: `CREATE … IF NOT EXISTS` matches on the name alone,
|
|
44
|
+
* so on every existing directory the old `(request_id, unit)` index would otherwise
|
|
45
|
+
* stand for good, while a fresh one — and any test that starts from one — gets the new.
|
|
46
|
+
*/
|
|
47
|
+
export function sweepRunsIntentHasKind(indexSql) {
|
|
48
|
+
const columns = /\(([^()]*)\)\s*;?\s*$/.exec(indexSql)?.[1];
|
|
49
|
+
return columns !== undefined && columns.split(',').some((c) => c.trim() === 'kind');
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* How long an issue row outlives its last occurrence (#1233). Deliberately longer
|
|
53
|
+
* than the 90-day evidence beneath it: an issue is the compressed memory of a
|
|
54
|
+
* failure class, and "we saw this five months ago" is exactly what a regression
|
|
55
|
+
* needs to be recognizable. Pruned on write like everything else here, and on the
|
|
56
|
+
* scheduled pass (`pruneTelemetry`, #1632), so a quiet directory sheds it on time too.
|
|
57
|
+
*/
|
|
58
|
+
export const ISSUE_RETENTION_DAYS = 180;
|
|
59
|
+
/**
|
|
60
|
+
* A caller-supplied row bound, checked before it reaches a SQL `LIMIT` (#1632). SQLite reads a
|
|
61
|
+
* negative `LIMIT` as no limit at all, so `-1` turns a bounded batch into an unbounded one; a
|
|
62
|
+
* fractional or non-finite value is refused by SQLite itself, as a failure every later call
|
|
63
|
+
* repeats. Neither is a value anyone means, so it is a configuration error, refused here with the
|
|
64
|
+
* option's name, and never silently normalized into something the caller did not ask for.
|
|
65
|
+
* Returns the value, so a call site can bind it in place.
|
|
66
|
+
*/
|
|
67
|
+
export function assertRowLimit(name, value) {
|
|
68
|
+
if (Number.isInteger(value) && value > 0)
|
|
69
|
+
return value;
|
|
70
|
+
throw substratError('validation_failed', `${name} must be a positive integer, got ${String(value)}`);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A caller-supplied row offset, checked before it reaches a SQL `OFFSET` — `assertRowLimit`'s
|
|
74
|
+
* sibling. Zero is a valid offset; a negative, fractional or non-finite one is refused rather
|
|
75
|
+
* than passed to SQLite, which fails the statement on it.
|
|
76
|
+
*/
|
|
77
|
+
export function assertRowOffset(name, value) {
|
|
78
|
+
if (Number.isInteger(value) && value >= 0)
|
|
79
|
+
return value;
|
|
80
|
+
throw substratError('validation_failed', `${name} must be a non-negative integer, got ${String(value)}`);
|
|
81
|
+
}
|
|
82
|
+
/** How many rows of EACH telemetry table one `pruneTelemetry` call deletes, by default. */
|
|
83
|
+
export const TELEMETRY_PRUNE_BATCH = 500;
|
|
84
|
+
/**
|
|
85
|
+
* The three telemetry retentions as statements, for `pruneTelemetry` on both adapters (#1632).
|
|
86
|
+
*
|
|
87
|
+
* Each table already prunes on write, and that bound holds only while something is written:
|
|
88
|
+
* a quiet directory keeps a row past its retention for as long as nothing new arrives in
|
|
89
|
+
* that table. An issue is the case that matters. Erasure skips an issue whose exemplar owner
|
|
90
|
+
* is unknown, on the promise that it ages out within `ISSUE_RETENTION_DAYS`, and on a
|
|
91
|
+
* directory with no new failures nothing ever deleted it. The scheduled pass runs these
|
|
92
|
+
* statements, which makes the stated retention a bound in time rather than in traffic.
|
|
93
|
+
*
|
|
94
|
+
* **Bounded per call, oldest first.** After a long pause or a restore the backlog can be a
|
|
95
|
+
* year of sweep runs, and one unbounded DELETE over it is a pass that fails on the Durable
|
|
96
|
+
* Object every tick. Each statement deletes at most `limit` rows, chosen through the table's
|
|
97
|
+
* own retention index (`… WHERE rowid IN (SELECT rowid … ORDER BY <ts> LIMIT ?)`), so the
|
|
98
|
+
* backlog drains over passes. `RETURNING` makes the count what was actually deleted on both
|
|
99
|
+
* adapters, rather than a rows-written figure that would also count index writes.
|
|
100
|
+
*/
|
|
101
|
+
export function telemetryRetentionStatements(nowMs, limit) {
|
|
102
|
+
const horizon = (days) => new Date(nowMs - days * 86_400_000).toISOString();
|
|
103
|
+
const bounded = boundedRetentionDelete;
|
|
104
|
+
return [
|
|
105
|
+
{
|
|
106
|
+
table: 'opsFailures',
|
|
107
|
+
sql: bounded('_substrat_ops_failures', 'at'),
|
|
108
|
+
params: [horizon(OPS_FAILURE_RETENTION_DAYS), limit],
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
table: 'issues',
|
|
112
|
+
sql: bounded('_substrat_issues', 'last_seen'),
|
|
113
|
+
params: [horizon(ISSUE_RETENTION_DAYS), limit],
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
table: 'sweepRuns',
|
|
117
|
+
sql: bounded('_substrat_sweep_runs', 'at'),
|
|
118
|
+
params: [horizon(SWEEP_RUN_RETENTION_DAYS), limit],
|
|
119
|
+
},
|
|
120
|
+
];
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* One bounded retention DELETE: at most `LIMIT ?` rows whose `column` is before `?`, oldest
|
|
124
|
+
* first through the column's own index, `RETURNING 1` so the count is what was deleted. Takes
|
|
125
|
+
* `(horizon, limit)`. The statement `telemetryRetentionStatements` and `pruneFindings` share.
|
|
126
|
+
*/
|
|
127
|
+
export function boundedRetentionDelete(table, column) {
|
|
128
|
+
return (`DELETE FROM ${table} WHERE rowid IN ` +
|
|
129
|
+
`(SELECT rowid FROM ${table} WHERE ${column} < ? ORDER BY ${column} LIMIT ?) RETURNING 1`);
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=retention.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retention.js","sourceRoot":"","sources":["../src/retention.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAClC,iHAAi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