Skip to content

Converge event-store auxiliary operations (archive / tombstone / progression) onto shared Weasel.Storage.Events seams #318

Description

@jeremydmiller

Follow-up from #273 (closed). The document storage runtime is now fully on the shared closed-shape runtime, and event append + stream-version ride IEventStoreSqlDialect / the shared EventStorage<TId> base. The remaining hand-written, EventGraph-driven event operations are the last bespoke SQL in Polecat.

Why this is a separate issue

The shared Weasel.Storage.Events.EventStorage<TId> base exposes seams only for the append/stream lifecycle:

AppendEvent · QuickAppendEventWithVersion · QuickAppendEvents · InsertStream · UpdateStreamVersion · AssertStreamVersion

There is no seam for archive / tombstone / progression. Marten keeps analogous operations store-local too, so converging these is blocked on adding the seams to Weasel.Storage.Events first (cross-repo Weasel work), then Polecat implementing the SQL Server dialect of them.

Polecat operations still bespoke (all in src/Polecat/Internal/Operations/)

Operation SQL Target tables
ArchiveStreamOperation UPDATE … SET is_archived = 1 pc_streams + pc_events
UnArchiveStreamOperation UPDATE … SET is_archived = 0 pc_streams + pc_events
TombstoneStreamOperation DELETE FROM … pc_events + pc_streams
ProgressMergeOperation MERGE (Floor == 0) pc_event_progression
ProgressUpdateOperation UPDATE (Floor > 0) pc_event_progression
AssertDcbConsistencyOperation SELECT CASE WHEN EXISTS … over pc_event_tag_* DCB tag tables

Proposed seam shape (to design upstream in Weasel first)

Extend the shared event storage contract — either new abstract methods on EventStorage<TId> or a companion interface — with dialect-provided operation factories:

  • IStorageOperation ArchiveStream(StreamAction / id, string tenantId, bool archived) — covers archive + un-archive (one flag).
  • IStorageOperation TombstoneStream(StreamAction / id, string tenantId) — hard delete of a stream's events + row.
  • Progression: IStorageOperation UpdateProgress(string projectionName, long ceiling, ...) with a merge-or-update variant (or let the dialect choose based on floor). This is the async-daemon high-water / projection-progress write; today PolecatProjectionBatch picks ProgressMerge vs ProgressUpdate.

AssertDcbConsistencyOperation is the most Polecat-specific (DCB tag-table EXISTS check) and may stay store-local even after the others converge — worth evaluating separately.

Suggested sequencing

  1. [Weasel] Design + add the archive/tombstone/progression seams to Weasel.Storage.Events (mirroring how IEventStoreSqlDialect / EventStorage<TId> already factor append). Release.
  2. [Polecat] Implement the SQL Server dialect of the new seams (SYSDATETIMEOFFSET(), pc_* tables, tenancy #234), retire the bespoke operation classes, keep the existing event-store test suite as the safety net.

Non-goals

  • Not converging DocumentMapping (config the descriptor is built from), the LINQ query-builder, the session/unit-of-work pipeline, or infra SQL (master-table tenancy, flat-table projections) — all intentionally store-local, matching Marten.

Low urgency: the current bespoke operations are correct and fully tested; this is about single-sourcing the last of the event-write SQL once the shared seams exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions