Skip to content

Promote AggregateVersion and exceptions to public API.#8

Merged
gustavofreze merged 5 commits into
mainfrom
feature/develop
May 19, 2026
Merged

Promote AggregateVersion and exceptions to public API.#8
gustavofreze merged 5 commits into
mainfrom
feature/develop

Conversation

@gustavofreze
Copy link
Copy Markdown
Member

No description provided.

The renames are part of a single API-surface refresh: the version concept
moves to AggregateVersion to match DDD vocabulary, the formerly internal
exceptions become catchable from consumer code, and the surrounding
EventRecord and accessor names are realigned in the same pass so the
public surface lands consistent.
Copilot AI review requested due to automatic review settings May 19, 2026 03:36
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request promotes previously-internal building blocks (aggregate versioning and exception types) into the public API, aligning the library’s terminology around AggregateVersion and updating tests/tooling to match.

Changes:

  • Replace SequenceNumber with AggregateVersion across aggregates, snapshots, and event envelopes, including new AggregateVersion and InvalidAggregateVersion.
  • Promote exceptions from TinyBlocks\BuildingBlocks\Internal\Exceptions into TinyBlocks\BuildingBlocks\Exceptions and update references accordingly.
  • Restructure/unit-normalize tests and refresh repository tooling/CI conventions (PHPUnit, PHPStan, PHPCS, reports paths, templates, workflows).

Reviewed changes

