@segmentstream/ontology 0.146.0 → 0.146.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.146.1
4
+
5
+ Ontology replication sends what a warehouse load committed only once. A generation whose events a
6
+ load put in the warehouse no longer sends them all again through Pub/Sub when it starts serving,
7
+ oldest first, ahead of every change written since. Records whose projection a deploy did not change
8
+ stayed on such a generation, so their changes reached the warehouse hours or days late. Delivery
9
+ records the events an earlier version loaded as delivered on its next pass, with no deploy needed.
10
+
3
11
  ## 0.146.0
4
12
 
5
13
  `initialize` lists the channels a tool call's runtime source may name (`telegram`, `slack`,
@@ -460,8 +460,15 @@ export const finishShadowSegment = (sql, segment, owner) => sql.withTransaction(
460
460
  if (!completed) {
461
461
  return false;
462
462
  }
463
- yield* sql.unsafe(`UPDATE _ontology_replication_delivery SET committed_at=now()
464
- WHERE segment_id=$1::uuid`, [segment.id]);
463
+ // The committed load put the segment's events in the warehouse: they are delivered, as a
464
+ // Pub/Sub receipt would record. Left pending, the generation would send them all again once
465
+ // it serves, oldest first, ahead of every change written since.
466
+ yield* sql.unsafe(`WITH loaded AS (
467
+ UPDATE _ontology_replication_delivery
468
+ SET committed_at=now(), accepted_at=COALESCE(accepted_at, now())
469
+ WHERE segment_id=$1::uuid RETURNING generation, event_id, accepted_at
470
+ ) INSERT INTO _ontology_replication_receipts (generation, event_id, accepted_at)
471
+ SELECT generation, event_id, accepted_at FROM loaded ON CONFLICT DO NOTHING`, [segment.id]);
465
472
  return true;
466
473
  }));
467
474
  export const retryShadowSegment = (sql, segment, owner, failure) => sql.unsafe(`UPDATE _ontology_replication_segments SET attempt=attempt+1,
@@ -26,6 +26,13 @@ export declare const pendingReplicationEvents: (sql: SqlClient.SqlClient, target
26
26
  readonly historyId: string;
27
27
  readonly event: ReplicationEvent;
28
28
  }[], import("effect/unstable/sql/SqlError").SqlError, never>;
29
+ /**
30
+ * Records as delivered, with receipts, the events of a generation an earlier SDK loaded into the
31
+ * warehouse without recording them, so that serving delivery does not send them through Pub/Sub
32
+ * again ahead of the changes written since. A committed load now records its own; this reads only
33
+ * the generation's undelivered rows.
34
+ */
35
+ export declare const recordLoadedReplicationEvents: (sql: SqlClient.SqlClient, generation: string) => Effect.Effect<void, import("effect/unstable/sql/SqlError").SqlError, never>;
29
36
  /** Acceptance comes only from Pub/Sub receipts; historical verification columns are not used. */
30
37
  export declare const replicationStatus: (sql: SqlClient.SqlClient, target: ReplicationTarget) => Effect.Effect<{
31
38
  total: string;
@@ -229,6 +229,22 @@ export const pendingReplicationEvents = (sql, target, options = {}) => Effect.ge
229
229
  }
230
230
  return result;
231
231
  });
232
+ // @legacy ontology.replication-loaded-events-pending
233
+ /**
234
+ * Records as delivered, with receipts, the events of a generation an earlier SDK loaded into the
235
+ * warehouse without recording them, so that serving delivery does not send them through Pub/Sub
236
+ * again ahead of the changes written since. A committed load now records its own; this reads only
237
+ * the generation's undelivered rows.
238
+ */
239
+ export const recordLoadedReplicationEvents = (sql, generation) => sql.withTransaction(Effect.gen(function* () {
240
+ yield* shareReplicationLifecycle(sql);
241
+ yield* sql.unsafe(`WITH loaded AS (
242
+ UPDATE _ontology_replication_delivery SET accepted_at = committed_at
243
+ WHERE generation = $1::uuid AND accepted_at IS NULL AND committed_at IS NOT NULL
244
+ RETURNING event_id, accepted_at
245
+ ) INSERT INTO _ontology_replication_receipts (generation, event_id, accepted_at)
246
+ SELECT $1::uuid, event_id, accepted_at FROM loaded ON CONFLICT DO NOTHING`, [generation]);
247
+ }));
232
248
  /** Lost publish responses deliberately leave the same immutable IDs pending. */
233
249
  const acknowledgeReplicationV4 = (sql, generation, ids) => sql.withTransaction(Effect.gen(function* () {
234
250
  // Receipt foreign keys touch targets after delivery rows; drain before migration table locks.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/ontology",
3
- "version": "0.146.0",
3
+ "version": "0.146.1",
4
4
  "description": "Define a SegmentStream workspace app's ontology: entities, relationships, roles and actions, written with Effect.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SegmentStream",