@lunora/do 1.0.0-alpha.269 → 1.0.0-alpha.270
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
|
@@ -952,6 +952,12 @@ interface HibernatableWebSocket {
|
|
|
952
952
|
* hook) — the shard uses it to decide which writes should trigger a re-run.
|
|
953
953
|
*/
|
|
954
954
|
interface SubscriptionOutcome {
|
|
955
|
+
/**
|
|
956
|
+
* Set only by an executor whose ctx routes every caller read through
|
|
957
|
+
* {@link ShardDO.noteIdentityRead}. Absent, the run is assumed to depend on
|
|
958
|
+
* the caller, so its path never shares a run across identities.
|
|
959
|
+
*/
|
|
960
|
+
identityTracked?: boolean;
|
|
955
961
|
/**
|
|
956
962
|
* Index slices the run was provably confined to, per table — see
|
|
957
963
|
* {@link SubscriptionMemo.ranges}. Absent when the run reported no
|
|
@@ -1911,6 +1917,20 @@ declare abstract class ShardDO {
|
|
|
1911
1917
|
private writeGeneration;
|
|
1912
1918
|
/** In-flight subscription seeds by stamp and run key; see {@link ShardDO.resolveSeedOutcome}. */
|
|
1913
1919
|
private readonly seedRuns;
|
|
1920
|
+
/**
|
|
1921
|
+
* Function paths a ctx has been seen reading its caller through (`ctx.auth`,
|
|
1922
|
+
* `ctx.ip`, or any facade built from them). Sticky for the instance's
|
|
1923
|
+
* lifetime: once a path reads identity, its live runs are never shared across
|
|
1924
|
+
* callers again.
|
|
1925
|
+
*/
|
|
1926
|
+
private readonly identityReadPaths;
|
|
1927
|
+
/**
|
|
1928
|
+
* Function paths a vouched live run completed without reading its caller, and
|
|
1929
|
+
* not in {@link ShardDO.identityReadPaths}: their runs are shared across
|
|
1930
|
+
* subscribers whatever their identity. A path starts outside this set, so its
|
|
1931
|
+
* first run is always keyed by caller.
|
|
1932
|
+
*/
|
|
1933
|
+
private readonly identityFreePaths;
|
|
1914
1934
|
/**
|
|
1915
1935
|
* Per-socket poke baseline for shape subscriptions: maps each shape's
|
|
1916
1936
|
* subscription id to the `__cdc_log` cursor it has been poked through.
|
|
@@ -2754,6 +2774,14 @@ declare abstract class ShardDO {
|
|
|
2754
2774
|
* would share one entry again.
|
|
2755
2775
|
*/
|
|
2756
2776
|
protected getCurrentIp(): string | undefined;
|
|
2777
|
+
/**
|
|
2778
|
+
* Record that a ctx built for `functionPath` handed its caller (identity,
|
|
2779
|
+
* userId or ip) to code. The generated `buildCtx` calls it from every
|
|
2780
|
+
* accessor that exposes the caller, synchronously at the read, so the mark
|
|
2781
|
+
* lands before the run that made it settles and a socket joining that run
|
|
2782
|
+
* sees it. See {@link ShardDO.joinReactiveRun}.
|
|
2783
|
+
*/
|
|
2784
|
+
protected noteIdentityRead(functionPath: string): void;
|
|
2757
2785
|
/**
|
|
2758
2786
|
* The origin the current request reached the worker on, or `undefined` when
|
|
2759
2787
|
* none was forwarded (an alarm, a subscription re-run, a server-side
|
|
@@ -5425,6 +5453,16 @@ declare abstract class ShardDO {
|
|
|
5425
5453
|
* - everything else → {@link executeSubscription} (the user query, under the socket's own by-value identity).
|
|
5426
5454
|
*/
|
|
5427
5455
|
private resolveReactiveOutcome;
|
|
5456
|
+
/**
|
|
5457
|
+
* Promote `functionPath` to identity-free once a tracked run of it finished
|
|
5458
|
+
* without reading its caller. The result is encoded first, because encoding
|
|
5459
|
+
* runs any getter the handler left on it, and such a getter may read the
|
|
5460
|
+
* caller too; it is the same encoding (cached per outcome) every delivery
|
|
5461
|
+
* reuses. A result that fails to encode proves nothing and promotes nothing.
|
|
5462
|
+
* A path already marked can never be promoted (marks are never cleared), so
|
|
5463
|
+
* it skips the encode, which no delivery may need.
|
|
5464
|
+
*/
|
|
5465
|
+
private settleIdentityUse;
|
|
5428
5466
|
/**
|
|
5429
5467
|
* SECURITY BOUNDARY for cross-socket reactive dedup. A read is
|
|
5430
5468
|
* identity-INDEPENDENT only when its result cannot vary by the caller's
|
|
@@ -5433,23 +5471,23 @@ declare abstract class ShardDO {
|
|
|
5433
5471
|
* {@link SubscriptionIdentity} entirely. Those share one result across ALL
|
|
5434
5472
|
* sockets (the null-identity bucket of {@link resolveReactiveOutcomeDeduped}).
|
|
5435
5473
|
*
|
|
5436
|
-
* Everything else is identity-DEPENDENT: a user query
|
|
5437
|
-
* `ctx.auth`-scoped and a flag read ({@link FLAGS_FUNCTION_PREFIX})
|
|
5438
|
-
* with the subscriber's identity. Those
|
|
5439
|
-
* identity (claims, ip, userId) is equal — see {@link subscriptionIdentityKey}
|
|
5474
|
+
* Everything else is identity-DEPENDENT until proven otherwise: a user query
|
|
5475
|
+
* may be `rls()` / `ctx.auth`-scoped and a flag read ({@link FLAGS_FUNCTION_PREFIX})
|
|
5476
|
+
* evaluates with the subscriber's identity. Those share between sockets whose
|
|
5477
|
+
* FULL identity (claims, ip, userId) is equal — see {@link subscriptionIdentityKey} —
|
|
5478
|
+
* unless the path has been observed never reading its caller; see
|
|
5479
|
+
* {@link ShardDO.reactiveRunKey}.
|
|
5440
5480
|
*/
|
|
5441
5481
|
protected isIdentityIndependent(functionPath: string): boolean;
|
|
5442
5482
|
/**
|
|
5443
5483
|
* Memoizing wrapper over {@link resolveReactiveOutcome}: flush-local sharing across sockets.
|
|
5444
5484
|
* Within a single {@link refreshSubscriptions} pass, sockets subscribed to the
|
|
5445
|
-
* SAME `(functionPath, args)` under the
|
|
5446
|
-
* first run is cached (by its in-flight Promise, since the
|
|
5447
|
-
* runs sockets in parallel) and shared with the rest
|
|
5448
|
-
*
|
|
5449
|
-
*
|
|
5450
|
-
*
|
|
5451
|
-
* The `cache` is created fresh per flush by the caller, so a result is never
|
|
5452
|
-
* reused across passes (it would go stale after the next write).
|
|
5485
|
+
* SAME `(functionPath, args)` under the same {@link ShardDO.reactiveRunKey} run
|
|
5486
|
+
* the query once: the first run is cached (by its in-flight Promise, since the
|
|
5487
|
+
* bounded worker pool runs sockets in parallel) and shared with the rest, through
|
|
5488
|
+
* {@link ShardDO.joinReactiveRun}. The `cache` is created fresh per flush by the
|
|
5489
|
+
* caller, so a result is never reused across passes (it would go stale after the
|
|
5490
|
+
* next write).
|
|
5453
5491
|
*
|
|
5454
5492
|
* `args` and `attachment` are the socket's own stored values and are only READ
|
|
5455
5493
|
* here, to build the key. What the handler receives is a copy — `handedArgs()`
|
|
@@ -5457,8 +5495,30 @@ declare abstract class ShardDO {
|
|
|
5457
5495
|
* so every socket that shares a run skips both deep clones.
|
|
5458
5496
|
*/
|
|
5459
5497
|
private resolveReactiveOutcomeDeduped;
|
|
5460
|
-
/**
|
|
5498
|
+
/**
|
|
5499
|
+
* The key two reactive runs share under, and — when it leaves the caller out —
|
|
5500
|
+
* the full identity key of the socket that starts the run.
|
|
5501
|
+
*
|
|
5502
|
+
* Admin/reserved reads (see {@link isIdentityIndependent}) never carry the
|
|
5503
|
+
* caller. A user query carries it unless its path is in
|
|
5504
|
+
* {@link ShardDO.identityFreePaths}: a tracked run of it already finished
|
|
5505
|
+
* without reading identity, and none has read it since. A path's first run is
|
|
5506
|
+
* therefore always keyed, and the moment any run reads identity the path is
|
|
5507
|
+
* keyed again for good.
|
|
5508
|
+
*/
|
|
5461
5509
|
private reactiveRunKey;
|
|
5510
|
+
/**
|
|
5511
|
+
* Join a run another socket started. A run keyed by caller is joined as is.
|
|
5512
|
+
* One keyed without it was started on the strength of earlier runs, and the
|
|
5513
|
+
* handler may still read the caller on a branch none of them took — so a
|
|
5514
|
+
* socket with a different identity only takes the result if the path is still
|
|
5515
|
+
* unmarked once the run has settled (every accessor marks synchronously, and
|
|
5516
|
+
* the result is encoded before the run settles, see
|
|
5517
|
+
* {@link ShardDO.settleIdentityUse}), and that encoding succeeded. Otherwise,
|
|
5518
|
+
* and on a rejection whose message may carry the leader's data, it runs the
|
|
5519
|
+
* query under its own identity.
|
|
5520
|
+
*/
|
|
5521
|
+
private joinReactiveRun;
|
|
5462
5522
|
/**
|
|
5463
5523
|
* Single-flight for subscription seeds: identical seeds (same key as the
|
|
5464
5524
|
* refresh dedup) that start while one is in flight join it, so a reconnect
|
|
@@ -5597,52 +5657,29 @@ declare abstract class ShardDO {
|
|
|
5597
5657
|
* subscription set is small (cap of {@link ShardDO.MAX_SUBSCRIPTIONS_PER_SOCKET}).
|
|
5598
5658
|
*
|
|
5599
5659
|
* ----------------------------------------------------------------------
|
|
5600
|
-
*
|
|
5660
|
+
* Sockets on the same `(functionPath, args)` share ONE run per flush.
|
|
5601
5661
|
* ----------------------------------------------------------------------
|
|
5602
|
-
*
|
|
5603
|
-
*
|
|
5604
|
-
*
|
|
5605
|
-
*
|
|
5606
|
-
*
|
|
5607
|
-
*
|
|
5608
|
-
*
|
|
5609
|
-
*
|
|
5610
|
-
*
|
|
5611
|
-
*
|
|
5612
|
-
*
|
|
5613
|
-
* (
|
|
5614
|
-
*
|
|
5615
|
-
* `{type:"delta"}`, a freshly-subscribed socket a full `{type:"data"}`
|
|
5616
|
-
* snapshot, and an up-to-date socket nothing at all. So only the QUERY RUN +
|
|
5617
|
-
* its result can be shared — `pushSubscriptionData` must still run per socket.
|
|
5618
|
-
* Dedup saves the N-1 redundant runs, not the fan-out.
|
|
5619
|
-
*
|
|
5620
|
-
* (b) Side-effect cardinality. The real `executeSubscription` lives in the
|
|
5621
|
-
* codegen subclass and dispatches the user handler, which records function
|
|
5622
|
-
* metrics, scan attribution, and `ctx.log` lines PER RUN. N subscribers today
|
|
5623
|
-
* produce N metric samples / N log lines; collapsing to one run silently
|
|
5624
|
-
* under-counts those in the studio. The base class can't see inside the
|
|
5625
|
-
* override, so it can't make that trade safely.
|
|
5626
|
-
*
|
|
5627
|
-
* (c) Error attribution. A throwing run is contained per (socket, sub) here
|
|
5628
|
-
* (see the catch below, and the integration test's isolation cases). A shared
|
|
5629
|
-
* run would have to fan one failure to every sharing socket while preserving
|
|
5630
|
-
* the "leave memo untouched ⇒ re-run next flush" contract.
|
|
5662
|
+
* Only the run and its outcome (value AND `tables`/`ranges` footprint) are
|
|
5663
|
+
* shared, through {@link ShardDO.resolveReactiveOutcomeDeduped}; the frame is
|
|
5664
|
+
* still built per socket (`pushSubscriptionData`), since each socket's memo
|
|
5665
|
+
* decides between a delta, a snapshot and nothing. Sharing is bounded by
|
|
5666
|
+
* {@link ShardDO.reactiveRunKey}: equal identity, or a path observed never
|
|
5667
|
+
* reading its caller.
|
|
5668
|
+
*
|
|
5669
|
+
* Two consequences are deliberate. A shared run records its function metrics,
|
|
5670
|
+
* scan attribution and `ctx.log` lines once, not once per subscriber. And a
|
|
5671
|
+
* shared run that throws fails every socket sharing it under the same key; a
|
|
5672
|
+
* socket of another identity that joined an identity-free run re-runs on its
|
|
5673
|
+
* own instead (see {@link ShardDO.joinReactiveRun}). Either way the memo is
|
|
5674
|
+
* left untouched, so the subscription re-runs next flush.
|
|
5631
5675
|
*
|
|
5632
5676
|
* The opt-in {@link ReactiveCache} (`ShardDOOptions.reactiveCache`) does NOT
|
|
5633
5677
|
* cover this, despite the shared key shape: it wraps `/rpc` query dispatch
|
|
5634
5678
|
* (see {@link ShardDO.runCachedQuery}), while a refresh runs through
|
|
5635
|
-
* `executeSubscription`, which never consults it. It cannot, either — a
|
|
5636
|
-
*
|
|
5637
|
-
*
|
|
5638
|
-
*
|
|
5639
|
-
* routing refreshes through the cache would quietly empty every memo's
|
|
5640
|
-
* dependency set and stop the subscription updating at all.
|
|
5641
|
-
*
|
|
5642
|
-
* So this fan-out stands as characterized. Collapsing it needs a dedup that
|
|
5643
|
-
* shares the footprint alongside the value — {@link ShardDO.resolveReactiveOutcomeDeduped}
|
|
5644
|
-
* is that, per flush, for the identity-independent subset — not a second
|
|
5645
|
-
* memo bolted into this loop.
|
|
5679
|
+
* `executeSubscription`, which never consults it. It cannot, either — a cache
|
|
5680
|
+
* hit produces a value with no footprint, so routing refreshes through it
|
|
5681
|
+
* would quietly empty every memo's dependency set and stop the subscription
|
|
5682
|
+
* updating at all.
|
|
5646
5683
|
*/
|
|
5647
5684
|
/**
|
|
5648
5685
|
* Count and log a subscription-delivery error that its caller is about to
|
package/dist/index.d.ts
CHANGED
|
@@ -952,6 +952,12 @@ interface HibernatableWebSocket {
|
|
|
952
952
|
* hook) — the shard uses it to decide which writes should trigger a re-run.
|
|
953
953
|
*/
|
|
954
954
|
interface SubscriptionOutcome {
|
|
955
|
+
/**
|
|
956
|
+
* Set only by an executor whose ctx routes every caller read through
|
|
957
|
+
* {@link ShardDO.noteIdentityRead}. Absent, the run is assumed to depend on
|
|
958
|
+
* the caller, so its path never shares a run across identities.
|
|
959
|
+
*/
|
|
960
|
+
identityTracked?: boolean;
|
|
955
961
|
/**
|
|
956
962
|
* Index slices the run was provably confined to, per table — see
|
|
957
963
|
* {@link SubscriptionMemo.ranges}. Absent when the run reported no
|
|
@@ -1911,6 +1917,20 @@ declare abstract class ShardDO {
|
|
|
1911
1917
|
private writeGeneration;
|
|
1912
1918
|
/** In-flight subscription seeds by stamp and run key; see {@link ShardDO.resolveSeedOutcome}. */
|
|
1913
1919
|
private readonly seedRuns;
|
|
1920
|
+
/**
|
|
1921
|
+
* Function paths a ctx has been seen reading its caller through (`ctx.auth`,
|
|
1922
|
+
* `ctx.ip`, or any facade built from them). Sticky for the instance's
|
|
1923
|
+
* lifetime: once a path reads identity, its live runs are never shared across
|
|
1924
|
+
* callers again.
|
|
1925
|
+
*/
|
|
1926
|
+
private readonly identityReadPaths;
|
|
1927
|
+
/**
|
|
1928
|
+
* Function paths a vouched live run completed without reading its caller, and
|
|
1929
|
+
* not in {@link ShardDO.identityReadPaths}: their runs are shared across
|
|
1930
|
+
* subscribers whatever their identity. A path starts outside this set, so its
|
|
1931
|
+
* first run is always keyed by caller.
|
|
1932
|
+
*/
|
|
1933
|
+
private readonly identityFreePaths;
|
|
1914
1934
|
/**
|
|
1915
1935
|
* Per-socket poke baseline for shape subscriptions: maps each shape's
|
|
1916
1936
|
* subscription id to the `__cdc_log` cursor it has been poked through.
|
|
@@ -2754,6 +2774,14 @@ declare abstract class ShardDO {
|
|
|
2754
2774
|
* would share one entry again.
|
|
2755
2775
|
*/
|
|
2756
2776
|
protected getCurrentIp(): string | undefined;
|
|
2777
|
+
/**
|
|
2778
|
+
* Record that a ctx built for `functionPath` handed its caller (identity,
|
|
2779
|
+
* userId or ip) to code. The generated `buildCtx` calls it from every
|
|
2780
|
+
* accessor that exposes the caller, synchronously at the read, so the mark
|
|
2781
|
+
* lands before the run that made it settles and a socket joining that run
|
|
2782
|
+
* sees it. See {@link ShardDO.joinReactiveRun}.
|
|
2783
|
+
*/
|
|
2784
|
+
protected noteIdentityRead(functionPath: string): void;
|
|
2757
2785
|
/**
|
|
2758
2786
|
* The origin the current request reached the worker on, or `undefined` when
|
|
2759
2787
|
* none was forwarded (an alarm, a subscription re-run, a server-side
|
|
@@ -5425,6 +5453,16 @@ declare abstract class ShardDO {
|
|
|
5425
5453
|
* - everything else → {@link executeSubscription} (the user query, under the socket's own by-value identity).
|
|
5426
5454
|
*/
|
|
5427
5455
|
private resolveReactiveOutcome;
|
|
5456
|
+
/**
|
|
5457
|
+
* Promote `functionPath` to identity-free once a tracked run of it finished
|
|
5458
|
+
* without reading its caller. The result is encoded first, because encoding
|
|
5459
|
+
* runs any getter the handler left on it, and such a getter may read the
|
|
5460
|
+
* caller too; it is the same encoding (cached per outcome) every delivery
|
|
5461
|
+
* reuses. A result that fails to encode proves nothing and promotes nothing.
|
|
5462
|
+
* A path already marked can never be promoted (marks are never cleared), so
|
|
5463
|
+
* it skips the encode, which no delivery may need.
|
|
5464
|
+
*/
|
|
5465
|
+
private settleIdentityUse;
|
|
5428
5466
|
/**
|
|
5429
5467
|
* SECURITY BOUNDARY for cross-socket reactive dedup. A read is
|
|
5430
5468
|
* identity-INDEPENDENT only when its result cannot vary by the caller's
|
|
@@ -5433,23 +5471,23 @@ declare abstract class ShardDO {
|
|
|
5433
5471
|
* {@link SubscriptionIdentity} entirely. Those share one result across ALL
|
|
5434
5472
|
* sockets (the null-identity bucket of {@link resolveReactiveOutcomeDeduped}).
|
|
5435
5473
|
*
|
|
5436
|
-
* Everything else is identity-DEPENDENT: a user query
|
|
5437
|
-
* `ctx.auth`-scoped and a flag read ({@link FLAGS_FUNCTION_PREFIX})
|
|
5438
|
-
* with the subscriber's identity. Those
|
|
5439
|
-
* identity (claims, ip, userId) is equal — see {@link subscriptionIdentityKey}
|
|
5474
|
+
* Everything else is identity-DEPENDENT until proven otherwise: a user query
|
|
5475
|
+
* may be `rls()` / `ctx.auth`-scoped and a flag read ({@link FLAGS_FUNCTION_PREFIX})
|
|
5476
|
+
* evaluates with the subscriber's identity. Those share between sockets whose
|
|
5477
|
+
* FULL identity (claims, ip, userId) is equal — see {@link subscriptionIdentityKey} —
|
|
5478
|
+
* unless the path has been observed never reading its caller; see
|
|
5479
|
+
* {@link ShardDO.reactiveRunKey}.
|
|
5440
5480
|
*/
|
|
5441
5481
|
protected isIdentityIndependent(functionPath: string): boolean;
|
|
5442
5482
|
/**
|
|
5443
5483
|
* Memoizing wrapper over {@link resolveReactiveOutcome}: flush-local sharing across sockets.
|
|
5444
5484
|
* Within a single {@link refreshSubscriptions} pass, sockets subscribed to the
|
|
5445
|
-
* SAME `(functionPath, args)` under the
|
|
5446
|
-
* first run is cached (by its in-flight Promise, since the
|
|
5447
|
-
* runs sockets in parallel) and shared with the rest
|
|
5448
|
-
*
|
|
5449
|
-
*
|
|
5450
|
-
*
|
|
5451
|
-
* The `cache` is created fresh per flush by the caller, so a result is never
|
|
5452
|
-
* reused across passes (it would go stale after the next write).
|
|
5485
|
+
* SAME `(functionPath, args)` under the same {@link ShardDO.reactiveRunKey} run
|
|
5486
|
+
* the query once: the first run is cached (by its in-flight Promise, since the
|
|
5487
|
+
* bounded worker pool runs sockets in parallel) and shared with the rest, through
|
|
5488
|
+
* {@link ShardDO.joinReactiveRun}. The `cache` is created fresh per flush by the
|
|
5489
|
+
* caller, so a result is never reused across passes (it would go stale after the
|
|
5490
|
+
* next write).
|
|
5453
5491
|
*
|
|
5454
5492
|
* `args` and `attachment` are the socket's own stored values and are only READ
|
|
5455
5493
|
* here, to build the key. What the handler receives is a copy — `handedArgs()`
|
|
@@ -5457,8 +5495,30 @@ declare abstract class ShardDO {
|
|
|
5457
5495
|
* so every socket that shares a run skips both deep clones.
|
|
5458
5496
|
*/
|
|
5459
5497
|
private resolveReactiveOutcomeDeduped;
|
|
5460
|
-
/**
|
|
5498
|
+
/**
|
|
5499
|
+
* The key two reactive runs share under, and — when it leaves the caller out —
|
|
5500
|
+
* the full identity key of the socket that starts the run.
|
|
5501
|
+
*
|
|
5502
|
+
* Admin/reserved reads (see {@link isIdentityIndependent}) never carry the
|
|
5503
|
+
* caller. A user query carries it unless its path is in
|
|
5504
|
+
* {@link ShardDO.identityFreePaths}: a tracked run of it already finished
|
|
5505
|
+
* without reading identity, and none has read it since. A path's first run is
|
|
5506
|
+
* therefore always keyed, and the moment any run reads identity the path is
|
|
5507
|
+
* keyed again for good.
|
|
5508
|
+
*/
|
|
5461
5509
|
private reactiveRunKey;
|
|
5510
|
+
/**
|
|
5511
|
+
* Join a run another socket started. A run keyed by caller is joined as is.
|
|
5512
|
+
* One keyed without it was started on the strength of earlier runs, and the
|
|
5513
|
+
* handler may still read the caller on a branch none of them took — so a
|
|
5514
|
+
* socket with a different identity only takes the result if the path is still
|
|
5515
|
+
* unmarked once the run has settled (every accessor marks synchronously, and
|
|
5516
|
+
* the result is encoded before the run settles, see
|
|
5517
|
+
* {@link ShardDO.settleIdentityUse}), and that encoding succeeded. Otherwise,
|
|
5518
|
+
* and on a rejection whose message may carry the leader's data, it runs the
|
|
5519
|
+
* query under its own identity.
|
|
5520
|
+
*/
|
|
5521
|
+
private joinReactiveRun;
|
|
5462
5522
|
/**
|
|
5463
5523
|
* Single-flight for subscription seeds: identical seeds (same key as the
|
|
5464
5524
|
* refresh dedup) that start while one is in flight join it, so a reconnect
|
|
@@ -5597,52 +5657,29 @@ declare abstract class ShardDO {
|
|
|
5597
5657
|
* subscription set is small (cap of {@link ShardDO.MAX_SUBSCRIPTIONS_PER_SOCKET}).
|
|
5598
5658
|
*
|
|
5599
5659
|
* ----------------------------------------------------------------------
|
|
5600
|
-
*
|
|
5660
|
+
* Sockets on the same `(functionPath, args)` share ONE run per flush.
|
|
5601
5661
|
* ----------------------------------------------------------------------
|
|
5602
|
-
*
|
|
5603
|
-
*
|
|
5604
|
-
*
|
|
5605
|
-
*
|
|
5606
|
-
*
|
|
5607
|
-
*
|
|
5608
|
-
*
|
|
5609
|
-
*
|
|
5610
|
-
*
|
|
5611
|
-
*
|
|
5612
|
-
*
|
|
5613
|
-
* (
|
|
5614
|
-
*
|
|
5615
|
-
* `{type:"delta"}`, a freshly-subscribed socket a full `{type:"data"}`
|
|
5616
|
-
* snapshot, and an up-to-date socket nothing at all. So only the QUERY RUN +
|
|
5617
|
-
* its result can be shared — `pushSubscriptionData` must still run per socket.
|
|
5618
|
-
* Dedup saves the N-1 redundant runs, not the fan-out.
|
|
5619
|
-
*
|
|
5620
|
-
* (b) Side-effect cardinality. The real `executeSubscription` lives in the
|
|
5621
|
-
* codegen subclass and dispatches the user handler, which records function
|
|
5622
|
-
* metrics, scan attribution, and `ctx.log` lines PER RUN. N subscribers today
|
|
5623
|
-
* produce N metric samples / N log lines; collapsing to one run silently
|
|
5624
|
-
* under-counts those in the studio. The base class can't see inside the
|
|
5625
|
-
* override, so it can't make that trade safely.
|
|
5626
|
-
*
|
|
5627
|
-
* (c) Error attribution. A throwing run is contained per (socket, sub) here
|
|
5628
|
-
* (see the catch below, and the integration test's isolation cases). A shared
|
|
5629
|
-
* run would have to fan one failure to every sharing socket while preserving
|
|
5630
|
-
* the "leave memo untouched ⇒ re-run next flush" contract.
|
|
5662
|
+
* Only the run and its outcome (value AND `tables`/`ranges` footprint) are
|
|
5663
|
+
* shared, through {@link ShardDO.resolveReactiveOutcomeDeduped}; the frame is
|
|
5664
|
+
* still built per socket (`pushSubscriptionData`), since each socket's memo
|
|
5665
|
+
* decides between a delta, a snapshot and nothing. Sharing is bounded by
|
|
5666
|
+
* {@link ShardDO.reactiveRunKey}: equal identity, or a path observed never
|
|
5667
|
+
* reading its caller.
|
|
5668
|
+
*
|
|
5669
|
+
* Two consequences are deliberate. A shared run records its function metrics,
|
|
5670
|
+
* scan attribution and `ctx.log` lines once, not once per subscriber. And a
|
|
5671
|
+
* shared run that throws fails every socket sharing it under the same key; a
|
|
5672
|
+
* socket of another identity that joined an identity-free run re-runs on its
|
|
5673
|
+
* own instead (see {@link ShardDO.joinReactiveRun}). Either way the memo is
|
|
5674
|
+
* left untouched, so the subscription re-runs next flush.
|
|
5631
5675
|
*
|
|
5632
5676
|
* The opt-in {@link ReactiveCache} (`ShardDOOptions.reactiveCache`) does NOT
|
|
5633
5677
|
* cover this, despite the shared key shape: it wraps `/rpc` query dispatch
|
|
5634
5678
|
* (see {@link ShardDO.runCachedQuery}), while a refresh runs through
|
|
5635
|
-
* `executeSubscription`, which never consults it. It cannot, either — a
|
|
5636
|
-
*
|
|
5637
|
-
*
|
|
5638
|
-
*
|
|
5639
|
-
* routing refreshes through the cache would quietly empty every memo's
|
|
5640
|
-
* dependency set and stop the subscription updating at all.
|
|
5641
|
-
*
|
|
5642
|
-
* So this fan-out stands as characterized. Collapsing it needs a dedup that
|
|
5643
|
-
* shares the footprint alongside the value — {@link ShardDO.resolveReactiveOutcomeDeduped}
|
|
5644
|
-
* is that, per flush, for the identity-independent subset — not a second
|
|
5645
|
-
* memo bolted into this loop.
|
|
5679
|
+
* `executeSubscription`, which never consults it. It cannot, either — a cache
|
|
5680
|
+
* hit produces a value with no footprint, so routing refreshes through it
|
|
5681
|
+
* would quietly empty every memo's dependency set and stop the subscription
|
|
5682
|
+
* updating at all.
|
|
5646
5683
|
*/
|
|
5647
5684
|
/**
|
|
5648
5685
|
* Count and log a subscription-delivery error that its caller is about to
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{installDeliveryFence as a}from"./packem_shared/installDeliveryFence-B6M9KOnb.mjs";import{MERGED_ROLES as o,mergeDurableObjects as c,roleNamespace as S}from"./packem_shared/MERGED_ROLES-C4RToZ16.mjs";import{serveRelationFanout as i}from"./packem_shared/serveRelationFanout-DcSjzAZv.mjs";import{SESSION_DO_TTL_DEFAULT as n,SessionDO as d}from"./packem_shared/SESSION_DO_TTL_DEFAULT-DSvTwRjc.mjs";import{ROOT_DO_SIZE_WARN_BYTES as p,ROOT_SHARD_NAME as m,ShardDO as h}from"./packem_shared/ROOT_DO_SIZE_WARN_BYTES-
|
|
1
|
+
import{installDeliveryFence as a}from"./packem_shared/installDeliveryFence-B6M9KOnb.mjs";import{MERGED_ROLES as o,mergeDurableObjects as c,roleNamespace as S}from"./packem_shared/MERGED_ROLES-C4RToZ16.mjs";import{serveRelationFanout as i}from"./packem_shared/serveRelationFanout-DcSjzAZv.mjs";import{SESSION_DO_TTL_DEFAULT as n,SessionDO as d}from"./packem_shared/SESSION_DO_TTL_DEFAULT-DSvTwRjc.mjs";import{ROOT_DO_SIZE_WARN_BYTES as p,ROOT_SHARD_NAME as m,ShardDO as h}from"./packem_shared/ROOT_DO_SIZE_WARN_BYTES-C8H5aHLT.mjs";import{SHARD_REGISTRY_DO_NAME as E,ShardRegistryDO as O,hostedShardRegistry as _}from"./packem_shared/SHARD_REGISTRY_DO_NAME-YZZk79QR.mjs";import{createStableIdFactory as u,createStableRandomFactory as b}from"./packem_shared/createStableIdFactory-DPDT_chw.mjs";import{createShardAlarms as T,createShardDirectory as I,createShardHost as g,createShardKvStore as y,createShardPlatform as A,createSocketHost as M,createWorkerPlatform as N}from"@lunora/platform-cloudflare";import{REPROJECTION_MIGRATION_PREFIX as F,UNVOUCHABLE_DEP as L,applyCdcChanges as C,assertShapeShardable as H,backfillSearchIndexes as P,backfillVectorIndexes as j,buildReprojectionMigration as v,clearMemoryTables as U,countLegacyRows as w,createReadFootprint as G,createShardCtxDb as B,exportShardRows as V,importShardRows as W,isSourceDue as Y,markUnvouchableReads as J,pullExternalSourceIncrementalTick as K,pullExternalSourceTick as X,reprojectionMigrationId as Z,reprojectionTables as q,runDataMigration as z,runShardMigrations as Q,subscriptionListDeltas as $}from"@lunora/shard-engine";export{o as MERGED_ROLES,F as REPROJECTION_MIGRATION_PREFIX,p as ROOT_DO_SIZE_WARN_BYTES,m as ROOT_SHARD_NAME,n as SESSION_DO_TTL_DEFAULT,E as SHARD_REGISTRY_DO_NAME,d as SessionDO,h as ShardDO,O as ShardRegistryDO,L as UNVOUCHABLE_DEP,C as applyCdcChanges,H as assertShapeShardable,P as backfillSearchIndexes,j as backfillVectorIndexes,v as buildReprojectionMigration,U as clearMemoryTables,w as countLegacyRows,G as createReadFootprint,T as createShardAlarms,B as createShardCtxDb,I as createShardDirectory,g as createShardHost,y as createShardKvStore,A as createShardPlatform,M as createSocketHost,u as createStableIdFactory,b as createStableRandomFactory,N as createWorkerPlatform,V as exportShardRows,_ as hostedShardRegistry,W as importShardRows,a as installDeliveryFence,Y as isSourceDue,J as markUnvouchableReads,c as mergeDurableObjects,K as pullExternalSourceIncrementalTick,X as pullExternalSourceTick,Z as reprojectionMigrationId,q as reprojectionTables,S as roleNamespace,z as runDataMigration,Q as runShardMigrations,i as serveRelationFanout,$ as subscriptionListDeltas};
|