@substrat-run/adapter-cloudflare 0.226.0 → 0.229.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/control-plane-do.d.ts +9 -2
- package/dist/control-plane-do.d.ts.map +1 -1
- package/dist/control-plane-do.js +29 -5
- package/dist/control-plane-do.js.map +1 -1
- package/dist/delivery-broker-do.d.ts +13 -0
- package/dist/delivery-broker-do.d.ts.map +1 -1
- package/dist/delivery-broker-do.js +8 -1
- package/dist/delivery-broker-do.js.map +1 -1
- package/dist/delivery-broker-platform.d.ts +24 -2
- package/dist/delivery-broker-platform.d.ts.map +1 -1
- package/dist/delivery-broker-platform.js +43 -2
- package/dist/delivery-broker-platform.js.map +1 -1
- package/dist/delivery-handoff.d.ts +8 -1
- package/dist/delivery-handoff.d.ts.map +1 -1
- package/dist/delivery-handoff.js +8 -5
- package/dist/delivery-handoff.js.map +1 -1
- package/dist/host.d.ts +22 -4
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +61 -13
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/reconcile-on-wake.d.ts +17 -1
- package/dist/reconcile-on-wake.d.ts.map +1 -1
- package/dist/reconcile-on-wake.js +84 -12
- package/dist/reconcile-on-wake.js.map +1 -1
- package/dist/scope-do.d.ts.map +1 -1
- package/dist/scope-do.js +104 -17
- package/dist/scope-do.js.map +1 -1
- package/dist/scope-sweeper-do.d.ts +7 -1
- package/dist/scope-sweeper-do.d.ts.map +1 -1
- package/dist/scope-sweeper-do.js +17 -1
- package/dist/scope-sweeper-do.js.map +1 -1
- package/dist/scope-wake.d.ts +5 -0
- package/dist/scope-wake.d.ts.map +1 -1
- package/dist/scope-wake.js +2 -0
- package/dist/scope-wake.js.map +1 -1
- package/package.json +10 -10
package/dist/index.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export { defineCopyJobDO, type CopyJobDo, type CopyJobDoConfig, type CopyJobDoRe
|
|
|
32
32
|
export { defineScopeSweeperDO, SCOPE_SWEEPER_NAME } from './scope-sweeper-do.js';
|
|
33
33
|
export { defineDeliveryBrokerDO, type DeliveryBrokerDOClass, type DeliveryBrokerDeadLetterRpc, type DeliveryBrokerOptions, type DeliveryBrokerRelayRpc, type DeliveryBrokerRpc, type DeliveryBrokerSubscription, type DeliveryComparisonOptions, } from './delivery-broker-do.js';
|
|
34
34
|
export { DELIVERY_HANDOFF_KEY, DELIVERY_MODE_KEY, type DeliveryModeState, type HandoffState } from './delivery-handoff.js';
|
|
35
|
-
export { askControlPlaneToDrain, definePlatformDeliveryBrokerDO, registerPlatformDeliveryBroker, type PlatformBrokerEnv, type PlatformBrokerFactory, type ScopeDeliveryRpc, } from './delivery-broker-platform.js';
|
|
35
|
+
export { askControlPlaneToDrain, askControlPlaneToShip, lakeShipAnswerOf, definePlatformDeliveryBrokerDO, registerPlatformDeliveryBroker, type PlatformBrokerEnv, type PlatformBrokerFactory, type ScopeDeliveryRpc, } from './delivery-broker-platform.js';
|
|
36
36
|
export type { ScopeSweeperDo, ScopeSweeperDoConfig, ScopeSweepHost, ScopeSweepOutcome, ScopeSweepReport, } from './scope-sweeper-do.js';
|
|
37
37
|
export { createD1TenantStores, d1TenantRelationalStore, tenantStoreDatabaseName, } from './d1.js';
|
|
38
38
|
export type { D1TenantStores, D1TenantStoresOptions } from './d1.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,YAAY,EACV,0BAA0B,EAC1B,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,E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AY,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,7 @@ export { defineScopeSweeperDO, SCOPE_SWEEPER_NAME } from './scope-sweeper-do.js'
|
|
|
34
34
|
export { defineDeliveryBrokerDO, } from './delivery-broker-do.js';
|
|
35
35
|
export { DELIVERY_HANDOFF_KEY, DELIVERY_MODE_KEY } from './delivery-handoff.js';
|
|
36
36
|
// A5 (#3471): the broker the platform supplies to a pushed vertical, and what it reads.
|
|
37
|
-
export { askControlPlaneToDrain, definePlatformDeliveryBrokerDO, registerPlatformDeliveryBroker, } from './delivery-broker-platform.js';
|
|
37
|
+
export { askControlPlaneToDrain, askControlPlaneToShip, lakeShipAnswerOf, definePlatformDeliveryBrokerDO, registerPlatformDeliveryBroker, } from './delivery-broker-platform.js';
|
|
38
38
|
export { createD1TenantStores, d1TenantRelationalStore, tenantStoreDatabaseName, } from './d1.js';
|
|
39
39
|
export { blobStoreBucketName, createR2BlobStores, r2TenantBlobStore, } from './r2.js';
|
|
40
40
|
export { createRouteResolver } from './route-resolver.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAchD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,uGAAuG;AACvG,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAiE,MAAM,0BAA0B,CAAC;AACrJ,OAAO,EAAE,cAAc,EAAE,MAAM,oB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CAAC;AACjI,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACjF,OAAO,EACL,sBAAsB,GAQvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAA6C,MAAM,uBAAuB,CAAC;AAC3H,wFAAwF;AACxF,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,8BAA8B,EAC9B,8BAA8B,GAI/B,MAAM,+BAA+B,CAAC;AAQvC,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,iGAAiG;AACjG,mGAAmG;AACnG,OAAO,EACL,aAAa,EACb,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,GAKzB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAElG,0EAA0E;AAC1E,OAAO,EACL,oCAAoC,EACpC,gCAAgC,EAChC,sBAAsB,GACvB,MAAM,sBAAsB,CAAC"}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
/** The `_substrat_meta` key holding the version this scope last asked a reconcile for. */
|
|
2
2
|
export declare const RECONCILE_ASKED_KEY = "reconcile_asked_for";
|
|
3
|
+
/**
|
|
4
|
+
* The `_substrat_meta` key holding the ask the scope last wrote or leaned on, as JSON
|
|
5
|
+
* `{ id, asks }`: the intent's id, and how many asks the version in `RECONCILE_ASKED_KEY` has had.
|
|
6
|
+
* Read by primary key on every wake, so the never-pruned journal is never scanned to find it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const RECONCILE_ASK_KEY = "reconcile_ask";
|
|
9
|
+
/** How many asks one version gets before a scope leaves it to the batched pass. */
|
|
10
|
+
export declare const RECONCILE_ASKS_PER_VERSION = 3;
|
|
3
11
|
/** Who a `provision-reconcile` intent is requested by: the scope's host, never a person. */
|
|
4
12
|
export declare const RECONCILE_ON_WAKE_REQUESTED_BY: string;
|
|
5
13
|
/** What one wake did, for the caller's signal and a test's assertion. */
|
|
6
14
|
export type ReconcileOnWake =
|
|
7
15
|
/** An intent was written: the response that woke the scope should flag a drain. */
|
|
8
16
|
'requested'
|
|
9
|
-
/** Already asked for this version (or for an earlier one still pending): nothing written. */
|
|
17
|
+
/** Already asked for this version (or for an earlier one still pending), and the answer covers it or the version's asks are spent: nothing written. */
|
|
10
18
|
| 'asked'
|
|
11
19
|
/** A first provision: the platform's own provision marks the receipt; recorded, nothing asked. */
|
|
12
20
|
| 'first-provision'
|
|
@@ -37,4 +45,12 @@ export interface WakeSql {
|
|
|
37
45
|
* would then never be handed off.
|
|
38
46
|
*/
|
|
39
47
|
export declare function reconcileOnWake(sql: WakeSql, version: string | null | undefined, upgrade: boolean, now: string, mintId: () => string): ReconcileOnWake;
|
|
48
|
+
/**
|
|
49
|
+
* Whether a scope that already asked for `version` should ask again: the ask it last wrote or leaned
|
|
50
|
+
* on is settled, and either gave up or was answered for a version other than `version`, and `version`
|
|
51
|
+
* has not had `RECONCILE_ASKS_PER_VERSION` asks yet. A pending ask, an answer for `version`, a
|
|
52
|
+
* switched-off handler and a scope that is not an install all say no, and so does a scope that has
|
|
53
|
+
* no record of its ask (it recorded the version at its provision, or before this rule).
|
|
54
|
+
*/
|
|
55
|
+
export declare function reaskDue(sql: WakeSql, version: string): boolean;
|
|
40
56
|
//# sourceMappingURL=reconcile-on-wake.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconcile-on-wake.d.ts","sourceRoot":"","sources":["../src/reconcile-on-wake.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reconcile-on-wake.d.ts","sourceRoot":"","sources":["../src/reconcile-on-wake.ts"],"names":[],"mappings":"AAgDA,0FAA0F;AAC1F,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAEzD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD,mFAAmF;AACnF,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C,4FAA4F;AAC5F,eAAO,MAAM,8BAA8B,QAAkD,CAAC;AAE9F,yEAAyE;AACzE,MAAM,MAAM,eAAe;AACzB,mFAAmF;AACjF,WAAW;AACb,uJAAuJ;GACrJ,OAAO;AACT,kGAAkG;GAChG,iBAAiB;AACnB,sFAAsF;GACpF,MAAM;AACR,gFAAgF;GAC9E,MAAM;AACR,wEAAwE;GACtE,YAAY,CAAC;AAEjB,kEAAkE;AAClE,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,OAAO,EAAE,GAAG;QAAE,OAAO,IAAI,OAAO,EAAE,CAAA;KAAE,CAAC;CACrE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAClC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,MAAM,GACnB,eAAe,CAoDjB;AAcD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAa/D"}
|
|
@@ -15,16 +15,41 @@
|
|
|
15
15
|
* the backstop. The handler decides from the directory, with the batched pass's own rule
|
|
16
16
|
* (`provisionReconcileTarget`), and does nothing when the receipt already matches.
|
|
17
17
|
*
|
|
18
|
-
* The scope remembers what it asked for in `_substrat_meta` (`RECONCILE_ASKED_KEY
|
|
19
|
-
* transaction as the intent row, so asking is once per version, not once per wake: a scope evicted
|
|
18
|
+
* The scope remembers what it asked for in `_substrat_meta` (`RECONCILE_ASKED_KEY`, and the ask
|
|
19
|
+
* itself in `RECONCILE_ASK_KEY`), in the same transaction as the intent row, so asking is once per version, not once per wake: a scope evicted
|
|
20
20
|
* and revived a hundred times a day writes one row per promote. Nothing here may fail the
|
|
21
21
|
* migration pass it runs after: a scope that cannot ask stays on the batched pass, which is still
|
|
22
22
|
* running (step 5 keeps it until the count has been watched through several promotes).
|
|
23
|
+
*
|
|
24
|
+
* Once per version, unless the answer did not cover the version (`reaskDue`). The settled ask is in
|
|
25
|
+
* the scope's own journal, so a later wake reads it without asking anyone. Two answers do not cover
|
|
26
|
+
* what the scope runs, and on either the next wake asks again:
|
|
27
|
+
*
|
|
28
|
+
* - **The ask gave up** (`failed`, at the drain's attempt ceiling or on a terminal refusal). The
|
|
29
|
+
* batched pass used to be the only thing that reached that scope again on that version.
|
|
30
|
+
* - **The answer named another version.** A promote uploads the script first and writes the serving
|
|
31
|
+
* pointer after, so a scope can wake on the new code while the directory still names the old
|
|
32
|
+
* version. A drain in that window answers `up-to-date` for the old one, and a scope that took
|
|
33
|
+
* that as done would never ask for the version it runs. The same holds for an earlier ask a
|
|
34
|
+
* later promote leaned on (one pending ask is enough, below) when it settled before the pointer
|
|
35
|
+
* moved.
|
|
36
|
+
*
|
|
37
|
+
* Each version is asked at most `RECONCILE_ASKS_PER_VERSION` times. An answer that keeps missing
|
|
38
|
+
* (a directory that cannot name what the scope runs) is left to the batched pass after that,
|
|
39
|
+
* instead of an intent on every wake.
|
|
23
40
|
*/
|
|
24
|
-
import { MAX_PENDING_PLATFORM_REQUESTS, PROVISION_RECONCILE_KIND, platformRequestId } from '@substrat-run/contracts';
|
|
41
|
+
import { MAX_PENDING_PLATFORM_REQUESTS, PROVISION_RECONCILE_KIND, platformRequestId, provisionReconcileResult, } from '@substrat-run/contracts';
|
|
25
42
|
import { CONNECTOR_DISPATCH_REQUESTED_BY, IS_COPY_SQL } from '@substrat-run/kernel';
|
|
26
43
|
/** The `_substrat_meta` key holding the version this scope last asked a reconcile for. */
|
|
27
44
|
export const RECONCILE_ASKED_KEY = 'reconcile_asked_for';
|
|
45
|
+
/**
|
|
46
|
+
* The `_substrat_meta` key holding the ask the scope last wrote or leaned on, as JSON
|
|
47
|
+
* `{ id, asks }`: the intent's id, and how many asks the version in `RECONCILE_ASKED_KEY` has had.
|
|
48
|
+
* Read by primary key on every wake, so the never-pruned journal is never scanned to find it.
|
|
49
|
+
*/
|
|
50
|
+
export const RECONCILE_ASK_KEY = 'reconcile_ask';
|
|
51
|
+
/** How many asks one version gets before a scope leaves it to the batched pass. */
|
|
52
|
+
export const RECONCILE_ASKS_PER_VERSION = 3;
|
|
28
53
|
/** Who a `provision-reconcile` intent is requested by: the scope's host, never a person. */
|
|
29
54
|
export const RECONCILE_ON_WAKE_REQUESTED_BY = JSON.stringify({ system: 'reconcile-on-wake' });
|
|
30
55
|
/**
|
|
@@ -45,9 +70,15 @@ export function reconcileOnWake(sql, version, upgrade, now, mintId) {
|
|
|
45
70
|
if (!version)
|
|
46
71
|
return 'no-version';
|
|
47
72
|
const asked = sql.exec(`SELECT value FROM _substrat_meta WHERE key = ?`, RECONCILE_ASKED_KEY).toArray()[0]?.value;
|
|
48
|
-
if (asked === version)
|
|
73
|
+
if (asked === version && (!upgrade || !reaskDue(sql, version)))
|
|
49
74
|
return 'asked';
|
|
50
|
-
const
|
|
75
|
+
const again = asked === version;
|
|
76
|
+
const setMeta = (key, value) => sql.exec(`INSERT OR REPLACE INTO _substrat_meta (key, value) VALUES (?, ?)`, key, value);
|
|
77
|
+
const remember = (ask) => {
|
|
78
|
+
setMeta(RECONCILE_ASKED_KEY, version);
|
|
79
|
+
if (ask)
|
|
80
|
+
setMeta(RECONCILE_ASK_KEY, JSON.stringify(ask));
|
|
81
|
+
};
|
|
51
82
|
if (!upgrade) {
|
|
52
83
|
remember();
|
|
53
84
|
return 'first-provision';
|
|
@@ -55,12 +86,13 @@ export function reconcileOnWake(sql, version, upgrade, now, mintId) {
|
|
|
55
86
|
if (hasTable(sql, '_substrat_copy_origin') && sql.exec(IS_COPY_SQL).toArray().length > 0)
|
|
56
87
|
return 'copy';
|
|
57
88
|
// One pending ask is enough whatever version it named: the handler reconciles against what the
|
|
58
|
-
// scope runs when it is drained, not against the payload.
|
|
89
|
+
// scope runs when it is drained, not against the payload. Leaned on, it is the ask a later wake
|
|
90
|
+
// reads the answer of, and not one of this version's asks.
|
|
59
91
|
const pending = sql
|
|
60
|
-
.exec(`SELECT
|
|
61
|
-
.toArray();
|
|
62
|
-
if (pending
|
|
63
|
-
remember();
|
|
92
|
+
.exec(`SELECT id FROM _substrat_platform_requests WHERE kind = ? AND status = 'pending' LIMIT 1`, PROVISION_RECONCILE_KIND)
|
|
93
|
+
.toArray()[0];
|
|
94
|
+
if (pending) {
|
|
95
|
+
remember({ id: pending.id, asks: again ? (lastAsk(sql)?.asks ?? 0) : 0 });
|
|
64
96
|
return 'asked';
|
|
65
97
|
}
|
|
66
98
|
// The shared journal's room (platform-intents.md): a wake never takes the last slot a vertical's
|
|
@@ -70,12 +102,52 @@ export function reconcileOnWake(sql, version, upgrade, now, mintId) {
|
|
|
70
102
|
.toArray()[0].c;
|
|
71
103
|
if (held >= MAX_PENDING_PLATFORM_REQUESTS)
|
|
72
104
|
return 'full';
|
|
105
|
+
const id = platformRequestId.parse(mintId());
|
|
73
106
|
sql.exec(`INSERT INTO _substrat_platform_requests
|
|
74
107
|
(id, kind, payload, requested_by, impersonation, status, attempts, requested_at)
|
|
75
|
-
VALUES (?, ?, ?, ?, NULL, 'pending', 0, ?)`,
|
|
76
|
-
remember();
|
|
108
|
+
VALUES (?, ?, ?, ?, NULL, 'pending', 0, ?)`, id, PROVISION_RECONCILE_KIND, JSON.stringify({ wokeOn: version }), RECONCILE_ON_WAKE_REQUESTED_BY, now);
|
|
109
|
+
remember({ id, asks: again ? (lastAsk(sql)?.asks ?? 0) + 1 : 1 });
|
|
77
110
|
return 'requested';
|
|
78
111
|
}
|
|
112
|
+
function lastAsk(sql) {
|
|
113
|
+
const raw = sql.exec(`SELECT value FROM _substrat_meta WHERE key = ?`, RECONCILE_ASK_KEY).toArray()[0]
|
|
114
|
+
?.value;
|
|
115
|
+
const v = parseJson(raw ?? null);
|
|
116
|
+
return v && typeof v.id === 'string' && typeof v.asks === 'number' ? { id: v.id, asks: v.asks } : null;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Whether a scope that already asked for `version` should ask again: the ask it last wrote or leaned
|
|
120
|
+
* on is settled, and either gave up or was answered for a version other than `version`, and `version`
|
|
121
|
+
* has not had `RECONCILE_ASKS_PER_VERSION` asks yet. A pending ask, an answer for `version`, a
|
|
122
|
+
* switched-off handler and a scope that is not an install all say no, and so does a scope that has
|
|
123
|
+
* no record of its ask (it recorded the version at its provision, or before this rule).
|
|
124
|
+
*/
|
|
125
|
+
export function reaskDue(sql, version) {
|
|
126
|
+
const ask = lastAsk(sql);
|
|
127
|
+
if (!ask || ask.asks >= RECONCILE_ASKS_PER_VERSION)
|
|
128
|
+
return false;
|
|
129
|
+
const row = sql.exec(`SELECT status, result FROM _substrat_platform_requests WHERE id = ?`, ask.id).toArray()[0];
|
|
130
|
+
if (!row || row.status === 'pending')
|
|
131
|
+
return false;
|
|
132
|
+
if (row.status === 'done') {
|
|
133
|
+
const answer = provisionReconcileResult.safeParse(parseJson(row.result));
|
|
134
|
+
if (!answer.success || !('versionId' in answer.data))
|
|
135
|
+
return false;
|
|
136
|
+
if (answer.data.versionId === version)
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
function parseJson(text) {
|
|
142
|
+
if (text === null)
|
|
143
|
+
return null;
|
|
144
|
+
try {
|
|
145
|
+
return JSON.parse(text);
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
79
151
|
function hasTable(sql, name) {
|
|
80
152
|
return sql.exec(`SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?`, name).toArray().length > 0;
|
|
81
153
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconcile-on-wake.js","sourceRoot":"","sources":["../src/reconcile-on-wake.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"reconcile-on-wake.js","sourceRoot":"","sources":["../src/reconcile-on-wake.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,OAAO,EACL,6BAA6B,EAC7B,wBAAwB,EACxB,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,+BAA+B,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEpF,0FAA0F;AAC1F,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAEjD,mFAAmF;AACnF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAE5C,4FAA4F;AAC5F,MAAM,CAAC,MAAM,8BAA8B,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAC;AAsB9F;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,eAAe,CAC7B,GAAY,EACZ,OAAkC,EAClC,OAAgB,EAChB,GAAW,EACX,MAAoB;IAEpB,IAAI,CAAC,OAAO;QAAE,OAAO,YAAY,CAAC;IAClC,MAAM,KAAK,GAAI,GAAG,CAAC,IAAI,CAAC,gDAAgD,EAAE,mBAAmB,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAE5F,EAAE,KAAK,CAAC;IACtB,IAAI,KAAK,KAAK,OAAO,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;Q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,CAAC;CAClB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AAimBjG,kGAAkG;AAClG,wBAAgB,QAAQ,CAAC,GAAG,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAQxD;AAgQD;;;GAGG;AACH,MAAM,MAAM,yBAAyB,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;AAmBtD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG,SAAS,CAOxD;AAED,gHAAgH;AAChH,OAAO,EAAE,kBAAkB,EAAE,CAAC;AA2B9B,wBAAgB,aAAa,CAC3B,OAAO,EAAE,kBAAkB,EAAE,EAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACzD;;;;GAIG;AACH,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,mBAAmB,CAAA;CAAO,GAClD,KAAK,GAAG,EAAE,kBAAkB,EAAE,GAAG,EAAE,UAAU,KAAK,aAAa,CAAC,UAAU,CAAC,CA2sU7E"}
|
package/dist/scope-do.js
CHANGED
|
@@ -14,7 +14,7 @@ import { OperationQueue } from './serialization.js';
|
|
|
14
14
|
import { reconcileOnWake } from './reconcile-on-wake.js';
|
|
15
15
|
import { meterScopeWorkEntries, ScopeWorkMeter } from './scope-work.js';
|
|
16
16
|
import { assertNoRuntimeStorage, doScopedSql, doBuiltColumnsOf, doRedactionSql, doSpineSql } from './sql.js';
|
|
17
|
-
import { actorOf, admitPeer, boundToPeerDeclarations, collectPeers, switchPeer, peerSubjectRef, subjectGrantState, assertNoSecret, CAPABILITY_DDL, UPLOAD_LINK_DDL, DOWNLOAD_LINK_DDL, STORE_PROOF_DDL, mintStoreProof, redeemStoreProof, createAttachmentVerbs, inspectUploadLink, resolveDownloadLink, redeemUploadLinkInTransaction, COPY_ORIGIN_DDL, ENTITY_STATE_MOVES_DDL, SWITCH_FENCES_DDL, TABLE_OWNERS_DDL, assertMigrationLeavesLedgerAlone, recordOwnershipSteps, runMigrationStatements, splitSqlStatements, executableSqlStatements, blankSqlComments, CAPABILITY_EXCHANGE_OPERATION, CAPABILITY_BECOME_MINT_OPERATION, becomeMintCheck, mintBecomeCapabilityAsPrincipal, CAPABILITY_BIND_MINT_OPERATION, bindLinkMintCheck, mintBindLinkAsPrincipal, revokeBecomeCapabilityAsPrincipal, readBecomeLinkStates, ENTITY_UNBIND_OPERATION, allowedFor, unbindEntityHolderBounded, capabilityAttachmentWriteRefused, createCapabilityVerbs, createEntityEdgeVerbs, createEntityStateVerbs, createTrashedReads, CONTINUATION_POSITION_CAP, visibleContinuation, searchStateWhere, uncheckedView, addStatePlans, addUpdatedStampPlans, watchUpdatedStamps, assertNoCallerPurge, isUnreachableParent, PURGE_ALARM_MIN_GAP_MS, PURGE_BATCH, PURGE_DUE_BY_EVENT, consumeScheduleDue, dueByEventSchedulesOf, noteScheduleDue, readScheduleDue, scheduleDueAt, heldPurgePass, purgeDueAt, readPurgeLap, lifecycleRefusal, purgeHeldBy, assertPlatformRequestRoom, CONNECTOR_DISPATCH_REQUESTED_BY, MAX_PENDING_CONNECTOR_DISPATCHES, purgeDueOf, purgeOnlyKeysOf, runPurgePass, refuseTrashedTarget, assertBoundOperations, checkHeldOperationsOf, countChecks, noteUncheckedCompletion, registerTrashTargets, withheldKeysFor, capCoverage, delegationCeilingOf, delegationStampOf, outsideCeiling, parseScopeDelegation, statefulTablesOf, afterMigration, afterRuntimeDdl, derivesAnything, repairDerivedObjects, StateColumnLost, exchangeCapability, exchangeBecomeLinkById, guardSecrets, mintBecomeCapability, redactSecrets, redactSecretText, moduleLog, asyncInvocationId, asyncLinePass, resolveCapabilitySession, revokeCapabilityAsPlatform, readCapabilityPage, domainEventOf, facetEvents, readDeadLetters, readLifecycleFlow, readOperationSeries, readHistory, readInvocation, readUndrainedOutbox, walkEventCause, walkEventEffects, } from '@substrat-run/kernel';
|
|
17
|
+
import { actorOf, admitPeer, boundToPeerDeclarations, collectPeers, switchPeer, peerSubjectRef, subjectGrantState, assertNoSecret, CAPABILITY_DDL, UPLOAD_LINK_DDL, DOWNLOAD_LINK_DDL, STORE_PROOF_DDL, mintStoreProof, redeemStoreProof, createAttachmentVerbs, inspectUploadLink, resolveDownloadLink, redeemUploadLinkInTransaction, COPY_ORIGIN_DDL, ENTITY_STATE_MOVES_DDL, SWITCH_FENCES_DDL, TABLE_OWNERS_DDL, assertMigrationLeavesLedgerAlone, recordOwnershipSteps, runMigrationStatements, splitSqlStatements, executableSqlStatements, blankSqlComments, CAPABILITY_EXCHANGE_OPERATION, CAPABILITY_BECOME_MINT_OPERATION, becomeMintCheck, mintBecomeCapabilityAsPrincipal, CAPABILITY_BIND_MINT_OPERATION, bindLinkMintCheck, mintBindLinkAsPrincipal, revokeBecomeCapabilityAsPrincipal, readBecomeLinkStates, ENTITY_UNBIND_OPERATION, allowedFor, unbindEntityHolderBounded, capabilityAttachmentWriteRefused, createCapabilityVerbs, createEntityEdgeVerbs, createEntityStateVerbs, createTrashedReads, CONTINUATION_POSITION_CAP, visibleContinuation, searchStateWhere, uncheckedView, addStatePlans, addUpdatedStampPlans, watchUpdatedStamps, assertNoCallerPurge, isUnreachableParent, PURGE_ALARM_MIN_GAP_MS, PURGE_BATCH, PURGE_DUE_BY_EVENT, consumeScheduleDue, dueByEventSchedulesOf, noteScheduleDue, readScheduleDue, scheduleDueAt, createJobVerbs, declaredJobsOf, jobRunDueAt, jobRunEndedOutbox, JOB_DEFER_MS, heldPurgePass, purgeDueAt, readPurgeLap, lifecycleRefusal, purgeHeldBy, assertPlatformRequestRoom, CONNECTOR_DISPATCH_REQUESTED_BY, MAX_PENDING_CONNECTOR_DISPATCHES, purgeDueOf, purgeOnlyKeysOf, runPurgePass, refuseTrashedTarget, assertBoundOperations, checkHeldOperationsOf, countChecks, noteUncheckedCompletion, registerTrashTargets, withheldKeysFor, capCoverage, delegationCeilingOf, delegationStampOf, outsideCeiling, parseScopeDelegation, statefulTablesOf, afterMigration, afterRuntimeDdl, derivesAnything, repairDerivedObjects, StateColumnLost, exchangeCapability, exchangeBecomeLinkById, guardSecrets, mintBecomeCapability, redactSecrets, redactSecretText, moduleLog, asyncInvocationId, asyncLinePass, resolveCapabilitySession, revokeCapabilityAsPlatform, readCapabilityPage, domainEventOf, facetEvents, readDeadLetters, readLifecycleFlow, readOperationSeries, readHistory, readInvocation, readUndrainedOutbox, walkEventCause, walkEventEffects, } from '@substrat-run/kernel';
|
|
18
18
|
import { assertSameAttachmentGate, attachmentGateOf, decideAttachmentRemove } from '@substrat-run/kernel';
|
|
19
19
|
import { COPY_RESTORE_FENCE_LAPSED, copyRestoreFenceLapsed, orphanSweepVersionRefusal } from '@substrat-run/kernel';
|
|
20
20
|
import { createDoTupleChecker, createLocalControlPlaneReader, scopeTupleReader } from './checker.js';
|
|
@@ -26,7 +26,7 @@ import { analyticsBrokerSink, brokerTelemetryDataset } from './broker-telemetry.
|
|
|
26
26
|
import { DELIVERY_HANDOFF_KEY, DELIVERY_MODE_KEY, HANDOFF_ROUNDS, deliveryModeAfter, handoffAfterFailure, handoffDue, handoffPending, mergeHandoff, sameMarks, } from './delivery-handoff.js';
|
|
27
27
|
import { registerPlatformDeliveryBroker } from './delivery-broker-platform.js';
|
|
28
28
|
import { advanceMarks, brokerName, handoffQueries, messagesOf, senderDeliveryOf } from '@substrat-run/kernel';
|
|
29
|
-
import { DELIVERY_HANDOFF_ENV, intentStateOf, intentStateQuery, witnessesOf, witnessQueries, } from '@substrat-run/kernel';
|
|
29
|
+
import { DELIVERY_HANDOFF_ENV, intentStateOf, intentStateQuery, eventLakeStateOf, eventLakeStateQuery, witnessesOf, witnessQueries, } from '@substrat-run/kernel';
|
|
30
30
|
import { SCOPE_SWEEPER_NAME, kickPlatformDrain, runScopeDueWork } from './scope-sweeper-do.js';
|
|
31
31
|
import { SCOPE_WAKE_KEY, keepRegisteredMeanwhile, kickControlPlane, runWake, wakeAfterCommit, wakeDueAt } from './scope-wake.js';
|
|
32
32
|
import { CARRIED_AWAY_KEY, COPY_MARK_CLEARED_KEY, KEPT_COPY_REFUSAL, KEPT_DIVERGENT_KEY, LOAD_STAMP_KEY, STORE_LOCAL_META_KEYS, WRITE_REVISION_KEY, carriedAwayDump, isCopyMarkInsert, isWriteStatement, assertSpineTablesBuilt, clearCopyMarker, dumpRowsInsert, isSpineTable, markCopyOrigin, repointScopeGrants, settleCopiedWork, emittedHere, IS_COPY_SQL, CLEAN_ROOM_COPY_SQL, isCopyLoad, isLifecycleWrite, readLifecycle, settleLifecycleAfterLoad, writeLifecycle, spineColumnAdditions } from '@substrat-run/kernel';
|
|
@@ -1023,6 +1023,9 @@ options = {}) {
|
|
|
1023
1023
|
* may name, and the operations whose every run clears their date in its own transaction.
|
|
1024
1024
|
*/
|
|
1025
1025
|
dueSchedules = new Map();
|
|
1026
|
+
/** D-85: the modules that declare jobs, and every declared job by name (`declaredJobsOf`). */
|
|
1027
|
+
jobDeclarers = [];
|
|
1028
|
+
declaredJobs = new Map();
|
|
1026
1029
|
/**
|
|
1027
1030
|
* #3540: true while this scope's alarm is waiting on its sweeper's purge run. The purges that
|
|
1028
1031
|
* run meanwhile commit through `settleCommitted`, and must not arm the alarm the handler is about
|
|
@@ -1237,6 +1240,11 @@ options = {}) {
|
|
|
1237
1240
|
assertBoundOperations(manifest.id, registration.operations);
|
|
1238
1241
|
// #119: refused before anything is recorded, as in the pure adapter.
|
|
1239
1242
|
const trashTargets = registerTrashTargets(manifest.id, new Set(Object.keys(registration.operations?.handlers ?? {})), registration.operations?.inputs, manifest.entityStates, manifest.schedules);
|
|
1243
|
+
// D-85: refused before anything else is recorded (a name taken, an undeclared key).
|
|
1244
|
+
const jobs = declaredJobsOf([...this.jobDeclarers, { manifest, jobs: registration.jobs }]);
|
|
1245
|
+
if (registration.jobs)
|
|
1246
|
+
this.jobDeclarers.push({ manifest, jobs: registration.jobs });
|
|
1247
|
+
this.declaredJobs = jobs;
|
|
1240
1248
|
this.purgeOnlyKeys.set(manifest.id, purgeOnlyKeysOf(manifest.schedules ?? []));
|
|
1241
1249
|
for (const [operation, due] of dueByEventSchedulesOf(manifest.schedules))
|
|
1242
1250
|
this.dueSchedules.set(operation, due);
|
|
@@ -3121,7 +3129,7 @@ options = {}) {
|
|
|
3121
3129
|
* `due: 'event'` schedule among the registered modules.
|
|
3122
3130
|
*/
|
|
3123
3131
|
dueAlarmApplies() {
|
|
3124
|
-
return this.dueByEventSwitched() && (this.purgeSchedules.size > 0 || this.dueSchedules.size > 0);
|
|
3132
|
+
return this.dueByEventSwitched() && (this.purgeSchedules.size > 0 || this.dueSchedules.size > 0 || this.declaredJobs.size > 0);
|
|
3125
3133
|
}
|
|
3126
3134
|
/** #3540: when this scope's purges are next due, read from its own rows (`purgeDueAt`). */
|
|
3127
3135
|
purgeDueAtNow(now) {
|
|
@@ -3136,7 +3144,11 @@ options = {}) {
|
|
|
3136
3144
|
dueAtNow(now, schedules) {
|
|
3137
3145
|
const purges = this.purgeDueByEvent() ? this.purgeDueAtNow(now) : null;
|
|
3138
3146
|
const events = schedules && this.dueSchedules.size > 0 ? scheduleDueAt(doSpineSql(this.sql), this.dueSchedules.values()) : null;
|
|
3139
|
-
|
|
3147
|
+
// D-85: a declared job's live runs, on the same condition as the schedules: the due work the
|
|
3148
|
+
// alarm runs (`runScopeDueWork`) drives them only once a pass has said its sweeper takes it.
|
|
3149
|
+
const jobs = schedules ? jobRunDueAt(doSpineSql(this.sql), this.declaredJobs) : null;
|
|
3150
|
+
const due = [purges, events, jobs].filter((at) => at !== null);
|
|
3151
|
+
return due.length === 0 ? null : Math.min(...due);
|
|
3140
3152
|
}
|
|
3141
3153
|
/**
|
|
3142
3154
|
* #3540: arm the scope's alarm for its earliest due work, and record the pair the alarm will ask
|
|
@@ -3299,6 +3311,10 @@ options = {}) {
|
|
|
3299
3311
|
return;
|
|
3300
3312
|
}
|
|
3301
3313
|
const minutes = [...this.purgeSchedules.values(), ...(schedules ? this.dueSchedules.values() : [])].map((p) => p.everyMinutes);
|
|
3314
|
+
// D-85: while a job run is due, a failed or held ask waits a job's deferral, not a schedule's
|
|
3315
|
+
// cadence, and a scope whose only due work is its runs does not wait forever.
|
|
3316
|
+
if (schedules && jobRunDueAt(doSpineSql(this.sql), this.declaredJobs) !== null)
|
|
3317
|
+
minutes.push(JOB_DEFER_MS / 60_000);
|
|
3302
3318
|
const cadence = after + Math.min(...minutes) * 60_000;
|
|
3303
3319
|
if ('held' in answer) {
|
|
3304
3320
|
// Not re-armed, and no commit re-arms it within the cadence: a held scope does not ask on
|
|
@@ -3314,7 +3330,8 @@ options = {}) {
|
|
|
3314
3330
|
else {
|
|
3315
3331
|
const sql = doSpineSql(this.sql);
|
|
3316
3332
|
const open = [...this.purgeSchedules.keys()].some((op) => readPurgeLap(sql, op).after !== null);
|
|
3317
|
-
|
|
3333
|
+
// D-85: a job pass that left its run going (`progressed`) is an open lap too.
|
|
3334
|
+
floor = open || answer.progressed === true ? after : after + PURGE_ALARM_MIN_GAP_MS;
|
|
3318
3335
|
}
|
|
3319
3336
|
await this.ctx.storage.put(PURGE_ALARM_KEY, keep(floor));
|
|
3320
3337
|
await this.armAlarmBy(Math.max(next, floor));
|
|
@@ -3384,16 +3401,19 @@ options = {}) {
|
|
|
3384
3401
|
}
|
|
3385
3402
|
let answered;
|
|
3386
3403
|
let answeredEnvironment;
|
|
3404
|
+
let answeredLake = false;
|
|
3387
3405
|
const ran = await runWake(state, Date.now(), () => this.wakeWork(), async (body) => {
|
|
3388
3406
|
const answer = await kickControlPlane(transport, body);
|
|
3389
3407
|
answered = answer?.broker;
|
|
3390
3408
|
answeredEnvironment = answer?.brokerEnvironment;
|
|
3409
|
+
answeredLake = answer?.brokerLake === true;
|
|
3391
3410
|
return answer;
|
|
3392
3411
|
});
|
|
3393
3412
|
// A5: the delivery mode the control plane holds for this tenant, on the same answer, and
|
|
3394
|
-
// (#3639) the named environment whose broker it hands off to
|
|
3413
|
+
// (#3639) the named environment whose broker it hands off to, and (A6) whether the lake is
|
|
3414
|
+
// that broker's.
|
|
3395
3415
|
if (answered)
|
|
3396
|
-
await this.applyDeliveryMode(state.tenantId, state.scopeId, answered, answeredEnvironment);
|
|
3416
|
+
await this.applyDeliveryMode(state.tenantId, state.scopeId, answered, answeredEnvironment, answeredLake);
|
|
3397
3417
|
// The object took other calls while the kick was out: keep what a commit stored meanwhile.
|
|
3398
3418
|
const next = keepRegisteredMeanwhile(state, ran, (await this.ctx.storage.get(SCOPE_WAKE_KEY)) ?? null);
|
|
3399
3419
|
if (!next) {
|
|
@@ -3556,6 +3576,8 @@ options = {}) {
|
|
|
3556
3576
|
return null;
|
|
3557
3577
|
return {
|
|
3558
3578
|
mode: state.mode,
|
|
3579
|
+
// A6 (#3472): the lake is the broker's, so each event is also owed the lake receiver.
|
|
3580
|
+
...(state.mode === 'live' && state.lake ? { lake: true } : {}),
|
|
3559
3581
|
...(state.startPending && tenantId && scopeId ? { start: { tenantId, scopeId, after: state.start } } : {}),
|
|
3560
3582
|
};
|
|
3561
3583
|
}
|
|
@@ -3582,12 +3604,12 @@ options = {}) {
|
|
|
3582
3604
|
* Public for the platform and the suites; a caller in the script can only change which receivers
|
|
3583
3605
|
* its own next messages are owed, never what the control plane lets the broker drive.
|
|
3584
3606
|
*/
|
|
3585
|
-
async applyDeliveryMode(tenantId, scopeId, mode, environment) {
|
|
3607
|
+
async applyDeliveryMode(tenantId, scopeId, mode, environment, lake) {
|
|
3586
3608
|
await this.ensureMigrations();
|
|
3587
3609
|
// #3639: production is named by no environment, whichever way an answer spells it.
|
|
3588
3610
|
const named = environment && environment !== PRODUCTION_ENVIRONMENT ? environment : undefined;
|
|
3589
3611
|
const prior = (await this.ctx.storage.get(DELIVERY_MODE_KEY)) ?? null;
|
|
3590
|
-
const { next, seeded } = deliveryModeAfter(prior, mode, () => this.handoffSeed(), named);
|
|
3612
|
+
const { next, seeded } = deliveryModeAfter(prior, mode, () => this.handoffSeed(), named, lake);
|
|
3591
3613
|
if (next === prior)
|
|
3592
3614
|
return;
|
|
3593
3615
|
if (!next) {
|
|
@@ -3616,6 +3638,12 @@ options = {}) {
|
|
|
3616
3638
|
const q = intentStateQuery(id);
|
|
3617
3639
|
return intentStateOf(this.sql.exec(q.sql, ...q.params).toArray());
|
|
3618
3640
|
}
|
|
3641
|
+
/** A6 (#3472): whether one event of this scope is in the lake yet, for the broker's lake receiver. One primary-key read. */
|
|
3642
|
+
async eventLakeState(id) {
|
|
3643
|
+
await this.ensureMigrations();
|
|
3644
|
+
const q = eventLakeStateQuery(id);
|
|
3645
|
+
return eventLakeStateOf(this.sql.exec(q.sql, ...q.params).toArray());
|
|
3646
|
+
}
|
|
3619
3647
|
/** #3474: one point per handoff round, when the script binds `SUBSTRAT_BROKER_TELEMETRY`. */
|
|
3620
3648
|
reportHandoffRound(tenantId, scopeId, round, outcome,
|
|
3621
3649
|
/** #3639: the named environment whose broker the round went to; undefined for production's. */
|
|
@@ -5775,11 +5803,50 @@ options = {}) {
|
|
|
5775
5803
|
* partial update that wrote three of the four would leave a run carrying the
|
|
5776
5804
|
* last failure's error beside the new cursor, which reads as broken forever.
|
|
5777
5805
|
*/
|
|
5778
|
-
async jobRunPatch(id, patch, owner) {
|
|
5806
|
+
async jobRunPatch(id, patch, owner, scope) {
|
|
5779
5807
|
// A compare-and-set on `running` (#1632) and on the pass's lease (#2034) — see
|
|
5780
|
-
// `JOB_RUN_PATCH_SQL`. `owner` is
|
|
5808
|
+
// `JOB_RUN_PATCH_SQL`. `owner` is optional: a coordinator from before leases
|
|
5781
5809
|
// sends none, and patches the unleased rows it drives.
|
|
5782
|
-
return this.
|
|
5810
|
+
return this.withJobRunEnd(scope, (announce) => {
|
|
5811
|
+
if (this.sql.exec(JOB_RUN_PATCH_SQL, ...this.jobPatchArgs(id, patch, owner)).rowsWritten === 0)
|
|
5812
|
+
return false;
|
|
5813
|
+
if (patch.status !== 'running')
|
|
5814
|
+
announce(id);
|
|
5815
|
+
return true;
|
|
5816
|
+
});
|
|
5817
|
+
}
|
|
5818
|
+
/**
|
|
5819
|
+
* D-85: run `write` in ONE transaction, handing it `announce`, which writes a declared run's
|
|
5820
|
+
* `job.run-ended` event (`jobRunEndedOutbox`) beside the write that ended it. After the commit,
|
|
5821
|
+
* an announced end reaches this scope's consumers, as a settle's outcome event does. `scope` is
|
|
5822
|
+
* what the event is stamped with; a coordinator from before this change sends none, and its
|
|
5823
|
+
* writes announce nothing.
|
|
5824
|
+
*/
|
|
5825
|
+
async withJobRunEnd(scope, write) {
|
|
5826
|
+
const liveSince = scope ? this.liveHighWaterMark() : null;
|
|
5827
|
+
let ended = false;
|
|
5828
|
+
const out = this.revision.transactionSync(() => write((id) => {
|
|
5829
|
+
if (!scope)
|
|
5830
|
+
return;
|
|
5831
|
+
const run = this.sql.exec('SELECT * FROM _substrat_job_runs WHERE id = ?', id).toArray()[0];
|
|
5832
|
+
const st = run &&
|
|
5833
|
+
jobRunEndedOutbox(run, {
|
|
5834
|
+
tenantId: scope.tenantId,
|
|
5835
|
+
scopeId: scope.scopeId,
|
|
5836
|
+
now: new Date().toISOString(),
|
|
5837
|
+
mintEventId: (ms) => this.mintEventId(ms),
|
|
5838
|
+
version: this.env.SUBSTRAT_VERSION_ID ?? null,
|
|
5839
|
+
});
|
|
5840
|
+
if (!st)
|
|
5841
|
+
return;
|
|
5842
|
+
this.sql.exec(st.sql, ...st.params);
|
|
5843
|
+
ended = true;
|
|
5844
|
+
}));
|
|
5845
|
+
if (ended && scope) {
|
|
5846
|
+
// #1525: null — a pass's end is the platform's write, not a vertical caller's.
|
|
5847
|
+
await this.queue.enqueue(() => this.settleCommitted(scope.tenantId, scope.scopeId, liveSince, null));
|
|
5848
|
+
}
|
|
5849
|
+
return out;
|
|
5783
5850
|
}
|
|
5784
5851
|
jobPatchArgs(id, patch, owner) {
|
|
5785
5852
|
return [
|
|
@@ -5810,14 +5877,17 @@ options = {}) {
|
|
|
5810
5877
|
* `JOB_RUN_MISS_SETTLE_SQL` (the backoff or failure that count calls for) in ONE transaction,
|
|
5811
5878
|
* by this object's clock. Null = the claim no longer held the run, or had begun.
|
|
5812
5879
|
*/
|
|
5813
|
-
async jobRunMiss(id, owner, note) {
|
|
5814
|
-
return this.
|
|
5880
|
+
async jobRunMiss(id, owner, note, scope) {
|
|
5881
|
+
return this.withJobRunEnd(scope, (announce) => {
|
|
5815
5882
|
const at = new Date(Date.now()).toISOString();
|
|
5816
5883
|
const counted = this.sql.exec(JOB_RUN_MISS_SQL, at, id, owner).toArray()[0];
|
|
5817
5884
|
if (!counted)
|
|
5818
5885
|
return null;
|
|
5819
5886
|
const o = admissionMissOutcome(counted.admission_misses, at, note);
|
|
5820
|
-
this.sql.exec(JOB_RUN_MISS_SETTLE_SQL, o.status, o.nextAttemptAt, o.endedAt, o.lastError, id, counted.admission_misses)
|
|
5887
|
+
const settled = this.sql.exec(JOB_RUN_MISS_SETTLE_SQL, o.status, o.nextAttemptAt, o.endedAt, o.lastError, id, counted.admission_misses)
|
|
5888
|
+
.rowsWritten > 0;
|
|
5889
|
+
if (settled && o.status === 'failed')
|
|
5890
|
+
announce(id);
|
|
5821
5891
|
return { misses: counted.admission_misses, failed: o.status === 'failed' };
|
|
5822
5892
|
});
|
|
5823
5893
|
}
|
|
@@ -5880,16 +5950,18 @@ options = {}) {
|
|
|
5880
5950
|
* results, not to the cursor) then skips work it never did. The kernel's
|
|
5881
5951
|
* `runJobPass` carries the full argument.
|
|
5882
5952
|
*/
|
|
5883
|
-
async jobCommitPass(id, patch, owner) {
|
|
5953
|
+
async jobCommitPass(id, patch, owner, scope) {
|
|
5884
5954
|
// `transactionSync` with both statements inline — NOT `await
|
|
5885
5955
|
// this.jobRunPatch(...)` then the delete. The await is an output-gate
|
|
5886
5956
|
// boundary, which is precisely the gap this method exists to close.
|
|
5887
|
-
return this.
|
|
5957
|
+
return this.withJobRunEnd(scope, (announce) => {
|
|
5888
5958
|
// #2034: the ledger goes only with a patch that applied — a stale holder's commit must
|
|
5889
5959
|
// not empty the ledger of the pass that took the run over.
|
|
5890
5960
|
if (this.sql.exec(JOB_RUN_PATCH_SQL, ...this.jobPatchArgs(id, patch, owner)).rowsWritten === 0)
|
|
5891
5961
|
return false;
|
|
5892
5962
|
this.sql.exec('DELETE FROM _substrat_job_steps WHERE run_id = ?', id);
|
|
5963
|
+
if (patch.status !== 'running')
|
|
5964
|
+
announce(id);
|
|
5893
5965
|
return true;
|
|
5894
5966
|
});
|
|
5895
5967
|
}
|
|
@@ -7379,6 +7451,8 @@ options = {}) {
|
|
|
7379
7451
|
'ALTER TABLE _substrat_job_runs ADD COLUMN lease_began_at TEXT',
|
|
7380
7452
|
// #2042 r3: consecutive admission misses. NULL = none, right for every run already there.
|
|
7381
7453
|
'ALTER TABLE _substrat_job_runs ADD COLUMN admission_misses INTEGER',
|
|
7454
|
+
// D-85: the declared job's definition version. NULL = a run of an undeclared job, or one before it.
|
|
7455
|
+
'ALTER TABLE _substrat_job_runs ADD COLUMN definition_version INTEGER',
|
|
7382
7456
|
// Executor retry state (#100). The defaults read as "terminal", which is
|
|
7383
7457
|
// right for every row already there: each is a completed delivery or a
|
|
7384
7458
|
// consumer dead-letter.
|
|
@@ -9124,6 +9198,19 @@ options = {}) {
|
|
|
9124
9198
|
}),
|
|
9125
9199
|
// Upload links: mint / revoke / list, written once in the kernel — the same four things
|
|
9126
9200
|
// `capabilities` is handed, and the same consumer-is-system-actor rule.
|
|
9201
|
+
// D-85: start or join a declared job's run, in this transaction, checked as the caller. The
|
|
9202
|
+
// commit's `notePurgeDue` then arms the scope's alarm for it (`jobRunDueAt`).
|
|
9203
|
+
jobs: createJobVerbs({
|
|
9204
|
+
sql: doSpineSql(sql),
|
|
9205
|
+
// #2993: only the jobs of the modules this scope's type runs; the drive keeps the whole map.
|
|
9206
|
+
jobs: scopeTypePlan.declared ? new Map([...this.declaredJobs].filter(([, j]) => this.runs(j.moduleId))) : this.declaredJobs,
|
|
9207
|
+
check: (permission) => runCheck(permission),
|
|
9208
|
+
now: at,
|
|
9209
|
+
mintId: ulid,
|
|
9210
|
+
assertWrites: (verb) => assertImpersonationWrites(impersonation, verb),
|
|
9211
|
+
subject: systemActor ? { kind: 'system', id: systemActor.system } : subject,
|
|
9212
|
+
minted,
|
|
9213
|
+
}),
|
|
9127
9214
|
attachments: createAttachmentVerbs({
|
|
9128
9215
|
sql: doSpineSql(sql),
|
|
9129
9216
|
subject: systemActor ? { kind: 'system', id: systemActor.system } : subject,
|