@lunora/do 1.0.0-alpha.301 → 1.0.0-alpha.303

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/index.d.mts CHANGED
@@ -1635,6 +1635,8 @@ declare abstract class ShardDO {
1635
1635
  * not throw.
1636
1636
  */
1637
1637
  private afterCommitTail;
1638
+ /** Links on {@link ShardDO.afterCommitTail} not yet settled. See {@link ShardDO.hasUnfinishedWork}. */
1639
+ private unfinishedAfterCommitLinks;
1638
1640
  /**
1639
1641
  * True once a dispatch's bounded wait for its link on
1640
1642
  * {@link ShardDO.afterCommitTail} expired — i.e. a hook is stuck on a remote
@@ -2168,6 +2170,8 @@ declare abstract class ShardDO {
2168
2170
  private readonly liveSubscribers;
2169
2171
  /** The keepalive timer for open live streams. Runs only while at least one is open. */
2170
2172
  private liveKeepalive;
2173
+ /** SSE response bodies this instance created that are neither closed nor cancelled. See {@link ShardDO.hasUnfinishedWork}. */
2174
+ private openLiveStreams;
2171
2175
  /**
2172
2176
  * Per-socket {@link AbortController} map keyed by stream id, used to
2173
2177
  * propagate a client unsubscribe (or a socket close) into the user
@@ -2519,6 +2523,16 @@ declare abstract class ShardDO {
2519
2523
  * or one second of successful request-log rows.
2520
2524
  */
2521
2525
  flushBeforeClose(): void;
2526
+ /**
2527
+ * Whether this instance holds work in memory that a close would lose: a response body it created is still streaming
2528
+ * (its subscribers live only here), or an after-commit link is unfinished. A bounded wait can return with a hook still
2529
+ * running on the chain; an instance dropped then would let a later write on a fresh instance start a new chain that
2530
+ * overtakes it, so an external projection would see writes out of commit order.
2531
+ *
2532
+ * Node: the host keeps a shard open while this answers true. Cloudflare keeps the instance alive for an open response
2533
+ * body and pending work on its own and never calls it.
2534
+ */
2535
+ hasUnfinishedWork(): boolean;
2522
2536
  /**
2523
2537
  * Whether an upgrade may take a pending slot; an authenticated one always may. Closes
2524
2538
  * the pending sockets past their connect deadline first, so the count is of live ones.
@@ -3461,6 +3475,19 @@ declare abstract class ShardDO {
3461
3475
  * `LUNORA_FUNCTIONS` lookup, which is what production dispatch uses.
3462
3476
  */
3463
3477
  protected isMutationFunction(_functionPath: string): boolean;
3478
+ /**
3479
+ * Whether `functionPath` names a registered `query`, whose dispatch runs
3480
+ * through the host's read gate ({@link ShardHost.runShared}): on a host
3481
+ * without an input gate (Node) it then waits for an open mutation instead of
3482
+ * being refused by it, and a mutation waits for it.
3483
+ *
3484
+ * The base class has no function registry, so the default is `false`: an
3485
+ * unknown function is never gated, which keeps a subclass without the
3486
+ * registry dispatching exactly as it did. Gating an action by mistake would
3487
+ * hold every mutation on the shard for the length of its outbound I/O. The
3488
+ * codegen-generated subclass overrides it with the `LUNORA_FUNCTIONS` lookup.
3489
+ */
3490
+ protected isQueryFunction(_functionPath: string): boolean;
3464
3491
  /**
3465
3492
  * Classify an in-flight custom-mutator push against the shard's stored
3466
3493
  * high-watermark for `currentRequestClientId`. The watermark is the highest
@@ -5650,6 +5677,16 @@ declare abstract class ShardDO {
5650
5677
  * query under its own identity.
5651
5678
  */
5652
5679
  private joinReactiveRun;
5680
+ /**
5681
+ * Run a read-only dispatch under the host's read gate, or directly on a host
5682
+ * with an input gate, which has none.
5683
+ *
5684
+ * The gated read must never wait on same-shard work that needs the write
5685
+ * gate (a self-fetch to a mutation on this shard, say): that work waits for
5686
+ * the read to finish, and the two deadlock. The host lets a read upgrade
5687
+ * only for work in its own async chain.
5688
+ */
5689
+ private runShared;
5653
5690
  /**
5654
5691
  * Single-flight for subscription seeds: identical seeds (same key as the
5655
5692
  * refresh dedup) that start while one is in flight join it, so a reconnect
package/dist/index.d.ts CHANGED
@@ -1635,6 +1635,8 @@ declare abstract class ShardDO {
1635
1635
  * not throw.
1636
1636
  */
1637
1637
  private afterCommitTail;
1638
+ /** Links on {@link ShardDO.afterCommitTail} not yet settled. See {@link ShardDO.hasUnfinishedWork}. */
1639
+ private unfinishedAfterCommitLinks;
1638
1640
  /**
1639
1641
  * True once a dispatch's bounded wait for its link on
1640
1642
  * {@link ShardDO.afterCommitTail} expired — i.e. a hook is stuck on a remote
@@ -2168,6 +2170,8 @@ declare abstract class ShardDO {
2168
2170
  private readonly liveSubscribers;
2169
2171
  /** The keepalive timer for open live streams. Runs only while at least one is open. */
2170
2172
  private liveKeepalive;
2173
+ /** SSE response bodies this instance created that are neither closed nor cancelled. See {@link ShardDO.hasUnfinishedWork}. */
2174
+ private openLiveStreams;
2171
2175
  /**
2172
2176
  * Per-socket {@link AbortController} map keyed by stream id, used to
2173
2177
  * propagate a client unsubscribe (or a socket close) into the user
@@ -2519,6 +2523,16 @@ declare abstract class ShardDO {
2519
2523
  * or one second of successful request-log rows.
2520
2524
  */
2521
2525
  flushBeforeClose(): void;
2526
+ /**
2527
+ * Whether this instance holds work in memory that a close would lose: a response body it created is still streaming
2528
+ * (its subscribers live only here), or an after-commit link is unfinished. A bounded wait can return with a hook still
2529
+ * running on the chain; an instance dropped then would let a later write on a fresh instance start a new chain that
2530
+ * overtakes it, so an external projection would see writes out of commit order.
2531
+ *
2532
+ * Node: the host keeps a shard open while this answers true. Cloudflare keeps the instance alive for an open response
2533
+ * body and pending work on its own and never calls it.
2534
+ */
2535
+ hasUnfinishedWork(): boolean;
2522
2536
  /**
2523
2537
  * Whether an upgrade may take a pending slot; an authenticated one always may. Closes
2524
2538
  * the pending sockets past their connect deadline first, so the count is of live ones.
@@ -3461,6 +3475,19 @@ declare abstract class ShardDO {
3461
3475
  * `LUNORA_FUNCTIONS` lookup, which is what production dispatch uses.
3462
3476
  */
3463
3477
  protected isMutationFunction(_functionPath: string): boolean;
3478
+ /**
3479
+ * Whether `functionPath` names a registered `query`, whose dispatch runs
3480
+ * through the host's read gate ({@link ShardHost.runShared}): on a host
3481
+ * without an input gate (Node) it then waits for an open mutation instead of
3482
+ * being refused by it, and a mutation waits for it.
3483
+ *
3484
+ * The base class has no function registry, so the default is `false`: an
3485
+ * unknown function is never gated, which keeps a subclass without the
3486
+ * registry dispatching exactly as it did. Gating an action by mistake would
3487
+ * hold every mutation on the shard for the length of its outbound I/O. The
3488
+ * codegen-generated subclass overrides it with the `LUNORA_FUNCTIONS` lookup.
3489
+ */
3490
+ protected isQueryFunction(_functionPath: string): boolean;
3464
3491
  /**
3465
3492
  * Classify an in-flight custom-mutator push against the shard's stored
3466
3493
  * high-watermark for `currentRequestClientId`. The watermark is the highest
@@ -5650,6 +5677,16 @@ declare abstract class ShardDO {
5650
5677
  * query under its own identity.
5651
5678
  */
5652
5679
  private joinReactiveRun;
5680
+ /**
5681
+ * Run a read-only dispatch under the host's read gate, or directly on a host
5682
+ * with an input gate, which has none.
5683
+ *
5684
+ * The gated read must never wait on same-shard work that needs the write
5685
+ * gate (a self-fetch to a mutation on this shard, say): that work waits for
5686
+ * the read to finish, and the two deadlock. The host lets a read upgrade
5687
+ * only for work in its own async chain.
5688
+ */
5689
+ private runShared;
5653
5690
  /**
5654
5691
  * Single-flight for subscription seeds: identical seeds (same key as the
5655
5692
  * refresh dedup) that start while one is in flight join it, so a reconnect
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{AdminRevocationDO as a}from"./packem_shared/AdminRevocationDO-DHjoZWfF.mjs";import{installDeliveryFence as t}from"./packem_shared/installDeliveryFence-B6M9KOnb.mjs";import{MERGED_ROLES as S,mergeDurableObjects as i,roleNamespace as l}from"./packem_shared/MERGED_ROLES-BAMAmIcW.mjs";import{serveRelationFanout as n}from"./packem_shared/serveRelationFanout-Bms_fuoY.mjs";import{SESSION_DO_TTL_DEFAULT as d,SessionDO as p}from"./packem_shared/SESSION_DO_TTL_DEFAULT-DSvTwRjc.mjs";import{ROOT_DO_SIZE_WARN_BYTES as D,ROOT_SHARD_NAME as O,ShardDO as E}from"./packem_shared/ROOT_DO_SIZE_WARN_BYTES-Dj8nZ80f.mjs";import{SHARD_REGISTRY_DO_NAME as h,ShardRegistryDO as x,hostedShardRegistry as f}from"./packem_shared/SHARD_REGISTRY_DO_NAME-Dbh8JQJQ.mjs";import{createStableIdFactory as A,createStableRandomFactory as I}from"./packem_shared/createStableIdFactory-DPDT_chw.mjs";import{createShardAlarms as b,createShardDirectory as M,createShardHost as N,createShardKvStore as g,createShardPlatform as y,createSocketHost as k,createWorkerPlatform as F}from"@lunora/platform-cloudflare";import{REPROJECTION_MIGRATION_PREFIX as L,UNVOUCHABLE_DEP as v,applyCdcChanges as H,assertShapeShardable as P,backfillSearchIndexes as j,backfillVectorIndexes as U,buildReprojectionMigration as w,clearMemoryTables as G,countLegacyRows as V,createReadFootprint as B,createShardCtxDb as W,exportShardRows as Y,importShardRows as J,isSourceDue as K,markUnvouchableReads as X,pullExternalSourceIncrementalTick as Z,pullExternalSourceTick as q,reprojectionMigrationId as z,reprojectionTables as Q,runDataMigration as $,runShardMigrations as ee,subscriptionListDeltas as re}from"@lunora/shard-engine";import{A as oe}from"./packem_shared/admin-token-DrufJIZV.mjs";export{oe as ADMIN_REVOCATION_DO_NAME,a as AdminRevocationDO,S as MERGED_ROLES,L as REPROJECTION_MIGRATION_PREFIX,D as ROOT_DO_SIZE_WARN_BYTES,O as ROOT_SHARD_NAME,d as SESSION_DO_TTL_DEFAULT,h as SHARD_REGISTRY_DO_NAME,p as SessionDO,E as ShardDO,x as ShardRegistryDO,v as UNVOUCHABLE_DEP,H as applyCdcChanges,P as assertShapeShardable,j as backfillSearchIndexes,U as backfillVectorIndexes,w as buildReprojectionMigration,G as clearMemoryTables,V as countLegacyRows,B as createReadFootprint,b as createShardAlarms,W as createShardCtxDb,M as createShardDirectory,N as createShardHost,g as createShardKvStore,y as createShardPlatform,k as createSocketHost,A as createStableIdFactory,I as createStableRandomFactory,F as createWorkerPlatform,Y as exportShardRows,f as hostedShardRegistry,J as importShardRows,t as installDeliveryFence,K as isSourceDue,X as markUnvouchableReads,i as mergeDurableObjects,Z as pullExternalSourceIncrementalTick,q as pullExternalSourceTick,z as reprojectionMigrationId,Q as reprojectionTables,l as roleNamespace,$ as runDataMigration,ee as runShardMigrations,n as serveRelationFanout,re as subscriptionListDeltas};
1
+ import{AdminRevocationDO as a}from"./packem_shared/AdminRevocationDO-DHjoZWfF.mjs";import{installDeliveryFence as t}from"./packem_shared/installDeliveryFence-B6M9KOnb.mjs";import{MERGED_ROLES as S,mergeDurableObjects as i,roleNamespace as l}from"./packem_shared/MERGED_ROLES-BAMAmIcW.mjs";import{serveRelationFanout as n}from"./packem_shared/serveRelationFanout-Bms_fuoY.mjs";import{SESSION_DO_TTL_DEFAULT as d,SessionDO as p}from"./packem_shared/SESSION_DO_TTL_DEFAULT-DSvTwRjc.mjs";import{ROOT_DO_SIZE_WARN_BYTES as D,ROOT_SHARD_NAME as O,ShardDO as E}from"./packem_shared/ROOT_DO_SIZE_WARN_BYTES-DiCZKDDD.mjs";import{SHARD_REGISTRY_DO_NAME as h,ShardRegistryDO as x,hostedShardRegistry as f}from"./packem_shared/SHARD_REGISTRY_DO_NAME-Dbh8JQJQ.mjs";import{createStableIdFactory as A,createStableRandomFactory as I}from"./packem_shared/createStableIdFactory-DPDT_chw.mjs";import{createShardAlarms as b,createShardDirectory as M,createShardHost as N,createShardKvStore as g,createShardPlatform as y,createSocketHost as k,createWorkerPlatform as F}from"@lunora/platform-cloudflare";import{REPROJECTION_MIGRATION_PREFIX as L,UNVOUCHABLE_DEP as v,applyCdcChanges as H,assertShapeShardable as P,backfillSearchIndexes as j,backfillVectorIndexes as U,buildReprojectionMigration as w,clearMemoryTables as G,countLegacyRows as V,createReadFootprint as B,createShardCtxDb as W,exportShardRows as Y,importShardRows as J,isSourceDue as K,markUnvouchableReads as X,pullExternalSourceIncrementalTick as Z,pullExternalSourceTick as q,reprojectionMigrationId as z,reprojectionTables as Q,runDataMigration as $,runShardMigrations as ee,subscriptionListDeltas as re}from"@lunora/shard-engine";import{A as oe}from"./packem_shared/admin-token-DrufJIZV.mjs";export{oe as ADMIN_REVOCATION_DO_NAME,a as AdminRevocationDO,S as MERGED_ROLES,L as REPROJECTION_MIGRATION_PREFIX,D as ROOT_DO_SIZE_WARN_BYTES,O as ROOT_SHARD_NAME,d as SESSION_DO_TTL_DEFAULT,h as SHARD_REGISTRY_DO_NAME,p as SessionDO,E as ShardDO,x as ShardRegistryDO,v as UNVOUCHABLE_DEP,H as applyCdcChanges,P as assertShapeShardable,j as backfillSearchIndexes,U as backfillVectorIndexes,w as buildReprojectionMigration,G as clearMemoryTables,V as countLegacyRows,B as createReadFootprint,b as createShardAlarms,W as createShardCtxDb,M as createShardDirectory,N as createShardHost,g as createShardKvStore,y as createShardPlatform,k as createSocketHost,A as createStableIdFactory,I as createStableRandomFactory,F as createWorkerPlatform,Y as exportShardRows,f as hostedShardRegistry,J as importShardRows,t as installDeliveryFence,K as isSourceDue,X as markUnvouchableReads,i as mergeDurableObjects,Z as pullExternalSourceIncrementalTick,q as pullExternalSourceTick,z as reprojectionMigrationId,Q as reprojectionTables,l as roleNamespace,$ as runDataMigration,ee as runShardMigrations,n as serveRelationFanout,re as subscriptionListDeltas};