@lunora/do 1.0.0-alpha.305 → 1.0.0-alpha.306

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.
@@ -1795,6 +1795,14 @@ declare abstract class ShardDO {
1795
1795
  * reader never mutates one; a writer edits {@link ShardDO.readAttachmentCopy}.
1796
1796
  */
1797
1797
  private readonly attachmentCache;
1798
+ /**
1799
+ * The refresh visit running on a socket, so a write that changes several of its subscriptions
1800
+ * costs two attachment writes (digests out before the first send, in after the last), not two
1801
+ * per subscription. Present only while the visit runs.
1802
+ */
1803
+ private readonly resultDigestVisits;
1804
+ /** A socket's digest salt from the moment a digest is taken under it until the attachment holds it. */
1805
+ private readonly pendingResultSalts;
1798
1806
  /** Sockets whose `serializeAttachment` already reports into {@link ShardDO.attachmentCache}. */
1799
1807
  private readonly cacheWiredSockets;
1800
1808
  /**
@@ -6466,6 +6474,11 @@ declare abstract class ShardDO {
6466
6474
  * after the next wake.
6467
6475
  */
6468
6476
  private persistSubscriptionTables;
6477
+ /**
6478
+ * Retry a refused widening without the result digests and their salt: a missing table set makes a
6479
+ * write after a wake re-run a query, a missing digest only makes that re-run send in full.
6480
+ */
6481
+ private widenWithoutResultDigests;
6469
6482
  /**
6470
6483
  * Memoise `outcome` for `(ws, subId)` and push it to the socket, unless an
6471
6484
  * identical result was already sent. Always refreshes the memo's table set
@@ -6493,6 +6506,48 @@ declare abstract class ShardDO {
6493
6506
  * `pageDeltas` a redundant attachment read.
6494
6507
  */
6495
6508
  private pushSubscriptionData;
6509
+ /**
6510
+ * Whether `json` is the result `subId`'s client already holds: its memo's baseline, or, for a memo
6511
+ * without one (restored after a wake, or dropped for size), the socket's stored digest. A digest
6512
+ * match makes `json` the memo's baseline, so later changes diff against it.
6513
+ *
6514
+ * A false match suppresses a real change until the next one. The digest is 64 bits of FNV-1a,
6515
+ * keyed by a random per-socket salt: the salt stops a user who controls part of a shared result
6516
+ * from crafting a collision, since FNV-1a over a known prefix is easy to invert; it does not make
6517
+ * the digest cryptographic, so it guards against chance and steering, not against someone who has
6518
+ * read the socket's attachment. Chance alone is about one in 2^64 per comparison.
6519
+ *
6520
+ * A stored digest never describes a value the client may have replaced: a refresh visit removes
6521
+ * the digests of the subscriptions it may send to before its first frame leaves, and writes the
6522
+ * new ones after its last, so a restart between the two leaves no digest rather than a stale one.
6523
+ */
6524
+ private clientHoldsResult;
6525
+ /** The digest of the result `subId`'s client holds, counting what a running visit has not written yet. */
6526
+ private resultDigest;
6527
+ /** The salt a digest taken now is taken under, without minting one. */
6528
+ private currentResultSalt;
6529
+ /** A (re)subscribe, unsubscribe or permit change: whatever a running visit holds for `subId` no longer applies. */
6530
+ private forgetResultDigest;
6531
+ /**
6532
+ * Before a `data`/`delta` frame for `subId` leaves: take every digest the running visit may make
6533
+ * stale out of storage in one write, the first time it sends; outside a visit (a seed), just this
6534
+ * subscription's. A subscription the prediction left out costs one more write when it sends anyway.
6535
+ */
6536
+ private clearResultDigestsBeforeSend;
6537
+ /** Whether this flush may send `subId` a new value; the restored-memo view of a cold subscription comes from its persisted tables. */
6538
+ private maySendOnFlush;
6539
+ /** Record what `subId`'s client holds after a send of `json`: at the end of a running refresh visit, else at once. */
6540
+ private stageResultDigest;
6541
+ /** `json`'s digest under the socket's salt, minting the salt on the socket's first digest. */
6542
+ private digestResult;
6543
+ /** Run one socket's refresh visit with its result digests written back once, when it ends. */
6544
+ private withResultDigestVisit;
6545
+ /**
6546
+ * Fold `digests` into the attachment in one write, reporting whether it landed. Never throws. A
6547
+ * write the runtime refuses would leave the digests of the values these frames replaced, so it is
6548
+ * retried as a copy without any entry for those subscriptions, smaller than the stored attachment.
6549
+ */
6550
+ private writeResultDigests;
6496
6551
  private sendSubscriptionSettlement;
6497
6552
  private allowsSubscriptionOutcome;
6498
6553
  /**
@@ -6997,13 +7052,14 @@ declare abstract class ShardDO {
6997
7052
  * Persist `value` as the socket's attachment and cache it; `undefined` clears
6998
7053
  * both. The caller must not mutate `value` afterwards.
6999
7054
  *
7000
- * The table sets in `subTables` are optional and share the size limit with
7001
- * everything a socket must hold, so a write the runtime refuses is retried
7002
- * once as a copy without them: a registration never fails for
7003
- * their sake, and their subscriptions re-run after a wake until a run records
7004
- * them again. `shedTableSets: false` refuses that retry, for the write that
7005
- * only widens one set. A write that still fails drops the cache entry and
7006
- * rethrows, so the next read decodes what storage actually holds.
7055
+ * The table sets in `subTables` and the result digests in `subResults` are
7056
+ * optional and share the size limit with everything a socket must hold, so a
7057
+ * write the runtime refuses is retried once as a copy without them: a
7058
+ * registration never fails for their sake, and their subscriptions re-run (and
7059
+ * resend in full) after a wake until a run records them again.
7060
+ * `shedTableSets: false` refuses that retry, for the writes that only add to
7061
+ * them. A write that still fails drops the cache entry and rethrows, so the
7062
+ * next read decodes what storage actually holds.
7007
7063
  */
7008
7064
  private writeAttachment;
7009
7065
  }
