Averor/event-sourcing
50.5
Adequate · 10 November 2026
1.2k
lines of production code
PHP
primary language
9
measurements over time
What this system is
This system is an event-sourcing framework that manages aggregate state by persisting and replaying domain events. It provides a repository pattern for loading and saving aggregates, along with an event store that supports both in-memory and MongoDB backends. The architecture includes optimistic locking to handle concurrency and a trait-based approach for reconstituting aggregate state from event streams.
Features
Add optimistic locking to the event store
A new OptimisticLockingEventStore implementation has been introduced to manage event streams with version-based concurrency control. This change ensures that concurrent updates to an aggregate root are detected and rejected via a ConcurrencyException when a version mismatch occurs during commit, preventing lost updates.
src/EventStore · high confidence
Added core contracts for the event-sourcing subsystem
Introduced a new set of interfaces in the \Averor\\MessageBus\\EventSourcing\\Contract\ namespace to define the event-sourcing architecture. This includes \AggregateRoot\ and \EventSourcedAggregateRoot\ for managing state and events, \DomainEvent\ for domain notifications, and \EventStore\/\EventStream\ for persistence. The \Repository\ interface now supports an optional aggregate name parameter, and new exception classes (\AggregateMethodNotFoundException\, \AggregateRootNotFoundException\, \ConcurrencyException\, \EventStoreCommitException\) are added to handle specific error conditions.
src/Contract · high confidence
Added in-memory and MongoDB event store implementations
Introduced new storage backends for the event store: a simple in-memory implementation (MemoryStorage) and a MongoDB-based implementation (MongoDbStorage) that persists events to a configurable collection. To support the MongoDB storage, a SimpleSerializer was added to handle serialization and deserialization of domain events using reflection, enabling the storage of scalar event data without external dependencies.
src/EventStore/Storage · high confidence
New event-sourcing domain classes for aggregate reconstitution and persistence
The domain layer now includes new classes and traits to support event sourcing: \AggregateRootReconstitutionTrait\ handles reconstructing aggregate state from an event stream; \DomainEventStream\ and \DomainEventsTransaction\ manage event collections and versions; \DomainEventTrait\ provides standard event metadata; \EventProducerTrait\ manages pending domain events and applies them to the aggregate; and \EventSourcedRepository\ implements the repository interface to load aggregates from an event store, save new events, and dispatch them via an event bus.
src/Domain · medium confidence
Test coverage
Added unit tests for event sourcing components
Added comprehensive unit tests for the event sourcing domain, including \AggregateRootTest\ for managing and reconstituting aggregates, \DomainEventStreamTest\ for event stream operations, \DomainEventTest\ for event metadata, \DomainEventsTransactionTest\ for transaction handling, \EventSourcedRepositoryTest\ for repository interactions, and \OptimisticLockingEventStoreTest\ for event store commit and concurrency logic.
tests · high confidence
Dependencies
Update PHP dependencies and add optional MongoDB storage support
The project's dependencies have been updated to include php-ds, ramsey/uuid, and averor/cqrs-es-bundle, while also adding a suggested dependency on mongodb/mongodb for MongoDB storage functionality.
(dependencies) · medium confidence
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 50 → 50 (+0.0)
- Rubric changed (rubric-2026.10.5 → rubric-2026.11.2) — scores are not directly comparable.
Lenses
- Code Health 71 → 71 (+0.0)
- Architecture 69 → 69 (+0.0)
- Maturity 51 → 51 (+0.0)
- Readiness 37 → 37 (+0.0)
- Security 100 → 100 (+0.0)
Resolved (6)
- Documentation: no installation or build instructions (README.md)
- Documentation: no project overview (README.md)
- Documentation: no usage examples (README.md)
- Duplicate reconstitution logic. The interface EventSourcedAggregateRoot defines reconstitute as a method on the aggregate itself, while the trait AggregateRootReconstitutionTrait provides the same method but returns the aggregate. This suggests a design conflict: should reconstitution be a method called on the aggregate instance (which is impossible before the instance exists) or a static/factory method provided by a trait? The trait returns the aggregate, implying it's a factory, while the interface method implies an instance method.
- Redundant types with identical signatures. EventStream (Contract) and DomainEventStream (Domain) have nearly identical method signatures (append, newEvents, markCommited, count, id, name, version, newVersion). This duplication suggests that the contract and domain layer are not properly separated or that one is an unnecessary wrapper. The contract should define the interface, and the domain should implement it, but here both expose the same public API surface, leading to confusion about which type to use.
- Semantic ambiguity between 'id' and 'name' across related types. In EventStream, 'id' and 'name' are distinct string properties. In Transaction, 'id' and 'name' are also distinct. However, looking at EventStore.create(id: Identifier, name: string) and EventStore.load(id: Identifier), the 'id' is the primary key. In EventStream, id() returns string, but the constructor/creation uses Identifier. More critically, Transaction and EventStream have identical surface methods (id, name, version, count, events) but represent different stages (in-memory stream vs persisted transaction). This creates confusion on whether 'id' refers to the aggregate root ID or the stream/transaction ID.
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
Averor/event-sourcing was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 10 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 692fee58117fd6736137d9bc2982cf27b0994d77 — the exact code this score is about.
- Scored under rubric-2026.11.2 — the same rubric and the same method as every other entry in this index.
- Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.4+preprod-464a0040a931.