@substrat-run/kernel 0.220.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.
Files changed (51) hide show
  1. package/dist/adopt-major.d.ts +150 -0
  2. package/dist/adopt-major.d.ts.map +1 -0
  3. package/dist/adopt-major.js +150 -0
  4. package/dist/adopt-major.js.map +1 -0
  5. package/dist/app-environments.d.ts +54 -3
  6. package/dist/app-environments.d.ts.map +1 -1
  7. package/dist/app-environments.js +126 -3
  8. package/dist/app-environments.js.map +1 -1
  9. package/dist/carried-copy.d.ts.map +1 -1
  10. package/dist/carried-copy.js +3 -0
  11. package/dist/carried-copy.js.map +1 -1
  12. package/dist/directory-lake-keep.d.ts.map +1 -1
  13. package/dist/directory-lake-keep.js +1 -0
  14. package/dist/directory-lake-keep.js.map +1 -1
  15. package/dist/index.d.ts +9 -5
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +10 -3
  18. package/dist/index.js.map +1 -1
  19. package/dist/permission-checker.d.ts.map +1 -1
  20. package/dist/permission-checker.js +4 -2
  21. package/dist/permission-checker.js.map +1 -1
  22. package/dist/reserved-roles.d.ts +6 -1
  23. package/dist/reserved-roles.d.ts.map +1 -1
  24. package/dist/reserved-roles.js.map +1 -1
  25. package/dist/schedule-due.d.ts +88 -0
  26. package/dist/schedule-due.d.ts.map +1 -0
  27. package/dist/schedule-due.js +116 -0
  28. package/dist/schedule-due.js.map +1 -0
  29. package/dist/schedule-state.d.ts +1 -1
  30. package/dist/schedule-state.d.ts.map +1 -1
  31. package/dist/schedule-state.js +6 -0
  32. package/dist/schedule-state.js.map +1 -1
  33. package/dist/scope-copy.d.ts.map +1 -1
  34. package/dist/scope-copy.js +7 -1
  35. package/dist/scope-copy.js.map +1 -1
  36. package/dist/scope-host.d.ts +138 -2
  37. package/dist/scope-host.d.ts.map +1 -1
  38. package/dist/scope-host.js.map +1 -1
  39. package/dist/scope-store.d.ts +30 -6
  40. package/dist/scope-store.d.ts.map +1 -1
  41. package/dist/scope-store.js +30 -1
  42. package/dist/scope-store.js.map +1 -1
  43. package/dist/scope-types.d.ts +107 -3
  44. package/dist/scope-types.d.ts.map +1 -1
  45. package/dist/scope-types.js +153 -2
  46. package/dist/scope-types.js.map +1 -1
  47. package/dist/store-proof.d.ts +45 -0
  48. package/dist/store-proof.d.ts.map +1 -0
  49. package/dist/store-proof.js +97 -0
  50. package/dist/store-proof.js.map +1 -0
  51. package/package.json +2 -2