@@ -1795,6 +1795,14 @@ declare abstract class ShardDO {
1795
1795
  * reader never mutates one; a writer edits {@link ShardDO.readAttachmentCopy}.
1796
1796
  */
1797
1797
  private readonly attachmentCache;
1798
+ /**
1799
+ * The refresh visit running on a socket, so a write that changes several of its subscriptions
1800
+ * costs two attachment writes (digests out before the first send, in after the last), not two
1801
+ * per subscription. Present only while the visit runs.
1802
+ */
1803
+ private readonly resultDigestVisits;
1804
+ /** A socket's digest salt from the moment a digest is taken under it until the attachment holds it. */
1805
+ private readonly pendingResultSalts;
1798
1806
  /** Sockets whose `serializeAttachment` already reports into {@link ShardDO.attachmentCache}. */
1799
1807
  private readonly cacheWiredSockets;
1800
1808
  /**
@@ -6466,6 +6474,11 @@ declare abstract class ShardDO {
6466
6474
  * after the next wake.
6467
6475
  */
6468
6476
  private persistSubscriptionTables;
6477
+ /**
6478
+ * Retry a refused widening without the result digests and their salt: a missing table set makes a
6479
+ * write after a wake re-run a query, a missing digest only makes that re-run send in full.
6480
+ */
6481
+ private widenWithoutResultDigests;
6469
6482
  /**
6470
6483
  * Memoise `outcome` for `(ws, subId)` and push it to the socket, unless an
6471
6484
  * identical result was already sent. Always refreshes the memo's table set
@@ -6493,6 +6506,48 @@ declare abstract class ShardDO {
6493
6506
  * `pageDeltas` a redundant attachment read.
6494
6507
  */
6495
6508
  private pushSubscriptionData;
6509
+ /**
6510
+ * Whether `json` is the result `subId`'s client already holds: its memo's baseline, or, for a memo
6511
+ * without one (restored after a wake, or dropped for size), the socket's stored digest. A digest
6512
+ * match makes `json` the memo's baseline, so later changes diff against it.
6513
+ *
6514
+ * A false match suppresses a real change until the next one. The digest is 64 bits of FNV-1a,
6515
+ * keyed by a random per-socket salt: the salt stops a user who controls part of a shared result
6516
+ * from crafting a collision, since FNV-1a over a known prefix is easy to invert; it does not make
6517
+ * the digest cryptographic, so it guards against chance and steering, not against someone who has
6518
+ * read the socket's attachment. Chance alone is about one in 2^64 per comparison.
6519
+ *
6520
+ * A stored digest never describes a value the client may have replaced: a refresh visit removes
6521
+ * the digests of the subscriptions it may send to before its first frame leaves, and writes the
6522
+ * new ones after its last, so a restart between the two leaves no digest rather than a stale one.
6523
+ */
6524
+ private clientHoldsResult;
6525
+ /** The digest of the result `subId`'s client holds, counting what a running visit has not written yet. */
6526
+ private resultDigest;
6527
+ /** The salt a digest taken now is taken under, without minting one. */
6528
+ private currentResultSalt;
6529
+ /** A (re)subscribe, unsubscribe or permit change: whatever a running visit holds for `subId` no longer applies. */
6530
+ private forgetResultDigest;
6531
+ /**
6532
+ * Before a `data`/`delta` frame for `subId` leaves: take every digest the running visit may make
6533
+ * stale out of storage in one write, the first time it sends; outside a visit (a seed), just this
6534
+ * subscription's. A subscription the prediction left out costs one more write when it sends anyway.
6535
+ */
6536
+ private clearResultDigestsBeforeSend;
6537
+ /** Whether this flush may send `subId` a new value; the restored-memo view of a cold subscription comes from its persisted tables. */
6538
+ private maySendOnFlush;
6539
+ /** Record what `subId`'s client holds after a send of `json`: at the end of a running refresh visit, else at once. */
6540
+ private stageResultDigest;
6541
+ /** `json`'s digest under the socket's salt, minting the salt on the socket's first digest. */
6542
+ private digestResult;
6543
+ /** Run one socket's refresh visit with its result digests written back once, when it ends. */
6544
+ private withResultDigestVisit;
6545
+ /**
6546
+ * Fold `digests` into the attachment in one write, reporting whether it landed. Never throws. A
6547
+ * write the runtime refuses would leave the digests of the values these frames replaced, so it is
6548
+ * retried as a copy without any entry for those subscriptions, smaller than the stored attachment.
6549
+ */
6550
+ private writeResultDigests;
6496
6551
  private sendSubscriptionSettlement;
6497
6552
  private allowsSubscriptionOutcome;
6498
6553
  /**
@@ -6997,13 +7052,14 @@ declare abstract class ShardDO {
6997
7052
  * Persist `value` as the socket's attachment and cache it; `undefined` clears
6998
7053
  * both. The caller must not mutate `value` afterwards.
6999
7054
  *
7000
- * The table sets in `subTables` are optional and share the size limit with
7001
- * everything a socket must hold, so a write the runtime refuses is retried
7002
- * once as a copy without them: a registration never fails for
7003
- * their sake, and their subscriptions re-run after a wake until a run records
7004
- * them again. `shedTableSets: false` refuses that retry, for the write that
7005
- * only widens one set. A write that still fails drops the cache entry and
7006
- * rethrows, so the next read decodes what storage actually holds.
7055
+ * The table sets in `subTables` and the result digests in `subResults` are
7056
+ * optional and share the size limit with everything a socket must hold, so a
7057
+ * write the runtime refuses is retried once as a copy without them: a
7058
+ * registration never fails for their sake, and their subscriptions re-run (and
7059
+ * resend in full) after a wake until a run records them again.
7060
+ * `shedTableSets: false` refuses that retry, for the writes that only add to
7061
+ * them. A write that still fails drops the cache entry and rethrows, so the
7062
+ * next read decodes what storage actually holds.
7007
7063
  */
7008
7064
  private writeAttachment;
7009
7065
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/do",
3
- "version": "1.0.0-alpha.305",
3
+ "version": "1.0.0-alpha.306",
4
4
  "description": "Lunora Durable Objects: ShardDO (SQLite, OCC, hibernated WebSocket subscriptions) and SessionDO",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -54,7 +54,7 @@
54
54
  "@lunora/observability": "^1.0.0-alpha.207",
55
55
  "@lunora/platform": "^1.0.0-alpha.85",
56
56
  "@lunora/platform-cloudflare": "^1.0.0-alpha.126",
57
- "@lunora/shard-engine": "^1.0.0-alpha.215",
57
+ "@lunora/shard-engine": "^1.0.0-alpha.216",
58
58
  "@lunora/values": "^1.0.0-alpha.95",
59
59
  "@lunora/wire": "1.0.0-alpha.6",
60
60
  "drizzle-orm": "1.0.0-rc.5"