@lunora/do 1.0.0-alpha.11 → 1.0.0-alpha.13

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
@@ -5045,10 +5045,22 @@ declare abstract class ShardDO {
5045
5045
  */
5046
5046
  protected respondFromIdempotencyCache(functionPath: string, dispatchStartedAt: number, mutatorClass: ClientMutationClass | undefined, cachedValue: unknown): Response;
5047
5047
  /**
5048
+ * The CDC cursor a just-committed plain mutation landed at — the post-write
5049
+ * high-watermark, on the same scale as the `cursor` on `data`/`delta` frames.
5050
+ * The client drops a pending per-call optimistic overlay once it sees a frame
5051
+ * with `cursor >= commitCursor` (gapless reconciliation that keeps mutations
5052
+ * concurrent, without the serialized custom-mutator watermark). Scoped to a
5053
+ * mutation (carries an `x-lunora-mutation-id`) on a CDC-enabled shard;
5054
+ * `undefined` otherwise, leaving the wire byte-identical for queries/actions
5055
+ * and CDC-off shards.
5056
+ */
5057
+ protected mutationCommitCursor(): number | undefined;
5058
+ /**
5048
5059
  * Build the success response for a dispatched RPC. A `"next"` custom-mutator
5049
5060
  * push echoes the applied `lastMutationId` so the client drops the pending
5050
- * optimistic overlay as soon as the ack lands; ordinary calls return the bare
5051
- * `{ result }` envelope unchanged.
5061
+ * optimistic overlay as soon as the ack lands; a plain mutation echoes
5062
+ * `commitCursor` (see {@link mutationCommitCursor}); other calls return the
5063
+ * bare `{ result }` envelope unchanged.
5052
5064
  */
5053
5065
  protected buildDispatchResponse(mutatorClass: ClientMutationClass | undefined, result: unknown): Response;
5054
5066
  /**
package/dist/index.d.ts CHANGED
@@ -5045,10 +5045,22 @@ declare abstract class ShardDO {
5045
5045
  */
5046
5046
  protected respondFromIdempotencyCache(functionPath: string, dispatchStartedAt: number, mutatorClass: ClientMutationClass | undefined, cachedValue: unknown): Response;
5047
5047
  /**
5048
+ * The CDC cursor a just-committed plain mutation landed at — the post-write
5049
+ * high-watermark, on the same scale as the `cursor` on `data`/`delta` frames.
5050
+ * The client drops a pending per-call optimistic overlay once it sees a frame
5051
+ * with `cursor >= commitCursor` (gapless reconciliation that keeps mutations
5052
+ * concurrent, without the serialized custom-mutator watermark). Scoped to a
5053
+ * mutation (carries an `x-lunora-mutation-id`) on a CDC-enabled shard;
5054
+ * `undefined` otherwise, leaving the wire byte-identical for queries/actions
5055
+ * and CDC-off shards.
5056
+ */
5057
+ protected mutationCommitCursor(): number | undefined;
5058
+ /**
5048
5059
  * Build the success response for a dispatched RPC. A `"next"` custom-mutator
5049
5060
  * push echoes the applied `lastMutationId` so the client drops the pending
5050
- * optimistic overlay as soon as the ack lands; ordinary calls return the bare
5051
- * `{ result }` envelope unchanged.
5061
+ * optimistic overlay as soon as the ack lands; a plain mutation echoes
5062
+ * `commitCursor` (see {@link mutationCommitCursor}); other calls return the
5063
+ * bare `{ result }` envelope unchanged.
5052
5064
  */
5053
5065
  protected buildDispatchResponse(mutatorClass: ClientMutationClass | undefined, result: unknown): Response;
5054
5066
  /**
package/dist/index.mjs CHANGED
@@ -23,7 +23,7 @@ export { RLS_UNWRAP_SYMBOL, RlsRequiredError, guardWriter } from './packem_share
23
23
  export { buildFtsMatch, ftsTableName, scoreDocument, stringifySearchText, tokenizeSearch } from './packem_shared/buildFtsMatch-BLEMawrp.mjs';
24
24
  export { M as MIN_ADMIN_TOKEN_LENGTH, a as MIN_AUTH_SECRET_LENGTH, b as buildSecurityAudit } from './packem_shared/security-audit-CucgBice.mjs';
25
25
  export { SESSION_DO_TTL_DEFAULT, SessionDO } from './packem_shared/SESSION_DO_TTL_DEFAULT-ilPZsVwu.mjs';
26
- export { ROOT_DO_SIZE_WARN_BYTES, ROOT_SHARD_NAME, ShardDO } from './packem_shared/ROOT_DO_SIZE_WARN_BYTES-DtZqOBIF.mjs';
26
+ export { ROOT_DO_SIZE_WARN_BYTES, ROOT_SHARD_NAME, ShardDO } from './packem_shared/ROOT_DO_SIZE_WARN_BYTES-XEs4csIH.mjs';
27
27
  export { SHARD_REGISTRY_DO_NAME, ShardRegistryDO } from './packem_shared/SHARD_REGISTRY_DO_NAME-BsAbi5Mn.mjs';
28
28
  export { MAX_SQL_ROWS, assertReadonly, runReadonlySql } from './packem_shared/MAX_SQL_ROWS-dDcFE1YZ.mjs';
29
29
  export { createSystemReader } from './packem_shared/createSystemReader-8CzSZP9V.mjs';
@@ -1391,6 +1391,9 @@ class ShardDO {
1391
1391
  }
1392
1392
  const result = await this.handleRpc(payload.functionPath, payload.args ?? {});
1393
1393
  this.recordPostDispatchBookkeeping(result, mutatorClass);
1394
+ if (mutatorClass?.kind === "next") {
1395
+ this.advanceClientMutationWatermark();
1396
+ }
1394
1397
  const durationMs = Date.now() - dispatchStartedAt;
1395
1398
  this.recordFunctionCall(payload.functionPath, durationMs, void 0, this.currentScannedTables, this.currentIndexHits);
1396
1399
  this.flushStmtSamples();
@@ -2423,19 +2426,35 @@ class ShardDO {
2423
2426
  this.advanceClientMutationWatermark();
2424
2427
  return this.buildDispatchResponse(mutatorClass, cachedValue);
2425
2428
  }
2426
- return jsonResponse({ result: cachedValue }, 200, this.currentResponseBookmark);
2429
+ const commitCursor = this.mutationCommitCursor();
2430
+ return jsonResponse(commitCursor === void 0 ? { result: cachedValue } : { commitCursor, result: cachedValue }, 200, this.currentResponseBookmark);
2431
+ }
2432
+ /**
2433
+ * The CDC cursor a just-committed plain mutation landed at — the post-write
2434
+ * high-watermark, on the same scale as the `cursor` on `data`/`delta` frames.
2435
+ * The client drops a pending per-call optimistic overlay once it sees a frame
2436
+ * with `cursor >= commitCursor` (gapless reconciliation that keeps mutations
2437
+ * concurrent, without the serialized custom-mutator watermark). Scoped to a
2438
+ * mutation (carries an `x-lunora-mutation-id`) on a CDC-enabled shard;
2439
+ * `undefined` otherwise, leaving the wire byte-identical for queries/actions
2440
+ * and CDC-off shards.
2441
+ */
2442
+ mutationCommitCursor() {
2443
+ return this.currentRequestMutationId === void 0 ? void 0 : this.currentCdcCursor();
2427
2444
  }
2428
2445
  /**
2429
2446
  * Build the success response for a dispatched RPC. A `"next"` custom-mutator
2430
2447
  * push echoes the applied `lastMutationId` so the client drops the pending
2431
- * optimistic overlay as soon as the ack lands; ordinary calls return the bare
2432
- * `{ result }` envelope unchanged.
2448
+ * optimistic overlay as soon as the ack lands; a plain mutation echoes
2449
+ * `commitCursor` (see {@link mutationCommitCursor}); other calls return the
2450
+ * bare `{ result }` envelope unchanged.
2433
2451
  */
2434
2452
  buildDispatchResponse(mutatorClass, result) {
2435
2453
  if (mutatorClass?.kind === "next") {
2436
2454
  return jsonResponse({ lastMutationId: this.currentRequestClientSeq, result }, 200, this.currentResponseBookmark);
2437
2455
  }
2438
- return jsonResponse({ result }, 200, this.currentResponseBookmark);
2456
+ const commitCursor = this.mutationCommitCursor();
2457
+ return jsonResponse(commitCursor === void 0 ? { result } : { commitCursor, result }, 200, this.currentResponseBookmark);
2439
2458
  }
2440
2459
  /**
2441
2460
  * Commit a mutation's replay bookkeeping — the `(identity, mutationId)`
@@ -4841,9 +4860,8 @@ class ShardDO {
4841
4860
  if (existing?.lastJson === json) {
4842
4861
  existing.tables = outcome.tables;
4843
4862
  const settledWatermark = this.socketClientWatermark(ws);
4844
- if (settledWatermark !== void 0) {
4845
- trySendFrame(ws, `{"type":"settled","id":${JSON.stringify(subId)},"lastMutationId":${String(settledWatermark)}${cursorSuffix}}`);
4846
- }
4863
+ const watermarkField = settledWatermark === void 0 ? "" : `,"lastMutationId":${String(settledWatermark)}`;
4864
+ trySendFrame(ws, `{"type":"settled","id":${JSON.stringify(subId)}${watermarkField}${cursorSuffix}}`);
4847
4865
  return;
4848
4866
  }
4849
4867
  const deltaFrames = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/do",
3
- "version": "1.0.0-alpha.11",
3
+ "version": "1.0.0-alpha.13",
4
4
  "description": "Lunora Durable Objects: ShardDO (SQLite, OCC, hibernated WebSocket subscriptions) and SessionDO",
5
5
  "keywords": [
6
6
  "cloudflare",