@substrat-run/adapter-cloudflare 0.222.0 → 0.224.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/client-context.d.ts +8 -1
- package/dist/client-context.d.ts.map +1 -1
- package/dist/client-context.js +13 -1
- package/dist/client-context.js.map +1 -1
- package/dist/control-plane-do.d.ts +18 -5
- package/dist/control-plane-do.d.ts.map +1 -1
- package/dist/control-plane-do.js +24 -11
- package/dist/control-plane-do.js.map +1 -1
- package/dist/delivery-broker-do.d.ts +13 -5
- package/dist/delivery-broker-do.d.ts.map +1 -1
- package/dist/delivery-broker-do.js +2 -0
- package/dist/delivery-broker-do.js.map +1 -1
- package/dist/delivery-broker-platform.d.ts +1 -1
- package/dist/delivery-broker-platform.d.ts.map +1 -1
- package/dist/delivery-broker-platform.js +1 -1
- package/dist/delivery-broker-platform.js.map +1 -1
- package/dist/directory-placement.d.ts.map +1 -1
- package/dist/directory-placement.js +1 -0
- package/dist/directory-placement.js.map +1 -1
- package/dist/executor-route.d.ts +13 -0
- package/dist/executor-route.d.ts.map +1 -0
- package/dist/executor-route.js +12 -0
- package/dist/executor-route.js.map +1 -0
- package/dist/host.d.ts +73 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +204 -35
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +3 -3
- 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 +6 -1
- package/dist/reconcile-on-wake.d.ts.map +1 -1
- package/dist/reconcile-on-wake.js +8 -3
- package/dist/reconcile-on-wake.js.map +1 -1
- package/dist/scope-do.d.ts.map +1 -1
- package/dist/scope-do.js +83 -24
- package/dist/scope-do.js.map +1 -1
- package/dist/tenant-due-work-do.d.ts +8 -3
- package/dist/tenant-due-work-do.d.ts.map +1 -1
- package/dist/tenant-due-work-do.js +1 -1
- package/dist/tenant-due-work-do.js.map +1 -1
- package/package.json +14 -10
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* driving `drainDue`/`runDueSchedules` per scope (#461)
|
|
15
15
|
*/
|
|
16
16
|
export { CloudflareScopeHost } from './host.js';
|
|
17
|
-
export type { CloudflareScopeHostOptions, ConnectorDelegation, EventDrainDelegation, PeerSwitchDelegation, ImportCursorDelegation, CapabilityDelegation, SystemSwitchDelegation, LifecycleDelegation, LifecycleDeliveryReport, } from './host.js';
|
|
17
|
+
export type { CloudflareScopeHostOptions, ConnectorDelegation, EventDrainDelegation, PeerSwitchDelegation, ImportCursorDelegation, CapabilityDelegation, SystemSwitchDelegation, LifecycleDelegation, LifecycleDeliveryReport, LifecycleRetryItem, LifecycleRetryOwner, } from './host.js';
|
|
18
18
|
export { defineScopeDO } from './scope-do.js';
|
|
19
19
|
export { ControlPlaneDO } from './control-plane-do.js';
|
|
20
20
|
export type { DirectoryInventory } from './control-plane-do.js';
|
|
@@ -30,7 +30,7 @@ export { defineTenantDueWorkDO, tenantDueWorkName, type TenantDueItem, type Tena
|
|
|
30
30
|
export type { PlatformSweeperDoConfig, PlatformSweepOutcome } from './platform-sweeper-do.js';
|
|
31
31
|
export { defineCopyJobDO, type CopyJobDo, type CopyJobDoConfig, type CopyJobDoRecord, type CopyJobStep } from './copy-job-do.js';
|
|
32
32
|
export { defineScopeSweeperDO, SCOPE_SWEEPER_NAME } from './scope-sweeper-do.js';
|
|
33
|
-
export { defineDeliveryBrokerDO, type DeliveryBrokerDOClass, type DeliveryBrokerDeadLetterRpc, type DeliveryBrokerOptions, type DeliveryBrokerRelayRpc, type DeliveryBrokerRpc, type DeliveryBrokerSubscription, } from './delivery-broker-do.js';
|
|
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
35
|
export { askControlPlaneToDrain, 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';
|
|
@@ -42,7 +42,7 @@ export { createRouteResolver } from './route-resolver.js';
|
|
|
42
42
|
export { routeEntryKey, routeEntryOf, servingPolicyEntryKey, servingPolicyEntryOf, sqlPublishedLedger, writeRouteReadModelEntry, type PublishedLedger, type RouteKvWriter, type RouteReadModelKey, type RouteSourceFields, } from './route-read-model-publisher.js';
|
|
43
43
|
export type { RouteResolver } from './route-resolver.js';
|
|
44
44
|
export type { ControlPlaneReader, DoCheckerDeps } from './checker.js';
|
|
45
|
-
export { cloudflareClientContext, cloudflareGeo } from './client-context.js';
|
|
45
|
+
export { cloudflareClientContext, cloudflareGeo, cloudflareRoutedGeo } from './client-context.js';
|
|
46
46
|
export type { CloudflareRequestLike } from './client-context.js';
|
|
47
47
|
export { analyticsEngineConnectorCallRecorder, CONNECTOR_CALL_DATA_POINT_LAYOUT, connectorCallDataPoint, } from './connector-calls.js';
|
|
48
48
|
export type { AnalyticsEngineDatasetLike } from './connector-calls.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,E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,MAAM,SAAS,CAAC;AACrE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG1D,OAAO,EACL,aAAa,EACb,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,GACvB,MAAM,iCAAiC,CAAC;AACzC,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAClG,YAAY,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEjE,OAAO,EACL,oCAAoC,EACpC,gCAAgC,EAChC,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -41,7 +41,7 @@ export { createRouteResolver } from './route-resolver.js';
|
|
|
41
41
|
// #3395: the routing read model's one projection writer and its entry builders, for every source
|
|
42
42
|
// that will feed it (the directory today; the registry and per-tenant objects after K-68's split).
|
|
43
43
|
export { routeEntryKey, routeEntryOf, servingPolicyEntryKey, servingPolicyEntryOf, sqlPublishedLedger, writeRouteReadModelEntry, } from './route-read-model-publisher.js';
|
|
44
|
-
export { cloudflareClientContext, cloudflareGeo } from './client-context.js';
|
|
44
|
+
export { cloudflareClientContext, cloudflareGeo, cloudflareRoutedGeo } from './client-context.js';
|
|
45
45
|
// #1978: moved here from the kernel — the hosted connector-call recorder.
|
|
46
46
|
export { analyticsEngineConnectorCallRecorder, CONNECTOR_CALL_DATA_POINT_LAYOUT, connectorCallDataPoint, } from './connector-calls.js';
|
|
47
47
|
//# sourceMappingURL=index.js.map
|
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;
|
|
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,oBAAoB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAC1F,6FAA6F;AAC7F,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,6BAA6B,GAK9B,MAAM,wBAAwB,CAAC;AAChC,+FAA+F;AAC/F,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,QAAQ,IAAI,uBAAuB,EACnC,4BAA4B,EAC5B,2BAA2B,EAC3B,gCAAgC,GAMjC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,qBAAqB,EACrB,iBAAiB,GAIlB,MAAM,yBAAyB,CAAC;AAEjC,wEAAwE;AACxE,OAAO,EAAE,eAAe,EAAgF,MAAM,kBAAkB,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,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"}
|
|
@@ -30,6 +30,11 @@ export interface WakeSql {
|
|
|
30
30
|
* Synchronous on purpose, and called with no `await` between the reads and the writes, so the
|
|
31
31
|
* check, the intent and the key land in one of the object's implicit transactions and two
|
|
32
32
|
* requests racing to wake the scope cannot both ask (the object runs one at a time).
|
|
33
|
+
*
|
|
34
|
+
* `mintId` is the scope's own intent mint. #3704 hands the ask to the delivery broker on its own,
|
|
35
|
+
* which moves the broker's mark to the ask's id, and a handoff reads only ids above the mark. An id
|
|
36
|
+
* from any other mint can sort above an intent the scope mints in the same millisecond, which
|
|
37
|
+
* would then never be handed off.
|
|
33
38
|
*/
|
|
34
|
-
export declare function reconcileOnWake(sql: WakeSql, version: string | null | undefined, upgrade: boolean, now: string): ReconcileOnWake;
|
|
39
|
+
export declare function reconcileOnWake(sql: WakeSql, version: string | null | undefined, upgrade: boolean, now: string, mintId: () => string): ReconcileOnWake;
|
|
35
40
|
//# 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":"AA0BA,0FAA0F;AAC1F,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAEzD,4FAA4F;AAC5F,eAAO,MAAM,8BAA8B,QAAkD,CAAC;AAE9F,yEAAyE;AACzE,MAAM,MAAM,eAAe;AACzB,mFAAmF;AACjF,WAAW;AACb,6FAA6F;GAC3F,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
|
|
1
|
+
{"version":3,"file":"reconcile-on-wake.d.ts","sourceRoot":"","sources":["../src/reconcile-on-wake.ts"],"names":[],"mappings":"AA0BA,0FAA0F;AAC1F,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAEzD,4FAA4F;AAC5F,eAAO,MAAM,8BAA8B,QAAkD,CAAC;AAE9F,yEAAyE;AACzE,MAAM,MAAM,eAAe;AACzB,mFAAmF;AACjF,WAAW;AACb,6FAA6F;GAC3F,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,CA6CjB"}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* running (step 5 keeps it until the count has been watched through several promotes).
|
|
23
23
|
*/
|
|
24
24
|
import { MAX_PENDING_PLATFORM_REQUESTS, PROVISION_RECONCILE_KIND, platformRequestId } from '@substrat-run/contracts';
|
|
25
|
-
import { CONNECTOR_DISPATCH_REQUESTED_BY, IS_COPY_SQL
|
|
25
|
+
import { CONNECTOR_DISPATCH_REQUESTED_BY, IS_COPY_SQL } from '@substrat-run/kernel';
|
|
26
26
|
/** The `_substrat_meta` key holding the version this scope last asked a reconcile for. */
|
|
27
27
|
export const RECONCILE_ASKED_KEY = 'reconcile_asked_for';
|
|
28
28
|
/** Who a `provision-reconcile` intent is requested by: the scope's host, never a person. */
|
|
@@ -35,8 +35,13 @@ export const RECONCILE_ON_WAKE_REQUESTED_BY = JSON.stringify({ system: 'reconcil
|
|
|
35
35
|
* Synchronous on purpose, and called with no `await` between the reads and the writes, so the
|
|
36
36
|
* check, the intent and the key land in one of the object's implicit transactions and two
|
|
37
37
|
* requests racing to wake the scope cannot both ask (the object runs one at a time).
|
|
38
|
+
*
|
|
39
|
+
* `mintId` is the scope's own intent mint. #3704 hands the ask to the delivery broker on its own,
|
|
40
|
+
* which moves the broker's mark to the ask's id, and a handoff reads only ids above the mark. An id
|
|
41
|
+
* from any other mint can sort above an intent the scope mints in the same millisecond, which
|
|
42
|
+
* would then never be handed off.
|
|
38
43
|
*/
|
|
39
|
-
export function reconcileOnWake(sql, version, upgrade, now) {
|
|
44
|
+
export function reconcileOnWake(sql, version, upgrade, now, mintId) {
|
|
40
45
|
if (!version)
|
|
41
46
|
return 'no-version';
|
|
42
47
|
const asked = sql.exec(`SELECT value FROM _substrat_meta WHERE key = ?`, RECONCILE_ASKED_KEY).toArray()[0]?.value;
|
|
@@ -67,7 +72,7 @@ export function reconcileOnWake(sql, version, upgrade, now) {
|
|
|
67
72
|
return 'full';
|
|
68
73
|
sql.exec(`INSERT INTO _substrat_platform_requests
|
|
69
74
|
(id, kind, payload, requested_by, impersonation, status, attempts, requested_at)
|
|
70
|
-
VALUES (?, ?, ?, ?, NULL, 'pending', 0, ?)`, platformRequestId.parse(
|
|
75
|
+
VALUES (?, ?, ?, ?, NULL, 'pending', 0, ?)`, platformRequestId.parse(mintId()), PROVISION_RECONCILE_KIND, JSON.stringify({ wokeOn: version }), RECONCILE_ON_WAKE_REQUESTED_BY, now);
|
|
71
76
|
remember();
|
|
72
77
|
return 'requested';
|
|
73
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconcile-on-wake.js","sourceRoot":"","sources":["../src/reconcile-on-wake.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,6BAA6B,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACrH,OAAO,EAAE,+BAA+B,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"reconcile-on-wake.js","sourceRoot":"","sources":["../src/reconcile-on-wake.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH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,EAAE,CAAC;QACvB,QAAQ,EAAE,CAAC;QACX,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,iGAAiG;IACjG,oEAAoE;IACpE,MAAM,IAAI,GACR,GAAG;SACA,IAAI,CACH,sGAAsG,EACtG,+BAA+B,CAChC;SACA,OAAO,EAAE,CAAC,CAAC,CACf,CAAC,CAAC,CAAC;IACJ,IAAI,IAAI,IAAI,6BAA6B;QAAE,OAAO,MAAM,CAAC;IACzD,GAAG,CAAC,IAAI,CACN;;gDAE4C,EAC5C,iBAAiB,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EACjC,wBAAwB,EACxB,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EACnC,8BAA8B,EAC9B,GAAG,CACJ,CAAC;IACF,QAAQ,EAAE,CAAC;IACX,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,SAAS,QAAQ,CAAC,GAAY,EAAE,IAAY;IAC1C,OAAO,GAAG,CAAC,IAAI,CAAC,+DAA+D,EAAE,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AAC9G,CAAC"}
|
package/dist/scope-do.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope-do.d.ts","sourceRoot":"","sources":["../src/scope-do.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scope-do.d.ts","sourceRoot":"","sources":["../src/scope-do.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EA0CL,KAAK,OAAO,EAiBZ,KAAK,QAAQ,EAsBd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAiEL,KAAK,mBAAmB,EASxB,KAAK,SAAS,EA2Bd,KAAK,kBAAkB,EAEvB,KAAK,gBAAgB,EAmJtB,MAAM,sBAAsB,CAAC;AAuD9B,OAAO,EAAW,KAAK,OAAO,EAAE,MAAM,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AA;CAAO,GAClD,KAAK,GAAG,EAAE,kBAAkB,EAAE,GAAG,EAAE,UAAU,KAAK,aAAa,CAAC,UAAU,CAAC,CAukU7E"}
|
package/dist/scope-do.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { REWIND_REFUSED } from './rewind-refusal.js';
|
|
2
|
+
import { EXECUTOR_ROUTE_NOT_DUE } from './executor-route.js';
|
|
2
3
|
import { SYSTEM_DOOR_MOVED } from './system-door.js';
|
|
3
4
|
import { DurableObject } from 'cloudflare:workers';
|
|
4
5
|
import { PRODUCTION_ENVIRONMENT, ATTACHMENT_ADDED, ATTACHMENT_REMOVED, CAPTURE_REFUSALS, attachmentRecord, domainEvent, domainEventInput, eventId, instant, objectRef, entityObjectRef, assertModuleEmittableType, assertKernelAuthoredType, toWireFailure, grantRefFromProof, principalId, principalBecomeCapabilityInput, principalBindLinkInput, scopeId as scopeIdOf, tenantId as tenantIdOf, platformRequestInput, platformRequestId, MAX_PENDING_PLATFORM_REQUESTS, MAX_PENDING_SWEEP_RUNS, SWEEP_RUNS_KIND, SCOPE_DUMP_PAGE_MAX_BYTES, SCOPE_TABLE_PAGE_MAX, SCOPE_QUERY_ROW_MAX, listLimitOf, pageOf, countedPageOf, requestFingerprint, substratError, errorCodeOf, assertReplayableDump, DUMP_OBJECTS_QUERY, dumpObjectsOf, isRuntimeTable, replayDumpObjects, dumpObjectsAudit, REDRAIN_BATCH, storeOperationKeyOf, SCOPE_DUE_HOST_KEY, } from '@substrat-run/contracts';
|
|
@@ -3556,11 +3557,12 @@ options = {}) {
|
|
|
3556
3557
|
}
|
|
3557
3558
|
/**
|
|
3558
3559
|
* A5: the drain's witness for the shadow comparison — this scope's own messages past `after`,
|
|
3559
|
-
* committed before `before
|
|
3560
|
+
* committed before `before` (and, #3684, at or after `since`), with when the drain delivered
|
|
3561
|
+
* each (`witnessQueries`). Reads only.
|
|
3560
3562
|
*/
|
|
3561
|
-
async deliveryWitness(after, before, limit) {
|
|
3563
|
+
async deliveryWitness(after, before, limit, since) {
|
|
3562
3564
|
await this.ensureMigrations();
|
|
3563
|
-
return witnessQueries(after, before, Math.min(Math.max(1, limit), 1_000)).flatMap((q) => witnessesOf(q.kind, this.sql.exec(q.sql, ...q.params).toArray()));
|
|
3565
|
+
return witnessQueries(after, before, Math.min(Math.max(1, limit), 1_000), since).flatMap((q) => witnessesOf(q.kind, this.sql.exec(q.sql, ...q.params).toArray()));
|
|
3564
3566
|
}
|
|
3565
3567
|
/** A5: an intent's state, for the broker's live receiver. One primary-key read. */
|
|
3566
3568
|
async intentDeliveryState(id) {
|
|
@@ -5900,7 +5902,7 @@ options = {}) {
|
|
|
5900
5902
|
*/
|
|
5901
5903
|
askReconcileOnWake(upgrade) {
|
|
5902
5904
|
try {
|
|
5903
|
-
const asked = reconcileOnWake(this.sql, this.env.SUBSTRAT_VERSION_ID, upgrade, new Date().toISOString());
|
|
5905
|
+
const asked = reconcileOnWake(this.sql, this.env.SUBSTRAT_VERSION_ID, upgrade, new Date().toISOString(), this.mintIntentId);
|
|
5904
5906
|
if (asked !== 'requested')
|
|
5905
5907
|
return false;
|
|
5906
5908
|
this.reconcileAskUnsignalled = true;
|
|
@@ -5932,12 +5934,36 @@ options = {}) {
|
|
|
5932
5934
|
try {
|
|
5933
5935
|
const tenant = tenantIdOf.safeParse(this.provisionedFor() ?? this.soleRoleTenant());
|
|
5934
5936
|
const scope = scopeIdOf.safeParse(this.ctx.id.name);
|
|
5937
|
+
if (tenant.success && scope.success)
|
|
5938
|
+
await this.noteScopeWake(tenant.data, scope.data);
|
|
5939
|
+
}
|
|
5940
|
+
catch (err) {
|
|
5941
|
+
console.error('reconcile-on-wake: scope wake not armed; the router flag and the pass remain', err);
|
|
5942
|
+
}
|
|
5943
|
+
await this.handOffReconcileAsk();
|
|
5944
|
+
}
|
|
5945
|
+
/**
|
|
5946
|
+
* #3704: the ask has no commit's handoff to carry it to the delivery broker, for the same reason
|
|
5947
|
+
* it has no commit's kick. A scope that commits nothing after the wake would leave it past the
|
|
5948
|
+
* broker's marks until its next commit, and in shadow the comparison counted it as delivered by
|
|
5949
|
+
* the drain alone. So it is handed off here, as a commit's messages are.
|
|
5950
|
+
*
|
|
5951
|
+
* The ids are the ones the handoff state was kept under when the tenant's mode went on, as the
|
|
5952
|
+
* alarm's retry reads them (`retryHandoff`), not the receipt guess above: a scope with no handoff
|
|
5953
|
+
* state has no mode on, and nothing to hand off. Never throws. The handoff reads storage and SQL
|
|
5954
|
+
* only, never the migration pass this runs at the end of.
|
|
5955
|
+
*/
|
|
5956
|
+
async handOffReconcileAsk() {
|
|
5957
|
+
try {
|
|
5958
|
+
const state = (await this.ctx.storage.get(DELIVERY_HANDOFF_KEY)) ?? null;
|
|
5959
|
+
const tenant = tenantIdOf.safeParse(state?.tenantId);
|
|
5960
|
+
const scope = scopeIdOf.safeParse(state?.scopeId);
|
|
5935
5961
|
if (!tenant.success || !scope.success)
|
|
5936
5962
|
return;
|
|
5937
|
-
await this.
|
|
5963
|
+
await this.handOffCommitted(tenant.data, scope.data);
|
|
5938
5964
|
}
|
|
5939
5965
|
catch (err) {
|
|
5940
|
-
console.error('reconcile-on-wake:
|
|
5966
|
+
console.error('reconcile-on-wake: the ask was not handed off; the next commit or the alarm hands it off', err);
|
|
5941
5967
|
}
|
|
5942
5968
|
}
|
|
5943
5969
|
/** The one tenant this scope's role rows name, or null for none or several (`tenantVerdict`'s `inferred`). */
|
|
@@ -6495,6 +6521,18 @@ options = {}) {
|
|
|
6495
6521
|
* is counted over the routed deliveries alone (`MAX_PENDING_CONNECTOR_DISPATCHES`): module
|
|
6496
6522
|
* intents and `sweep-runs` reports no longer take a delivery's slot, nor it theirs.
|
|
6497
6523
|
*
|
|
6524
|
+
* #3676: routed once per logical delivery. `pendingExecutorDeliveries` is a read, and more than
|
|
6525
|
+
* one pass can act on the same read — the inline drain after a commit, the router's kick, the
|
|
6526
|
+
* scope's alarm, `routeDueDeliveries`. Each used to insert an intent and bump the journal, so
|
|
6527
|
+
* one event became as many intents as passes reached it, with as many attempts on its journal
|
|
6528
|
+
* row, and a comparison by intent id could not see it. So the decision is made here, in the
|
|
6529
|
+
* transaction that writes: a delivery this scope's journal no longer holds due (routed,
|
|
6530
|
+
* dead-lettered, or waiting out a backoff) answers `'not-due'` and writes nothing. Due is the
|
|
6531
|
+
* read's own predicate — no row, or a next attempt that has come — so a dead letter a person
|
|
6532
|
+
* re-drives (`retryExecutorDelivery`) routes again, and a different `deliveryId` for the same
|
|
6533
|
+
* event routes its own. The due check comes before the room check: a delivery already routed
|
|
6534
|
+
* is not one waiting for room, and must not stop the caller's pass.
|
|
6535
|
+
*
|
|
6498
6536
|
* `invocationId` is LAST, and defaulted, for the RPC-skew reason `recordExecutorAttempt`
|
|
6499
6537
|
* states at length.
|
|
6500
6538
|
*/
|
|
@@ -6506,31 +6544,52 @@ options = {}) {
|
|
|
6506
6544
|
* so leaving it null would make the column read "no call" for the common case.
|
|
6507
6545
|
*/
|
|
6508
6546
|
invocationId = null) {
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
.
|
|
6521
|
-
|
|
6522
|
-
|
|
6523
|
-
|
|
6524
|
-
|
|
6547
|
+
const now = new Date().toISOString();
|
|
6548
|
+
const routed = this.revision.transactionSync(() => {
|
|
6549
|
+
if (!this.executorDeliveryDue(eventId, deliveryId, now))
|
|
6550
|
+
return EXECUTOR_ROUTE_NOT_DUE;
|
|
6551
|
+
if (this.pendingConnectorDispatches() >= MAX_PENDING_CONNECTOR_DISPATCHES)
|
|
6552
|
+
return null;
|
|
6553
|
+
const id = platformRequestId.parse(this.mintIntentId());
|
|
6554
|
+
// K-42: the intent inherits the SOURCE EVENT's stamp rather than being written
|
|
6555
|
+
// unstamped. Nobody is impersonating at this moment — the drain runs long after
|
|
6556
|
+
// the session's invoke returned — but the intent exists BECAUSE of an event that
|
|
6557
|
+
// was raised under one, and the platform drain is where an operator asks who
|
|
6558
|
+
// caused an outbound effect. Read here rather than passed over the RPC: the DO
|
|
6559
|
+
// owns the outbox, so a coordinator cannot claim a stamp or drop one.
|
|
6560
|
+
const source = this.sql
|
|
6561
|
+
.exec('SELECT impersonation, tenant_id, scope_id FROM _substrat_outbox WHERE id = ?', eventId)
|
|
6562
|
+
.toArray()[0];
|
|
6563
|
+
this.sql.exec(`INSERT INTO _substrat_platform_requests
|
|
6564
|
+
(id, kind, payload, requested_by, impersonation, status, attempts, requested_at)
|
|
6565
|
+
VALUES (?, ?, ?, ?, ?, 'pending', 0, ?)`, id, kind, payload, requestedBy, source?.impersonation ?? null, instant.parse(now));
|
|
6566
|
+
this.recordExecutorAttempt(eventId, deliveryId, null, null, invocationId);
|
|
6567
|
+
return { id, source };
|
|
6568
|
+
});
|
|
6569
|
+
if (routed === null || routed === EXECUTOR_ROUTE_NOT_DUE)
|
|
6570
|
+
return routed;
|
|
6571
|
+
const { id, source } = routed;
|
|
6525
6572
|
// K-69: this intent is enqueued by the coordinator after the commit's own wake was armed, so
|
|
6526
|
-
// it arms one too, under the ids its source event carries. Both writes above
|
|
6527
|
-
//
|
|
6573
|
+
// it arms one too, under the ids its source event carries. Both writes above committed in
|
|
6574
|
+
// one transaction, before this await.
|
|
6528
6575
|
if (source) {
|
|
6529
6576
|
await this.noteScopeWake(tenantIdOf.parse(source.tenant_id), scopeIdOf.parse(source.scope_id));
|
|
6530
6577
|
await this.handOffCommitted(tenantIdOf.parse(source.tenant_id), scopeIdOf.parse(source.scope_id));
|
|
6531
6578
|
}
|
|
6532
6579
|
return id;
|
|
6533
6580
|
}
|
|
6581
|
+
/**
|
|
6582
|
+
* #3676: whether this executor delivery is still due — `pendingExecutorDeliveries`'s journal
|
|
6583
|
+
* predicate for one row: never attempted, or retrying with its next attempt come. A routed or
|
|
6584
|
+
* delivered row, a dead letter, and a retry still backing off are not.
|
|
6585
|
+
*/
|
|
6586
|
+
executorDeliveryDue(eventId, deliveryId, now) {
|
|
6587
|
+
return (this.sql
|
|
6588
|
+
.exec(`SELECT 1 FROM _substrat_deliveries
|
|
6589
|
+
WHERE event_id = ? AND consumer_module = ?
|
|
6590
|
+
AND (next_attempt_at IS NULL OR next_attempt_at > ?)`, eventId, deliveryId, now)
|
|
6591
|
+
.toArray().length === 0);
|
|
6592
|
+
}
|
|
6534
6593
|
/** #3365: the routed connector deliveries this scope holds pending — their own room. */
|
|
6535
6594
|
pendingConnectorDispatches() {
|
|
6536
6595
|
return Number(this.sql
|