@substrat-run/kernel 0.219.0 → 0.221.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/adopt-major.d.ts +150 -0
- package/dist/adopt-major.d.ts.map +1 -0
- package/dist/adopt-major.js +150 -0
- package/dist/adopt-major.js.map +1 -0
- package/dist/app-environments.d.ts +113 -0
- package/dist/app-environments.d.ts.map +1 -0
- package/dist/app-environments.js +239 -0
- package/dist/app-environments.js.map +1 -0
- package/dist/broker-relay-scope.d.ts +53 -0
- package/dist/broker-relay-scope.d.ts.map +1 -0
- package/dist/broker-relay-scope.js +77 -0
- package/dist/broker-relay-scope.js.map +1 -0
- package/dist/broker-relay.d.ts +5 -1
- package/dist/broker-relay.d.ts.map +1 -1
- package/dist/broker-relay.js.map +1 -1
- package/dist/broker-schema.d.ts.map +1 -1
- package/dist/broker-schema.js +12 -0
- package/dist/broker-schema.js.map +1 -1
- package/dist/carried-copy.d.ts.map +1 -1
- package/dist/carried-copy.js +3 -0
- package/dist/carried-copy.js.map +1 -1
- package/dist/connect-intent.d.ts +24 -0
- package/dist/connect-intent.d.ts.map +1 -0
- package/dist/connect-intent.js +25 -0
- package/dist/connect-intent.js.map +1 -0
- package/dist/connection-context.d.ts +30 -0
- package/dist/connection-context.d.ts.map +1 -1
- package/dist/connection-context.js.map +1 -1
- package/dist/delivery-broker.d.ts +77 -1
- package/dist/delivery-broker.d.ts.map +1 -1
- package/dist/delivery-broker.js +112 -8
- package/dist/delivery-broker.js.map +1 -1
- package/dist/delivery-contract.d.ts +36 -0
- package/dist/delivery-contract.d.ts.map +1 -0
- package/dist/delivery-contract.js +84 -0
- package/dist/delivery-contract.js.map +1 -0
- package/dist/directory-lake-keep.d.ts.map +1 -1
- package/dist/directory-lake-keep.js +5 -0
- package/dist/directory-lake-keep.js.map +1 -1
- package/dist/email-intent.d.ts +32 -0
- package/dist/email-intent.d.ts.map +1 -1
- package/dist/email-intent.js +66 -1
- package/dist/email-intent.js.map +1 -1
- package/dist/entity-trash.d.ts +45 -0
- package/dist/entity-trash.d.ts.map +1 -1
- package/dist/entity-trash.js +52 -0
- package/dist/entity-trash.js.map +1 -1
- package/dist/index.d.ts +19 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -4
- package/dist/index.js.map +1 -1
- package/dist/permission-checker.d.ts.map +1 -1
- package/dist/permission-checker.js +4 -2
- package/dist/permission-checker.js.map +1 -1
- package/dist/release-within-major.d.ts +173 -0
- package/dist/release-within-major.d.ts.map +1 -0
- package/dist/release-within-major.js +283 -0
- package/dist/release-within-major.js.map +1 -0
- package/dist/reserved-roles.d.ts +12 -1
- package/dist/reserved-roles.d.ts.map +1 -1
- package/dist/reserved-roles.js.map +1 -1
- package/dist/schedule-due.d.ts +88 -0
- package/dist/schedule-due.d.ts.map +1 -0
- package/dist/schedule-due.js +116 -0
- package/dist/schedule-due.js.map +1 -0
- package/dist/schedule-state.d.ts +1 -1
- package/dist/schedule-state.d.ts.map +1 -1
- package/dist/schedule-state.js +6 -0
- package/dist/schedule-state.js.map +1 -1
- package/dist/scope-copy.d.ts.map +1 -1
- package/dist/scope-copy.js +13 -1
- package/dist/scope-copy.js.map +1 -1
- package/dist/scope-host.d.ts +202 -2
- package/dist/scope-host.d.ts.map +1 -1
- package/dist/scope-host.js.map +1 -1
- package/dist/scope-identity.d.ts +10 -1
- package/dist/scope-identity.d.ts.map +1 -1
- package/dist/scope-identity.js +12 -3
- package/dist/scope-identity.js.map +1 -1
- package/dist/scope-store.d.ts +30 -6
- package/dist/scope-store.d.ts.map +1 -1
- package/dist/scope-store.js +30 -1
- package/dist/scope-store.js.map +1 -1
- package/dist/scope-types.d.ts +161 -0
- package/dist/scope-types.d.ts.map +1 -0
- package/dist/scope-types.js +227 -0
- package/dist/scope-types.js.map +1 -0
- package/dist/store-proof.d.ts +45 -0
- package/dist/store-proof.d.ts.map +1 -0
- package/dist/store-proof.js +97 -0
- package/dist/store-proof.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A schedule made due by an event (#3540, K-69's second step).
|
|
3
|
+
*
|
|
4
|
+
* A schedule declared `due: 'event'` is not due again every `everyMinutes`. The work it acts on
|
|
5
|
+
* says when it is due: the operation that creates that work writes the instant, in its own
|
|
6
|
+
* transaction (`ctx.scheduleDue`), and every run of the schedule's operation clears it first, in
|
|
7
|
+
* the run's transaction, and writes the next one for the work it leaves. So a scope with nothing
|
|
8
|
+
* due has nothing to wake for, and its alarm is armed for the earliest due schedule.
|
|
9
|
+
*
|
|
10
|
+
* The state is one column of the schedule's own `_substrat_schedule_state` row, `due_at`:
|
|
11
|
+
*
|
|
12
|
+
* - **NULL**: the schedule has not run once under this form. Its cadence decides, as for any
|
|
13
|
+
* schedule. That is the reading of every row written before the column, so work a scope holds
|
|
14
|
+
* from before the switch, or from before its engine declared the form, is found by one run on
|
|
15
|
+
* the cadence, which then writes what it left. A write while NULL does nothing for the same
|
|
16
|
+
* reason: a date known for only SOME of the work is not a date the cadence may give way to.
|
|
17
|
+
* - **`'none'`** (`SCHEDULE_DUE_NONE`): it has, and nothing it acts on is due.
|
|
18
|
+
* - **an ISO instant**: when it is next due. A write only ever moves it earlier, so two
|
|
19
|
+
* operations naming two dates leave the earlier, and a date already due is never pushed back.
|
|
20
|
+
*
|
|
21
|
+
* `'none'` sorts after every ISO instant this platform writes (a digit sorts before a letter), so
|
|
22
|
+
* "earlier" is one comparison on the column and the write is one `UPDATE`.
|
|
23
|
+
*
|
|
24
|
+
* Who runs a due schedule is the adapter's to decide (`ScheduleTick.dueAlarm`): a Durable Object
|
|
25
|
+
* scope arms its one alarm for it, and the pure host's pass runs it when it is due by the host's
|
|
26
|
+
* clock. Neither changes who it runs as: a schedule runs as `system:<module>`, and `ctx.check` is
|
|
27
|
+
* still the only gate.
|
|
28
|
+
*/
|
|
29
|
+
import { type ScheduleSpec } from '@substrat-run/contracts';
|
|
30
|
+
import type { ScopedSql } from './scope-host.js';
|
|
31
|
+
/** `due_at` once the schedule has run under the form and nothing it acts on is due. */
|
|
32
|
+
export declare const SCHEDULE_DUE_NONE = "none";
|
|
33
|
+
/** What the due-date reads need of one schedule declared `due: 'event'`. */
|
|
34
|
+
export interface DueSchedule {
|
|
35
|
+
readonly operation: string;
|
|
36
|
+
/** The cadence a failed run waits before it is due again, as a cadence schedule would. */
|
|
37
|
+
readonly everyMinutes: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The schedules of a manifest that are due by event, keyed by operation. A purge schedule is left
|
|
41
|
+
* out whatever it declares: its due date is its trashed rows (`purgeDueAt`).
|
|
42
|
+
*/
|
|
43
|
+
export declare function dueByEventSchedulesOf(schedules: readonly ScheduleSpec[] | undefined): Map<string, DueSchedule>;
|
|
44
|
+
/**
|
|
45
|
+
* `ctx.scheduleDue(operation, at)`: the schedule named is due no later than `at`. Written through
|
|
46
|
+
* the spine seam, in the calling operation's transaction, so it rolls back with the work it
|
|
47
|
+
* describes.
|
|
48
|
+
*
|
|
49
|
+
* `operation` must be a schedule declared `due: 'event'` by a module the host registers, which is
|
|
50
|
+
* refused otherwise: a name that runs nothing would be a date nothing ever reads. It need not be
|
|
51
|
+
* the caller's own module's. An engine's in-scope function runs under the vertical's context, and
|
|
52
|
+
* making a schedule due grants nothing: the schedule runs as its own module's system principal,
|
|
53
|
+
* with its own declared input, and does what it would have done on its cadence.
|
|
54
|
+
*
|
|
55
|
+
* A no-op while the schedule has not run under the form (`due_at` NULL), since its cadence still
|
|
56
|
+
* decides there, and when the row already holds an earlier date.
|
|
57
|
+
*/
|
|
58
|
+
export declare function noteScheduleDue(sql: ScopedSql, schedules: ReadonlyMap<string, DueSchedule>, operation: string, at: string): void;
|
|
59
|
+
/**
|
|
60
|
+
* The start of a run of a due-by-event schedule's operation: its date is cleared, in the run's own
|
|
61
|
+
* transaction, before the handler, which writes the next one for the work it leaves. A run that
|
|
62
|
+
* throws rolls this back, so the date it was due by is still there for the next try. This is also
|
|
63
|
+
* what moves a schedule onto the form (NULL → `'none'`), which is why it is a run that does it and
|
|
64
|
+
* never a write: only a run has looked at all of the work.
|
|
65
|
+
*
|
|
66
|
+
* Every run clears it, whoever invoked the operation: whatever ran it ran over the work.
|
|
67
|
+
*/
|
|
68
|
+
export declare function consumeScheduleDue(sql: ScopedSql, operation: string): void;
|
|
69
|
+
/** One due-by-event schedule's row, read for the decision who runs it and when. */
|
|
70
|
+
export interface ScheduleDueRow {
|
|
71
|
+
/** Whether it has run under the form (`due_at` not NULL): only then may anything but its cadence decide. */
|
|
72
|
+
readonly established: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* When it is next due in epoch milliseconds, or null when nothing is due (or it is not
|
|
75
|
+
* established). A run that failed waits its cadence from that run, never earlier, as under the
|
|
76
|
+
* pass, so a schedule that keeps failing is tried once per cadence and never spins an alarm.
|
|
77
|
+
*/
|
|
78
|
+
readonly dueAt: number | null;
|
|
79
|
+
readonly lastRunAt: string | null;
|
|
80
|
+
}
|
|
81
|
+
/** Read `schedule`'s due state (`ScheduleDueRow`). */
|
|
82
|
+
export declare function readScheduleDue(sql: ScopedSql, schedule: DueSchedule): ScheduleDueRow;
|
|
83
|
+
/**
|
|
84
|
+
* The earliest instant any of `schedules` is due, in epoch milliseconds, or null when none is
|
|
85
|
+
* (nothing due, or none established). What a scope arms its one alarm for, beside its purges.
|
|
86
|
+
*/
|
|
87
|
+
export declare function scheduleDueAt(sql: ScopedSql, schedules: Iterable<DueSchedule>): number | null;
|
|
88
|
+
//# sourceMappingURL=schedule-due.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedule-due.d.ts","sourceRoot":"","sources":["../src/schedule-due.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAA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edule declared `due: 'event'` is not due again every `everyMinutes`. The work it acts on
|
|
5
|
+
* says when it is due: the operation that creates that work writes the instant, in its own
|
|
6
|
+
* transaction (`ctx.scheduleDue`), and every run of the schedule's operation clears it first, in
|
|
7
|
+
* the run's transaction, and writes the next one for the work it leaves. So a scope with nothing
|
|
8
|
+
* due has nothing to wake for, and its alarm is armed for the earliest due schedule.
|
|
9
|
+
*
|
|
10
|
+
* The state is one column of the schedule's own `_substrat_schedule_state` row, `due_at`:
|
|
11
|
+
*
|
|
12
|
+
* - **NULL**: the schedule has not run once under this form. Its cadence decides, as for any
|
|
13
|
+
* schedule. That is the reading of every row written before the column, so work a scope holds
|
|
14
|
+
* from before the switch, or from before its engine declared the form, is found by one run on
|
|
15
|
+
* the cadence, which then writes what it left. A write while NULL does nothing for the same
|
|
16
|
+
* reason: a date known for only SOME of the work is not a date the cadence may give way to.
|
|
17
|
+
* - **`'none'`** (`SCHEDULE_DUE_NONE`): it has, and nothing it acts on is due.
|
|
18
|
+
* - **an ISO instant**: when it is next due. A write only ever moves it earlier, so two
|
|
19
|
+
* operations naming two dates leave the earlier, and a date already due is never pushed back.
|
|
20
|
+
*
|
|
21
|
+
* `'none'` sorts after every ISO instant this platform writes (a digit sorts before a letter), so
|
|
22
|
+
* "earlier" is one comparison on the column and the write is one `UPDATE`.
|
|
23
|
+
*
|
|
24
|
+
* Who runs a due schedule is the adapter's to decide (`ScheduleTick.dueAlarm`): a Durable Object
|
|
25
|
+
* scope arms its one alarm for it, and the pure host's pass runs it when it is due by the host's
|
|
26
|
+
* clock. Neither changes who it runs as: a schedule runs as `system:<module>`, and `ctx.check` is
|
|
27
|
+
* still the only gate.
|
|
28
|
+
*/
|
|
29
|
+
import { substratError } from '@substrat-run/contracts';
|
|
30
|
+
/** `due_at` once the schedule has run under the form and nothing it acts on is due. */
|
|
31
|
+
export const SCHEDULE_DUE_NONE = 'none';
|
|
32
|
+
/**
|
|
33
|
+
* The schedules of a manifest that are due by event, keyed by operation. A purge schedule is left
|
|
34
|
+
* out whatever it declares: its due date is its trashed rows (`purgeDueAt`).
|
|
35
|
+
*/
|
|
36
|
+
export function dueByEventSchedulesOf(schedules) {
|
|
37
|
+
const out = new Map();
|
|
38
|
+
for (const schedule of schedules ?? []) {
|
|
39
|
+
if (schedule.due !== 'event' || schedule.purge)
|
|
40
|
+
continue;
|
|
41
|
+
out.set(schedule.operation, { operation: schedule.operation, everyMinutes: schedule.cadence.everyMinutes });
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* `ctx.scheduleDue(operation, at)`: the schedule named is due no later than `at`. Written through
|
|
47
|
+
* the spine seam, in the calling operation's transaction, so it rolls back with the work it
|
|
48
|
+
* describes.
|
|
49
|
+
*
|
|
50
|
+
* `operation` must be a schedule declared `due: 'event'` by a module the host registers, which is
|
|
51
|
+
* refused otherwise: a name that runs nothing would be a date nothing ever reads. It need not be
|
|
52
|
+
* the caller's own module's. An engine's in-scope function runs under the vertical's context, and
|
|
53
|
+
* making a schedule due grants nothing: the schedule runs as its own module's system principal,
|
|
54
|
+
* with its own declared input, and does what it would have done on its cadence.
|
|
55
|
+
*
|
|
56
|
+
* A no-op while the schedule has not run under the form (`due_at` NULL), since its cadence still
|
|
57
|
+
* decides there, and when the row already holds an earlier date.
|
|
58
|
+
*/
|
|
59
|
+
export function noteScheduleDue(sql, schedules, operation, at) {
|
|
60
|
+
if (!schedules.has(operation)) {
|
|
61
|
+
throw substratError('validation_failed', `ctx.scheduleDue: '${operation}' is not a schedule declared \`due: 'event'\` by a module this host registers`, { reason: 'schedule_not_due_by_event' });
|
|
62
|
+
}
|
|
63
|
+
const ms = typeof at === 'string' ? Date.parse(at) : Number.NaN;
|
|
64
|
+
if (!Number.isFinite(ms)) {
|
|
65
|
+
throw substratError('validation_failed', `ctx.scheduleDue: '${String(at)}' is not an instant`, {
|
|
66
|
+
reason: 'schedule_due_not_an_instant',
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
// One spelling, so the column compares as instants: `2026-03-02T00:00:00Z` and
|
|
70
|
+
// `2026-03-02T00:00:00.000Z` are the same instant and must not order by their punctuation.
|
|
71
|
+
const iso = new Date(ms).toISOString();
|
|
72
|
+
sql.exec(`UPDATE _substrat_schedule_state SET due_at = ?
|
|
73
|
+
WHERE kind = 'schedule' AND schedule_op = ? AND due_at IS NOT NULL AND due_at > ?`, [iso, operation, iso]);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The start of a run of a due-by-event schedule's operation: its date is cleared, in the run's own
|
|
77
|
+
* transaction, before the handler, which writes the next one for the work it leaves. A run that
|
|
78
|
+
* throws rolls this back, so the date it was due by is still there for the next try. This is also
|
|
79
|
+
* what moves a schedule onto the form (NULL → `'none'`), which is why it is a run that does it and
|
|
80
|
+
* never a write: only a run has looked at all of the work.
|
|
81
|
+
*
|
|
82
|
+
* Every run clears it, whoever invoked the operation: whatever ran it ran over the work.
|
|
83
|
+
*/
|
|
84
|
+
export function consumeScheduleDue(sql, operation) {
|
|
85
|
+
sql.exec(`INSERT INTO _substrat_schedule_state (kind, schedule_op, due_at) VALUES ('schedule', ?, ?)
|
|
86
|
+
ON CONFLICT(kind, schedule_op) DO UPDATE SET due_at = excluded.due_at`, [operation, SCHEDULE_DUE_NONE]);
|
|
87
|
+
}
|
|
88
|
+
/** Read `schedule`'s due state (`ScheduleDueRow`). */
|
|
89
|
+
export function readScheduleDue(sql, schedule) {
|
|
90
|
+
const [row] = sql.query(`SELECT due_at, last_run_at, last_status FROM _substrat_schedule_state WHERE kind = 'schedule' AND schedule_op = ?`, [schedule.operation]);
|
|
91
|
+
const lastRunAt = row?.last_run_at ?? null;
|
|
92
|
+
if (!row || row.due_at === null)
|
|
93
|
+
return { established: false, dueAt: null, lastRunAt };
|
|
94
|
+
if (row.due_at === SCHEDULE_DUE_NONE)
|
|
95
|
+
return { established: true, dueAt: null, lastRunAt };
|
|
96
|
+
let due = Date.parse(row.due_at);
|
|
97
|
+
if (!Number.isFinite(due))
|
|
98
|
+
return { established: true, dueAt: null, lastRunAt };
|
|
99
|
+
if (row.last_status === 'failed' && lastRunAt)
|
|
100
|
+
due = Math.max(due, Date.parse(lastRunAt) + schedule.everyMinutes * 60_000);
|
|
101
|
+
return { established: true, dueAt: due, lastRunAt };
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The earliest instant any of `schedules` is due, in epoch milliseconds, or null when none is
|
|
105
|
+
* (nothing due, or none established). What a scope arms its one alarm for, beside its purges.
|
|
106
|
+
*/
|
|
107
|
+
export function scheduleDueAt(sql, schedules) {
|
|
108
|
+
let earliest = null;
|
|
109
|
+
for (const schedule of schedules) {
|
|
110
|
+
const { dueAt } = readScheduleDue(sql, schedule);
|
|
111
|
+
if (dueAt !== null && (earliest === null || dueAt < earliest))
|
|
112
|
+
earliest = dueAt;
|
|
113
|
+
}
|
|
114
|
+
return earliest;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=schedule-due.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedule-due.js","sourceRoot":"","sources":["../src/schedule-due.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,aAAa,EAAqB,MAAM,yBAAyB,CAAC;AAG3E,uFAAuF;AACvF,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AASxC;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,SAA8C;IAClF,MAAM,GAAG,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC3C,KAAK,MAAM,QAAQ,IAAI,SAAS,IAAI,EAAE,EAAE,CAAC;QACvC,IAAI,QAAQ,CAAC,GAAG,KAAK,OAAO,IAAI,QAAQ,CAAC,KAAK;YAAE,SAAS;QACzD,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,EAAE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,KAAK,GAAG,QAAQ,CAAC;YAAE,QAAQ,GAAG,KAAK,CAAC;IAClF,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/schedule-state.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export type ScheduleStateKind = 'schedule' | 'freshness';
|
|
|
20
20
|
* definition is what keeps the rebuilt shape and the created shape the same shape;
|
|
21
21
|
* the gate then holds each adapter to including it.
|
|
22
22
|
*/
|
|
23
|
-
export declare const SCHEDULE_STATE_DDL = "\n CREATE TABLE IF NOT EXISTS _substrat_schedule_state (\n -- #1288: WHICH of the two families this row belongs to, named with the same two\n -- words _substrat_sweep_runs already records its entries under:\n -- * 'schedule' -- keyed by the operation (module/verb). last_run_at and\n -- last_status are when that operation RAN here and how it ended.\n -- * 'freshness' -- keyed freshness:<eventType> (#1232). last_run_at and\n -- last_status are when the evaluator last RECORDED a verdict for that event\n -- type and what it was. Nothing ran; the row gates what the sweep records.\n kind TEXT NOT NULL,\n schedule_op TEXT NOT NULL,\n last_run_at TEXT,\n last_status TEXT,\n -- #1525: the invocation this row's last run happened in, or null. Null is a fact\n -- here, not a gap: a 'freshness' row never invokes anything (the evaluator only\n -- records a verdict), a 'schedule' row a pass SKIPPED carries no fresh call to\n -- attribute and keeps whatever it already held, and a row written before this\n -- column existed predates the possibility. Only a due schedule's own invoke\n -- mints one and writes it here, in the same call that stamps it onto whatever\n -- the operation emits \u2014 see runDueSchedules in each adapter.\n invocation_id TEXT,\n -- #2096: a purge horizon's lap in progress (entity-trash.ts, PurgeLap) -- where its\n -- next pass resumes in the bin, and how many purges failed earlier in the lap. Only a\n -- 'schedule' row of a purge schedule holds one, and only mid-lap: NULL is the start\n -- of a lap, which is also the honest reading of every row written before the column.\n purge_cursor TEXT,\n -- The key LEADS with kind, and that is the point of #1288 rather than a tidy-up.\n -- Until it did, the two families were told apart by the spelling of one column:\n -- a freshness key could never LOOK like an operation (an event type has passed\n -- contracts' eventType regex -- lowercase ns.verb, no colon, no slash), but the\n -- other direction was convention only, because scheduleSpec.operation is\n -- z.string().min(1). A module declaring a schedule literally named\n -- \"freshness:orders.placed\" shared the evaluator's row and nothing refused it:\n -- each write clobbered the other's verdict, and the sweep read back whichever\n -- ran last. With kind in the key those are two rows that cannot meet.\n PRIMARY KEY (kind, schedule_op)\n );\n";
|
|
23
|
+
export declare const SCHEDULE_STATE_DDL = "\n CREATE TABLE IF NOT EXISTS _substrat_schedule_state (\n -- #1288: WHICH of the two families this row belongs to, named with the same two\n -- words _substrat_sweep_runs already records its entries under:\n -- * 'schedule' -- keyed by the operation (module/verb). last_run_at and\n -- last_status are when that operation RAN here and how it ended.\n -- * 'freshness' -- keyed freshness:<eventType> (#1232). last_run_at and\n -- last_status are when the evaluator last RECORDED a verdict for that event\n -- type and what it was. Nothing ran; the row gates what the sweep records.\n kind TEXT NOT NULL,\n schedule_op TEXT NOT NULL,\n last_run_at TEXT,\n last_status TEXT,\n -- #1525: the invocation this row's last run happened in, or null. Null is a fact\n -- here, not a gap: a 'freshness' row never invokes anything (the evaluator only\n -- records a verdict), a 'schedule' row a pass SKIPPED carries no fresh call to\n -- attribute and keeps whatever it already held, and a row written before this\n -- column existed predates the possibility. Only a due schedule's own invoke\n -- mints one and writes it here, in the same call that stamps it onto whatever\n -- the operation emits \u2014 see runDueSchedules in each adapter.\n invocation_id TEXT,\n -- #2096: a purge horizon's lap in progress (entity-trash.ts, PurgeLap) -- where its\n -- next pass resumes in the bin, and how many purges failed earlier in the lap. Only a\n -- 'schedule' row of a purge schedule holds one, and only mid-lap: NULL is the start\n -- of a lap, which is also the honest reading of every row written before the column.\n purge_cursor TEXT,\n -- #3540: when a schedule declared due: 'event' is next due (schedule-due.ts). NULL: it\n -- has not run once under that form, so its cadence decides -- the honest reading of every\n -- row written before the column, and of every row of a cadence schedule. 'none': it has,\n -- and nothing it acts on is due. Otherwise an ISO instant, which only ever moves earlier\n -- until the schedule's next run clears it (a run's own transaction writes 'none' first).\n due_at TEXT,\n -- The key LEADS with kind, and that is the point of #1288 rather than a tidy-up.\n -- Until it did, the two families were told apart by the spelling of one column:\n -- a freshness key could never LOOK like an operation (an event type has passed\n -- contracts' eventType regex -- lowercase ns.verb, no colon, no slash), but the\n -- other direction was convention only, because scheduleSpec.operation is\n -- z.string().min(1). A module declaring a schedule literally named\n -- \"freshness:orders.placed\" shared the evaluator's row and nothing refused it:\n -- each write clobbered the other's verdict, and the sweep read back whichever\n -- ran last. With kind in the key those are two rows that cannot meet.\n PRIMARY KEY (kind, schedule_op)\n );\n";
|
|
24
24
|
/**
|
|
25
25
|
* The `kind` a pre-#1288 row belongs to, derived from its `schedule_op` — the backfill's one
|
|
26
26
|
* rule, shared by `SCHEDULE_STATE_REBUILD` below and by a restore of a dump taken before the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedule-state.d.ts","sourceRoot":"","sources":["../src/schedule-state.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,WAAW,CAAC;AAEzD;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"schedule-state.d.ts","sourceRoot":"","sources":["../src/schedule-state.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,WAAW,CAAC;AAEzD;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,w7FA2C9B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,6FACsD,CAAC;AAE7F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,sBAAsB,QAclC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,kEAAkE;IAClE,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
package/dist/schedule-state.js
CHANGED
|
@@ -39,6 +39,12 @@ export const SCHEDULE_STATE_DDL = `
|
|
|
39
39
|
-- 'schedule' row of a purge schedule holds one, and only mid-lap: NULL is the start
|
|
40
40
|
-- of a lap, which is also the honest reading of every row written before the column.
|
|
41
41
|
purge_cursor TEXT,
|
|
42
|
+
-- #3540: when a schedule declared due: 'event' is next due (schedule-due.ts). NULL: it
|
|
43
|
+
-- has not run once under that form, so its cadence decides -- the honest reading of every
|
|
44
|
+
-- row written before the column, and of every row of a cadence schedule. 'none': it has,
|
|
45
|
+
-- and nothing it acts on is due. Otherwise an ISO instant, which only ever moves earlier
|
|
46
|
+
-- until the schedule's next run clears it (a run's own transaction writes 'none' first).
|
|
47
|
+
due_at TEXT,
|
|
42
48
|
-- The key LEADS with kind, and that is the point of #1288 rather than a tidy-up.
|
|
43
49
|
-- Until it did, the two families were told apart by the spelling of one column:
|
|
44
50
|
-- a freshness key could never LOOK like an operation (an event type has passed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedule-state.js","sourceRoot":"","sources":["../src/schedule-state.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG
|
|
1
|
+
{"version":3,"file":"schedule-state.js","sourceRoot":"","sources":["../src/schedule-state.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CjC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,yBAAyB,GACpC,0FAA0F,CAAC;AAE7F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;;IAElC,kBAAkB,CAAC,OAAO,CAC1B,qDAAqD,EACrD,2CAA2C,CAC5C;;;;;aAKU,yBAAyB;;;;CAIrC,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACnD,OAAO,QAAQ,CAAC,QAAQ,CAAC,iCAAiC,CAAC,CAAC;AAC9D,CAAC"}
|
package/dist/scope-copy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope-copy.d.ts","sourceRoot":"","sources":["../src/scope-copy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scope-copy.d.ts","sourceRoot":"","sources":["../src/scope-copy.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,UAAU,gBAAiB,MAAM,GAAG,SAAS,iBAAiB,MAAM,GAAG,SAAS,KAAG,OACpC,CAAC;AAc7D;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,OAAO,EAAE,CAAA;CAAE,EACtF,MAAM,EAAE,CAAC,EAAE,EACX,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,aAAa,EAAE,MAAM,GAAG,SAAS,GAChC,CAAC,EAAE,CAGL;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,EAAE,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAEzH;AAcD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,eAAe,8cAW3B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,sBAAiB,MACqD,CAAC;AAE/F;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,SAAS,EACd,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,GAAG,EAAE,MAAM,GACV,IAAI,CAqDN;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAInE;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,QAEa,CAAC;AAE/C;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,CAIpE;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,0FAA0F,CAAC;AAEnH;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,uHACsF,CAAC"}
|
package/dist/scope-copy.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { CAPABILITY_TABLE_NAMES } from './capability.js';
|
|
2
2
|
import { DOWNLOAD_LINK_TABLE_NAMES } from './download-link.js';
|
|
3
|
+
import { STORE_PROOF_TABLE_NAMES } from './store-proof.js';
|
|
3
4
|
import { UPLOAD_LINK_TABLE_NAMES } from './upload-link.js';
|
|
5
|
+
import { clearSettledEmailIn, pendingEmailIds } from './email-intent.js';
|
|
4
6
|
/**
|
|
5
7
|
* What a dump leaves behind when it lands in a scope other than the one it was captured from
|
|
6
8
|
* (#1686). One definition for both adapters' loaders, so the DO and the pure host agree.
|
|
@@ -35,11 +37,16 @@ import { UPLOAD_LINK_TABLE_NAMES } from './upload-link.js';
|
|
|
35
37
|
* consumer's position, so a copy's cursor acknowledges nothing at the source either.
|
|
36
38
|
*/
|
|
37
39
|
export const isCopyLoad = (destScopeId, sourceScopeId) => destScopeId === undefined || sourceScopeId !== destScopeId;
|
|
38
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* The capability tables — and the upload- and download-link tables, bearer links of the same kind,
|
|
42
|
+
* and the store proofs (#2996), bearer proofs of one store call — as `capabilitiesForLoad` matches a
|
|
43
|
+
* dump's (lowercased) names.
|
|
44
|
+
*/
|
|
39
45
|
const CAPABILITY_TABLES = new Set([
|
|
40
46
|
...CAPABILITY_TABLE_NAMES,
|
|
41
47
|
...UPLOAD_LINK_TABLE_NAMES,
|
|
42
48
|
...DOWNLOAD_LINK_TABLE_NAMES,
|
|
49
|
+
...STORE_PROOF_TABLE_NAMES,
|
|
43
50
|
]);
|
|
44
51
|
/**
|
|
45
52
|
* A dump's tables as a load into `destScopeId` takes them: **capability rows never cross a scope
|
|
@@ -143,9 +150,14 @@ export function settleCopiedWork(sql, destScopeId, sourceScopeId, now) {
|
|
|
143
150
|
if (!isCopyLoad(destScopeId, sourceScopeId))
|
|
144
151
|
return;
|
|
145
152
|
const reason = notCarried(sourceScopeId);
|
|
153
|
+
// #3568: a copy never sends (#2005), so a mail that asked to be cleared once settled is cleared by
|
|
154
|
+
// this settle — the copy's journal keeps that it was asked for, never what it said.
|
|
155
|
+
const clearable = pendingEmailIds(sql);
|
|
146
156
|
sql.run(`UPDATE _substrat_platform_requests
|
|
147
157
|
SET status = 'failed', last_error = ?, last_failure = ?, settled_at = ?
|
|
148
158
|
WHERE status = 'pending'`, reason, NOT_CARRIED_FAILURE, now);
|
|
159
|
+
for (const id of clearable)
|
|
160
|
+
clearSettledEmailIn(sql, id, now);
|
|
149
161
|
sql.run(`UPDATE _substrat_deliveries SET next_attempt_at = NULL, error = ?, delivered_at = ?
|
|
150
162
|
WHERE next_attempt_at IS NOT NULL`, reason, now);
|
|
151
163
|
sql.run(`UPDATE _substrat_job_runs
|
package/dist/scope-copy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope-copy.js","sourceRoot":"","sources":["../src/scope-copy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"scope-copy.js","sourceRoot":"","sources":["../src/scope-copy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,WAA+B,EAAE,aAAiC,EAAW,EAAE,CACxG,WAAW,KAAK,SAAS,IAAI,aAAa,KAAK,WAAW,CAAC;AAE7D;;;;GAIG;AACH,MAAM,iBAAiB,GAAwB,IAAI,GAAG,CAAS;IAC7D,GAAG,sBAAsB;IACzB,GAAG,uBAAuB;IAC1B,GAAG,yBAAyB;IAC5B,GAAG,uBAAuB;CAC3B,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAW,EACX,WAA+B,EAC/B,aAAiC;IAEjC,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,aAAa,CAAC;QAAE,OAAO,MAAM,CAAC;IAC3D,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,eAAe,CAAC,CAA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AC,MAAM,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IACvD,GAAG,CAAC,GAAG,CAAC,2DAA2D,CAAC,CAAC;IACrE,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,uFAAuF,CAAC;AAEnH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAC9B,oHAAoH,CAAC"}
|
package/dist/scope-host.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type { VerticalScopeStore } from './vertical-scope-stores.js';
|
|
|
9
9
|
import type { DeploymentWireAuthFilter, DeploymentWireAuthInput, WireWalkAudit } from './deployment-wire-auth.js';
|
|
10
10
|
import type { StoreDriverApprovalRecord, StoreDriverHoldMode, StoreDriverRebuildFailure, StoreDriverRebuildRecord, StoreDriverReleaseRecord, StoreDriverRevokeWalkRecord, StoreDriverRolloutAction, StoreDriverRolloutRecord, StoreDriverRolloutState, StoreDriverRolloutTarget, StoreDriverState } from './store-driver-releases.js';
|
|
11
11
|
import type { SubjectRedactionCounts } from './subject-redaction.js';
|
|
12
|
-
import type { OnBehalfOf, ExportReadInput, ExportedBatch, ImportBatch, ImportedEvent, ImportResult, ImportState, ImportCursorMove, ImportCursorMoved, AdminAction, BecomeCapabilityInput, CapabilityExchange, CapabilityExchangeOptions, CapabilityFilter, CapabilityId, CapabilityPage, MintedCapability, ListPage, ConnectLink, ConnectLinkConsume, ConnectLinkFilter, ConnectLinkKey, ConsumeConnectLinkInput, MintConnectLinkInput, Connection, ConnectionFilter, ConnectionId, ConnectionGrant, ConnectionRevoke, ConnectionGrantRecord, ConnectionSecret, CreateConnectionInput, OpenConnection, ProjectedConnectionGrant, ProjectedConnectionKey, AccessLogEntry, DelegatedReadRecord, OwnerTransferAudit, MemberChangeAudit, PeerBindingAudit, ConnectionBindingAudit, CopyMarkAudit, OrphanSweepAudit, DeliveryRedriveAudit, BrokerDeadLetterAudit, BindHostnameInput, AdminLogEntry, OpsFailureEntry, PlatformRequestDrainTotalsEntry, SweepRunEntry, SweepRunKind, SweepRunOutcome, ModelUsageEntry, ModelUsageSummary, MarkupRow, MarkupRowInput, CapabilityGrant, CreateTenantInput, Decision, Instant, DomainEvent, DomainEventInput, PlatformRequestInput, PlatformRequestId, PlatformRequestEntry, PlatformRequestFilter, PlatformRequestStatus, PlatformRequestFailure, PlatformOutcomeEvent, EntitlementGrant, EntitlementGrantInput, EntitlementView, MeterReading, MeterDay, MeterDayTake, StaleScope, StaleScopeTake, VerticalOwnerPeriod, ScopeStorageSample, StorageGauge, RequestDay, RequestRollupDay, CostDay, EntityRef, IdentityLink, IdentityPool, Jurisdiction, ModuleId, ModuleManifest, ScheduleSpec, SystemGrant, PeerGrantsStatusEntry, SystemGrantsStatusEntry, SystemSwitchRecord, SystemSwitch, SystemSwitchResult, PeerCoverage, PeerSwitch, PeerSwitchResult, VerticalCaller, VerticalResolution, PeerBinding, PeerInstanceResolution, CreateOrgInput, Node, Org, OrgId, OrgMembership, PermissionKey, PlatformActorId, ChannelName, ExportBreak, ChannelHistoryEntry, DnsRecord, HostnameBinding, HostnameStatus, PromotionAcknowledgement, BindAcknowledgement, PublishVersionInput, RegisterVerticalInput, VerticalServingState, DeploymentWireAuth, RouteTarget, DirectoryDump, DirectoryCopyByReference, DirectoryDumpPage, ScopeDumpTable, IdentityMembership, PrincipalId, ResolvedIdentity, RoleAssignment, RoleDefinition, QueryScopeInput, ReadScopeTableInput, Scope, ScopeDump, ScopeDumpInput, SubjectShredReceipt, SubjectReadPage, SubjectReadRequest, SubjectAccessReceipt, ScopeQueryResult, ScopeId, ScopeStatus, ScopeTable, DenialFilter, DenialSummary, RefusalFilter, RefusalRecord, PermissionDenial, Coverage, BeginImpersonationInput, ImpersonationFilter, ImpersonationSession, ImpersonationSessionId, ScopeTablePage, StorageShape, Tenant, TenantId, TenantRole, TenantStoreHandle, AttachmentRecord, UploadLinkView, BlobStoreHandle, Visibility, Vertical, VerticalChannel, VerticalVersion, TenantStatus, Page, CountedPage, FreshnessSpec, EntityHistoryInput, EventFacetInput, EventCauseInput, EventEffectsInput, EffectsTree, InvocationEventsInput, InvocationEvents, DeadLettersInput, DeadLetter, LifecycleFlowInput, LifecycleFlowResult, OperationSeriesInput, OperationSeriesResult, CauseChain, EventFacetResult, HistoryEntry, ErrorCode, PlatformRequestFailureOrigin, IssueEntry, IssueStatus, IssueStatusInput, FindingEntry, FindingFilter, FindingRuleEntry, FindingRuleInput, FindingStatusInput, DeclaredMigration, CheckSubject, EntityGrantShape, NotedTransition, VerticalTraceSampling } from '@substrat-run/contracts';
|
|
12
|
+
import type { OnBehalfOf, ExportReadInput, ExportedBatch, ImportBatch, ImportedEvent, ImportResult, ImportState, ImportCursorMove, ImportCursorMoved, AdminAction, BecomeCapabilityInput, CapabilityExchange, CapabilityExchangeOptions, CapabilityFilter, CapabilityId, CapabilityPage, MintedCapability, ListPage, ConnectLink, ConnectLinkConsume, ConnectLinkFilter, ConnectLinkKey, ConsumeConnectLinkInput, MintConnectLinkInput, Connection, ConnectionFilter, ConnectionId, ConnectionGrant, ConnectionRevoke, ConnectionGrantRecord, ConnectionSecret, CreateConnectionInput, OpenConnection, ProjectedConnectionGrant, ProjectedConnectionKey, AccessLogEntry, DelegatedReadRecord, OwnerTransferAudit, MemberChangeAudit, PeerBindingAudit, ConnectionBindingAudit, CopyMarkAudit, OrphanSweepAudit, DeliveryRedriveAudit, BrokerDeadLetterAudit, BindHostnameInput, AdminLogEntry, OpsFailureEntry, PlatformRequestDrainTotalsEntry, SweepRunEntry, SweepRunKind, SweepRunOutcome, ModelUsageEntry, ModelUsageSummary, MarkupRow, MarkupRowInput, CapabilityGrant, CreateTenantInput, Decision, Instant, DomainEvent, DomainEventInput, PlatformRequestInput, PlatformRequestId, PlatformRequestEntry, PlatformRequestFilter, PlatformRequestStatus, PlatformRequestFailure, PlatformOutcomeEvent, EntitlementGrant, EntitlementGrantInput, EntitlementView, MeterReading, MeterDay, MeterDayTake, StaleScope, StaleScopeTake, VerticalOwnerPeriod, ScopeStorageSample, StorageGauge, RequestDay, RequestRollupDay, CostDay, EntityRef, IdentityLink, IdentityPool, Jurisdiction, ModuleId, ModuleManifest, ScheduleSpec, SystemGrant, PeerGrantsStatusEntry, SystemGrantsStatusEntry, SystemSwitchRecord, SystemSwitch, SystemSwitchResult, PeerCoverage, PeerSwitch, PeerSwitchResult, VerticalCaller, VerticalResolution, PeerBinding, AppEnvironment, EnvironmentServing, PeerInstanceResolution, CreateOrgInput, Node, Org, OrgId, OrgMembership, PermissionKey, PlatformActorId, ChannelName, ExportBreak, ChannelHistoryEntry, DnsRecord, HostnameBinding, HostnameStatus, PromotionAcknowledgement, BindAcknowledgement, PublishVersionInput, RegisterVerticalInput, VerticalServingState, DeploymentWireAuth, RouteTarget, DirectoryDump, DirectoryCopyByReference, DirectoryDumpPage, ScopeDumpTable, IdentityMembership, PrincipalId, ResolvedIdentity, RoleAssignment, RoleDefinition, QueryScopeInput, ReadScopeTableInput, Scope, ScopeDump, ScopeDumpInput, SubjectShredReceipt, SubjectReadPage, SubjectReadRequest, SubjectAccessReceipt, ScopeQueryResult, ScopeId, ScopeStatus, ScopeTable, DenialFilter, DenialSummary, RefusalFilter, RefusalRecord, PermissionDenial, Coverage, BeginImpersonationInput, ImpersonationFilter, ImpersonationSession, ImpersonationSessionId, ScopeTablePage, StorageShape, Tenant, TenantId, TenantRole, TenantStoreHandle, AttachmentRecord, UploadLinkView, BlobStoreHandle, Visibility, Vertical, VerticalChannel, VerticalVersion, TenantStatus, Page, CountedPage, FreshnessSpec, EntityHistoryInput, EventFacetInput, EventCauseInput, EventEffectsInput, EffectsTree, InvocationEventsInput, InvocationEvents, DeadLettersInput, DeadLetter, LifecycleFlowInput, LifecycleFlowResult, OperationSeriesInput, OperationSeriesResult, CauseChain, EventFacetResult, HistoryEntry, ErrorCode, PlatformRequestFailureOrigin, IssueEntry, IssueStatus, IssueStatusInput, FindingEntry, FindingFilter, FindingRuleEntry, FindingRuleInput, FindingStatusInput, DeclaredMigration, CheckSubject, EntityGrantShape, NotedTransition, VerticalTraceSampling, StoreProof } from '@substrat-run/contracts';
|
|
13
13
|
import type { ConnectionUseOutcome } from './connector-calls.js';
|
|
14
14
|
import type { ScopeDelegation } from './delegation-ceiling.js';
|
|
15
15
|
import type { ByteBody } from './byte-stream.js';
|
|
@@ -38,6 +38,7 @@ import type { EntityVersion } from './entity-version.js';
|
|
|
38
38
|
import type { UndrainedEvents } from './outbox-event.js';
|
|
39
39
|
import type { PruneDrainedEventsInput } from './outbox-prune.js';
|
|
40
40
|
import type { AccessSummaryResult } from './access-summary.js';
|
|
41
|
+
import type { SupersedeMajor } from './release-within-major.js';
|
|
41
42
|
import type { DirectoryLakeBackfillPage, DirectoryLakeCaptureResult, DirectoryLakeCaptureState, DirectoryLakeDataset, DirectoryLakePruneRefusal, DirectoryLakeRow } from './directory-lake.js';
|
|
42
43
|
import type { JobDriveReport, JobHandler, JobRun, JobRunFilter, StartJobRunInput } from './job-run.js';
|
|
43
44
|
/**
|
|
@@ -504,6 +505,26 @@ export interface OperationContext {
|
|
|
504
505
|
* type that declares neither.
|
|
505
506
|
*/
|
|
506
507
|
entityState(entity: EntityRef): EntityStateName | null;
|
|
508
|
+
/**
|
|
509
|
+
* Mint the proof a scope-store call needs (#2996, K-64). A module operation does not call its
|
|
510
|
+
* store inside its transaction: it checks the permission key the vertical declared for
|
|
511
|
+
* `operation` on `binding` (`definePermissions({ stores })`) and records a proof, and host code
|
|
512
|
+
* makes the call with it through `getScopeStore(...).invoke(operation, input, proof)`, between two
|
|
513
|
+
* transactions. A second operation records the result.
|
|
514
|
+
*
|
|
515
|
+
* - **Checks the declared key** as the caller, scope-wide; a denial throws `PermissionDenied`, and
|
|
516
|
+
* a store operation with no declared key is refused `forbidden`, since nothing could prove it.
|
|
517
|
+
* - **Transactional.** The proof is a row in the scope's spine. A rollback takes it, so a proof
|
|
518
|
+
* from an operation that failed redeems nothing.
|
|
519
|
+
* - **Narrow and short.** Good for one call of `operation` on `binding` in this scope, by this
|
|
520
|
+
* principal's stub, within a minute; spent by that call whatever the store answers.
|
|
521
|
+
* - **A principal's operation only.** A consumer (whose checks allow unconditionally), a
|
|
522
|
+
* capability session, a peer, a system actor and a read-only impersonation are refused.
|
|
523
|
+
*
|
|
524
|
+
* Return the proof in the operation's output so the host code that called it can make the call.
|
|
525
|
+
* The secret is withheld from the invocation's idempotency record, as every kernel secret is.
|
|
526
|
+
*/
|
|
527
|
+
storeProof(binding: string, operation: string): Promise<StoreProof>;
|
|
507
528
|
/**
|
|
508
529
|
* One page of the TRASH of a declared entity (#119) — `ctx.page` over the trashed rows,
|
|
509
530
|
* with the declared trash key checked on EACH row inside the kernel, so a handler cannot
|
|
@@ -666,6 +687,26 @@ export interface OperationContext {
|
|
|
666
687
|
* `onEmitted`). Names only: a note whose type or states are not shaped like names is dropped.
|
|
667
688
|
*/
|
|
668
689
|
noteTransition(transition: NotedTransition): void;
|
|
690
|
+
/**
|
|
691
|
+
* #3540 (K-69): the schedule `operation`, declared `due: 'event'`, is due no later than `at`.
|
|
692
|
+
* The operation that creates the work a schedule acts on calls this in the same transaction, so
|
|
693
|
+
* the date rolls back with the work; and the schedule's own operation calls it for the earliest
|
|
694
|
+
* work its run left, since every run clears the date first.
|
|
695
|
+
*
|
|
696
|
+
* ```ts
|
|
697
|
+
* ctx.scheduleDue?.('absence/expire-stale', `${dayAfter(startDate)}T00:00:00.000Z`);
|
|
698
|
+
* ```
|
|
699
|
+
*
|
|
700
|
+
* It only ever moves a date earlier, and it does nothing until the schedule has run once under
|
|
701
|
+
* this form: its cadence decides until then, and that first run writes what it found. Making a
|
|
702
|
+
* schedule due grants nothing: it runs as its own module's system principal, with its declared
|
|
703
|
+
* input, and `ctx.check` is still its only gate. Refused for an operation that is not a
|
|
704
|
+
* due-by-event schedule a registered module declares (`schedule-due.ts`).
|
|
705
|
+
*
|
|
706
|
+
* Optional, so an engine can call it on a host older than it: absent there, the schedule runs on
|
|
707
|
+
* its cadence, which is what it did before. Call it as `ctx.scheduleDue?.(…)`.
|
|
708
|
+
*/
|
|
709
|
+
scheduleDue?(operation: string, at: Instant): void;
|
|
669
710
|
}
|
|
670
711
|
export type OperationHandler<I = unknown, O = unknown> = (ctx: OperationContext, input: I) => O | Promise<O>;
|
|
671
712
|
/**
|
|
@@ -869,6 +910,23 @@ export interface ScopeStub {
|
|
|
869
910
|
* around an operation can react to what the operation did without the module
|
|
870
911
|
* carrying a new surface.
|
|
871
912
|
*/
|
|
913
|
+
/**
|
|
914
|
+
* Who calls through `ScopeHost.getChildScope` (#2995): the calling scope, which the host holds to be
|
|
915
|
+
* the child's parent, and the actor the call acts for. These are the facts K-66's second envelope
|
|
916
|
+
* carries on the hosted path as the calling scope and the actor.
|
|
917
|
+
*/
|
|
918
|
+
export interface ChildScopeCaller {
|
|
919
|
+
/** The calling scope. A host refuses a child whose recorded parent is any other scope. */
|
|
920
|
+
readonly parentScopeId: ScopeId;
|
|
921
|
+
/**
|
|
922
|
+
* The person the call acts for, as the parent's own door named them. The app acting as itself,
|
|
923
|
+
* which K-64 allows where the child admits it, is not built: nothing yet says what a child admits.
|
|
924
|
+
*/
|
|
925
|
+
readonly actor: {
|
|
926
|
+
readonly kind: 'person';
|
|
927
|
+
readonly principal: PrincipalId;
|
|
928
|
+
};
|
|
929
|
+
}
|
|
872
930
|
/** `getScope`'s options: the person's door is the only one an address may arrive through. */
|
|
873
931
|
export interface PersonScopeOptions extends ScopeStubOptions {
|
|
874
932
|
/**
|
|
@@ -1314,6 +1372,35 @@ export interface ScheduleRunReport {
|
|
|
1314
1372
|
export interface ScheduleTick {
|
|
1315
1373
|
/** Platform requests the purge runs of the tick's earlier calls on this scope enqueued (their `purgeRequests`). */
|
|
1316
1374
|
earlierPurgeRequests?: number;
|
|
1375
|
+
/**
|
|
1376
|
+
* #3540: the call comes from the scope's OWN alarm, which found a purge due by event
|
|
1377
|
+
* (`purgeDueAt`). Only the module's purge schedules run, each whatever its cadence row says (the
|
|
1378
|
+
* scope decided it is due, and the scope re-checks every cutoff inside each purge); its other
|
|
1379
|
+
* schedules are left to the pass. A host older than the field reads it as an ordinary pass.
|
|
1380
|
+
*/
|
|
1381
|
+
purgeAlarm?: true;
|
|
1382
|
+
/**
|
|
1383
|
+
* #3540: the caller is a coordinator that can take a scope alarm's call (the scope sweeper's
|
|
1384
|
+
* `runScopePurges`), so a scope whose purges are due by event may answer a pass `byAlarm`: arm its
|
|
1385
|
+
* own alarm, and run nothing here. Absent, the scope runs the pass's purges as it always did, which
|
|
1386
|
+
* is what keeps an older coordinator from leaving them to an alarm nothing would answer.
|
|
1387
|
+
*/
|
|
1388
|
+
alarmRunsPurges?: true;
|
|
1389
|
+
/**
|
|
1390
|
+
* #3540: the call comes from the scope's OWN alarm, which found work due by event: its purges
|
|
1391
|
+
* (as `purgeAlarm`) and its `due: 'event'` schedules whose date has come (`readScheduleDue`). A
|
|
1392
|
+
* cadence schedule is left to the pass. A host older than the field reads it as an ordinary pass,
|
|
1393
|
+
* which is why a coordinator sends it only through `runScopeDue`, which an older scope never asks.
|
|
1394
|
+
*/
|
|
1395
|
+
dueAlarm?: true;
|
|
1396
|
+
/**
|
|
1397
|
+
* #3540: the caller can take a scope alarm's `runScopeDue` call, so a `due: 'event'` schedule
|
|
1398
|
+
* that has run under that form may be left to the scope's alarm: the scope arms it and the pass
|
|
1399
|
+
* runs nothing. Absent, the pass runs it on its cadence, as it always did, which is what keeps an
|
|
1400
|
+
* older coordinator from leaving it to an alarm nothing would answer. Separate from
|
|
1401
|
+
* `alarmRunsPurges`, which a coordinator that cannot take that call already sends.
|
|
1402
|
+
*/
|
|
1403
|
+
alarmRunsDue?: true;
|
|
1317
1404
|
}
|
|
1318
1405
|
/**
|
|
1319
1406
|
* The host's clock (#812) — what `ctx.now()` reads.
|
|
@@ -2181,9 +2268,16 @@ export interface HostAdmin {
|
|
|
2181
2268
|
* version promised and the incoming one drops or re-versions, which a running consumer imports
|
|
2182
2269
|
* (`exportBreaksOf`). The refusal counts what breaks and names no tenant, since this layer does
|
|
2183
2270
|
* not know who is asking. `promotionImpact` is the listing, for a caller that may see it.
|
|
2271
|
+
*
|
|
2272
|
+
* **K-65 (#3539): a listed app's prod promote is judged by `releaseWithinMajorRefusal`.**
|
|
2273
|
+
* `servesMajors` says the caller serves a new major from a script of its own, beside the old one
|
|
2274
|
+
* (the control-plane API's in-place serve). A new major of a listed app is refused without it,
|
|
2275
|
+
* and for an incoming version with no archive script (`deploymentRef` null), which no serve can
|
|
2276
|
+
* put on a script of its own.
|
|
2184
2277
|
*/
|
|
2185
2278
|
promoteVersion(actor: PlatformActorId, verticalSlug: string, channel: ChannelName, versionId: string, acknowledge?: PromotionAcknowledgement, options?: {
|
|
2186
2279
|
unlistedOnly?: boolean;
|
|
2280
|
+
servesMajors?: boolean;
|
|
2187
2281
|
}): Promise<void>;
|
|
2188
2282
|
/**
|
|
2189
2283
|
* Which installed consumers promoting `versionId` to `channel` would break (#1705 PR 3): the
|
|
@@ -2309,8 +2403,17 @@ export interface HostAdmin {
|
|
|
2309
2403
|
* gone. Its ref and version are not compared: a serve recorded meanwhile that moved only those
|
|
2310
2404
|
* left the upload's migration right, and the record lands over it as it did before. Either
|
|
2311
2405
|
* refusal is `precondition_failed` (`servingRaceRefusal`) and writes nothing.
|
|
2406
|
+
*
|
|
2407
|
+
* `supersede` (K-65, #3539 part 2) records the first serve of a NEW major, on a script of its
|
|
2408
|
+
* own: in the same write, the serving state the row holds moves to `earlierMajors` as major
|
|
2409
|
+
* `supersede.major`, served until `supersede.endsAt`, and `state` becomes the current major. It
|
|
2410
|
+
* needs `expected` to be that state, non-null, on another ref; anything else is refused
|
|
2411
|
+
* (`precondition_failed`) and writes nothing. No install moves: every scope on the earlier
|
|
2412
|
+
* script stays there and runs what it ran, so the #2178 strand gate has nobody to judge.
|
|
2312
2413
|
*/
|
|
2313
|
-
setVerticalServing(actor: PlatformActorId, verticalSlug: string, state: VerticalServingState, expected?: VerticalServingState | null
|
|
2414
|
+
setVerticalServing(actor: PlatformActorId, verticalSlug: string, state: VerticalServingState, expected?: VerticalServingState | null, opts?: {
|
|
2415
|
+
supersede?: SupersedeMajor;
|
|
2416
|
+
}): Promise<void>;
|
|
2314
2417
|
/**
|
|
2315
2418
|
* The pushed DeployManifest (JSON) of one version — what a serve rebuilds upload
|
|
2316
2419
|
* metadata from. Null for a version pushed before manifests were retained; such a
|
|
@@ -2678,6 +2781,67 @@ export interface HostAdmin {
|
|
|
2678
2781
|
changed: boolean;
|
|
2679
2782
|
previous: ScopeId | null;
|
|
2680
2783
|
}>;
|
|
2784
|
+
/**
|
|
2785
|
+
* The app's environments in the tenant: production first, always (the tenant's installs, never
|
|
2786
|
+
* stored, so an app that runs today reads as production with no step), then each named one, a
|
|
2787
|
+
* name over the tagged, pinned preview of that name. Recorded as an admin read.
|
|
2788
|
+
*/
|
|
2789
|
+
listEnvironments(actor: PlatformActorId, tenantId: TenantId, vertical: string): Promise<AppEnvironment[]>;
|
|
2790
|
+
/**
|
|
2791
|
+
* Name the app's preview tagged `name` an environment. Refused unless that preview exists, is
|
|
2792
|
+
* active and is pinned; `prod` is refused (production is never defined). Idempotent: a name that
|
|
2793
|
+
* is already an environment answers `created: false` and writes nothing. Audited.
|
|
2794
|
+
*/
|
|
2795
|
+
defineEnvironment(actor: PlatformActorId, input: {
|
|
2796
|
+
tenantId: TenantId;
|
|
2797
|
+
vertical: string;
|
|
2798
|
+
name: string;
|
|
2799
|
+
}): Promise<{
|
|
2800
|
+
environment: AppEnvironment;
|
|
2801
|
+
created: boolean;
|
|
2802
|
+
}>;
|
|
2803
|
+
/**
|
|
2804
|
+
* Take the name off; the preview stays. `prod` is refused. Audited when a row went. #3530 step 4:
|
|
2805
|
+
* refused (`conflict`) while the environment serves from a script of its own and its preview still
|
|
2806
|
+
* lives, since the preview's data is on that script: the preview is reaped first.
|
|
2807
|
+
*/
|
|
2808
|
+
removeEnvironment(actor: PlatformActorId, input: {
|
|
2809
|
+
tenantId: TenantId;
|
|
2810
|
+
vertical: string;
|
|
2811
|
+
name: string;
|
|
2812
|
+
}): Promise<{
|
|
2813
|
+
removed: boolean;
|
|
2814
|
+
}>;
|
|
2815
|
+
/**
|
|
2816
|
+
* Record what an environment's own serving script runs (#3530 step 4), after an upload onto it
|
|
2817
|
+
* landed: compare-and-set on `expected` (the record the upload diffed from, null for the first
|
|
2818
|
+
* serve), refused with `precondition_failed` when the row moved since. `not_found` for a name that
|
|
2819
|
+
* is no environment; `conflict` for another script than the one it serves from. Audited.
|
|
2820
|
+
*/
|
|
2821
|
+
setEnvironmentServing(actor: PlatformActorId, input: {
|
|
2822
|
+
tenantId: TenantId;
|
|
2823
|
+
vertical: string;
|
|
2824
|
+
name: string;
|
|
2825
|
+
}, next: EnvironmentServing, expected: EnvironmentServing | null,
|
|
2826
|
+
/** The serve lease's claim: when given, the record lands only while that claim still holds it. */
|
|
2827
|
+
claim?: string): Promise<void>;
|
|
2828
|
+
/**
|
|
2829
|
+
* Take an environment's serve lease for `leaseMs` (#3530 step 4), so its serves run one at a time:
|
|
2830
|
+
* upload, record and bind. False while another live claim holds it; a lapsed one is taken over and
|
|
2831
|
+
* `claim`'s own is renewed. `not_found` for a name that is no environment. Not audited: it moves
|
|
2832
|
+
* nothing a reader sees, and the serve it guards is.
|
|
2833
|
+
*/
|
|
2834
|
+
claimEnvironmentServe(actor: PlatformActorId, input: {
|
|
2835
|
+
tenantId: TenantId;
|
|
2836
|
+
vertical: string;
|
|
2837
|
+
name: string;
|
|
2838
|
+
}, claim: string, leaseMs: number): Promise<boolean>;
|
|
2839
|
+
/** Give an environment's serve lease back, if `claim` still holds it. */
|
|
2840
|
+
releaseEnvironmentServe(actor: PlatformActorId, input: {
|
|
2841
|
+
tenantId: TenantId;
|
|
2842
|
+
vertical: string;
|
|
2843
|
+
name: string;
|
|
2844
|
+
}, claim: string): Promise<void>;
|
|
2681
2845
|
/**
|
|
2682
2846
|
* Persist a tenant. Idempotent on the id — re-creating an existing tenant is a
|
|
2683
2847
|
* no-op, not an error (control-plane.md §4.1). `status` starts `active` and
|
|
@@ -4303,6 +4467,21 @@ export interface ProvisionScopeInput {
|
|
|
4303
4467
|
name?: string;
|
|
4304
4468
|
/** Which vertical's deployment executes this scope. Defaults to null. */
|
|
4305
4469
|
vertical?: string | null;
|
|
4470
|
+
/**
|
|
4471
|
+
* #2993: the scope's type, one the vertical declares (`scopeTypes` on its permission surface).
|
|
4472
|
+
* Defaults to `home`. Fixed when the scope is first provisioned: a re-provision naming another
|
|
4473
|
+
* type is refused (`conflict`), and one naming none keeps the recorded type.
|
|
4474
|
+
*/
|
|
4475
|
+
scopeType?: string;
|
|
4476
|
+
/**
|
|
4477
|
+
* #2995 (K-64): the scope this one is a CHILD of, in the same tenant and app. Written by the
|
|
4478
|
+
* `provision-child` drain alone, with the scope the intent was drained from, and never from a
|
|
4479
|
+
* request body: no route carries it. The host refuses a link its declaration does not allow
|
|
4480
|
+
* (`childScopeRefusal`) before anything is written, and the link is fixed once written
|
|
4481
|
+
* (`provisionedParent`): a re-provision restates it or names none. A host that cannot keep the
|
|
4482
|
+
* link refuses the field rather than provisioning a scope without it.
|
|
4483
|
+
*/
|
|
4484
|
+
parentScopeId?: ScopeId;
|
|
4306
4485
|
/**
|
|
4307
4486
|
* Where `vertical` came from, which decides what it is held to. `'input'` (the default): a
|
|
4308
4487
|
* caller named it, and it must be a `verticalSlug`. `'copy'`: it is the stored vertical of a
|
|
@@ -5302,6 +5481,27 @@ export interface ScopeHost {
|
|
|
5302
5481
|
* provisioned for the scope's vertical, exactly like `attachments`.
|
|
5303
5482
|
*/
|
|
5304
5483
|
getCapabilityAttachments?(sessionToken: string, tenantId: TenantId, scopeId: ScopeId): Promise<ScopeAttachments>;
|
|
5484
|
+
/**
|
|
5485
|
+
* A person's stub on a CHILD scope, minted for host code of its parent (#2995, K-64): the door a
|
|
5486
|
+
* parent's app calls a child through, between two of its own transactions. No operation reaches a
|
|
5487
|
+
* child: there is no `ctx.scope(id).invoke()`. An ordered exchange commits the parent's intent
|
|
5488
|
+
* first, host code calls through this door, and a second operation in the parent records the
|
|
5489
|
+
* outcome; the two invocations share a request id, never a transaction.
|
|
5490
|
+
*
|
|
5491
|
+
* What it checks, before anything runs: the (tenant, child) pair as every door does; that the
|
|
5492
|
+
* caller's scope is the child's own parent (`childDoorRefusal`: a sibling, another scope's child or
|
|
5493
|
+
* another tenant's scope is `not_found`); that the child's type accepts `parent`; that the parent
|
|
5494
|
+
* is active; and then the child's lifecycle gates, as `getScope` applies them.
|
|
5495
|
+
*
|
|
5496
|
+
* What it grants: nothing. The stub acts as `caller.actor`'s person, and every check in the child
|
|
5497
|
+
* is that person's own grants in the child, under the child's own permissions. The parent holds
|
|
5498
|
+
* no standing access to its child, so a person who holds a role at the parent and none at the
|
|
5499
|
+
* child is refused there like anyone else.
|
|
5500
|
+
*
|
|
5501
|
+
* OPTIONAL: a host that does not keep parent links (the Durable Object host, until #2995's hosted
|
|
5502
|
+
* half lands) does not have it, and a caller feature-detects it.
|
|
5503
|
+
*/
|
|
5504
|
+
getChildScope?(caller: ChildScopeCaller, tenantId: TenantId, scopeId: ScopeId, options?: PersonScopeOptions): Promise<ScopeStub>;
|
|
5305
5505
|
/**
|
|
5306
5506
|
* A scope stub whose authority is ANOTHER VERTICAL of the same tenant (#1706) — the sixth door,
|
|
5307
5507
|
* beside the principal, connection, system, impersonation and capability ones, and a door
|