@lunora/do 1.0.0-alpha.291 → 1.0.0-alpha.292

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
@@ -1912,8 +1912,22 @@ declare abstract class ShardDO {
1912
1912
  /**
1913
1913
  * D1 bookmarks the `.global()` writes behind {@link ShardDO.pendingChangedTables} reported, recorded with
1914
1914
  * their tables by {@link ShardDO.recordGlobalWrite} so they travel with them however dispatches interleave.
1915
+ * Keyed by the writer that reported each, which keeps only its latest: one session's bookmark only
1916
+ * moves forward, so the last covers every earlier write of that writer.
1915
1917
  */
1916
1918
  private pendingChangedBookmarks;
1919
+ /**
1920
+ * The `.global()` tables behind {@link ShardDO.pendingChangedTables}. A write the writer announced
1921
+ * before its transaction committed invalidated the reactive cache too early to cover a read made
1922
+ * during that transaction, so the flush, which runs after the commit, invalidates them again.
1923
+ */
1924
+ private pendingGlobalWriteTables;
1925
+ /** Live queries a refresh ran that recorded no result, so the poll cannot learn what they read. */
1926
+ private readonly unrecordedQueries;
1927
+ /** Whether this instance has warned that a live query reads a `.global()` table nothing polls for. */
1928
+ private warnedUnpolledGlobalRead;
1929
+ /** When the poll last re-ran global live queries without a changelog answer; see {@link ShardDO.refreshFromGlobalPoll}. */
1930
+ private lastBlindRefreshAt;
1917
1931
  /** Coalesced twin of {@link ShardDO.pendingChangedBookmarks}; see {@link refreshReadBookmark}. */
1918
1932
  private pendingRefreshBookmarks;
1919
1933
  /** Coalesced twin of {@link ShardDO.pendingChangedKeys} for the in-flight refresh pass. */
@@ -4351,8 +4365,17 @@ declare abstract class ShardDO {
4351
4365
  * A row the `.global()` writer stored, reported by the writer itself (its `onWrite`), so a write a
4352
4366
  * trigger made inside it is announced too: the shard engine's broadcast only sees the writes it issued.
4353
4367
  * `bookmark` is the D1 bookmark the writer's session held after the write; the refresh reads at it.
4368
+ * `writer` identifies the session that reported it: a later report from the same writer replaces
4369
+ * the earlier one, so one dispatch's writes contribute one bookmark. Omitted, each call counts as a
4370
+ * writer of its own.
4371
+ */
4372
+ protected recordGlobalWrite(table: string, bookmark: string | undefined, writer?: object): void;
4373
+ /**
4374
+ * A `.global()` write the writer could only announce once its statement settled past its deadline,
4375
+ * after the dispatch that issued it had already flushed. Nothing else would flush it, so this does,
4376
+ * reading at the primary: the session's bookmark for an abandoned statement is unknown.
4354
4377
  */
4355
- protected recordGlobalWrite(table: string, bookmark: string | undefined): void;
4378
+ protected recordLateGlobalWrite(table: string): void;
4356
4379
  /**
4357
4380
  * Per-batch progress hook for the codegen subclass's data-migration runner
4358
4381
  * (wired via `runDataMigration`'s `onBatch`). The runner persists progress to
@@ -5862,11 +5885,12 @@ declare abstract class ShardDO {
5862
5885
  */
5863
5886
  private flushChangedTables;
5864
5887
  /**
5865
- * Merge `changed` into the coalesced refresh state and start the drain unless one is running.
5866
- * Shared by a local write's flush and the global poll tick, which learns of another shard's
5867
- * `.global()` write, so both coalesce into one pass.
5888
+ * Merge `changed` into the coalesced refresh state. Shared by a local write's flush and the global
5889
+ * poll tick, which learns of another shard's `.global()` write, so both coalesce into one pass.
5868
5890
  */
5869
- private queueSubscriptionRefresh;
5891
+ private mergeSubscriptionRefresh;
5892
+ /** Start the drain of the merged refresh state, unless one is running or nothing is pending. */
5893
+ private startSubscriptionRefresh;
5870
5894
  /**
5871
5895
  * Drain {@link ShardDO.pendingRefreshTables} one coalesced batch at a time
5872
5896
  * until it is empty, then release the {@link ShardDO.refreshInFlight} gate.
@@ -6514,6 +6538,11 @@ declare abstract class ShardDO {
6514
6538
  * `.global()` tables.
6515
6539
  */
6516
6540
  protected polledGlobalTables(): ReadonlySet<string>;
6541
+ /**
6542
+ * Every `.global()` table of the schema, changelog or not, so a shard can tell its operator that a
6543
+ * live query reads one nothing polls for. The codegen subclass overrides it.
6544
+ */
6545
+ protected globalTables(): ReadonlySet<string>;
6517
6546
  /**
6518
6547
  * The two answers a `/rpc` can earn between the replica gate and
6519
6548
  * `beginDispatch`: a reserved admin RPC (served under its own scope and
@@ -6635,6 +6664,19 @@ declare abstract class ShardDO {
6635
6664
  * queries stops polling one tick after waking.
6636
6665
  */
6637
6666
  private countGlobalQueryReaders;
6667
+ /**
6668
+ * Another shard's write to a global table a live query read reaches it only through the poll tick, so
6669
+ * reading a polled table arms the tick; reading one nothing polls for is warned about instead.
6670
+ */
6671
+ private watchGlobalReads;
6672
+ /** Record that a refresh ran `subId` and it recorded no result to learn its tables from. */
6673
+ private noteUnrecordedQuery;
6674
+ /**
6675
+ * Warn once per instance that a live query reads a `.global()` table this shard cannot poll for:
6676
+ * without the global changelog (`.cdc()` on the app), another shard's write to it never reaches
6677
+ * this query, and nothing else would say so.
6678
+ */
6679
+ private warnIfGlobalReadUnpolled;
6638
6680
  /**
6639
6681
  * Re-run the live queries that read a `.global()` table the changelog says another writer moved,
6640
6682
  * through the same coalesced refresh a local write schedules. A full pass treats every polled
package/dist/index.d.ts CHANGED
@@ -1912,8 +1912,22 @@ declare abstract class ShardDO {
1912
1912
  /**
1913
1913
  * D1 bookmarks the `.global()` writes behind {@link ShardDO.pendingChangedTables} reported, recorded with
1914
1914
  * their tables by {@link ShardDO.recordGlobalWrite} so they travel with them however dispatches interleave.
1915
+ * Keyed by the writer that reported each, which keeps only its latest: one session's bookmark only
1916
+ * moves forward, so the last covers every earlier write of that writer.
1915
1917
  */
1916
1918
  private pendingChangedBookmarks;
1919
+ /**
1920
+ * The `.global()` tables behind {@link ShardDO.pendingChangedTables}. A write the writer announced
1921
+ * before its transaction committed invalidated the reactive cache too early to cover a read made
1922
+ * during that transaction, so the flush, which runs after the commit, invalidates them again.
1923
+ */
1924
+ private pendingGlobalWriteTables;
1925
+ /** Live queries a refresh ran that recorded no result, so the poll cannot learn what they read. */
1926
+ private readonly unrecordedQueries;
1927
+ /** Whether this instance has warned that a live query reads a `.global()` table nothing polls for. */
1928
+ private warnedUnpolledGlobalRead;
1929
+ /** When the poll last re-ran global live queries without a changelog answer; see {@link ShardDO.refreshFromGlobalPoll}. */
1930
+ private lastBlindRefreshAt;
1917
1931
  /** Coalesced twin of {@link ShardDO.pendingChangedBookmarks}; see {@link refreshReadBookmark}. */
1918
1932
  private pendingRefreshBookmarks;
1919
1933
  /** Coalesced twin of {@link ShardDO.pendingChangedKeys} for the in-flight refresh pass. */
@@ -4351,8 +4365,17 @@ declare abstract class ShardDO {
4351
4365
  * A row the `.global()` writer stored, reported by the writer itself (its `onWrite`), so a write a
4352
4366
  * trigger made inside it is announced too: the shard engine's broadcast only sees the writes it issued.
4353
4367
  * `bookmark` is the D1 bookmark the writer's session held after the write; the refresh reads at it.
4368
+ * `writer` identifies the session that reported it: a later report from the same writer replaces
4369
+ * the earlier one, so one dispatch's writes contribute one bookmark. Omitted, each call counts as a
4370
+ * writer of its own.
4371
+ */
4372
+ protected recordGlobalWrite(table: string, bookmark: string | undefined, writer?: object): void;
4373
+ /**
4374
+ * A `.global()` write the writer could only announce once its statement settled past its deadline,
4375
+ * after the dispatch that issued it had already flushed. Nothing else would flush it, so this does,
4376
+ * reading at the primary: the session's bookmark for an abandoned statement is unknown.
4354
4377
  */
4355
- protected recordGlobalWrite(table: string, bookmark: string | undefined): void;
4378
+ protected recordLateGlobalWrite(table: string): void;
4356
4379
  /**
4357
4380
  * Per-batch progress hook for the codegen subclass's data-migration runner
4358
4381
  * (wired via `runDataMigration`'s `onBatch`). The runner persists progress to
@@ -5862,11 +5885,12 @@ declare abstract class ShardDO {
5862
5885
  */
5863
5886
  private flushChangedTables;
5864
5887
  /**
5865
- * Merge `changed` into the coalesced refresh state and start the drain unless one is running.
5866
- * Shared by a local write's flush and the global poll tick, which learns of another shard's
5867
- * `.global()` write, so both coalesce into one pass.
5888
+ * Merge `changed` into the coalesced refresh state. Shared by a local write's flush and the global
5889
+ * poll tick, which learns of another shard's `.global()` write, so both coalesce into one pass.
5868
5890
  */
5869
- private queueSubscriptionRefresh;
5891
+ private mergeSubscriptionRefresh;
5892
+ /** Start the drain of the merged refresh state, unless one is running or nothing is pending. */
5893
+ private startSubscriptionRefresh;
5870
5894
  /**
5871
5895
  * Drain {@link ShardDO.pendingRefreshTables} one coalesced batch at a time
5872
5896
  * until it is empty, then release the {@link ShardDO.refreshInFlight} gate.
@@ -6514,6 +6538,11 @@ declare abstract class ShardDO {
6514
6538
  * `.global()` tables.
6515
6539
  */
6516
6540
  protected polledGlobalTables(): ReadonlySet<string>;
6541
+ /**
6542
+ * Every `.global()` table of the schema, changelog or not, so a shard can tell its operator that a
6543
+ * live query reads one nothing polls for. The codegen subclass overrides it.
6544
+ */
6545
+ protected globalTables(): ReadonlySet<string>;
6517
6546
  /**
6518
6547
  * The two answers a `/rpc` can earn between the replica gate and
6519
6548
  * `beginDispatch`: a reserved admin RPC (served under its own scope and
@@ -6635,6 +6664,19 @@ declare abstract class ShardDO {
6635
6664
  * queries stops polling one tick after waking.
6636
6665
  */
6637
6666
  private countGlobalQueryReaders;
6667
+ /**
6668
+ * Another shard's write to a global table a live query read reaches it only through the poll tick, so
6669
+ * reading a polled table arms the tick; reading one nothing polls for is warned about instead.
6670
+ */
6671
+ private watchGlobalReads;
6672
+ /** Record that a refresh ran `subId` and it recorded no result to learn its tables from. */
6673
+ private noteUnrecordedQuery;
6674
+ /**
6675
+ * Warn once per instance that a live query reads a `.global()` table this shard cannot poll for:
6676
+ * without the global changelog (`.cdc()` on the app), another shard's write to it never reaches
6677
+ * this query, and nothing else would say so.
6678
+ */
6679
+ private warnIfGlobalReadUnpolled;
6638
6680
  /**
6639
6681
  * Re-run the live queries that read a `.global()` table the changelog says another writer moved,
6640
6682
  * through the same coalesced refresh a local write schedules. A full pass treats every polled
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-DcSjzAZv.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-SCKW1DmN.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-DcSjzAZv.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-Dq6YDdyQ.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};