Repository navigation
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Persisted records using the old namespaces lack deserialization compatibility, risking duplicate execution after deployment.
No open issues 🎉
What changed in this PR
Moves the public idempotency API into Tempest\Idempotency, addressing #2075 while keeping implementation internals in their existing namespaces.
Changes:
- Relocates public types and updates internal references and tests.
- Adds the
tempest321Rector upgrade set, cumulative set, and migration fixtures. - Updates documentation examples and API references.
| File | Description |
|---|---|
| packages/upgrade/tests/Tempest321/Tempest321RectorTest.php | Tests imported and fully qualified namespace migrations. |
| packages/upgrade/tests/Tempest321/tempest321_rector.php | Configures upgrade tests. |
| packages/upgrade/tests/Tempest321/Fixtures/IdempotencyNamespaceChange.input.php | Provides legacy attribute and exception imports. |
| packages/upgrade/tests/Tempest321/Fixtures/FullyQualifiedIdempotencyStore.input.php | Provides fully qualified legacy store references. |
| packages/upgrade/src/Set/TempestSetList.php | Exposes the new upgrade set. |
| packages/upgrade/src/Set/TempestLevelSetList.php | Exposes the cumulative upgrade set. |
| packages/upgrade/config/sets/tempest321.php | Maps old public names to root names. |
| packages/upgrade/config/sets/level/up-to-tempest-321.php | Includes the new and preceding upgrade sets. |
| packages/idempotency/tests/IdempotentCommandMiddlewareTest.php | Updates command middleware test imports. |
| packages/idempotency/tests/IdempotencyMiddlewareTest.php | Updates HTTP middleware test imports. |
| packages/idempotency/tests/HeartbeatRenewerTest.php | Updates heartbeat test imports. |
| packages/idempotency/tests/Fixtures/RecordingStore.php | Updates store fixture imports. |
| packages/idempotency/src/Support/IdempotencyKeyResolver.php | References the relocated configuration. |
| packages/idempotency/src/Support/HeartbeatRenewer.php | References the relocated store interface. |
| packages/idempotency/src/StoredResponse.php | Moves stored responses to the root namespace. |
| packages/idempotency/src/Middleware/IdempotentCommandMiddleware.php | Updates public API imports. |
| packages/idempotency/src/Middleware/IdempotencyMiddleware.php | Updates public API imports. |
| packages/idempotency/src/Initializers/IdempotencyInitializer.php | Updates configuration and store imports. |
| packages/idempotency/src/Initializers/IdempotencyFingerprintGeneratorInitializer.php | Updates the HTTP fingerprint interface import. |
| packages/idempotency/src/Initializers/CommandFingerprintGeneratorInitializer.php | Updates the command fingerprint interface import. |
| packages/idempotency/src/IdempotentRoute.php | Moves the route attribute to the root namespace. |
| packages/idempotency/src/Idempotent.php | Moves the idempotency attribute to the root namespace. |
| packages/idempotency/src/IdempotencyStore.php | Moves the store interface to the root namespace. |
| packages/idempotency/src/IdempotencyState.php | Moves the state enum to the root namespace. |
| packages/idempotency/src/IdempotencyRecord.php | Moves the record type to the root namespace. |
| packages/idempotency/src/IdempotencyPlatformWasNotSupported.php | Moves the platform exception to the root namespace. |
| packages/idempotency/src/IdempotencyMethodWasNotSupported.php | Moves the method exception and removes a redundant import. |
| packages/idempotency/src/IdempotencyKeyWasAlreadyUsed.php | Moves the key-reuse exception to the root namespace. |
| packages/idempotency/src/IdempotencyException.php | Moves the base exception to the root namespace. |
| packages/idempotency/src/IdempotencyConfig.php | Moves configuration and removes redundant imports. |
| packages/idempotency/src/idempotency.config.php | Instantiates the relocated configuration. |
| packages/idempotency/src/HttpFingerprintGenerator.php | Moves the HTTP fingerprint interface. |
| packages/idempotency/src/Fingerprint/RequestFingerprintGenerator.php | Imports the relocated HTTP interface. |
| packages/idempotency/src/Fingerprint/ObjectFingerprintGenerator.php | Imports the relocated command interface. |
| packages/idempotency/src/CommandFingerprintGenerator.php | Moves the command fingerprint interface. |
| packages/idempotency/src/CacheIdempotencyStore.php | Moves the cache-backed store to the root namespace. |
| docs/2-features/19-idempotency.md | Updates public API references and examples. |
| docs/2-features/10-command-bus.md | Updates idempotent command examples and references. |
| docs/1-essentials/01-routing.md | Updates idempotent route examples and references. |
Review effort: Balanced
Member
|
Please rebase on 4.x and rename the rectors to target 4.0 |
Akiyo974
force-pushed
the
refactor/idempotency-namespaces
branch
from
November 22, 2026 22:31
b072d94 to
adbcb04
Compare
Author
|
Rebased on 4.x and moved the upgrade rules to a new tempest40 set (TEMPEST_40 / UP_TO_TEMPEST_40). I also added an upgrade note to the description about idempotency records already in the cache: they were serialized with the old class names, so clearing those entries when upgrading avoids a retried request running twice. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2075
What
Moves the user-facing classes of
tempest/idempotencyout of their sub-namespaces and intoTempest\Idempotency, matching the layout of other packages such astempest/cache.Tempest\Idempotency\Attributes\IdempotentTempest\Idempotency\IdempotentTempest\Idempotency\Attributes\IdempotentRouteTempest\Idempotency\IdempotentRouteTempest\Idempotency\Config\IdempotencyConfigTempest\Idempotency\IdempotencyConfigTempest\Idempotency\Exceptions\IdempotencyExceptionTempest\Idempotency\IdempotencyExceptionTempest\Idempotency\Exceptions\IdempotencyKeyWasAlreadyUsedTempest\Idempotency\IdempotencyKeyWasAlreadyUsedTempest\Idempotency\Exceptions\IdempotencyMethodWasNotSupportedTempest\Idempotency\IdempotencyMethodWasNotSupportedTempest\Idempotency\Exceptions\IdempotencyPlatformWasNotSupportedTempest\Idempotency\IdempotencyPlatformWasNotSupportedTempest\Idempotency\Store\IdempotencyStoreTempest\Idempotency\IdempotencyStoreTempest\Idempotency\Store\CacheIdempotencyStoreTempest\Idempotency\CacheIdempotencyStoreTempest\Idempotency\Store\IdempotencyRecordTempest\Idempotency\IdempotencyRecordTempest\Idempotency\Store\IdempotencyStateTempest\Idempotency\IdempotencyStateTempest\Idempotency\Store\StoredResponseTempest\Idempotency\StoredResponseTempest\Idempotency\Fingerprint\HttpFingerprintGeneratorTempest\Idempotency\HttpFingerprintGeneratorTempest\Idempotency\Fingerprint\CommandFingerprintGeneratorTempest\Idempotency\CommandFingerprintGeneratorThe default
idempotency.config.phpmoves to the package root as well.Internal classes stay in their sub-namespaces:
Middleware,Initializers,Support, and the fingerprint implementations (RequestFingerprintGenerator,ObjectFingerprintGenerator).Store classes count as user-facing because a custom
IdempotencyStoreneedsIdempotencyRecord,IdempotencyStateandStoredResponsein its signatures. The fingerprint interfaces count too, because they are the extension points.Breaking change & upgrade path
tempest/idempotencyhas been released since v3.3.0, so this is a breaking change. To make migrating easy, this PR adds atempest40upgrade set (plusUP_TO_TEMPEST_40) that usesRenameClassRectorto rewrite every old class name, in bothuseimports and fully-qualified references.The set targets 4.0, since this is a breaking change.
Upgrade note: idempotency records already in the cache were serialized with the old class names, so after upgrading they no longer deserialize and are treated as missing. A retried request right after deploying could therefore run once more. Clearing the idempotency cache entries when upgrading avoids this.
Other changes
19-idempotency.md,10-command-bus.md,01-routing.mdpackages/upgrade/tests/Tempest40Checks
packages/idempotency/tests: 34 tests passpackages/upgrade/tests: 37 tests pass, including the new onesmago fmt/mago lint: cleanphpstan: no new errors