refactor(#4968): route stream archive through the shared Weasel event-store seam#4973
Merged
Conversation
…-store seam Weasel 9.17.0 (weasel#360) adds a dialect-supplied auxiliary-operation seam to Weasel.Storage.Events (archive / tombstone / progression). This has Marten's PostgresEventStoreDialect implement BuildAuxiliaryOperations for the one operation that maps cleanly — stream ARCHIVE — so the invocation is single-sourced with Polecat instead of instantiating ArchiveStreamOperation directly. No behavior change; the existing event-store archiving suite is the safety net. - PostgresEventStoreDialect.BuildAuxiliaryOperations vends an EventAuxiliaryOperations whose ArchiveStream factory builds the existing Postgres ArchiveStreamOperation (the SQL stays in Marten). Marten only ever archives, so the factory rejects un-archive. - IEventStorage / EventDocumentStorage / ClosedShapeEventDocumentStorage gain ArchiveStream, delegating to the built Weasel EventStorage<TId>.ArchiveStream (same Guid/string dispatch as AppendEvent). - The public EventStore.ArchiveStream(Guid/string) and the daemon's projection archive-on-delete path (ProjectionStorage.ArchiveStream) now build the op via session.EventStorage().ArchiveStream; the per-TId cache is refactored from an op-builder into a raw stream-id unwrapper (strong-typed id handling unchanged). Tombstone and progression are intentionally left OUT of the seam (factories null), because the shipped seam does not fit Marten's operations: - Tombstone: Marten's EstablishTombstoneStream ESTABLISHES the tombstone bookkeeping stream (keyed only by tenant, no stream id), not a hard delete of a given stream as the seam's TombstoneStream(streamId, tenantId) contract implies. - Progression: Marten's UpdateProjectionProgress guards its update with the sequence FLOOR (where last_seq_id = floor); the seam's UpdateProgress(name, sequence, upsert) factory cannot carry the floor, so routing it would drop the optimistic-concurrency guard. Both are documented on the dialect method; single-sourcing them would need a richer Weasel factory. Closes #4968. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XKKBPsFJ83jd2o4hyGJnj6
This was referenced Jul 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Marten-side companion to JasperFx/weasel#360 (Weasel 9.17.0) / JasperFx/polecat#318. The new
Weasel.Storage.Eventsauxiliary-operation seam vends dialect-supplied factories for archive / tombstone / progression. This PR has Marten'sPostgresEventStoreDialectimplementBuildAuxiliaryOperationsfor the one operation that maps cleanly — stream archive — single-sourcing its invocation with Polecat.Purely a convergence/refactor: no behavior change, the SQL stays in Marten, and the existing event-store archiving suite is the safety net.
What changed
PostgresEventStoreDialect.BuildAuxiliaryOperationsvends anEventAuxiliaryOperationswhoseArchiveStreamfactory builds the existingArchiveStreamOperation.IEventStorage/EventDocumentStorage/ClosedShapeEventDocumentStoragegainArchiveStream, delegating to the built WeaselEventStorage<TId>.ArchiveStream(same Guid/string dispatch asAppendEvent).EventStore.ArchiveStream(Guid/string)and the daemon's archive-on-delete path (ProjectionStorage.ArchiveStream) now build the op viasession.EventStorage().ArchiveStream(...); the per-TIdcache is refactored from an op-builder into a raw stream-id unwrapper (strong-typed id handling unchanged).Why tombstone + progression stay Marten-local (factories left null)
The shipped seam doesn't fit Marten's other two operations — documented inline on the dialect method:
EstablishTombstoneStreamestablishes the tombstone bookkeeping stream (keyed only by tenant, no stream id), not a hard-delete of a given stream as the seam'sTombstoneStream(streamId, tenantId)contract implies.UpdateProjectionProgressguards its update with the sequence floor (where last_seq_id = floor); the seam'sUpdateProgress(name, sequence, upsert)factory can't carry the floor, so routing it would drop the optimistic-concurrency guard.Single-sourcing those would need a richer Weasel factory (a follow-up on the Weasel side).
Verification
IEventStorageimplementers).EventSourcingTests/archiving_events— 29/29 pass (incl. tenanted/conjoined archive).side_effects_in_aggregations.calls_side_effects_when_there_is_a_delete_event) passes.Closes #4968.
🤖 Generated with Claude Code