@byok-sdk/core 0.11.0 → 0.13.0

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/mailbox.d.ts CHANGED
@@ -73,16 +73,44 @@ export interface MailboxPage {
73
73
  */
74
74
  readonly nextSeq: number;
75
75
  readonly hasMore: boolean;
76
+ /**
77
+ * The earliest seq a reader can still recover from: one past the highest row
78
+ * this device LOST. A caller at `recoverableFrom - 1` can still be handed
79
+ * the first row it has any claim to; a caller below that has a gap it cannot
80
+ * see, and resuming it would hand back a partial tail indistinguishable from
81
+ * a complete one.
82
+ *
83
+ * Lost means `expired` — a row that aged out before anyone acked it. An
84
+ * `acked` row is consumed, not lost, so acking never moves this and never
85
+ * turns a re-poll from an old cursor into a failure; that distinction is the
86
+ * whole point of the field.
87
+ *
88
+ * `1` for a mailbox that has lost nothing, so a fresh device's cursor `0` is
89
+ * always inside the window. Monotonic for as long as dead-lettered rows are
90
+ * retained, which §12.7.5 requires.
91
+ *
92
+ * This is a READ of the retained window, never a second retention authority:
93
+ * `collectRetired` decides what is retained, this reports what it cost.
94
+ */
95
+ readonly recoverableFrom: number;
76
96
  }
77
97
  export interface MailboxAdvanceCursorInput {
78
98
  readonly deviceId: string;
79
99
  /** Highest seq the device has durably journaled. */
80
100
  readonly ackedSeq: number;
81
101
  }
82
- /** The device's durable acknowledgement position. */
102
+ /** Server-owned proof that a cursor was returned to this device. */
103
+ export interface MailboxRecordDeliveryInput {
104
+ readonly deviceId: string;
105
+ /** Highest cursor the server has returned to this device. */
106
+ readonly deliveredSeq: number;
107
+ }
108
+ /** The device's durable delivery and acknowledgement positions. */
83
109
  export interface MailboxCursorState {
84
110
  readonly tenantId: TenantId;
85
111
  readonly deviceId: string;
112
+ /** Highest cursor the server has returned to this device. */
113
+ readonly deliveredSeq: number;
86
114
  readonly ackedSeq: number;
87
115
  readonly updatedAt: string;
88
116
  }
@@ -112,6 +140,8 @@ export interface MailboxRetentionResult {
112
140
  *
113
141
  * Raises: `mailbox_cursor_regression` (an ack that moves the cursor backwards,
114
142
  * which would silently re-deliver already-journaled work),
143
+ * `mailbox_cursor_ahead_of_delivery` (an ack beyond the highest cursor the
144
+ * server has returned to that device),
115
145
  * `timestamp_not_canonical` (a retention cutoff that is not a canonical
116
146
  * ISO-8601 UTC instant).
117
147
  */
@@ -119,7 +149,9 @@ export interface MailboxStore {
119
149
  append(tenant: TenantId, input: MailboxAppendInput): Promise<MailboxMessage>;
120
150
  /** Pure read. Never advances the cursor, never deletes, never marks acked. */
121
151
  readAfter(tenant: TenantId, query: MailboxReadQuery): Promise<MailboxPage>;
122
- /** The one and only ack. Monotonic; a lower `ackedSeq` is rejected. */
152
+ /** Records the highest cursor a device-facing response is about to return. */
153
+ recordDelivery(tenant: TenantId, input: MailboxRecordDeliveryInput): Promise<MailboxCursorState>;
154
+ /** The one and only ack. Monotonic and bounded by the recorded delivery watermark. */
123
155
  advanceCursor(tenant: TenantId, input: MailboxAdvanceCursorInput): Promise<MailboxCursorState>;
124
156
  readCursor(tenant: TenantId, deviceId: string): Promise<MailboxCursorState>;
125
157
  /** Retention hook: delete acked rows, dead-letter unacked ones. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byok-sdk/core",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "BYOK SDK platform contracts: branded tenant identity, tenant-first store ports, device proof canonicalization, and the composition conformance reference",
5
5
  "type": "module",
6
6
  "license": "MIT",