@@ -0,0 +1,150 @@
1
+ /**
2
+ * K-65 between majors (#3539 part 3): the rules behind an install's move from an earlier major of a
3
+ * listed app to the newest one, the refusal of a bind that would name a version of another major,
4
+ * and the notice each install is shown. Pure, so both the control plane and a test can hold them.
5
+ *
6
+ * An install of a listed app follows its publisher within its major (K-65). A new major is served
7
+ * from a script of its own (#3539 part 2), and the installs of the earlier major stay on theirs.
8
+ * An install moves to the new major only when its tenant chooses to, through the hop K-33 already
9
+ * has: export from the script that holds its data, restore into the new major's script, then flip
10
+ * the route. These rules are what the control plane judges before anything moves.
11
+ */
12
+ import type { EarlierMajor } from '@substrat-run/contracts';
13
+ /** The `reason` a move between majors carries when the two majors' migrations cannot be judged compatible. */
14
+ export declare const MAJOR_MIGRATIONS_DIVERGE_REASON = "major_migrations_diverge";
15
+ /** The `reason` a bind carries when it would name a version of another major than its script serves. */
16
+ export declare const CROSS_MAJOR_BIND_REASON = "cross_major_bind";
17
+ /** A vertical's serving state, as the rules here read it: the newest major's script, and the earlier ones'. */
18
+ export interface MajorsServed {
19
+ /** The newest major's serving script and the version it runs, with that version's label. */
20
+ readonly current: {
21
+ readonly ref: string;
22
+ readonly versionId: string;
23
+ readonly version: string;
24
+ } | null;
25
+ /** Every earlier major still served, oldest first (`verticals.earlier_majors`). */
26
+ readonly earlier: readonly EarlierMajor[];
27
+ }
28
+ /** Which major a serving script serves, and the version it runs: the current one, an earlier one, or none. */
29
+ export type ScriptMajor = {
30
+ readonly kind: 'current';
31
+ readonly major: number | null;
32
+ readonly versionId: string;
33
+ } | {
34
+ readonly kind: 'earlier';
35
+ readonly major: number;
36
+ readonly versionId: string;
37
+ readonly entry: EarlierMajor;
38
+ };
39
+ /**
40
+ * The major `ref` serves, or `null` when it is none of the vertical's serving scripts (a scope on
41
+ * per-version dispatch, or one pinned to a script the directory no longer names). The current
42
+ * major's number is read from its version label, so a label that is not semver gives `null`.
43
+ */
44
+ export declare function scriptMajorOf(ref: string | null | undefined, served: MajorsServed): ScriptMajor | null;
45
+ /** One side of a move between majors: the version a script runs, and the migrations stored for it. */
46
+ export interface MajorSide {
47
+ readonly major: number;
48
+ readonly version: string;
49
+ /** The version's stored migrations (`versionMigrations`), or `null` when none are stored to show. */
50
+ readonly migrations: readonly {
51
+ readonly moduleId: string;
52
+ readonly version: string;
53
+ readonly sql: string;
54
+ }[] | null;
55
+ }
56
+ /**
57
+ * Why a scope that ran `from`'s migrations cannot be moved onto a script that runs `to`'s, or `null`
58
+ * when it can. Judged before anything moves, because the scope's journal travels with its data, and
59
+ * the destination's next migration pass fails the scope closed on a journal it cannot trust (#2066)
60
+ * — after the route has flipped, which is the one place the move must not fail.
61
+ *
62
+ * For every module both versions register, `from`'s authored migrations, in order, must be the
63
+ * first of `to`'s, with the same SQL: the append-only rule `lint:migration-ledger` holds within a
64
+ * lineage, applied across the two majors. `to` then applies only what follows them. A module that
65
+ * only `from` registers is left behind: its journal rows and tables stay, and nothing runs them. A
66
+ * migration the kernel derives from a declaration (`search/…`, `state/…`, `list/…`) is never compared,
67
+ * as `migrationSetDigest` does not compare it. A side whose migrations are not stored cannot be
68
+ * judged, and is refused: nothing else can say the move is safe.
69
+ */
70
+ export declare function majorMigrationsRefusal(input: {
71
+ readonly vertical: string;
72
+ readonly from: MajorSide;
73
+ readonly to: MajorSide;
74
+ }): string | null;
75
+ /**
76
+ * Why binding a scope pinned to `servingRef` to `target` is refused, or `null` (K-65, #3539 part 3).
77
+ *
78
+ * A scope on a serving script runs what that script runs, whatever version it is bound to: the bind
79
+ * moves only its pointer. Within one major that pointer is the install's acknowledgement of what it
80
+ * already runs. Bound to a version of ANOTHER major, it would name code the scope does not run, and
81
+ * an Update would read as a move to the new major while the scope stayed on the old one. The move
82
+ * between majors is its own act, which carries the data (`adopt-major`).
83
+ *
84
+ * Judged only for a vertical that serves more than one major, on a scope pinned to one of its
85
+ * serving scripts, and only when both majors can be read. Everything else is not refused here.
86
+ */
87
+ export declare function crossMajorBindRefusal(input: {
88
+ readonly vertical: string;
89
+ readonly scopeId: string;
90
+ readonly servingRef: string | null | undefined;
91
+ readonly served: MajorsServed;
92
+ readonly target: {
93
+ readonly versionId: string;
94
+ readonly version: string;
95
+ };
96
+ }): string | null;
97
+ /** One version, as a notice names it. */
98
+ export interface NoticeVersion {
99
+ readonly versionId: string;
100
+ readonly version: string;
101
+ }
102
+ /**
103
+ * What an install is told about its app's releases (K-65, #3539 part 3). Derived from the directory
104
+ * on every read, never stored: a row per install per release is the directory growing with tenants
105
+ * times time, which the target architecture refuses to deepen.
106
+ */
107
+ export interface InstallReleaseNotice {
108
+ /** What the install runs, and its major (`null` when the label is not semver). Null when nothing can be named. */
109
+ readonly running: (NoticeVersion & {
110
+ readonly major: number | null;
111
+ }) | null;
112
+ /**
113
+ * A release within the install's major that already runs for it, and that its version pointer has
114
+ * not caught up with: the install follows its publisher within a major, so the update was applied,
115
+ * and this is it being told. `badge` is K-33's: `schema-change` when the two versions' migration
116
+ * digests differ, else `code-only`. Null when the pointer names what runs, or another major.
117
+ */
118
+ readonly update: {
119
+ readonly from: NoticeVersion;
120
+ readonly to: NoticeVersion;
121
+ readonly badge: 'code-only' | 'schema-change';
122
+ } | null;
123
+ /**
124
+ * A newer major, served beside the install's own, that the install moves to only by its tenant's
125
+ * choice (`adopt-major`). `endsAt` is when the install's own major stops being served, as recorded
126
+ * at the new major's release; what happens then is not decided (K-65). Null on the newest major.
127
+ */
128
+ readonly newerMajor: (NoticeVersion & {
129
+ readonly major: number | null;
130
+ readonly endsAt: string;
131
+ }) | null;
132
+ }
133
+ /** A version as the notice reads it: its label and its migration digest. */
134
+ export interface NoticeVersionFacts {
135
+ readonly version: string;
136
+ readonly migrationDigest: string;
137
+ }
138
+ /**
139
+ * The notice for one install. `versions` holds the facts of every version named here that the
140
+ * reader could find; a version it could not find is left out of the notice rather than guessed.
141
+ */
142
+ export declare function installReleaseNoticeOf(input: {
143
+ readonly scope: {
144
+ readonly verticalVersionId?: string | null | undefined;
145
+ readonly servingRef?: string | null | undefined;
146
+ };
147
+ readonly served: MajorsServed;
148
+ readonly versions: ReadonlyMap<string, NoticeVersionFacts>;
149
+ }): InstallReleaseNotice;
150
+ //# sourceMappingURL=adopt-major.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adopt-major.d.ts","sourceRoot":"","sources":["../src/adopt-major.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAI5D,8GAA8G;AAC9G,eAAO,MAAM,+BAA+B,6BAA6B,CAAC;AAE1E,wGAAwG;AACxG,eAAO,MAAM,uBAAuB,qBAAqB,CAAC;AAE1D,+GAA+G;AAC/G,MAAM,WAAW,YAAY;IAC3B,4FAA4F;IAC5F,QAAQ,CAAC,OAAO,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACxG,mFAAmF;IACnF,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,CAAC;CAC3C;AAED,8GAA8G;AAC9G,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACvF;IAA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AQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;CAC5D,GAAG,oBAAoB,CAiCvB"}
@@ -0,0 +1,150 @@
1
+ import { isDerivedMigrationVersion } from './migration-digest.js';
2
+ import { majorOf } from './release-within-major.js';
3
+ /** The `reason` a move between majors carries when the two majors' migrations cannot be judged compatible. */
4
+ export const MAJOR_MIGRATIONS_DIVERGE_REASON = 'major_migrations_diverge';
5
+ /** The `reason` a bind carries when it would name a version of another major than its script serves. */
6
+ export const CROSS_MAJOR_BIND_REASON = 'cross_major_bind';
7
+ /**
8
+ * The major `ref` serves, or `null` when it is none of the vertical's serving scripts (a scope on
9
+ * per-version dispatch, or one pinned to a script the directory no longer names). The current
10
+ * major's number is read from its version label, so a label that is not semver gives `null`.
11
+ */
12
+ export function scriptMajorOf(ref, served) {
13
+ if (!ref)
14
+ return null;
15
+ if (served.current && ref === served.current.ref) {
16
+ return { kind: 'current', major: majorOf(served.current.version), versionId: served.current.versionId };
17
+ }
18
+ const entry = served.earlier.find((m) => m.ref === ref);
19
+ return entry ? { kind: 'earlier', major: entry.major, versionId: entry.versionId, entry } : null;
20
+ }
21
+ /** How many divergent migrations a refusal names before it counts the rest. */
22
+ const NAMED = 5;
23
+ /**
24
+ * Why a scope that ran `from`'s migrations cannot be moved onto a script that runs `to`'s, or `null`
25
+ * when it can. Judged before anything moves, because the scope's journal travels with its data, and
26
+ * the destination's next migration pass fails the scope closed on a journal it cannot trust (#2066)
27
+ * — after the route has flipped, which is the one place the move must not fail.
28
+ *
29
+ * For every module both versions register, `from`'s authored migrations, in order, must be the
30
+ * first of `to`'s, with the same SQL: the append-only rule `lint:migration-ledger` holds within a
31
+ * lineage, applied across the two majors. `to` then applies only what follows them. A module that
32
+ * only `from` registers is left behind: its journal rows and tables stay, and nothing runs them. A
33
+ * migration the kernel derives from a declaration (`search/…`, `state/…`, `list/…`) is never compared,
34
+ * as `migrationSetDigest` does not compare it. A side whose migrations are not stored cannot be
35
+ * judged, and is refused: nothing else can say the move is safe.
36
+ */
37
+ export function majorMigrationsRefusal(input) {
38
+ const { vertical, from, to } = input;
39
+ const subject = `moving an install of '${vertical}' from major ${from.major} (${from.version}) to major ${to.major} (${to.version})`;
40
+ const missing = [from, to].filter((s) => s.migrations === null).map((s) => s.version);
41
+ if (missing.length > 0) {
42
+ return (`${subject} is refused: no migrations are stored for ${missing.join(' and ')} (pushed before they were carried, or ` +
43
+ `over the push's caps), so whether its scopes can run the newer major's migrations cannot be judged. Nothing was moved.`);
44
+ }
45
+ const byModule = (ms) => {
46
+ const out = new Map();
47
+ for (const m of ms ?? []) {
48
+ if (isDerivedMigrationVersion(m.version))
49
+ continue;
50
+ const list = out.get(m.moduleId) ?? [];
51
+ list.push(m);
52
+ out.set(m.moduleId, list);
53
+ }
54
+ return out;
55
+ };
56
+ const before = byModule(from.migrations);
57
+ const after = byModule(to.migrations);
58
+ const diverged = [];
59
+ for (const [moduleId, applied] of before) {
60
+ const next = after.get(moduleId);
61
+ if (!next)
62
+ continue;
63
+ for (let i = 0; i < applied.length; i++) {
64
+ const a = applied[i];
65
+ const b = next[i];
66
+ if (!b) {
67
+ diverged.push(`${moduleId}@${a.version} is not in major ${to.major}`);
68
+ break;
69
+ }
70
+ if (b.version !== a.version) {
71
+ diverged.push(`${moduleId}@${a.version} is followed in major ${to.major} by ${moduleId}@${b.version} in its place`);
72
+ break;
73
+ }
74
+ if (b.sql !== a.sql) {
75
+ diverged.push(`${moduleId}@${a.version} has different SQL in major ${to.major}`);
76
+ break;
77
+ }
78
+ }
79
+ }
80
+ if (diverged.length === 0)
81
+ return null;
82
+ const more = diverged.length > NAMED ? `; and ${diverged.length - NAMED} more` : '';
83
+ return (`${subject} is refused: its scopes have applied migrations major ${to.major} does not continue from ` +
84
+ `(${diverged.slice(0, NAMED).join('; ')}${more}). The newer major's next migration pass would fail the scope closed ` +
85
+ `after its route had moved. A migration is never edited, removed or renumbered once shipped: the publisher releases a ` +
86
+ `major whose migrations continue from the earlier one's. Nothing was moved.`);
87
+ }
88
+ /**
89
+ * Why binding a scope pinned to `servingRef` to `target` is refused, or `null` (K-65, #3539 part 3).
90
+ *
91
+ * A scope on a serving script runs what that script runs, whatever version it is bound to: the bind
92
+ * moves only its pointer. Within one major that pointer is the install's acknowledgement of what it
93
+ * already runs. Bound to a version of ANOTHER major, it would name code the scope does not run, and
94
+ * an Update would read as a move to the new major while the scope stayed on the old one. The move
95
+ * between majors is its own act, which carries the data (`adopt-major`).
96
+ *
97
+ * Judged only for a vertical that serves more than one major, on a scope pinned to one of its
98
+ * serving scripts, and only when both majors can be read. Everything else is not refused here.
99
+ */
100
+ export function crossMajorBindRefusal(input) {
101
+ const { vertical, scopeId, served, target } = input;
102
+ if (served.earlier.length === 0)
103
+ return null;
104
+ const on = scriptMajorOf(input.servingRef, served);
105
+ if (!on || on.major === null)
106
+ return null;
107
+ const targetMajor = majorOf(target.version);
108
+ if (targetMajor === null || targetMajor === on.major)
109
+ return null;
110
+ return (`binding scope ${scopeId} of '${vertical}' to ${target.version} is refused: the scope is served by major ${on.major}'s ` +
111
+ `script, so it would still run major ${on.major} while its version said major ${targetMajor} (K-65). A move to ` +
112
+ `another major carries the scope's data onto that major's script: POST /tenants/:tenantId/scopes/:scopeId/adopt-major.`);
113
+ }
114
+ /**
115
+ * The notice for one install. `versions` holds the facts of every version named here that the
116
+ * reader could find; a version it could not find is left out of the notice rather than guessed.
117
+ */
118
+ export function installReleaseNoticeOf(input) {
119
+ const { scope, served, versions } = input;
120
+ const on = scriptMajorOf(scope.servingRef, served);
121
+ const runningId = on ? on.versionId : (scope.verticalVersionId ?? null);
122
+ const runningFacts = runningId ? versions.get(runningId) : undefined;
123
+ const running = runningId && runningFacts
124
+ ? { versionId: runningId, version: runningFacts.version, major: majorOf(runningFacts.version) }
125
+ : null;
126
+ let update = null;
127
+ const boundId = scope.verticalVersionId ?? null;
128
+ const boundFacts = boundId ? versions.get(boundId) : undefined;
129
+ if (running && runningFacts && boundId && boundFacts && boundId !== running.versionId
130
+ && majorOf(boundFacts.version) === running.major) {
131
+ update = {
132
+ from: { versionId: boundId, version: boundFacts.version },
133
+ to: { versionId: running.versionId, version: running.version },
134
+ badge: boundFacts.migrationDigest === runningFacts.migrationDigest ? 'code-only' : 'schema-change',
135
+ };
136
+ }
137
+ let newerMajor = null;
138
+ const current = served.current;
139
+ const currentFacts = current ? versions.get(current.versionId) : undefined;
140
+ if (on?.kind === 'earlier' && current && currentFacts) {
141
+ newerMajor = {
142
+ versionId: current.versionId,
143
+ version: currentFacts.version,
144
+ major: majorOf(currentFacts.version),
145
+ endsAt: on.entry.endsAt,
146
+ };
147
+ }
148
+ return { running, update, newerMajor };
149
+ }
150
+ //# sourceMappingURL=adopt-major.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adopt-major.js","sourceRoot":"","sources":["../src/adopt-major.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,8GAA8G;AAC9G,MAAM,CAAC,MAAM,+BAA+B,GAAG,0BAA0B,CAAC;AAE1E,wGAAwG;AACxG,MAAM,CAAC,MAAM,uBAAuB,GAAG,kBAAkB,CAAC;AAe1D;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,GAA8B,EAAE,MAAoB;IAChF,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtB,IAAI,MAAM,CAAC,OAAO,IAAI,GAAG,KAAK,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QACjD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;IAC1G,CAAC;IACD,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AO,CAAC,KAAK,OAAO,CAAC,KAAK,EAAE,CAAC;QACnD,MAAM,GAAG;YACP,IAAI,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE;YACzD,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE;YAC9D,KAAK,EAAE,UAAU,CAAC,eAAe,KAAK,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe;SACnG,CAAC;IACJ,CAAC;IAED,IAAI,UAAU,GAAuC,IAAI,CAAC;IAC1D,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC/B,MAAM,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3E,IAAI,EAAE,EAAE,IAAI,KAAK,SAAS,IAAI,OAAO,IAAI,YAAY,EAAE,CAAC;QACtD,UAAU,GAAG;YACX,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,OAAO,EAAE,YAAY,CAAC,OAAO;YAC7B,KAAK,EAAE,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC;YACpC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM;SACxB,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AACzC,CAAC"}
@@ -13,13 +13,35 @@
13
13
  * written only over a preview that exists, is active and is pinned (no expiry), so an environment is
