@lunora/do 1.0.0-alpha.286 → 1.0.0-alpha.288

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
@@ -123,7 +123,7 @@ declare const roleNamespace: <Namespace extends RoleNamespaceTarget>(namespace:
123
123
  * relation tables.
124
124
  * @param schema The generated schema (for the table + `shardMode` lookup).
125
125
  * @param database The request's schema-aware ctx-db writer (built by the subclass).
126
- * @param functionPath The reserved path — `${RELATION_FUNCTION_PREFIX}read` or `:count`.
126
+ * @param functionPath The reserved path: `RELATION_FUNCTION_PREFIX` followed by `read` or `count`.
127
127
  * @param args The fan-out args. Typed as {@link CrossShardReadArgs} — the SAME
128
128
  * contract `@lunora/sql-store` produces and `@lunora/runtime` forwards — plus the
129
129
  * `table` the envelope names. It arrives as parsed JSON, so `table` still gets a
@@ -1798,6 +1798,8 @@ declare abstract class ShardDO {
1798
1798
  * stays near a limit warns again after a wake.
1799
1799
  */
1800
1800
  private readonly rerunNearLimitWarned;
1801
+ /** One-shot warning for subscriptions `broadcastDelta` skips because re-execution serves them. */
1802
+ private broadcastSkipWarned;
1801
1803
  /**
1802
1804
  * Client-issued idempotency key for the in-flight mutation, forwarded via the
1803
1805
  * `x-lunora-mutation-id` header. When set, the dispatch path dedups the call
@@ -3727,8 +3729,11 @@ declare abstract class ShardDO {
3727
3729
  protected matchesSubscription(query: SubscriptionQuery, delta: MutationDelta): boolean;
3728
3730
  /**
3729
3731
  * Broadcast a mutation delta to every subscriber whose registered query
3730
- * targets the affected table _and_ matches its args. The wire payload
3731
- * includes the per-socket subscription id, so we serialise once per
3732
+ * targets the affected table _and_ matches its args. Subscriptions this
3733
+ * shard serves by re-execution (see `servedByReexecution`) are skipped: the
3734
+ * row sent is the written row, not filtered by RLS, masks or the
3735
+ * subscriber's query, and `matchesSubscription` is its only filter. The wire
3736
+ * payload includes the per-socket subscription id, so we serialise once per
3732
3737
  * `(socket, sub)` pair — but the structural delta body itself is
3733
3738
  * identical, so we build a payload keyed by `subId` lazily.
3734
3739
  */
@@ -3738,8 +3743,11 @@ declare abstract class ShardDO {
3738
3743
  * the set of tables it read. The base class can't dispatch user functions,
3739
3744
  * so it returns `null` — the codegen-generated subclass overrides this to
3740
3745
  * run the handler from the project's function registry. Returning `null`
3741
- * disables server re-execution and leaves the legacy `broadcastDelta`
3742
- * path as the only live-update mechanism.
3746
+ * from the seed disables server re-execution for that subscription and
3747
+ * leaves the legacy `broadcastDelta` path as its only live-update
3748
+ * mechanism; a subscription whose seed returned a result never receives a
3749
+ * broadcast. Refuse a subscriber by throwing, never by returning `null`:
3750
+ * `null` opts the subscription into raw, unfiltered broadcast rows.
3743
3751
  *
3744
3752
  * `identity` is the EXPLICIT subscriber context the query runs under —
3745
3753
  * identity claims, userId, and the socket's own `ip`. It is passed by value
@@ -4502,6 +4510,34 @@ declare abstract class ShardDO {
4502
4510
  * as this request's. The dispatch path re-pins its own afterwards.
4503
4511
  */
4504
4512
  protected restoreRequestScope(scope: RequestScope): void;
4513
+ /**
4514
+ * Whether a subscription gets its updates by re-execution, which diffs the
4515
+ * query's own result. A broadcast row would bypass that diff baseline (no
4516
+ * later delta removes it) and the subscriber's RLS, masks and query filter,
4517
+ * so `broadcastDelta` must not reach such a subscription.
4518
+ *
4519
+ * Decided per subscription. On a shard that overrides `executeSubscription`,
4520
+ * only a subscription whose seed resolved to `null` (recorded in
4521
+ * `broadcastSubs`) and that has no diff baseline is left to broadcast. Fails
4522
+ * closed: a seed still in flight, one that threw (an auth refusal unsubscribes
4523
+ * it), and one that returned a result are all served by re-execution.
4524
+ * @returns `true` when the shard re-runs this subscription's query
4525
+ */
4526
+ private servedByReexecution;
4527
+ /**
4528
+ * `broadcastDelta`'s skip for a subscription the shard re-runs, logging the
4529
+ * one-time warning the first time it fires.
4530
+ * @returns `true` when `broadcastDelta` must not send this subscription the delta
4531
+ */
4532
+ private skipsForReexecution;
4533
+ /**
4534
+ * Record that `subId`'s seed resolved to `null` through an overridden
4535
+ * `executeSubscription`, which leaves it to `broadcastDelta`. Skipped while
4536
+ * the subscription is gone or now names another function, so a seed that
4537
+ * outlived its subscription cannot mark the one that replaced it.
4538
+ */
4539
+ private markBroadcastSubscription;
4540
+ private unmarkBroadcastSubscription;
4505
4541
  private deliveryRoleSupported;
4506
4542
  private revokeSubscription;
4507
4543
  private sendFrame;
package/dist/index.d.ts CHANGED
@@ -123,7 +123,7 @@ declare const roleNamespace: <Namespace extends RoleNamespaceTarget>(namespace:
123
123
  * relation tables.
124
124
  * @param schema The generated schema (for the table + `shardMode` lookup).
125
125
  * @param database The request's schema-aware ctx-db writer (built by the subclass).
126
- * @param functionPath The reserved path — `${RELATION_FUNCTION_PREFIX}read` or `:count`.
126
+ * @param functionPath The reserved path: `RELATION_FUNCTION_PREFIX` followed by `read` or `count`.
127
127
  * @param args The fan-out args. Typed as {@link CrossShardReadArgs} — the SAME
128
128
  * contract `@lunora/sql-store` produces and `@lunora/runtime` forwards — plus the
129
129
  * `table` the envelope names. It arrives as parsed JSON, so `table` still gets a
@@ -1798,6 +1798,8 @@ declare abstract class ShardDO {
1798
1798
  * stays near a limit warns again after a wake.
1799
1799
  */
1800
1800
  private readonly rerunNearLimitWarned;
1801
+ /** One-shot warning for subscriptions `broadcastDelta` skips because re-execution serves them. */
1802
+ private broadcastSkipWarned;
1801
1803
  /**
1802
1804
  * Client-issued idempotency key for the in-flight mutation, forwarded via the
1803
1805
  * `x-lunora-mutation-id` header. When set, the dispatch path dedups the call
@@ -3727,8 +3729,11 @@ declare abstract class ShardDO {
3727
3729
  protected matchesSubscription(query: SubscriptionQuery, delta: MutationDelta): boolean;
3728
3730
  /**
3729
3731
  * Broadcast a mutation delta to every subscriber whose registered query
3730
- * targets the affected table _and_ matches its args. The wire payload
3731
- * includes the per-socket subscription id, so we serialise once per
3732
+ * targets the affected table _and_ matches its args. Subscriptions this
3733
+ * shard serves by re-execution (see `servedByReexecution`) are skipped: the
3734
+ * row sent is the written row, not filtered by RLS, masks or the
3735
+ * subscriber's query, and `matchesSubscription` is its only filter. The wire
3736
+ * payload includes the per-socket subscription id, so we serialise once per
3732
3737
  * `(socket, sub)` pair — but the structural delta body itself is
3733
3738
  * identical, so we build a payload keyed by `subId` lazily.
3734
3739
  */
@@ -3738,8 +3743,11 @@ declare abstract class ShardDO {
3738
3743
  * the set of tables it read. The base class can't dispatch user functions,
3739
3744
  * so it returns `null` — the codegen-generated subclass overrides this to
3740
3745
  * run the handler from the project's function registry. Returning `null`
3741
- * disables server re-execution and leaves the legacy `broadcastDelta`
3742
- * path as the only live-update mechanism.
3746
+ * from the seed disables server re-execution for that subscription and
3747
+ * leaves the legacy `broadcastDelta` path as its only live-update
3748
+ * mechanism; a subscription whose seed returned a result never receives a
3749
+ * broadcast. Refuse a subscriber by throwing, never by returning `null`:
3750
+ * `null` opts the subscription into raw, unfiltered broadcast rows.
3743
3751
  *
3744
3752
  * `identity` is the EXPLICIT subscriber context the query runs under —
3745
3753
  * identity claims, userId, and the socket's own `ip`. It is passed by value
@@ -4502,6 +4510,34 @@ declare abstract class ShardDO {
4502
4510
  * as this request's. The dispatch path re-pins its own afterwards.
4503
4511
  */
4504
4512
  protected restoreRequestScope(scope: RequestScope): void;
4513
+ /**
4514
+ * Whether a subscription gets its updates by re-execution, which diffs the
4515
+ * query's own result. A broadcast row would bypass that diff baseline (no
4516
+ * later delta removes it) and the subscriber's RLS, masks and query filter,
4517
+ * so `broadcastDelta` must not reach such a subscription.
4518
+ *
4519
+ * Decided per subscription. On a shard that overrides `executeSubscription`,
4520
+ * only a subscription whose seed resolved to `null` (recorded in
4521
+ * `broadcastSubs`) and that has no diff baseline is left to broadcast. Fails
4522
+ * closed: a seed still in flight, one that threw (an auth refusal unsubscribes
4523
+ * it), and one that returned a result are all served by re-execution.
4524
+ * @returns `true` when the shard re-runs this subscription's query
4525
+ */
4526
+ private servedByReexecution;
4527
+ /**
4528
+ * `broadcastDelta`'s skip for a subscription the shard re-runs, logging the
4529
+ * one-time warning the first time it fires.
4530
+ * @returns `true` when `broadcastDelta` must not send this subscription the delta
4531
+ */
4532
+ private skipsForReexecution;
4533
+ /**
4534
+ * Record that `subId`'s seed resolved to `null` through an overridden
4535
+ * `executeSubscription`, which leaves it to `broadcastDelta`. Skipped while
4536
+ * the subscription is gone or now names another function, so a seed that
4537
+ * outlived its subscription cannot mark the one that replaced it.
4538
+ */
4539
+ private markBroadcastSubscription;
4540
+ private unmarkBroadcastSubscription;
4505
4541
  private deliveryRoleSupported;
4506
4542
  private revokeSubscription;
4507
4543
  private sendFrame;
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-vdebJc1d.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-w1SvVlQ0.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};