Skip to content

Build out the building blocks library and project tooling.#10

Merged
gustavofreze merged 1 commit into
mainfrom
feature/mapper
Jun 6, 2026
Merged

Build out the building blocks library and project tooling.#10
gustavofreze merged 1 commit into
mainfrom
feature/mapper

Conversation

@gustavofreze

Copy link
Copy Markdown
Member
  • Rework the aggregate roots (event-sourced and eventual) with aggregate versioning, reflection-based reconstitution, and snapshot support.
  • Rework domain events, event records, revisions, and upcasting.
  • Add the Utc, Uuid, and Ordinal value objects with their dedicated exceptions and comparison behavior.
  • Add the tiny-blocks Claude skills, rules, and CLAUDE.md.
  • Refresh the CI workflows, tooling config, and README.

Please follow the contributing guidelines.

Summary

What this pull request does.

Related issue

Closes #...

Checklist

  • Tests added or updated.
  • Documentation updated when applicable.
  • composer review passes.
  • composer tests passes.

- Rework the aggregate roots (event-sourced and eventual) with aggregate
  versioning, reflection-based reconstitution, and snapshot support.
- Rework domain events, event records, revisions, and upcasting.
- Add the Utc, Uuid, and Ordinal value objects with their dedicated
  exceptions and comparison behavior.
- Add the tiny-blocks Claude skills, rules, and CLAUDE.md.
- Refresh the CI workflows, tooling config, and README.
Copilot AI review requested due to automatic review settings June 6, 2026 13:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR significantly expands the tiny-blocks/building-blocks PHP library by reworking aggregate-root/event infrastructure (including event envelopes, versioning, strict/partial reconstitution, snapshots, and upcasting) and by introducing new foundational value objects (Uuid, Utc, Ordinal). It also adds the tiny-blocks Claude rules/skills/tooling scaffolding and refreshes repo configuration and CI/docs to match ecosystem standards.

Changes:

  • Introduce Uuid (UUIDv7) and Utc value objects plus dedicated exceptions, and switch envelope/snapshot timestamps and identifiers to these types.
  • Rework aggregate-root recorded-events handling (peekEvents() + draining pullEvents()), and add strict vs partial reconstitution for state-based aggregates.
  • Add and standardize repository tooling and contributor guidance (Claude rules/skills, CI/workflows, PHPStan/Infection config, README updates).

Reviewed changes