Copilot reviewed 100 out of 101 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/Unit/Upcast/UpcastersTest.php Update test namespace to Unit\Upcast.
tests/Unit/Upcast/SingleUpcasterBehaviorTest.php Update test namespace to Unit\Upcast.
tests/Unit/Upcast/IntermediateEventTest.php Update namespace and adjust equality test to use AggregateVersion.
tests/Unit/Upcast/DefaultValuesTest.php Update namespace and tighten BDD step structure.
tests/Unit/Snapshot/SnapshotTest.php Update namespace and migrate snapshot API usage to aggregateType() / aggregateVersion().
tests/Unit/Snapshot/SnapshotterBehaviorTest.php Update namespace/imports and migrate assertions to aggregate version fields.
tests/Unit/Snapshot/SnapshotNeverTest.php Update namespace and variable naming for clarity.
tests/Unit/Snapshot/SnapshotEveryTest.php Update namespace and exception import; rename variables for clarity.
tests/Unit/Snapshot/SnapshotConditionTest.php Update test namespace to Unit\Snapshot.
tests/Unit/FileSnapshotter.php Move mock snapshotter into tests/Unit namespace (per new testing layout).
tests/Unit/Event/RevisionTest.php Update namespace and exception import; formatting tweaks in data provider.
tests/Unit/Event/EventTypeTest.php Update namespace and exception import; formatting tweaks in data provider.
tests/Unit/Event/EventRecordTest.php Update EventRecord field names and remove SnapshotData-related assertions.
tests/Unit/Event/EventRecordsTest.php Update EventRecord construction to new envelope fields and AggregateVersion.
tests/Unit/Event/DomainEventBehaviorTest.php Update test namespace to Unit\Event.
tests/Unit/Entity/SingleIdentityBehaviorTest.php Update namespace and variable naming for clarity.
tests/Unit/Entity/EntityBehaviorTest.php Update namespace and exception import; variable naming improvements.
tests/Unit/Entity/CompoundIdentityBehaviorTest.php Add coverage for compound identities (including mixed scalar/object fields).
tests/Unit/Aggregate/ModelVersionTest.php Add unit coverage for new comparison helpers on ModelVersion.
tests/Unit/Aggregate/EventualAggregateRootBehaviorTest.php Add behavior tests for EventualAggregateRoot reconstitution and versioning.
tests/Unit/Aggregate/EventSourcingRootBehaviorTest.php Update terminology and assertions to AggregateVersion and new EventRecord fields.
tests/Unit/Aggregate/AggregateVersionTest.php Add unit coverage for AggregateVersion value object semantics.
tests/Unit/Aggregate/AggregateRootBehaviorTest.php Update behavior tests for aggregateType() and aggregateVersion().
tests/Snapshot/SnapshotDataTest.php Remove tests for deleted SnapshotData.
tests/Models/ReservationId.php Add fixture identity used by new aggregate reconstitution tests.
tests/Models/ReservationConfirmed.php Add domain event fixture for eventual aggregate tests.
tests/Models/ReservationBooked.php Add domain event fixture for eventual aggregate tests.
tests/Models/Reservation.php Add eventual aggregate fixture using the new behavior.
tests/Models/Order.php Update fixture to new reconstitute(Identity, AggregateVersion, state) signature and version storage.
tests/Models/ExplicitCart.php Remove PHPDoc list annotations and tweak alignment in handler map.
tests/Models/CartWithLogger.php Update snapshot state omissions (aggregateVersion instead of sequenceNumber) and minor string style tweak.
tests/Models/Cart.php Remove PHPDoc list annotations and keep snapshot behavior aligned with new version field.
tests/Models/AppointmentSlot.php Add compound identity fixture with mixed scalar/object fields.
tests/Event/SequenceNumberTest.php Remove tests for deleted SequenceNumber.
tests/Entity/CompoundIdentityBehaviorTest.php Remove old location in favor of tests/Unit/Entity.
tests/Aggregate/ModelVersionTest.php Remove old location in favor of tests/Unit/Aggregate.
tests/Aggregate/EventualAggregateRootBehaviorTest.php Remove old location in favor of tests/Unit/Aggregate.
src/Upcast/Upcasters.php Add documentation and make reduce result type explicit for static analysis.
src/Upcast/SingleUpcasterBehavior.php Add documentation for the rewrite() extension point.
src/Upcast/IntermediateEvent.php Add documentation for copy/with methods.
src/Upcast/DefaultValues.php Make class non-readonly and document get().
src/Snapshot/SnapshotterBehavior.php Document persist() extension point.
src/Snapshot/SnapshotNever.php Document factory method intent.
src/Snapshot/SnapshotEvery.php Switch to AggregateVersion and promote InvalidSnapshotCount to public exceptions.
src/Snapshot/SnapshotData.php Remove SnapshotData value object.
src/Snapshot/SnapshotCondition.php Update docs to “version” terminology and wording adjustments.
src/Snapshot/Snapshot.php Rename fields to aggregate-centric naming and replace sequence number with aggregate version.
src/Internal/Exceptions/InvalidSequenceNumber.php Remove internal exception tied to deleted SequenceNumber.
src/Exceptions/NoEventHandlerRegistered.php Move exception to public namespace and adjust constructor call style.
src/Exceptions/MissingIdentityProperty.php Move exception to public namespace and adjust constructor call style.
src/Exceptions/InvalidSnapshotCount.php Move exception to public namespace and adjust constructor call style.
src/Exceptions/InvalidRevision.php Move exception to public namespace and adjust constructor call style.
src/Exceptions/InvalidModelVersion.php Move exception to public namespace and adjust constructor call style.
src/Exceptions/InvalidEventType.php Move exception to public namespace and adjust constructor call style.
src/Exceptions/InvalidAggregateVersion.php Add new public exception for invalid aggregate versions.
src/Exceptions/EventHandlerMethodNotFound.php Move exception to public namespace and adjust constructor call style.
src/Event/SequenceNumber.php Remove SequenceNumber value object.
src/Event/Revision.php Switch to public exception namespace and add public-method PHPDoc.
src/Event/EventType.php Switch to public exception namespace and add public-method PHPDoc.
src/Event/EventRecord.php Update envelope fields (eventType, occurredAt, aggregateId, aggregateVersion) and remove SnapshotData dependency.
src/Event/DomainEvent.php Documentation edits (but still mentions sequence number).
src/Entity/SingleIdentity.php Minor doc wording adjustment.
src/Entity/Identity.php Minor doc wording adjustment.
src/Entity/EntityBehavior.php Reorder members and add docblock for identity property resolution.
src/Entity/Entity.php Switch to public exception namespace and doc wording adjustments.
src/Aggregate/ModelVersion.php Switch to public exception namespace and add comparison helpers + docs.
src/Aggregate/EventualAggregateRootBehavior.php Add default reconstitute() implementation and switch event recording to aggregate version.
src/Aggregate/EventualAggregateRoot.php Add reconstitute() contract docs and minor doc wording tweaks.
src/Aggregate/EventSourcingRootBehavior.php Rename sequence tracking to aggregate version, update snapshot behavior, and tighten internal method visibility.
src/Aggregate/EventSourcingRoot.php Update docs to aggregate version terminology and reorder documented members.
src/Aggregate/AggregateVersion.php Add new AggregateVersion value object.
src/Aggregate/AggregateRootBehavior.php Replace sequence number logic with aggregate version and update event envelope construction.
src/Aggregate/AggregateRoot.php Promote aggregate version to the core aggregate contract and rename aggregate “name” to “type”.
SECURITY.md Add security policy document.
phpunit.xml Tighten PHPUnit strictness flags and unify report output under reports/.
phpstan.neon.dist Raise analysis level, include tests, and codify ignore rules with reportUnmatchedIgnoredErrors: true.
phpcs.xml Add PHPCS ruleset file for PSR-12 over src and tests.
Makefile Align targets with new Composer scripts and move artifacts under reports/.
infection.json.dist Move Infection output paths under reports/.
composer.json Update dependency versions and standardize scripts to configure, configure-and-update, review, test-file, tests.
.gitignore Ignore tooling caches and reports/ artifacts; reorganize sections.
.github/workflows/codeql.yml Add concurrency + timeout and update checkout action version.
.github/workflows/ci.yml Rename config job, propagate new output name, and update checkout action version.
.github/workflows/auto-assign.yml Add concurrency/permissions/timeout structure and rename job key.
.github/PULL_REQUEST_TEMPLATE.md Add canonical PR template.
.github/ISSUE_TEMPLATE/feature_request.md Add canonical feature request issue template.
.github/ISSUE_TEMPLATE/bug_report.md Add canonical bug report issue template.
.github/copilot-instructions.md Refresh contributor instruction wording and references to .claude rules.
.gitattributes Add export-ignore entries for reports/cache and adjust wording.
.editorconfig Set max_line_length = 120.
.claude/rules/php-library-tooling.md Add canonical tooling configuration guidance for the ecosystem.
.claude/rules/php-library-testing.md Expand and formalize PHPUnit/BDD/testing discipline rules.
.claude/rules/php-library-modeling.md Expand modeling rules (nomenclature, VO/exceptions, complexity).
.claude/rules/php-library-github-workflows.md Add canonical workflow structure and action pinning rules.
.claude/rules/php-library-documentation.md Expand documentation rules and canonical templates.
.claude/rules/php-library-commits.md Add Conventional Commits rules (used only when requested).
.claude/rules/php-library-architecture.md Add canonical folder structure + public/Internal boundary rules.
.claude/rules/github-workflows.md Remove outdated workflow rules file.
.claude/CLAUDE.md Replace prior content with an index pointing to scoped rule files.
Comments suppressed due to low confidence (2)

src/Aggregate/AggregateRootBehavior.php:52

  • buildEventRecord() is declared private in a non-Internal trait. Per the code-style rules, private methods are reserved for src/Internal/ (except private constructors). Consider making this protected so other behaviors can call it without violating the style guide.
    private function buildEventRecord(DomainEvent $event): EventRecord
    {

.github/workflows/auto-assign.yml:27

  • The workflow guidelines in .claude/rules/php-library-github-workflows.md require actions to be pinned to a major version tag. gustavofreze/auto-assign@2.1.0 is a patch pin; update it to the @2 major tag to match the repository’s workflow convention.
      - name: Assign issues and pull requests
        uses: gustavofreze/auto-assign@2.1.0
        with:

Comment thread src/Aggregate/AggregateRootBehavior.php
Comment thread src/Aggregate/EventSourcingRootBehavior.php
Comment thread src/Event/DomainEvent.php
Comment thread src/Upcast/DefaultValues.php
@gustavofreze gustavofreze merged commit 8a01f84 into main May 19, 2026
11 checks passed
@gustavofreze gustavofreze deleted the feature/develop branch May 19, 2026 03:44
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.

2 participants