PHPackages                             azaharizaman/nexus-idempotency - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. azaharizaman/nexus-idempotency

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

azaharizaman/nexus-idempotency
==============================

Domain-level idempotency: command deduplication and replay-safe results (Layer 1).

v0.1.0-alpha1(1mo ago)02↓100%1MITPHPPHP ^8.3

Since May 5Pushed 1mo agoCompare

[ Source](https://github.com/azaharizaman/nexus-idempotency)[ Packagist](https://packagist.org/packages/azaharizaman/nexus-idempotency)[ RSS](/packages/azaharizaman-nexus-idempotency/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (1)Versions (2)Used By (1)

Nexus\\Idempotency
==================

[](#nexusidempotency)

Overview
--------

[](#overview)

`Nexus\Idempotency` is a **Layer 1** package for **command-level idempotency**: deduplicate mutating operations using a tenant-scoped composite key `(tenantId, operationRef, clientKey)` plus a **request fingerprint**, and **replay** a stored opaque result for safe retries.

It does **not** implement HTTP, databases, outbox, event streams, or audit trails—see [REQUIREMENTS.md](REQUIREMENTS.md) for boundaries.

Architecture
------------

[](#architecture)

- Layer 1: pure PHP 8.3+, framework-agnostic
- Explicit lifecycle: `begin()` → domain work → `complete()` or `fail()`
- Persistence via `IdempotencyStoreInterface` (composite of `IdempotencyQueryInterface` + `IdempotencyPersistInterface`; e.g. `InMemoryIdempotencyStore` for tests — uses **JSON-encoded tuple keys** `json_encode([tenantId, operationRef, clientKey])` so segments cannot collide across delimiter characters)
- Time via `IdempotencyClockInterface` (`SystemClock` returns UTC `DateTimeImmutable`, or test doubles)

Key interfaces
--------------

[](#key-interfaces)

- `Nexus\Idempotency\Contracts\IdempotencyServiceInterface`
- `Nexus\Idempotency\Contracts\IdempotencyStoreInterface` (extends query + persist ports)
- `Nexus\Idempotency\Contracts\IdempotencyClockInterface`

Installation
------------

[](#installation)

From monorepo root:

```
composer dump-autoload
vendor/bin/phpunit -c packages/Idempotency/phpunit.xml
```

Usage (conceptual)
------------------

[](#usage-conceptual)

```
$service = new IdempotencyService($store, $store, $clock, IdempotencyPolicy::default());

$decision = $service->begin($tenantId, $operationRef, $clientKey, $fingerprint);

if ($decision->outcome === BeginOutcome::Replay) {
    return $decision->replayResult; // replay cached outcome
}

if ($decision->outcome === BeginOutcome::InProgress) {
    // Another in-flight execution for the same key + fingerprint; surface 409 + Retry-After in Layer 3.
    return;
}

// BeginOutcome::FirstExecution — run domain command, then complete using the attempt bound to this reservation:
$service->complete(
    $tenantId,
    $operationRef,
    $clientKey,
    $fingerprint,
    $decision->record->attemptToken,
    new ResultEnvelope($json),
);
```

`complete()` / `fail()` require the **`AttemptToken`** from the `FirstExecution` record for that attempt so completions cannot attach to a superseded reservation after TTL expiry/replace.

License
-------

[](#license)

MIT

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance93

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

36d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/117408?v=4)[Azahari Zaman](/maintainers/azaharizaman)[@azaharizaman](https://github.com/azaharizaman)

---

Top Contributors

[![azaharizaman](https://avatars.githubusercontent.com/u/117408?v=4)](https://github.com/azaharizaman "azaharizaman (9 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/azaharizaman-nexus-idempotency/health.svg)

```
[![Health](https://phpackages.com/badges/azaharizaman-nexus-idempotency/health.svg)](https://phpackages.com/packages/azaharizaman-nexus-idempotency)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
