Skip to content

refactor(#4968): route stream archive through the shared Weasel event-store seam#4973

Merged
jeremydmiller merged 1 commit into
masterfrom
feature/4968-archive-seam
Jul 17, 2026
Merged

refactor(#4968): route stream archive through the shared Weasel event-store seam#4973
jeremydmiller merged 1 commit into
masterfrom
feature/4968-archive-seam

Conversation

@jeremydmiller

Copy link
Copy Markdown
Member

Marten-side companion to JasperFx/weasel#360 (Weasel 9.17.0) / JasperFx/polecat#318. The new Weasel.Storage.Events auxiliary-operation seam vends dialect-supplied factories for archive / tombstone / progression. This PR has Marten's PostgresEventStoreDialect implement BuildAuxiliaryOperations for 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.BuildAuxiliaryOperations vends an EventAuxiliaryOperations whose ArchiveStream factory builds the existing ArchiveStreamOperation.
  • IEventStorage / EventDocumentStorage / ClosedShapeEventDocumentStorage gain ArchiveStream, delegating to the built Weasel EventStorage<TId>.ArchiveStream (same Guid/string dispatch as AppendEvent).
  • Public EventStore.ArchiveStream(Guid/string) and the daemon's 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).

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:

  • 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 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

  • Marten builds clean (no other IEventStorage implementers).
  • EventSourcingTests/archiving_events — 29/29 pass (incl. tenanted/conjoined archive).
  • Daemon archive-on-delete path (side_effects_in_aggregations.calls_side_effects_when_there_is_a_delete_event) passes.

Closes #4968.

🤖 Generated with Claude Code

…-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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adopt the shared Weasel.Storage.Events auxiliary-operation seam (archive / tombstone / progression)

1 participant