@substrat-run/adapter-cloudflare 0.229.0 → 0.231.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/broker-lake.d.ts +27 -2
- package/dist/broker-lake.d.ts.map +1 -1
- package/dist/broker-lake.js +57 -3
- package/dist/broker-lake.js.map +1 -1
- package/dist/control-plane-do.d.ts +57 -18
- package/dist/control-plane-do.d.ts.map +1 -1
- package/dist/control-plane-do.js +154 -70
- package/dist/control-plane-do.js.map +1 -1
- package/dist/delivery-broker-do.d.ts +13 -1
- package/dist/delivery-broker-do.d.ts.map +1 -1
- package/dist/delivery-broker-do.js +43 -3
- package/dist/delivery-broker-do.js.map +1 -1
- package/dist/directory-cutover.d.ts +93 -1
- package/dist/directory-cutover.d.ts.map +1 -1
- package/dist/directory-cutover.js +91 -2
- package/dist/directory-cutover.js.map +1 -1
- package/dist/directory-objects.d.ts +12 -0
- package/dist/directory-objects.d.ts.map +1 -1
- package/dist/directory-objects.js +8 -1
- package/dist/directory-objects.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/directory-tenant-connect-links.d.ts +40 -0
- package/dist/directory-tenant-connect-links.d.ts.map +1 -0
- package/dist/directory-tenant-connect-links.js +48 -0
- package/dist/directory-tenant-connect-links.js.map +1 -0
- package/dist/directory-tenant-identities.d.ts +30 -0
- package/dist/directory-tenant-identities.d.ts.map +1 -0
- package/dist/directory-tenant-identities.js +64 -0
- package/dist/directory-tenant-identities.js.map +1 -0
- package/dist/directory-tenant-tuples.d.ts +69 -3
- package/dist/directory-tenant-tuples.d.ts.map +1 -1
- package/dist/directory-tenant-tuples.js +52 -0
- package/dist/directory-tenant-tuples.js.map +1 -1
- package/dist/host.d.ts +27 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +81 -9
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/peer-call-target.d.ts +16 -2
- package/dist/peer-call-target.d.ts.map +1 -1
- package/dist/peer-call-target.js +36 -6
- package/dist/peer-call-target.js.map +1 -1
- package/dist/route-read-model-publisher.d.ts.map +1 -1
- package/dist/route-read-model-publisher.js +4 -0
- package/dist/route-read-model-publisher.js.map +1 -1
- package/dist/route-resolver.d.ts +19 -2
- package/dist/route-resolver.d.ts.map +1 -1
- package/dist/route-resolver.js +25 -5
- package/dist/route-resolver.js.map +1 -1
- package/dist/scope-do.d.ts +19 -0
- package/dist/scope-do.d.ts.map +1 -1
- package/dist/scope-do.js +294 -8
- package/dist/scope-do.js.map +1 -1
- package/dist/scope-facets.d.ts +121 -0
- package/dist/scope-facets.d.ts.map +1 -0
- package/dist/scope-facets.js +98 -0
- package/dist/scope-facets.js.map +1 -0
- package/dist/scope-supervisor-do.d.ts +112 -0
- package/dist/scope-supervisor-do.d.ts.map +1 -0
- package/dist/scope-supervisor-do.js +529 -0
- package/dist/scope-supervisor-do.js.map +1 -0
- package/dist/scope-work.d.ts +1 -1
- package/dist/scope-work.js +1 -1
- package/dist/scope-work.js.map +1 -1
- package/dist/supplied-pass-box.d.ts +77 -0
- package/dist/supplied-pass-box.d.ts.map +1 -0
- package/dist/supplied-pass-box.js +265 -0
- package/dist/supplied-pass-box.js.map +1 -0
- package/dist/tenant-due-index-do.d.ts +76 -0
- package/dist/tenant-due-index-do.d.ts.map +1 -0
- package/dist/tenant-due-index-do.js +90 -0
- package/dist/tenant-due-index-do.js.map +1 -0
- package/dist/tenant-due-nudge.d.ts +67 -0
- package/dist/tenant-due-nudge.d.ts.map +1 -0
- package/dist/tenant-due-nudge.js +77 -0
- package/dist/tenant-due-nudge.js.map +1 -0
- package/dist/tenant-due-work-do.d.ts +53 -0
- package/dist/tenant-due-work-do.d.ts.map +1 -1
- package/dist/tenant-due-work-do.js +204 -5
- package/dist/tenant-due-work-do.js.map +1 -1
- package/package.json +12 -12
package/dist/scope-do.d.ts
CHANGED
|
@@ -255,4 +255,23 @@ export declare function defineScopeDO(modules: ModuleRegistration[], bareOps: Re
|
|
|
255
255
|
options?: {
|
|
256
256
|
permissions?: DeclaredPermissions;
|
|
257
257
|
}): new (ctx: DurableObjectState, env: ScopeDoEnv) => DurableObject<ScopeDoEnv>;
|
|
258
|
+
/**
|
|
259
|
+
* Track B (broker RFC §6, #3466): the same scope class, to run as a FACET a scope supervisor
|
|
260
|
+
* (`defineScopeSupervisorDO`) loads through the Worker Loader. Switched: nothing on `main` builds
|
|
261
|
+
* a scope bundle with it, so every deployed scope still runs `defineScopeDO`.
|
|
262
|
+
*
|
|
263
|
+
* Three differences, each because a facet cannot do what the object does:
|
|
264
|
+
*
|
|
265
|
+
* - **The alarm is the supervisor's.** A facet cannot set one (workerd: "Facets currently cannot
|
|
266
|
+
* set alarms", `spikes/scope-facet-wakeups`). The one place the class arms (`armAlarmBy`) records
|
|
267
|
+
* the instant instead, and the supervisor reads it back with the call's answer.
|
|
268
|
+
* - **The sockets are the supervisor's.** A socket a facet accepts dies with the facet, so a
|
|
269
|
+
* rollout would drop every live reader. The facet decides who may subscribe (`liveAdmit`) and
|
|
270
|
+
* what each socket is owed (`liveCatchUp`); the supervisor holds the sockets and sends.
|
|
271
|
+
* - **It is reached through `supervisedCall`**, which returns the wake and the scope's tenant with
|
|
272
|
+
* the value. Its env is empty: no binding reaches it, and nothing in it reaches the network.
|
|
273
|
+
*/
|
|
274
|
+
export declare function defineScopeFacet(modules: ModuleRegistration[], bareOps: Record<string, OperationHandler<never, unknown>>, options?: {
|
|
275
|
+
permissions?: DeclaredPermissions;
|
|
276
|
+
}): new (ctx: DurableObjectState, env: ScopeDoEnv) => DurableObject<ScopeDoEnv>;
|
|
258
277
|
//# sourceMappingURL=scope-do.d.ts.map
|
package/dist/scope-do.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope-do.d.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D,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,mBAAmB,CAAA;CAAO,GAClD,KAAK,GAAG,EAAE,kBAAkB,EAAE,GAAG,EAAE,UAAU,KAAK,aAAa,CAAC,UAAU,CAAC,CAE7E"}
|
package/dist/scope-do.js
CHANGED
|
@@ -10,6 +10,7 @@ HOME_SCOPE_TYPE, SCOPE_TYPE_META_KEY,
|
|
|
10
10
|
PARENT_SCOPE_META_KEY, provisionedParent, operationNotInScopeType, provisionedScopeType, scopeTypePlanOf, scopeTypeRoleRefusal, scopeTypeRuns, listQuery, cursorOf, searchLimit, searchMatchExpression, searchQuery, ATTACHMENT_TEXT_DDL, ATTACHMENT_BYTES_SQL, ATTACHMENT_CONDEMNED_DDL, ATTACHMENT_SWEEP_LICENCE_DDL, ATTACHMENT_SWEEP_LICENCE_TABLE, WIRE_NONCE_DDL, WIRE_NONCE_FULL, claimWireNonceIn, isWireNonceTable, isWireNonceWrite, clearOrphanSweepLicence, condemnLicensedOrphanAttachments, consumeOrphanSweepLicence, licensedOrphanIds, recordOrphanSweepLicence, refuseUnlicensedOrphanSweep, refuseCondemnedAttachment, refuseCondemnedInDump, rowlessAttachmentIds, attachmentRecordOfRow, enqueueAttachmentText, reconcileAttachmentText, queueAttachmentTextBackfill, startAttachmentTextBackfill, readAttachmentTextRecheckPage, requeueUnsupportedAttachmentText, startAttachmentTextRecheck, recordAttachmentText, searchAttachments, IDEMPOTENCY_DDL, REFUSALS_TABLE_DDL, REFUSALS_INDEX, refusalInsert, refusalOf, markGuardRefusal, REFUSALS_REBUILD, refusalsAdmitGuards, assertIdempotencyKey, assertPermissionKey, idempotencyLookupQuery, idempotencyPruneStatement, idempotencyRecordStatement, idempotencyOptedOutMessage, replayFor, entityVersionQuery, entityVersionOf, assertIfMatch, OUTBOX_ENTITY_INDEX, SCHEDULE_STATE_DDL, SCHEDULE_STATE_REBUILD, scheduleStateHasKind, VERTICAL_EVENTS_DDL, EXPORT_HOPS_SQL, emptyImportResult, IMPORT_CURSORS_SQL, IMPORT_CURSOR_OF_SQL, OUTBOX_MARK_SQL, exportedSinceQuery, emittedSinceQuery, emittedReportOf, EMITTED_REPORT_CAP, noteTransitionInto, withTransitions, IMPORT_CURSOR_ADVANCE_SQL, IMPORT_RECORD_SQL, moveImportCursor, CrossVerticalRegistry, exportReadPlan, exportReadQuery, planExportBatch, withheldNote, JOB_RUN_DDL, JOB_RUN_DUE_AT, jobRunListLimit, SYSTEM_DOOR_WAIT, ancestorsWithin, } from '@substrat-run/kernel';
|
|
11
11
|
import { isUpgradeRequest, readSubscription, LIVE_DECIDE_ATTEMPTS, LIVE_FANOUT_LIMIT, LIVE_PRINCIPAL_HEADER, LIVE_SCOPE_HEADER, LIVE_SUBSCRIBE_PATH, LIVE_TENANT_HEADER, LIVE_WITHIN_HEADER, LIVE_EXPIRES_HEADER, LIVE_CLOSE, LIVE_SOCKETS_PER_PRINCIPAL, decodeLiveWithin, liveInstant, liveRefusal, liveRefusalStatus, } from './live-reads.js';
|
|
12
12
|
import { replyOf } from './do-reply.js';
|
|
13
|
+
import { assertNotSupervised, HOLDS_DATA_TABLES, SUPERVISOR_OWNED_METHODS, } from './scope-facets.js';
|
|
13
14
|
import { OperationQueue } from './serialization.js';
|
|
14
15
|
import { reconcileOnWake } from './reconcile-on-wake.js';
|
|
15
16
|
import { meterScopeWorkEntries, ScopeWorkMeter } from './scope-work.js';
|
|
@@ -57,8 +58,6 @@ const REAPED_MARKER = '_substrat_reaped';
|
|
|
57
58
|
const PROVISIONED_FOR_KEY = 'provisioned_for';
|
|
58
59
|
/** #2016: the refusal of a write that would re-point a scope's tenant, in one wording. */
|
|
59
60
|
const tenantReceiptRefusal = (held, asked) => `refused: this scope was provisioned for tenant ${held}, not ${asked}`;
|
|
60
|
-
/** #2016: the spine tables whose rows say a scope holds state (`ScopeDO.holdsData`). */
|
|
61
|
-
const HOLDS_DATA_TABLES = ['_substrat_migrations', '_substrat_tuples', '_substrat_outbox', '_substrat_schedule_state'];
|
|
62
61
|
/** #2016: why `tenantId` is foreign to a scope (`held`, the receipt `tenantVerdict` read), in one wording. */
|
|
63
62
|
const foreignTenant = (held, tenantId) => held !== null
|
|
64
63
|
? tenantReceiptRefusal(held, tenantId)
|
|
@@ -924,6 +923,29 @@ class SystemDoorMovedError extends Error {
|
|
|
924
923
|
}
|
|
925
924
|
/** #1834: the brand only `assertSystemDoor` sets, so nothing else can make a `SystemDoorPass`. */
|
|
926
925
|
const SYSTEM_DOOR_PASSED = Symbol('system door passed');
|
|
926
|
+
/** One of the object's own hibernatable sockets, as a pass target that starts at `since`. */
|
|
927
|
+
function liveTargetOfSocket(ws, since) {
|
|
928
|
+
return {
|
|
929
|
+
since,
|
|
930
|
+
cursor: since,
|
|
931
|
+
strict: false,
|
|
932
|
+
deserializeAttachment: () => ws.deserializeAttachment(),
|
|
933
|
+
send: (frame) => ws.send(frame),
|
|
934
|
+
close: (code, reason) => ws.close(code, reason),
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* Track B: is `name` a method of the object's own class chain, below `Object.prototype`? What a
|
|
939
|
+
* facet's `supervisedCall` may run: never an `Object.prototype` member, never a field.
|
|
940
|
+
*/
|
|
941
|
+
function definedHere(object, name) {
|
|
942
|
+
for (let p = Object.getPrototypeOf(object); p !== null && p !== Object.prototype; p = Object.getPrototypeOf(p)) {
|
|
943
|
+
const d = Object.getOwnPropertyDescriptor(p, name);
|
|
944
|
+
if (d)
|
|
945
|
+
return typeof d.value === 'function';
|
|
946
|
+
}
|
|
947
|
+
return false;
|
|
948
|
+
}
|
|
927
949
|
/** Close a live socket whose session has ended (#938). */
|
|
928
950
|
function closeSessionEnded(ws) {
|
|
929
951
|
try {
|
|
@@ -940,6 +962,28 @@ export function defineScopeDO(modules, bareOps,
|
|
|
940
962
|
* when the class is defined, as `registerModule` refuses one on either host.
|
|
941
963
|
*/
|
|
942
964
|
options = {}) {
|
|
965
|
+
return scopeClass(modules, bareOps, options, 'object');
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* Track B (broker RFC §6, #3466): the same scope class, to run as a FACET a scope supervisor
|
|
969
|
+
* (`defineScopeSupervisorDO`) loads through the Worker Loader. Switched: nothing on `main` builds
|
|
970
|
+
* a scope bundle with it, so every deployed scope still runs `defineScopeDO`.
|
|
971
|
+
*
|
|
972
|
+
* Three differences, each because a facet cannot do what the object does:
|
|
973
|
+
*
|
|
974
|
+
* - **The alarm is the supervisor's.** A facet cannot set one (workerd: "Facets currently cannot
|
|
975
|
+
* set alarms", `spikes/scope-facet-wakeups`). The one place the class arms (`armAlarmBy`) records
|
|
976
|
+
* the instant instead, and the supervisor reads it back with the call's answer.
|
|
977
|
+
* - **The sockets are the supervisor's.** A socket a facet accepts dies with the facet, so a
|
|
978
|
+
* rollout would drop every live reader. The facet decides who may subscribe (`liveAdmit`) and
|
|
979
|
+
* what each socket is owed (`liveCatchUp`); the supervisor holds the sockets and sends.
|
|
980
|
+
* - **It is reached through `supervisedCall`**, which returns the wake and the scope's tenant with
|
|
981
|
+
* the value. Its env is empty: no binding reaches it, and nothing in it reaches the network.
|
|
982
|
+
*/
|
|
983
|
+
export function defineScopeFacet(modules, bareOps, options = {}) {
|
|
984
|
+
return scopeClass(modules, bareOps, options, 'facet');
|
|
985
|
+
}
|
|
986
|
+
function scopeClass(modules, bareOps, options, runtime) {
|
|
943
987
|
// At definition, not at construction: a worker whose module list drifted fails at its first
|
|
944
988
|
// import, rather than at the first scope it wakes.
|
|
945
989
|
for (const registration of modules)
|
|
@@ -1167,8 +1211,23 @@ options = {}) {
|
|
|
1167
1211
|
}
|
|
1168
1212
|
return this.scopeWorkTenantId;
|
|
1169
1213
|
}
|
|
1214
|
+
/**
|
|
1215
|
+
* Track B: the earliest instant (epoch ms) this facet asked to be woken at and the supervisor
|
|
1216
|
+
* has not yet read back (`supervisedCall`). Memory only, by design: if the object resets before
|
|
1217
|
+
* the supervisor reads it, the alarm the supervisor armed before the call fires instead, and
|
|
1218
|
+
* every alarm user re-arms from what the store holds.
|
|
1219
|
+
*/
|
|
1220
|
+
#facetWakeAt = null;
|
|
1221
|
+
/** Track B: the tenant this facet's scope was provisioned for, once read (it never changes). */
|
|
1222
|
+
#facetTenant = null;
|
|
1170
1223
|
constructor(ctx, env) {
|
|
1171
1224
|
super(ctx, env);
|
|
1225
|
+
// Track B's rollback fence (`scope-facets.ts`): an object a scope supervisor served keeps the
|
|
1226
|
+
// scope's rows in its facet, not here. Refused before a single table is made, so a script
|
|
1227
|
+
// rolled back to this class neither answers from empty storage nor marks the object as a
|
|
1228
|
+
// scope's own. A facet's storage never holds the marker, so this is the object's check only.
|
|
1229
|
+
if (runtime === 'object')
|
|
1230
|
+
assertNotSupervised(ctx.storage);
|
|
1172
1231
|
// #1860: the client's 45s keep-alive (demos/ticket0/app/src/feed.ts) answered at
|
|
1173
1232
|
// the runtime level, before this object wakes for it. Without this, every idle
|
|
1174
1233
|
// subscriber's ping still reaches `webSocketMessage` and pins the DO in memory —
|
|
@@ -2953,7 +3012,12 @@ options = {}) {
|
|
|
2953
3012
|
* anything the asserted principal could not, because the filter downstream re-checks
|
|
2954
3013
|
* that principal against every frame.
|
|
2955
3014
|
*/
|
|
2956
|
-
|
|
3015
|
+
/**
|
|
3016
|
+
* Who may subscribe, decided once for both runtimes (Track B): the scope as an object accepts
|
|
3017
|
+
* the socket itself (`fetch`), a facet answers its supervisor (`liveAdmit`). Every check that
|
|
3018
|
+
* guards the handshake is here, so neither door can drift from the other.
|
|
3019
|
+
*/
|
|
3020
|
+
async admitLive(request) {
|
|
2957
3021
|
const url = new URL(request.url);
|
|
2958
3022
|
if (url.pathname !== LIVE_SUBSCRIBE_PATH) {
|
|
2959
3023
|
// The DO has exactly one fetch surface. Anything else reaching here is a
|
|
@@ -3011,6 +3075,13 @@ options = {}) {
|
|
|
3011
3075
|
(within?.checked !== undefined && !(await this.mayWatchRoot(() => this.liveContext(subscriber), within)))) {
|
|
3012
3076
|
return liveRefusal('forbidden', 'live reads: the subscriber may not watch this root', 'forbidden');
|
|
3013
3077
|
}
|
|
3078
|
+
return { subscriber, ...(within ? { within } : {}), ...(expiresAt ? { expiresAt } : {}) };
|
|
3079
|
+
}
|
|
3080
|
+
async fetch(request) {
|
|
3081
|
+
const admitted = await this.admitLive(request);
|
|
3082
|
+
if (admitted instanceof Response)
|
|
3083
|
+
return admitted;
|
|
3084
|
+
const { subscriber, within, expiresAt } = admitted;
|
|
3014
3085
|
const pair = new WebSocketPair();
|
|
3015
3086
|
const [client, server] = Object.values(pair);
|
|
3016
3087
|
/**
|
|
@@ -3097,6 +3168,13 @@ options = {}) {
|
|
|
3097
3168
|
}
|
|
3098
3169
|
/** The one alarm, moved only earlier: every user of it arms through here (#938, K-69). */
|
|
3099
3170
|
async armAlarmBy(at) {
|
|
3171
|
+
if (runtime === 'facet') {
|
|
3172
|
+
// Track B: a facet has no alarm of its own. The supervisor reads this back with the call's
|
|
3173
|
+
// answer and arms its own, earliest wins, as below.
|
|
3174
|
+
if (this.#facetWakeAt === null || this.#facetWakeAt > at)
|
|
3175
|
+
this.#facetWakeAt = at;
|
|
3176
|
+
return;
|
|
3177
|
+
}
|
|
3100
3178
|
const current = await this.ctx.storage.getAlarm();
|
|
3101
3179
|
if (current === null || current > at)
|
|
3102
3180
|
await this.ctx.storage.setAlarm(at);
|
|
@@ -3113,6 +3191,106 @@ options = {}) {
|
|
|
3113
3191
|
await this.retryHandoff();
|
|
3114
3192
|
await this.runPurgeAlarm();
|
|
3115
3193
|
}
|
|
3194
|
+
// -- Track B: the facet's doors for its supervisor (`defineScopeFacet`) ---------------
|
|
3195
|
+
/** A facet-only door refuses on the scope as an object: there, nothing supervises it. */
|
|
3196
|
+
assertFacet(door) {
|
|
3197
|
+
if (runtime !== 'facet') {
|
|
3198
|
+
throw new Error(`scope: '${door}' is a facet's door for its supervisor, and this scope runs as an object`);
|
|
3199
|
+
}
|
|
3200
|
+
}
|
|
3201
|
+
/** Track B: the tenant this facet's scope was provisioned for, read once it is known. */
|
|
3202
|
+
facetTenant() {
|
|
3203
|
+
return (this.#facetTenant ??= this.provisionedFor());
|
|
3204
|
+
}
|
|
3205
|
+
/**
|
|
3206
|
+
* Track B: one call from the supervisor, by name, with the wake the call asked for and the
|
|
3207
|
+
* scope's tenant beside its value. The supervisor arms its own alarm from the first and names
|
|
3208
|
+
* the facet's isolate from the second. What it forwards is the supervisor's decision, read off
|
|
3209
|
+
* the platform's own class (`scopeRpcMethods`); here, a method of this class's prototype chain
|
|
3210
|
+
* that the supervisor does not answer itself is callable, plus the alarm and the admission.
|
|
3211
|
+
*
|
|
3212
|
+
* A call that throws carries no wake: the supervisor keeps the alarm it armed before the call,
|
|
3213
|
+
* and the wake stays here for the next call to carry.
|
|
3214
|
+
*/
|
|
3215
|
+
async supervisedCall(method, args) {
|
|
3216
|
+
this.assertFacet('supervisedCall');
|
|
3217
|
+
const callable = method === 'alarm' || method === 'liveAdmit' || (typeof method === 'string' && !SUPERVISOR_OWNED_METHODS.has(method) && definedHere(this, method));
|
|
3218
|
+
const fn = callable ? this[method] : undefined;
|
|
3219
|
+
if (typeof fn !== 'function')
|
|
3220
|
+
throw new Error(`scope facet: no forwarded method '${String(method)}'`);
|
|
3221
|
+
const value = await fn.apply(this, Array.isArray(args) ? args : []);
|
|
3222
|
+
const wakeAt = this.#facetWakeAt;
|
|
3223
|
+
this.#facetWakeAt = null;
|
|
3224
|
+
return { value, wakeAt, tenant: this.facetTenant() };
|
|
3225
|
+
}
|
|
3226
|
+
/**
|
|
3227
|
+
* Track B: may this request subscribe? The same checks as the object's own handshake
|
|
3228
|
+
* (`admitLive`). Admitted, the subscription to hold and the outbox's mark to start from, so a
|
|
3229
|
+
* socket hears every change that commits after it was let in. The supervisor accepts the socket.
|
|
3230
|
+
*/
|
|
3231
|
+
async liveAdmit(asked) {
|
|
3232
|
+
this.assertFacet('liveAdmit');
|
|
3233
|
+
const admitted = await this.admitLive(new Request(asked.url, { headers: asked.headers }));
|
|
3234
|
+
if (admitted instanceof Response) {
|
|
3235
|
+
return { admitted: false, status: admitted.status, headers: [...admitted.headers], body: await admitted.text() };
|
|
3236
|
+
}
|
|
3237
|
+
const mark = this.sql.exec('SELECT MAX(id) AS id FROM _substrat_outbox').toArray()[0]
|
|
3238
|
+
?.id ?? '';
|
|
3239
|
+
const subscription = {
|
|
3240
|
+
...admitted.subscriber,
|
|
3241
|
+
since: new Date().toISOString(),
|
|
3242
|
+
...(admitted.within ? { within: admitted.within } : {}),
|
|
3243
|
+
...(admitted.expiresAt ? { expiresAt: admitted.expiresAt } : {}),
|
|
3244
|
+
};
|
|
3245
|
+
return { admitted: true, subscription: { ...subscription }, cursor: mark };
|
|
3246
|
+
}
|
|
3247
|
+
/**
|
|
3248
|
+
* Track B: what each of the supervisor's sockets is owed since its own cursor, decided by the
|
|
3249
|
+
* same pass the object runs (`fanOutLiveTo`), sent back through `handle`. Strict: a socket's
|
|
3250
|
+
* cursor passes only rows decided for it, so a change committed while the supervisor was
|
|
3251
|
+
* resetting, hibernating or between passes is decided on the next pass, never skipped. A frame
|
|
3252
|
+
* may go out twice (a push lost after its send); the client reads a push as a hint to re-read,
|
|
3253
|
+
* so a duplicate costs a read and a gap would cost a stale screen.
|
|
3254
|
+
*/
|
|
3255
|
+
async liveCatchUp(sockets, handle) {
|
|
3256
|
+
this.assertFacet('liveCatchUp');
|
|
3257
|
+
const cursors = {};
|
|
3258
|
+
let behind = false;
|
|
3259
|
+
const held = this.facetTenant();
|
|
3260
|
+
const groups = new Map();
|
|
3261
|
+
for (const socket of sockets) {
|
|
3262
|
+
cursors[socket.sid] = socket.cursor;
|
|
3263
|
+
const subscription = readSubscription(socket.attachment);
|
|
3264
|
+
// Unnamed, or named for another tenant than the scope's own: never fed (the pass skips the
|
|
3265
|
+
// first itself; the second is refused here, where the scope's own receipt is at hand).
|
|
3266
|
+
if (!subscription || (held !== null && subscription.tenantId !== held))
|
|
3267
|
+
continue;
|
|
3268
|
+
const key = `${subscription.tenantId}\n${subscription.scopeId}`;
|
|
3269
|
+
let group = groups.get(key);
|
|
3270
|
+
if (!group)
|
|
3271
|
+
groups.set(key, (group = { tenantId: subscription.tenantId, scopeId: subscription.scopeId, targets: [] }));
|
|
3272
|
+
const { sid } = socket;
|
|
3273
|
+
group.targets.push({
|
|
3274
|
+
sid,
|
|
3275
|
+
since: socket.cursor,
|
|
3276
|
+
cursor: socket.cursor,
|
|
3277
|
+
strict: true,
|
|
3278
|
+
deserializeAttachment: () => socket.attachment,
|
|
3279
|
+
// Not awaited: the call is issued in order on the stub as the pass decides, which is what
|
|
3280
|
+
// keeps no await between a decision and its send. A failure is the socket's, and the
|
|
3281
|
+
// supervisor's next pass, or the client's reconnect from its cursor, covers it.
|
|
3282
|
+
send: (frame) => void Promise.resolve(handle.liveSend(sid, frame)).catch(() => undefined),
|
|
3283
|
+
close: (code, reason) => void Promise.resolve(handle.liveClose(sid, code, reason)).catch(() => undefined),
|
|
3284
|
+
});
|
|
3285
|
+
}
|
|
3286
|
+
for (const group of groups.values()) {
|
|
3287
|
+
const pass = await this.fanOutLiveTo(group.targets, group.tenantId, group.scopeId);
|
|
3288
|
+
behind ||= pass.behind;
|
|
3289
|
+
for (const t of group.targets)
|
|
3290
|
+
cursors[t.sid] = t.cursor;
|
|
3291
|
+
}
|
|
3292
|
+
return { cursors, behind };
|
|
3293
|
+
}
|
|
3116
3294
|
/**
|
|
3117
3295
|
* #3540: whether this scope's purges are due by event: the switch is `event`, a sweeper is bound
|
|
3118
3296
|
* for the alarm to ask, and a registered module declares a purge horizon.
|
|
@@ -3851,6 +4029,17 @@ options = {}) {
|
|
|
3851
4029
|
const sockets = this.ctx.getWebSockets();
|
|
3852
4030
|
if (sockets.length === 0)
|
|
3853
4031
|
return;
|
|
4032
|
+
await this.fanOutLiveTo(sockets.map((ws) => liveTargetOfSocket(ws, sinceEventId)), tenantId, scopeId);
|
|
4033
|
+
}
|
|
4034
|
+
/**
|
|
4035
|
+
* The pass `fanOutLive` describes, over any set of targets (Track B): the object's own sockets,
|
|
4036
|
+
* all from one mark, or a supervisor's, each from its own cursor. One page of
|
|
4037
|
+
* `LIVE_FANOUT_LIMIT` rows above the lowest mark; `behind` says rows remain past it.
|
|
4038
|
+
*/
|
|
4039
|
+
async fanOutLiveTo(targets, tenantId, scopeId) {
|
|
4040
|
+
if (targets.length === 0)
|
|
4041
|
+
return { behind: false };
|
|
4042
|
+
const sinceEventId = targets.reduce((low, t) => (t.since < low ? t.since : low), targets[0].since);
|
|
3854
4043
|
const rows = this.sql
|
|
3855
4044
|
.exec(`SELECT id, type, entity_type, entity_id, occurred_at FROM _substrat_outbox
|
|
3856
4045
|
WHERE id > ? ORDER BY id LIMIT ?`, sinceEventId, LIVE_FANOUT_LIMIT)
|
|
@@ -3858,9 +4047,27 @@ options = {}) {
|
|
|
3858
4047
|
// Drop the undeclared entity types BEFORE any per-subscriber work. Not an
|
|
3859
4048
|
// optimisation: it is the fail-closed rule stated once, in the one place that
|
|
3860
4049
|
// decides, rather than relied upon inside the loop below.
|
|
4050
|
+
const behind = rows.length === LIVE_FANOUT_LIMIT;
|
|
4051
|
+
const last = rows.length > 0 ? rows[rows.length - 1].id : null;
|
|
4052
|
+
/** A target's cursor moved up to `upTo`, never back. */
|
|
4053
|
+
const advance = (t, upTo) => {
|
|
4054
|
+
if (upTo !== null && upTo > t.cursor)
|
|
4055
|
+
t.cursor = upTo;
|
|
4056
|
+
};
|
|
4057
|
+
/** The highest row of this page below `id`: where a walk that stopped at `id` has reached. */
|
|
4058
|
+
const lastBelow = (id) => {
|
|
4059
|
+
let below = null;
|
|
4060
|
+
for (const r of rows)
|
|
4061
|
+
if (r.id < id)
|
|
4062
|
+
below = r.id;
|
|
4063
|
+
return below;
|
|
4064
|
+
};
|
|
3861
4065
|
const announceable = rows.filter((r) => this.liveTargets.has(r.entity_type));
|
|
3862
|
-
if (announceable.length === 0)
|
|
3863
|
-
|
|
4066
|
+
if (announceable.length === 0) {
|
|
4067
|
+
for (const t of targets)
|
|
4068
|
+
advance(t, last);
|
|
4069
|
+
return { behind };
|
|
4070
|
+
}
|
|
3864
4071
|
/**
|
|
3865
4072
|
* Is a row's entity beneath a `within` root (#1853)? Each row's ancestors are walked
|
|
3866
4073
|
* once per pass, on first need, so a check per socket is a set lookup — every widget
|
|
@@ -3916,7 +4123,9 @@ options = {}) {
|
|
|
3916
4123
|
}
|
|
3917
4124
|
return (await up).has(`${root.entityType}:${root.entityId}`);
|
|
3918
4125
|
};
|
|
3919
|
-
for (const ws of
|
|
4126
|
+
for (const ws of targets) {
|
|
4127
|
+
/** The row this target's walk stopped short of (a strict target only), or null. */
|
|
4128
|
+
let stalledAt = null;
|
|
3920
4129
|
let subscription = null;
|
|
3921
4130
|
try {
|
|
3922
4131
|
subscription = readSubscription(ws.deserializeAttachment());
|
|
@@ -4059,6 +4268,9 @@ options = {}) {
|
|
|
4059
4268
|
};
|
|
4060
4269
|
};
|
|
4061
4270
|
rows: for (const row of announceable) {
|
|
4271
|
+
// Already passed by this target's own walk (a supervised socket resuming from its cursor).
|
|
4272
|
+
if (row.id <= ws.since)
|
|
4273
|
+
continue rows;
|
|
4062
4274
|
for (let attempt = 0; attempt < LIVE_DECIDE_ATTEMPTS; attempt++) {
|
|
4063
4275
|
const decidedAt = new Date().toISOString();
|
|
4064
4276
|
const e = epochAt(decidedAt);
|
|
@@ -4095,10 +4307,17 @@ options = {}) {
|
|
|
4095
4307
|
}
|
|
4096
4308
|
continue rows;
|
|
4097
4309
|
}
|
|
4098
|
-
// Still moving after every attempt: this row is not announced, and the
|
|
4099
|
-
// poll — the floor under every push — picks it up.
|
|
4310
|
+
// Still moving after every attempt: on the object this row is not announced, and the
|
|
4311
|
+
// client's poll — the floor under every push — picks it up. A supervised socket stops
|
|
4312
|
+
// here instead, its cursor short of this row, so its next pass decides it again.
|
|
4313
|
+
if (ws.strict) {
|
|
4314
|
+
stalledAt = row.id;
|
|
4315
|
+
break rows;
|
|
4316
|
+
}
|
|
4100
4317
|
}
|
|
4318
|
+
advance(ws, stalledAt === null ? last : lastBelow(stalledAt));
|
|
4101
4319
|
}
|
|
4320
|
+
return { behind };
|
|
4102
4321
|
}
|
|
4103
4322
|
// -- attachments (#473): the metadata half of the attachment surface --------
|
|
4104
4323
|
// The coordinator (worker) holds the bytes and the per-tenant R2 binding; this
|
|
@@ -4299,6 +4518,10 @@ options = {}) {
|
|
|
4299
4518
|
systemAttachmentRemoveReply(...args) {
|
|
4300
4519
|
return replyOf(() => this.removeSystemAttachment(...args));
|
|
4301
4520
|
}
|
|
4521
|
+
/** #3752: a module's own upload, as `system:<module>` (a container pass's `files.put`). */
|
|
4522
|
+
systemAttachmentAddReply(...args) {
|
|
4523
|
+
return replyOf(() => this.addSystemAttachment(...args));
|
|
4524
|
+
}
|
|
4302
4525
|
/** Record an uploaded attachment: write gate + row + `attachment.added`, one txn. */
|
|
4303
4526
|
async addAttachment(record, principal, tenantId, scopeId,
|
|
4304
4527
|
// #476: when set, the gate is checked as this CONNECTION (not `principal`, which is
|
|
@@ -4581,6 +4804,69 @@ options = {}) {
|
|
|
4581
4804
|
return record;
|
|
4582
4805
|
});
|
|
4583
4806
|
}
|
|
4807
|
+
/**
|
|
4808
|
+
* #3752: record a file a module wrote itself — a container pass's output — as `system:<module>`:
|
|
4809
|
+
* the target's write key, checked with the module's purge-only keys withheld, as `remove` is, and
|
|
4810
|
+
* refused while the module is switched off on this scope (the system door). The bytes are already in
|
|
4811
|
+
* the blob store; the host deletes them when this refuses. `createdBy` is the module's actor, JSON.
|
|
4812
|
+
*/
|
|
4813
|
+
async addSystemAttachment(record, moduleId, tenantId, scopeId,
|
|
4814
|
+
/** #1834: the instance the system door's gate read; see `invoke`. */
|
|
4815
|
+
systemDoorInstance) {
|
|
4816
|
+
await this.ensureMigrations();
|
|
4817
|
+
let systemDoor;
|
|
4818
|
+
try {
|
|
4819
|
+
systemDoor = this.assertSystemDoor(moduleId, systemDoorInstance);
|
|
4820
|
+
}
|
|
4821
|
+
catch (err) {
|
|
4822
|
+
if (err instanceof SystemDoorMovedError)
|
|
4823
|
+
return SYSTEM_DOOR_MOVED;
|
|
4824
|
+
throw err;
|
|
4825
|
+
}
|
|
4826
|
+
if (!this.modules.has(moduleId)) {
|
|
4827
|
+
throw substratError('not_found', `module not registered in this scope: ${moduleId}`);
|
|
4828
|
+
}
|
|
4829
|
+
const parsed = attachmentRecord.parse(record);
|
|
4830
|
+
if (parsed.createdBy !== JSON.stringify({ system: moduleId })) {
|
|
4831
|
+
throw substratError('validation_failed', `a module's own file is created by ${JSON.stringify({ system: moduleId })}`);
|
|
4832
|
+
}
|
|
4833
|
+
const gate = this.attachmentGate(parsed.entity.entityType);
|
|
4834
|
+
return this.queue.enqueue(async () => {
|
|
4835
|
+
const liveSince = this.liveHighWaterMark();
|
|
4836
|
+
try {
|
|
4837
|
+
await this.revision.transaction(async () => {
|
|
4838
|
+
const ctx = this.operationContext(this.systemPrincipal, tenantId, scopeId, undefined, undefined, systemDoor, undefined, undefined, 'attachments.upload', undefined, [], undefined, undefined, undefined, this.systemAttachmentWithheld(moduleId));
|
|
4839
|
+
assertAllowed(await ctx.check(gate.write, parsed.entity));
|
|
4840
|
+
refuseCondemnedAttachment(doSpineSql(this.sql), parsed.id);
|
|
4841
|
+
this.sql.exec(`INSERT INTO _substrat_attachments
|
|
4842
|
+
(id, entity_type, entity_id, filename, content_type, size, sha256,
|
|
4843
|
+
visibility, created_by, created_at)
|
|
4844
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, parsed.id, parsed.entity.entityType, parsed.entity.entityId, parsed.filename, parsed.contentType, parsed.size, parsed.sha256, parsed.visibility, parsed.createdBy, parsed.createdAt);
|
|
4845
|
+
kernelEmit(ctx, {
|
|
4846
|
+
type: ATTACHMENT_ADDED,
|
|
4847
|
+
schemaVersion: 1,
|
|
4848
|
+
entity: parsed.entity,
|
|
4849
|
+
piiClass: 'none',
|
|
4850
|
+
payload: { attachment: parsed },
|
|
4851
|
+
});
|
|
4852
|
+
enqueueAttachmentText(doSpineSql(this.sql), parsed.id, ulid(), new Date().toISOString());
|
|
4853
|
+
});
|
|
4854
|
+
}
|
|
4855
|
+
catch (err) {
|
|
4856
|
+
if (err instanceof PermissionDenied) {
|
|
4857
|
+
this.recordDenial({ kind: 'system', id: moduleId }, tenantId, 'attachments.upload', err, null);
|
|
4858
|
+
}
|
|
4859
|
+
throw err;
|
|
4860
|
+
}
|
|
4861
|
+
try {
|
|
4862
|
+
await this.settleCommitted(tenantId, scopeId, liveSince, null);
|
|
4863
|
+
}
|
|
4864
|
+
catch (err) {
|
|
4865
|
+
console.error('substrat: consumer drain failed after an attachment committed', err);
|
|
4866
|
+
}
|
|
4867
|
+
return parsed;
|
|
4868
|
+
});
|
|
4869
|
+
}
|
|
4584
4870
|
// -- attachment text (#1575) ---------------------------------------------------
|
|
4585
4871
|
/**
|
|
4586
4872
|
* Extracted-text search as `ctx`'s subject: authorized first — the check `open` makes,
|