Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ Critical path for MVP: Stages 1–5, 7–8, 10–11
no longer referenced, along with `xunit.runner.visualstudio` and `coverlet.collector`.
- **Pattern**: Mirror Marten's IntegrationContext base class
- **Database**: Dockerized SQL Server 2025 on localhost:11433
- **Never run two test runs at once.** Tests share one SQL Server instance and isolate by
`DatabaseSchemaName` inside `master`, not by database, so concurrent runs — a second `dotnet test`,
a run started before an earlier one finished, or a run left alive after you killed its parent shell
— step on each other's schemas and produce large, scattered, misleading failure sets across
unrelated areas (query plans, flat tables, partitioning, subscriptions). Let a run finish, and
confirm with `pgrep -f Polecat.Tests` before starting another. A killed run in particular can leave
its test host alive and its schemas half-torn-down; drop the leftovers before re-running.
- **Test naming**: snake_case file names (e.g., `start_stream_tests.cs`)
- **Assertions**: Shouldly (or similar fluent assertions)
- **Lifecycle**: `IAsyncLifetime` is ValueTask-based and inherits `IAsyncDisposable`. If a class
Expand Down
10 changes: 5 additions & 5 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,22 @@
re-reads progression and succeeds when the replay had already reached the mark, plus a
configurable DaemonSettings.SideEffectGateTimeout), jasperfx#595 (BatchingChannel could
deliver its trailing batch twice on shutdown) and #597. Same lockstep rule as above. -->
<PackageVersion Include="JasperFx" Version="2.37.1" />
<PackageVersion Include="JasperFx.Events" Version="2.37.1" />
<PackageVersion Include="JasperFx" Version="2.37.2" />
<PackageVersion Include="JasperFx.Events" Version="2.37.2" />
<!--
The shared cross-store event sourcing compliance suites. Source-only package: the
suites compile inside Polecat.Tests so JasperFx's aggregate source generator binds
Polecat's own session types.
-->
<PackageVersion Include="JasperFx.Events.ComplianceTests" Version="2.37.1" />
<PackageVersion Include="JasperFx.Events.ComplianceTests" Version="2.37.2" />
<!-- Pin the sibling JasperFx packages for parity with Marten 9's matrix
even though Polecat doesn't currently reference them directly —
keeps the lockstep matrix coherent when transitive resolution
surfaces them through JasperFx / JasperFx.Events updates. The
RuntimeCompiler 5.x line is the active continuation of the 4.x
lineage; do not pin against the parallel stale 2.0.x series. -->
<PackageVersion Include="JasperFx.RuntimeCompiler" Version="5.0.0" />
<PackageVersion Include="JasperFx.SourceGenerator" Version="2.37.1" />
<PackageVersion Include="JasperFx.SourceGenerator" Version="2.37.2" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0" />
Expand Down Expand Up @@ -165,7 +165,7 @@
<PackageVersion Include="StronglyTypedId" Version="1.0.0-beta08" />

<!-- Source generators (matched to JasperFx.Events above) -->
<PackageVersion Include="JasperFx.Events.SourceGenerator" Version="2.37.1" />
<PackageVersion Include="JasperFx.Events.SourceGenerator" Version="2.37.2" />

<!-- Build automation -->
<PackageVersion Include="Nuke.Common" Version="9.0.4" />
Expand Down
5 changes: 5 additions & 0 deletions src/Polecat.Tests/Compliance/ComplianceQuerySessionAlias.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
// by type name, so a per-consumer global alias lets one shared source file bind to Polecat's
// IQuerySession here and to Marten's in Marten.
global using ComplianceQuerySession = Polecat.IQuerySession;

// Same mechanism for the EventProjection suites. Those declare projection types at file scope, so
// they cannot reach the <TOperations, TQuerySession> pair their suite class is generic over.
global using ComplianceOperations = Polecat.IDocumentSession;
global using ComplianceEventProjection = Polecat.Projections.EventProjection;
29 changes: 28 additions & 1 deletion src/Polecat.Tests/Compliance/PolecatComplianceFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,17 @@ protected override async Task BuildStoreAsync(ComplianceStoreConfig config)

