fix: add stream_type to Delete/Tombstone/Snapshot/AdvisoryLock interfaces #240

Closed
opened 2026-03-10 17:26:32 +00:00 by ash · 0 comments
Owner

Problem

Delete, IsTombstoned, Archive, SaveSnapshot, LoadSnapshot, and advisory locks are all keyed by stream_id only — ignoring stream_type. This means:

  • Deleting order-123 in fulfillment also tombstones order-123 in pricing
  • Snapshots for different stream types with same ID collide
  • Advisory locks serialize unrelated streams across different types

This violates our core principle: (stream_type, stream_id) is the identity, everywhere.

Solution

  1. Update EventStoreWithDeletion interface: Delete(ctx, streamType, streamID), IsTombstoned(ctx, streamType, streamID)
  2. Update SnapshotStore interface: add streamType parameter
  3. Update tombstone table: composite key (stream_type, stream_id)
  4. Update snapshot table: composite key (stream_type, stream_id)
  5. Update advisory lock hash: include stream_type in hash
  6. Update all 3 backends: memorystore, sqlitestore, pgstore
  7. Schema migration for pgstore/sqlitestore
  8. Update all callers, examples, tests

Breaking change but necessary for correctness.

Pillar: Security, Data Integrity

## Problem Delete, IsTombstoned, Archive, SaveSnapshot, LoadSnapshot, and advisory locks are all keyed by `stream_id` only — ignoring `stream_type`. This means: - Deleting `order-123` in `fulfillment` also tombstones `order-123` in `pricing` - Snapshots for different stream types with same ID collide - Advisory locks serialize unrelated streams across different types This violates our core principle: `(stream_type, stream_id)` is the identity, everywhere. ## Solution 1. Update `EventStoreWithDeletion` interface: `Delete(ctx, streamType, streamID)`, `IsTombstoned(ctx, streamType, streamID)` 2. Update `SnapshotStore` interface: add `streamType` parameter 3. Update tombstone table: composite key `(stream_type, stream_id)` 4. Update snapshot table: composite key `(stream_type, stream_id)` 5. Update advisory lock hash: include `stream_type` in hash 6. Update all 3 backends: memorystore, sqlitestore, pgstore 7. Schema migration for pgstore/sqlitestore 8. Update all callers, examples, tests Breaking change but necessary for correctness. ## Pillar: Security, Data Integrity
ash closed this issue 2026-03-10 18:13:31 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ash/eskit#240
No description provided.