14
14
  * never a pointer without scopes, which is what `dev` and `staging` were when #509 retired them.
15
15
  *
16
- * What is deliberately not here: a serving script of the environment's own, edges, connections and
17
- * a broker per environment (D-83 steps 4 to 6). A named environment is a preview, so it is inert.
16
+ * **A named environment may serve from a script of its own** (#3530 step 4). Its first serve uploads
17
+ * a version onto a fresh script and moves the preview's data there once; every later serve replaces
18
+ * that script in place and moves only the version pointer, as production's serve does (K-33). The
19
+ * record is four columns on the row (`APP_ENVIRONMENT_SERVING_COLUMNS`), NULL until the first serve,
20
+ * so a row from before reads as an environment with no script, which is what it is. The script is
21
+ * fixed for the environment's life: a serve that names another one is refused.
22
+ *
23
+ * What is deliberately not here: edges, connections and a broker per environment (D-83 steps 5 and
24
+ * 6). A named environment's scope is a preview, so it is inert wherever it is served from.
18
25
  */
19
- import { type AppEnvironment, type ScopeId, type TenantId } from '@substrat-run/contracts';
26
+ import { type AppEnvironment, type EnvironmentServing, type ScopeId, type TenantId } from '@substrat-run/contracts';
20
27
  import type { SwitchSql } from './system-switch.js';
21
28
  /** Directory-owned, on both adapters. One row per named environment; production has none. */
22
29
  export declare const APP_ENVIRONMENTS_DDL = "\n CREATE TABLE IF NOT EXISTS app_environments (\n tenant_id TEXT NOT NULL,\n vertical TEXT NOT NULL,\n name TEXT NOT NULL,\n created_at TEXT NOT NULL,\n created_by TEXT NOT NULL,\n PRIMARY KEY (tenant_id, vertical, name)\n );\n";
30
+ /**
31
+ * #3530 step 4: what an environment's own serving script runs, ALTERed onto `app_environments` by
32
+ * both adapters (and copied into the K-68 objects' column list), all NULL until its first serve.
33
+ * `serving_ref` is the script; `serving_version_id` the version last uploaded onto it;
34
+ * `serving_do_classes` (JSON array) and `serving_migration_tag` what the next in-place upload diffs
35
+ * its Durable Object migrations against, as `verticals.serving_*` are for production.
36
+ */
37
+ export declare const APP_ENVIRONMENT_SERVING_COLUMNS: readonly ['serving_ref TEXT', 'serving_version_id TEXT', 'serving_do_classes TEXT', 'serving_migration_tag TEXT', 'serve_claim TEXT', 'serve_claimed_until TEXT'];
38
+ /**
39
+ * SQL: joins `ae`, the environment whose own script the scope `s` is served from, to a read over
40
+ * `scopes s`. Null for every scope that is not on one: production's installs, a preview on its
41
+ * version's script, a fork on its copy's. Keyed by the table's primary key prefix, so it is a range
42
+ * read of one tenant's environments of one app, empty for an app that has none.
43
+ */
44
+ export declare const ENVIRONMENT_SCRIPT_JOIN_SQL = "LEFT JOIN app_environments ae ON ae.tenant_id = s.tenant_id AND ae.vertical = s.vertical AND ae.serving_ref = s.serving_ref";
23
45
  /**
24
46
  * A preview's scope slug: `<app>--<tag>`, the app's last path segment (`t-acme/crm` → `crm`). The
25
47
  * preview routes find a tag by it, and an environment finds its preview by it.
@@ -59,4 +81,33 @@ export declare function removeEnvironmentIn(sql: SwitchSql, input: DefineEnviron
59
81
  removed: boolean;
60
82
  scopeId: ScopeId | null;
61
83
  };
84
+ /**
85
+ * Record what an environment's own script now runs (#3530 step 4), written only after the upload
86
+ * landed, in the caller's one directory transaction with its admin row. A compare-and-set on
87
+ * `expected`, the record the caller's upload diffed its migrations from (null: the first serve), as
88
+ * `setVerticalServing` is for production: `moved: false`, with nothing written, when the row holds
89
+ * another record now. Refused: a name that is no environment (`not_found`); another script than the
90
+ * one the environment already serves from (`conflict`, since the data lives there); a class set
91
+ * that drops a class the script already has (`validation_failed`: a class's storage cannot go).
92
+ */
93
+ export declare function setEnvironmentServingIn(sql: SwitchSql, input: DefineEnvironmentInput, next: EnvironmentServing, expected: EnvironmentServing | null,
94
+ /** The serve's claim (`claimEnvironmentServeIn`): the record lands only while it is still the one held. */
95
+ claim?: string): {
96
+ moved: boolean;
97
+ before: EnvironmentServing | null;
98
+ scopeId: ScopeId | null;
99
+ };
100
+ /**
101
+ * Take the environment's serve lease (#3530 step 4), so its serves run one at a time: a serve uploads
102
+ * onto the script before it records what it uploaded, and two at once could leave the script running
103
+ * the one whose record lost. True when `claim` now holds it: none was held, the one held has lapsed
104
+ * (`until` before `now`), or it is `claim`'s own (renewed). False while another live claim holds it.
105
+ * `not_found` for a name that is no environment.
106
+ */
107
+ export declare function claimEnvironmentServeIn(sql: SwitchSql, input: DefineEnvironmentInput, claim: string, at: {
108
+ now: string;
109
+ until: string;
110
+ }): boolean;
111
+ /** Give the serve lease back. Only `claim`'s own: a lapsed claim taken over since is left to its holder. */
112
+ export declare function releaseEnvironmentServeIn(sql: SwitchSql, input: DefineEnvironmentInput, claim: string): void;
62
113
  //# sourceMappingURL=app-environments.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"app-environments.d.ts","sourceRoot":"","sources":["../src/app-environments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAA0D,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnJ,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,6FAA6F;AAC7F,eAAO,MAAM,oBAAoB,6PAShC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,aAAc,MAAM,OAAO,MAAM,KAAG,MAAiD,CAAC;AAwBnH;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,EAAE,CAsBrG;AAED,0GAA0G;AAC1G,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAEzG;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,sBAAsB,EAC7B,KAAK,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,WAAW,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAwBrE;AAED;;;GAGG;AACH,wBAAgB,mB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CACjC,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,sBAAsB,EAC7B,KAAK,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,WAAW,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAwBrE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,sBAAsB,GAC5B;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,CAmB/C;AAkBD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,sBAAsB,EAC7B,IAAI,EAAE,kBAAkB,EACxB,QAAQ,EAAE,kBAAkB,GAAG,IAAI;AACnC,2GAA2G;AAC3G,KAAK,CAAC,EAAE,MAAM,GACb;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,CAsBhF;AAgBD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,sBAAsB,EAC7B,KAAK,EAAE,MAAM,EACb,EAAE,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjC,OAAO,CAST;AAED,4GAA4G;AAC5G,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,sBAAsB,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAM5G"}
@@ -13,8 +13,15 @@
13
13
  * written only over a preview that exists, is active and is pinned (no expiry), so an environment is
14
14
  * never a pointer without scopes, which is what `dev` and `staging` were when #509 retired them.
15
15
  *
16
- * What is deliberately not here: a serving script of the environment's own, edges, connections and
17
- * a broker per environment (D-83 steps 4 to 6). A named environment is a preview, so it is inert.
16
+ * **A named environment may serve from a script of its own** (#3530 step 4). Its first serve uploads
17
+ * a version onto a fresh script and moves the preview's data there once; every later serve replaces
18
+ * that script in place and moves only the version pointer, as production's serve does (K-33). The
19
+ * record is four columns on the row (`APP_ENVIRONMENT_SERVING_COLUMNS`), NULL until the first serve,
20
+ * so a row from before reads as an environment with no script, which is what it is. The script is
21
+ * fixed for the environment's life: a serve that names another one is refused.
22
+ *
23
+ * What is deliberately not here: edges, connections and a broker per environment (D-83 steps 5 and
24
+ * 6). A named environment's scope is a preview, so it is inert wherever it is served from.
18
25
  */
19
26
  import { PRODUCTION_ENVIRONMENT, environmentName, substratError } from '@substrat-run/contracts';
20
27
  import { isPrimaryScopeRow } from './scope-identity.js';
@@ -29,6 +36,43 @@ export const APP_ENVIRONMENTS_DDL = `
29
36
  PRIMARY KEY (tenant_id, vertical, name)
30
37
  );
31
38
  `;
39
+ /**
40
+ * #3530 step 4: what an environment's own serving script runs, ALTERed onto `app_environments` by
41
+ * both adapters (and copied into the K-68 objects' column list), all NULL until its first serve.
42
+ * `serving_ref` is the script; `serving_version_id` the version last uploaded onto it;
43
+ * `serving_do_classes` (JSON array) and `serving_migration_tag` what the next in-place upload diffs
44
+ * its Durable Object migrations against, as `verticals.serving_*` are for production.
45
+ */
46
+ export const APP_ENVIRONMENT_SERVING_COLUMNS = [
47
+ 'serving_ref TEXT',
48
+ 'serving_version_id TEXT',
49
+ 'serving_do_classes TEXT',
50
+ 'serving_migration_tag TEXT',
51
+ // The serve in flight: its claim id and the instant its lease ends. A serve uploads onto the
52
+ // script before it records, so two at once could leave the script running the one whose record
53
+ // lost; the lease makes them one at a time (`claimEnvironmentServeIn`).
54
+ 'serve_claim TEXT',
55
+ 'serve_claimed_until TEXT',
56
+ ];
57
+ /**
58
+ * SQL: joins `ae`, the environment whose own script the scope `s` is served from, to a read over
59
+ * `scopes s`. Null for every scope that is not on one: production's installs, a preview on its
60
+ * version's script, a fork on its copy's. Keyed by the table's primary key prefix, so it is a range
61
+ * read of one tenant's environments of one app, empty for an app that has none.
62
+ */
63
+ export const ENVIRONMENT_SCRIPT_JOIN_SQL = 'LEFT JOIN app_environments ae ON ae.tenant_id = s.tenant_id AND ae.vertical = s.vertical AND ae.serving_ref = s.serving_ref';
64
+ const servingOfRow = (r) => r.serving_ref && r.serving_version_id
65
+ ? {
66
+ ref: r.serving_ref,
67
+ versionId: r.serving_version_id,
68
+ doClasses: r.serving_do_classes ? JSON.parse(r.serving_do_classes) : [],
69
+ migrationTag: r.serving_migration_tag ?? 'v1',
70
+ }
71
+ : null;
72
+ const sameServing = (a, b) => a === null || b === null
73
+ ? a === b
74
+ : a.ref === b.ref && a.versionId === b.versionId && a.migrationTag === b.migrationTag &&
75
+ JSON.stringify([...a.doClasses].sort()) === JSON.stringify([...b.doClasses].sort());
32
76
  /**
33
77
  * A preview's scope slug: `<app>--<tag>`, the app's last path segment (`t-acme/crm` → `crm`). The
34
78
  * preview routes find a tag by it, and an environment finds its preview by it.
@@ -52,7 +96,8 @@ export function environmentsOf(sql, tenantId, vertical) {
52
96
  scopeIds: scopes.filter((s) => isPrimaryScopeRow(s)).map((s) => s.scope_id),
53
97
  createdAt: null, createdBy: null,
54
98
  };
55
- const rows = sql.all('SELECT name, created_at, created_by FROM app_environments WHERE tenant_id = ? AND vertical = ? ORDER BY name', tenantId, vertical);
99
+ const rows = sql.all(`SELECT name, created_at, created_by, serving_ref, serving_version_id, serving_do_classes, serving_migration_tag
100
+ FROM app_environments WHERE tenant_id = ? AND vertical = ? ORDER BY name`, tenantId, vertical);
56
101
  return [
57
102
  production,
58
103
  ...rows.map((r) => {
@@ -61,6 +106,7 @@ export function environmentsOf(sql, tenantId, vertical) {
61
106
  tenantId, vertical, name: r.name, production: false,
62
107
  scopeIds: preview ? [preview.scope_id] : [],
63
108
  createdAt: r.created_at, createdBy: r.created_by,
109
+ serving: servingOfRow(r),
64
110
  };
65
111
  }),
66
112
  ];
@@ -110,7 +156,84 @@ export function removeEnvironmentIn(sql, input) {
110
156
  if (!isEnvironmentTag(sql, tenantId, vertical, name))
111
157
  return { removed: false, scopeId: null };
112
158
  const preview = previewOf(liveScopesOf(sql, tenantId, vertical), vertical, name);
159
+ // #3530 step 4: an environment served from its own script keeps its data there. Taking the name
160
+ // off would leave a preview on a script nothing names, whose route then runs another version's
161
+ // policy, so the name goes only with the data (the preview reaped first) or before any serve. An
162
+ // archived preview counts: it keeps its data, and an unarchive would bring it back.
163
+ const serving = rowServing(sql, input);
164
+ if (serving && unreapedPreviewOf(sql, input)) {
165
+ throw substratError('conflict', `the environment '${name}' serves from a script of its own, where its data lives: delete the environment with ` +
166
+ `its data (substrat environment rm ${name} --delete-data), which reaps its preview first`);
167
+ }
113
168
  sql.run('DELETE FROM app_environments WHERE tenant_id = ? AND vertical = ? AND name = ?', tenantId, vertical, name);
114
169
  return { removed: true, scopeId: preview?.scope_id ?? null };
115
170
  }
171
+ /** The environment's preview while its row is kept, archived included: only a reap ends its data. */
172
+ const unreapedPreviewOf = (sql, input) => sql.all(`SELECT scope_id FROM scopes WHERE tenant_id = ? AND vertical = ? AND kind = 'preview' AND slug = ? AND status != 'reaped'`, input.tenantId, input.vertical, previewScopeSlug(input.vertical, input.name))[0]?.scope_id;
173
+ const rowServing = (sql, input) => {
174
+ const row = sql.all(`SELECT serving_ref, serving_version_id, serving_do_classes, serving_migration_tag
175
+ FROM app_environments WHERE tenant_id = ? AND vertical = ? AND name = ?`, input.tenantId, input.vertical, input.name)[0];
176
+ return row ? servingOfRow(row) : null;
177
+ };
178
+ /**
179
+ * Record what an environment's own script now runs (#3530 step 4), written only after the upload
180
+ * landed, in the caller's one directory transaction with its admin row. A compare-and-set on
181
+ * `expected`, the record the caller's upload diffed its migrations from (null: the first serve), as
182
+ * `setVerticalServing` is for production: `moved: false`, with nothing written, when the row holds
183
+ * another record now. Refused: a name that is no environment (`not_found`); another script than the
184
+ * one the environment already serves from (`conflict`, since the data lives there); a class set
185
+ * that drops a class the script already has (`validation_failed`: a class's storage cannot go).
186
+ */
187
+ export function setEnvironmentServingIn(sql, input, next, expected,
188
+ /** The serve's claim (`claimEnvironmentServeIn`): the record lands only while it is still the one held. */
189
+ claim) {
190
+ const { tenantId, vertical, name } = input;
191
+ assertEnvironment(sql, input);
192
+ const before = rowServing(sql, input);
193
+ const preview = previewOf(liveScopesOf(sql, tenantId, vertical), vertical, name);
194
+ const scopeId = preview?.scope_id ?? null;
195
+ if (!sameServing(before, expected))
196
+ return { moved: false, before, scopeId };
197
+ if (claim !== undefined && claimOf(sql, input)?.claim !== claim)
198
+ return { moved: false, before, scopeId };
199
+ if (before && before.ref !== next.ref) {
200
+ throw substratError('conflict', `the environment '${name}' serves from the script '${before.ref}', where its data lives: it cannot move to '${next.ref}'`);
201
+ }
202
+ const dropped = before?.doClasses.filter((c) => !next.doClasses.includes(c)) ?? [];
203
+ if (dropped.length) {
204
+ throw substratError('validation_failed', `a serving script's Durable Object classes only grow: ${dropped.join(', ')} would be dropped`);
205
+ }
206
+ sql.run(`UPDATE app_environments SET serving_ref = ?, serving_version_id = ?, serving_do_classes = ?, serving_migration_tag = ?
207
+ WHERE tenant_id = ? AND vertical = ? AND name = ?`, next.ref, next.versionId, JSON.stringify(next.doClasses), next.migrationTag, tenantId, vertical, name);
208
+ return { moved: true, before, scopeId };
209
+ }
210
+ const assertEnvironment = (sql, input) => {
211
+ if (input.name === PRODUCTION_ENVIRONMENT || !isEnvironmentTag(sql, input.tenantId, input.vertical, input.name)) {
212
+ throw substratError('not_found', `'${input.vertical}' has no environment '${input.name}' in tenant ${input.tenantId}`);
213
+ }
214
+ };
215
+ const claimOf = (sql, input) => {
216
+ const row = sql.all('SELECT serve_claim, serve_claimed_until FROM app_environments WHERE tenant_id = ? AND vertical = ? AND name = ?', input.tenantId, input.vertical, input.name)[0];
217
+ return row?.serve_claim && row.serve_claimed_until ? { claim: row.serve_claim, until: row.serve_claimed_until } : null;
218
+ };
219
+ /**
220
+ * Take the environment's serve lease (#3530 step 4), so its serves run one at a time: a serve uploads
221
+ * onto the script before it records what it uploaded, and two at once could leave the script running
222
+ * the one whose record lost. True when `claim` now holds it: none was held, the one held has lapsed
223
+ * (`until` before `now`), or it is `claim`'s own (renewed). False while another live claim holds it.
224
+ * `not_found` for a name that is no environment.
225
+ */
226
+ export function claimEnvironmentServeIn(sql, input, claim, at) {
227
+ assertEnvironment(sql, input);
228
+ const held = claimOf(sql, input);
229
+ if (held && held.claim !== claim && held.until > at.now)
230
+ return false;
231
+ sql.run('UPDATE app_environments SET serve_claim = ?, serve_claimed_until = ? WHERE tenant_id = ? AND vertical = ? AND name = ?', claim, at.until, input.tenantId, input.vertical, input.name);
232
+ return true;
233
+ }
234
+ /** Give the serve lease back. Only `claim`'s own: a lapsed claim taken over since is left to its holder. */
235
+ export function releaseEnvironmentServeIn(sql, input, claim) {
236
+ sql.run(`UPDATE app_environments SET serve_claim = NULL, serve_claimed_until = NULL
237
+ WHERE tenant_id = ? AND vertical = ? AND name = ? AND serve_claim = ?`, input.tenantId, input.vertical, input.name, claim);
238
+ }
116
239
  //# sourceMappingURL=app-environments.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app-environments.js","sourceRoot":"","sources":["../src/app-environments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,aAAa,EAAoD,MAAM,yBAAyB,CAAC;AACnJ,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,6FAA6F;AAC7F,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;CASnC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAAgB,EAAE,GAAW,EAAU,EAAE,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC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M,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,wFAAwF;AACxF,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,OAAO,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMzH;AAED,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG3F;AAED,wEAAwE;AACxE,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,GAAG,cAAc,EAAE,CASrE"}
@@ -1,4 +1,5 @@
1
1
  import { MARK_COPY_ORIGIN_SQL } from './scope-copy.js';
2
+ import { SCOPE_TYPE_META_KEY } from './scope-types.js';
2
3
  /**
3
4
  * The copy a carry leaves behind (#1722), as two `_substrat_meta` keys.
4
5
  *
@@ -54,6 +55,8 @@ export const STORE_LOCAL_META_KEYS = [
54
55
  WRITE_REVISION_KEY,
55
56
  KEPT_DIVERGENT_KEY,
56
57
  COPY_MARK_CLEARED_KEY,
58
+ // #2993 part 3: a store's type is the one its own provision fixed, never a source's.
59
+ SCOPE_TYPE_META_KEY,
57
60
  ];
58
61
  /** The refusal a load into a kept copy answers (409). */
59
62
  export const KEPT_COPY_REFUSAL = 'this copy of the scope holds writes that were not carried to where the scope now runs (#1722); ' +