Copilot reviewed 98 out of 99 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/Unit/UuidTest.php Adds unit coverage for Uuid parsing, equality, and v7 generation.
tests/Unit/UtcTest.php Adds unit coverage for Utc parsing, equality, and round-tripping.
tests/Unit/Upcast/UpcastersTest.php Updates tests to build intermediate events via the new factory.
tests/Unit/Upcast/SingleUpcasterBehaviorTest.php Updates intermediate-event construction to the new factory.
tests/Unit/Upcast/IntermediateEventTest.php Updates tests for factory construction and mapping API changes.
tests/Unit/Snapshot/SnapshotTest.php Updates snapshot timestamp type from Instant to Utc and updates reconstitution call shape.
tests/Unit/Internal/ClassNameTest.php Adds reflection-based coverage for irreducible internal constructor lines.
tests/Unit/Internal/AggregateReflectionTest.php Adds reflection-based coverage for irreducible internal constructor lines.
tests/Unit/Event/RevisionTest.php Adds coverage for Revision::value() accessor.
tests/Unit/Event/IntegrationEventTranslatorsTest.php Updates record construction to EventRecord::from(...).
tests/Unit/Event/IntegrationEventRecordTest.php Updates identifiers/timestamps to Uuid/Utc and uses EventRecord::from(...).
tests/Unit/Event/EventTypeTest.php Updates expectations to reflect the new DomainEvent::eventType() contract.
tests/Unit/Event/EventRecordTest.php Updates construction to EventRecord::from(...), and switches id/time to Uuid/Utc.
tests/Unit/Event/EventRecordsTest.php Updates record construction to EventRecord::from(...).
tests/Unit/Aggregate/ModelVersionTest.php Adds coverage for ModelVersion::value() accessor.
tests/Unit/Aggregate/EventualAggregateRootBehaviorTest.php Updates API usage (peekEvents, reconstitutePartial/Strict) and adds strict reconstitution tests.
tests/Unit/Aggregate/EventSourcingRootBehaviorTest.php Updates API usage (peekEvents, new reconstitute parameter order).
tests/Unit/Aggregate/AggregateVersionTest.php Adds coverage for AggregateVersion::value() accessor.
tests/Unit/Aggregate/AggregateRootBehaviorTest.php Updates reconstitution and adds coverage for draining recorded events via pullEvents().
tests/Unit/Aggregate/AggregateExtensionBehaviorTest.php Adds coverage for subclass extension seams (event recording, identity convention).
tests/Models/SpecializedReservation.php Adds a subclass model to exercise extension seams for eventual aggregates.
tests/Models/SpecializedCart.php Adds a subclass model to exercise extension seams for event-sourced aggregates.
tests/Models/ReservationConfirmed.php Adds stable eventType() implementation for the updated DomainEvent contract.
tests/Models/ReservationBooked.php Adds stable eventType() implementation for the updated DomainEvent contract.
tests/Models/Reservation.php Updates aggregate event recording to pushEvent(...).
tests/Models/ProductAddedV2.php Adds stable eventType() implementation.
tests/Models/ProductAdded.php Adds stable eventType() implementation.
tests/Models/OrderWithMissingIdentityProperty.php Updates aggregate event recording to pushEvent(...).
tests/Models/OrderShipped.php Adds stable eventType() implementation.
tests/Models/OrderPlaced.php Adds stable eventType() implementation.
tests/Models/Order.php Updates reconstitution signature and switches event recording to pushEvent(...).
tests/Models/GuestReservation.php Adds a model with multiple required state properties to validate strict reconstitution behavior.
tests/Models/BaseReservation.php Adds a base class for eventual-aggregate extension testing.
tests/Models/BaseCart.php Adds a base class for event-sourced-aggregate extension testing.
src/Uuid.php Adds UUID value object with parse, v7-parse, and v7-generate behavior.
src/Utc.php Adds UTC instant value object wrapping ISO8601 normalized string representation.
src/Upcast/Upcasters.php Adds generic collection typing metadata and simplifies chain(...).
src/Upcast/IntermediateEvent.php Makes construction private and introduces a from(...) factory plus mapper integration changes.
src/Snapshot/Snapshot.php Switches snapshot timestamp type from Instant to Utc.
src/OrdinalBehavior.php Adds shared ordering comparisons built on an value(): int ordinal contract.
src/Ordinal.php Introduces an ordering interface for integer-backed value objects.
src/Internal/ClassName.php Adds internal helper to derive short class names consistently.
src/Internal/AggregateReflection.php Centralizes reflection-based instantiation and state hydration for aggregates.
src/Exceptions/InvalidUuid.php Adds dedicated exception for invalid UUID inputs.
src/Exceptions/InvalidUtc.php Adds dedicated exception for invalid UTC/instant inputs.
src/Exceptions/IncompleteAggregateState.php Adds dedicated exception for strict reconstitution with missing required properties.
src/Event/Revision.php Implements Ordinal and adds value() accessor while reusing ordering behavior.
src/Event/IntegrationEventTranslators.php Simplifies findFor(...) return path and clarifies generics.
src/Event/IntegrationEventRecord.php Switches id/time types to Uuid/Utc and enforces factory-only construction.
src/Event/EventType.php Uses declared DomainEvent::eventType() for domain-event type resolution and internal short-name helper for integration events.
src/Event/EventRecords.php Adds element typing metadata for the event-record collection.
src/Event/EventRecord.php Switches id/time types to Uuid/Utc, makes constructor private, and renames factory to from(...).
src/Event/DomainEvent.php Extends the domain-event contract with stable eventType(): string.
src/Aggregate/ModelVersion.php Implements Ordinal and adds value() accessor while reusing ordering behavior.
src/Aggregate/EventualAggregateRootBehavior.php Adds reconstitutePartial + reconstituteStrict, centralizes hydration, and renames event recording hook to pushEvent(...).
src/Aggregate/EventualAggregateRoot.php Updates recorded-events API to peekEvents/pullEvents and updates reconstitution contract to strict/partial variants.
src/Aggregate/EventSourcingRootBehavior.php Switches to shared blank-creation seam and uses centralized recorded-event appending.
src/Aggregate/EventSourcingRoot.php Updates recorded-events API to peekEvents/pullEvents and adjusts reconstitution parameter order.
src/Aggregate/AggregateVersion.php Implements Ordinal and adds value() accessor while reusing ordering behavior.
src/Aggregate/AggregateRootBehavior.php Introduces createBlank(...), adds peekEvents/pullEvents, and centralizes record appending and envelope construction.
README.md Updates docs to match new APIs (pullEvents, strict/partial reconstitution, new factories, new value objects).
phpstan.neon.dist Updates ignores and adds clarifying comments for known false positives.
infection.json.dist Simplifies mutator config (drops explicit override).
composer.json Updates dependency versions and adds dev dependency for event-dispatcher contracts.
CLAUDE.md Adds repository-level contributor instructions and pointers to rules/skills.
.gitignore Adds ignored local overrides for PHPStan/Infection and a Claude local settings override.
.github/workflows/ci.yml Adjusts CI concurrency group naming.
.github/workflows/auto-assign.yml Renames workflow and job for consistency.
.github/copilot-instructions.md Updates mandatory pre-task step to point at root CLAUDE.md.
.gitattributes Aligns export-ignore list with the tiny-blocks canonical publish tarball content.
.claude/skills/tiny-blocks-create/SKILL.md Adds scaffolding skill documentation and canonical asset map.
.claude/skills/tiny-blocks-create/assets/github/workflows/ci.yml Adds canonical CI workflow asset used for scaffolding/restores.
.claude/skills/tiny-blocks-create/assets/github/PULL_REQUEST_TEMPLATE.md Adds canonical PR template asset.
.claude/skills/tiny-blocks-create/assets/github/ISSUE_TEMPLATE/feature_request.md Adds canonical feature request issue template asset.
.claude/skills/tiny-blocks-create/assets/github/ISSUE_TEMPLATE/bug_report.md Adds canonical bug report issue template asset.
.claude/skills/tiny-blocks-create/assets/docs/SECURITY.md Adds canonical security policy asset.
.claude/skills/tiny-blocks-create/assets/config/phpunit.xml Adds canonical PHPUnit configuration asset.
.claude/skills/tiny-blocks-create/assets/config/phpstan.neon.dist Adds canonical PHPStan configuration asset.
.claude/skills/tiny-blocks-create/assets/config/phpcs.xml Adds canonical PHPCS configuration asset.
.claude/skills/tiny-blocks-create/assets/config/Makefile Adds canonical Makefile asset.
.claude/skills/tiny-blocks-create/assets/config/infection.json.dist Adds canonical Infection configuration asset.
.claude/skills/tiny-blocks-create/assets/config/composer.json Adds canonical composer.json asset template.
.claude/skills/tiny-blocks-create/assets/config/.gitignore Adds canonical .gitignore asset.
.claude/skills/tiny-blocks-create/assets/config/.gitattributes Adds canonical .gitattributes asset.
.claude/skills/tiny-blocks-create/assets/config/.editorconfig Adds canonical .editorconfig asset.
.claude/skills/tiny-blocks-consume/SKILL.md Adds dependency-discovery/reuse skill documentation.
.claude/skills/tiny-blocks-consume/scripts/refresh-catalog.py Adds script to regenerate the tiny-blocks package catalog from Packagist.
.claude/skills/tiny-blocks-consume/references/catalog.md Adds generated tiny-blocks package catalog.
.claude/skills/commit-message/SKILL.md Adds conventional-commit message formatting skill.
.claude/settings.json Adds Claude permissions configuration for the repository.
.claude/rules/php-library-tooling.md Refactors tooling rules to invariants + .dist naming rationale.
.claude/rules/php-library-testing.md Refines PHPUnit/test discipline rules and clarifies allowed white-box coverage exceptions.
.claude/rules/php-library-modeling.md Refines modeling guidance (enums, DRY, optional-config value objects).
.claude/rules/php-library-github-workflows.md Refactors workflow guidance and updates action pinning requirements.
.claude/rules/php-library-documentation.md Refactors documentation rules and clarifies required repo files and their source of truth.
.claude/rules/php-library-commits.md Removes legacy commits rule file (replaced by the commit-message skill).
.claude/rules/php-library-architecture.md Refines test driver folder conventions and clarifies optional vendor-compat coverage layout.
.claude/CLAUDE.md Removes obsolete .claude/ index file (replaced by root CLAUDE.md).

Comment thread tests/Unit/Aggregate/EventualAggregateRootBehaviorTest.php
Comment thread tests/Unit/Aggregate/EventualAggregateRootBehaviorTest.php
Comment thread tests/Models/SpecializedCart.php
Comment thread README.md
Comment thread tests/Unit/Upcast/IntermediateEventTest.php
@gustavofreze gustavofreze merged commit 889261e into main Jun 6, 2026
8 checks passed
@gustavofreze gustavofreze deleted the feature/mapper branch June 6, 2026 13:43
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