var options = new StoreOptions
{
ConnectionString = ConnectionSource.ConnectionString,
ConnectionString = connectionStringFor(config),
AutoCreateSchemaObjects = AutoCreate.All,
DatabaseSchemaName = schemaName,
UseNativeJsonType = ConnectionSource.SupportsNativeJson
};

if (config.MaxConcurrentRebuildsPerDatabase.HasValue)
{
options.DaemonSettings.MaxConcurrentRebuildsPerDatabase = config.MaxConcurrentRebuildsPerDatabase;
}

config.ApplyTo(new PolecatComplianceRegistrar(options));

_store = new DocumentStore(options);
Expand All @@ -42,6 +47,19 @@ protected override async Task BuildStoreAsync(ComplianceStoreConfig config)
await _store.Database.ApplyAllConfiguredChangesToDatabaseAsync().ConfigureAwait(false);
}

private static string connectionStringFor(ComplianceStoreConfig config)
{
if (!config.MaxPoolSize.HasValue)
{
return ConnectionSource.ConnectionString;
}

return new SqlConnectionStringBuilder(ConnectionSource.ConnectionString)
{
MaxPoolSize = config.MaxPoolSize.Value
}.ConnectionString;
}

public override IDocumentSession OpenSession() => _store.LightweightSession();

public override Task SaveChangesAsync(IDocumentSession session, CancellationToken token)
Expand All @@ -59,8 +77,14 @@ public override Task SaveChangesAsync(IDocumentSession session, CancellationToke
$"Polecat cannot load documents by an identity of type {id.GetType().FullName}")
};

public override void StoreDocument<T>(IDocumentSession session, T document) => session.Store(document);

public override IEventStoreOperations EventsFor(IDocumentSession session) => session.Events;

public override IEventStore EventStore => _store;

public override IEnumerable<Type> AllAggregateTypes() => _store.Options.Projections.AllAggregateTypes();

public override IComplianceBatch CreateBatch(IQuerySession session)
=> new PolecatComplianceBatch(session.CreateBatchQuery());

Expand Down Expand Up @@ -130,6 +154,9 @@ public void Snapshot<TDoc>(SnapshotLifecycle lifecycle) where TDoc : notnull
public void LiveAggregation<TDoc>() where TDoc : notnull
{
}

public void AddProjection(ProjectionBase projection, ProjectionLifecycle lifecycle)
=> _options.Projections.Add((IProjectionSource<IDocumentSession, IQuerySession>)projection, lifecycle);
}

internal class PolecatComplianceBatch : IComplianceBatch
Expand Down
12 changes: 12 additions & 0 deletions src/Polecat.Tests/Compliance/polecat_event_store_compliance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,15 @@ public class assign_tag_where_compliance

public class async_daemon_compliance
: AsyncDaemonCompliance<PolecatComplianceFixture, IDocumentSession, IQuerySession>;

public class auto_discovered_aggregate_compliance
: AutoDiscoveredAggregateCompliance<PolecatComplianceFixture, IDocumentSession, IQuerySession>;

public class event_projection_registration_compliance
: EventProjectionRegistrationCompliance<PolecatComplianceFixture, IDocumentSession, IQuerySession>;

public class event_projection_enrichment_compliance
: EventProjectionEnrichmentCompliance<PolecatComplianceFixture, IDocumentSession, IQuerySession>;

public class rebuild_concurrency_cap_compliance
: RebuildConcurrencyCapCompliance<PolecatComplianceFixture, IDocumentSession, IQuerySession>;
43 changes: 0 additions & 43 deletions src/Polecat.Tests/Events/auto_discover_aggregate_types.cs

This file was deleted.

189 changes: 0 additions & 189 deletions src/Polecat.Tests/Projections/event_projection_enrichment_tests.cs

This file was deleted.

Loading
Loading