Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Code of Conduct — maatify/php-persistence

[![Maatify PHP Persistence](https://img.shields.io/badge/Maatify-PHP_Persistence-blue?style=for-the-badge)](https://github.com/Maatify-ltd/php-persistence)
[![Maatify Ecosystem](https://img.shields.io/badge/Maatify-Ecosystem-9C27B0?style=for-the-badge)](https://github.com/Maatify)
[![Maatify Ecosystem](https://img.shields.io/badge/Maatify-Ecosystem-9C27B0?style=for-the-badge)](https://github.com/Maatify-ltd)

## Our Standard

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ composer whitespace # git diff --check
composer test:unit # no Docker needed
composer test:regression # no Docker needed
composer test:integration # needs Docker; starts a disposable MySQL/MariaDB service
composer examples:smoke # needs Docker; smoke-executes examples/ against a real engine
composer examples:smoke # needs Docker; runs standalone examples against a real engine
composer test:consumer # needs Docker; two fresh external Composer verification runs
actionlint .github/workflows/*.yml
```
Expand Down
17 changes: 2 additions & 15 deletions PHP_PERSISTENCE_PACKAGE_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -961,20 +961,7 @@ An attempt is `New`, `Running`, or `Terminal`. settlement() returns null before

**Release, retirement, and discard.** release() makes the source available to another checkout only after confirmed idle status and resolution of pending settings and resources. retireForHost() permanently invalidates the source and transfers the same PDO after confirmed resource release. `ReturnedIdle` certifies the known idle state. `ReturnedForReconciliation` asks the Host to resolve the connection before further circulation. An unresolved resource prevents transfer. The Host can call discardForHost() to permanently invalidate the source and drop the library's references. This call initiates zero explicit SQL, state probes, or transaction-end commands. PDO or its driver may automatically send ROLLBACK or perform other I/O or close the session when the last reference is released. The caller does not receive an acknowledgement of transaction outcome, timing, or server closure. A retirement or discard request while a reservation is held is rejected.

```php
$checkout = $source->checkout();
$checkout->beginRepeatableRead();
$grant = $checkout->authorizePage('items', ['tenant' => 7], new PageRequest());
$attempt = $checkout->newAttempt($grant);
try {
$page = $paginator->paginate($attempt);
} finally {
$settlement = $attempt->settlement();
}
// The Host uses $settlement on either path and explicitly ends its transaction.
// The Host can reconcile after a classified handoff. Unresolved resources prevent handoff;
// the Host may explicitly discard that connection.
```
See the [Host Snapshot B example](examples/pagination_host_snapshot_usage.php) for a read-only page attempt, qualified rollback on read failure, and explicit connection disposition.

See [DEC-036](docs/decisions/DEC-036-pascalcase-enums-and-stable-settlement-json.md).

Expand Down Expand Up @@ -1223,7 +1210,7 @@ A detailed, dated per-behavior mapping (the B-01 to B-16 rows, each with its leg

- [README.md](README.md) — quick overview, installation/access status, requirements.
- [docs/guides/USAGE_GUIDE.md](docs/guides/USAGE_GUIDE.md) — capability map, walkthroughs, and the boundaries of each capability before its examples.
- [examples/](examples/) — runnable, Public-API-only examples for all three capabilities.
- [examples/](examples/) — standalone and Host-dependent examples using only the Public API across all three capabilities.
- [llms.txt](llms.txt) — AI consumer navigation map.
- [docs/architecture/ARCHITECTURE.md](docs/architecture/ARCHITECTURE.md), [CONTRACT_MATRIX.md](docs/architecture/CONTRACT_MATRIX.md), [BEHAVIOR_CONTRACT.md](docs/architecture/BEHAVIOR_CONTRACT.md), [DATABASE_SUPPORT_AND_TEST_POLICY.md](docs/architecture/DATABASE_SUPPORT_AND_TEST_POLICY.md), [CI_AND_INTEGRATION.md](docs/architecture/CI_AND_INTEGRATION.md) — design, legacy-mapping, and test-matrix detail, dated and framed as historical/evidence records rather than a second current contract.
- [docs/decisions/DECISIONS_INDEX.md](docs/decisions/DECISIONS_INDEX.md) — durable decisions this reference applies.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ $orderId = $runner->run(function () use ($pdo): int {
});
```

See [docs/guides/USAGE_GUIDE.md](docs/guides/USAGE_GUIDE.md) for a capability map covering Transaction, Pagination, and Ordering, each with its own `Input → Public Call → Result → Boundary` walkthrough, and [examples/](examples/) for complete, runnable scripts.
See [docs/guides/USAGE_GUIDE.md](docs/guides/USAGE_GUIDE.md) for a capability map covering Transaction, Pagination, and Ordering, each with its own `Input → Public Call → Result → Boundary` walkthrough, and [examples/](examples/) for standalone scripts and the Host Snapshot B integration example.

## Public Runtime API

Expand Down Expand Up @@ -147,13 +147,13 @@ Table and column identifiers passed to `ScopedOrderingConfig` and sort-key ident

## Examples

Runnable [examples](examples/) cover Transaction, Pagination and Ordering on a real MySQL/MariaDB connection. The [opt-in Snapshot example](examples/pagination_snapshot_usage.php) shows a single page with Host-owned connection settlement. See the [C1 contract](PHP_PERSISTENCE_PACKAGE_REFERENCE.md#531-optional-c1-snapshot-pagination) for eligibility and usage.
Runnable [examples](examples/) cover Transaction, Pagination and Ordering on a real MySQL/MariaDB connection. The [opt-in Snapshot example](examples/pagination_snapshot_usage.php) shows a single page with Host-owned connection settlement. See the [C1 contract](PHP_PERSISTENCE_PACKAGE_REFERENCE.md#531-optional-c1-snapshot-pagination) for eligibility and usage. The [Host Snapshot B example](examples/pagination_host_snapshot_usage.php) requires an application-owned PDO and page-plan catalog.

## Documentation

- [PHP_PERSISTENCE_PACKAGE_REFERENCE.md](PHP_PERSISTENCE_PACKAGE_REFERENCE.md) — canonical Public Runtime API, behavior, and exception contract.
- [docs/guides/USAGE_GUIDE.md](docs/guides/USAGE_GUIDE.md) — capability map and walkthroughs.
- [examples/](examples/) — runnable examples.
- [examples/](examples/) — standalone and Host-dependent examples.
- [CHANGELOG.md](CHANGELOG.md) · [SECURITY.md](SECURITY.md) · [CONTRIBUTING.md](CONTRIBUTING.md)
- [llms.txt](llms.txt) — AI consumer navigation map.
- [docs/architecture/ARCHITECTURE.md](docs/architecture/ARCHITECTURE.md) — design and topology (dated design record).
Expand All @@ -174,19 +174,20 @@ composer format:check # PER-CS 3.1, non-mutating
composer test:unit # no Docker needed
composer test:regression
composer test:integration # needs Docker; starts a disposable MySQL/MariaDB service
composer examples:smoke # needs Docker; smoke-executes examples/ against a real engine
composer examples:smoke # needs Docker; runs standalone examples against a real engine
```

See [docs/architecture/QUALITY_TOOLING.md](docs/architecture/QUALITY_TOOLING.md), [docs/architecture/CI_AND_INTEGRATION.md](docs/architecture/CI_AND_INTEGRATION.md), and [CONTRIBUTING.md](CONTRIBUTING.md) for the full local-verification contract.

## License

This package is proprietary. For use under the terms on this branch, request
a free written license from [support@maatify.dev](mailto:support@maatify.dev).
This package is proprietary. Under the terms on this branch, obtain written
authorization from Maatify Ltd. before use, subject to the exceptions in
[LICENSE](LICENSE). Request a free written license from [support@maatify.dev](mailto:support@maatify.dev).
Include your organization name, if applicable, and an email address for
security advisories and critical update notices. Maatify Ltd. uses these details
to administer licenses and send those notices. See [LICENSE](LICENSE) for
the terms. Published versions carry their own license file.
to administer licenses and send those notices. Published versions carry their
own license file.

## 👤 Author

Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ See [Packagist](https://packagist.org/packages/maatify/php-persistence) for curr
support@maatify.dev
```

Maatify publishes this private vulnerability-reporting address in its [security reporting instructions](https://github.com/Maatify/persistence/blob/main/SECURITY.md). It is also the contact in this repository’s [LICENSE](LICENSE). Include the affected file(s) or capability (Transaction, Pagination, or Ordering), the commit SHA you observed it on, and, where possible, a minimal reproduction.
This private contact is listed in this package's [LICENSE](LICENSE). Include the affected file(s) or capability (Transaction, Pagination, or Ordering), the commit SHA you observed it on, and, where possible, a minimal reproduction.

## Scope

Expand Down
2 changes: 1 addition & 1 deletion docs/architecture/CI_AND_INTEGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ composer examples:smoke
PP_DB_CELL=mariadb-11.8.9 composer examples:smoke
```

CI requires both `mysql-8.4.13` and `mariadb-11.8.9` smoke jobs on PHP 8.4 and on PHP 8.6. This smoke matrix is separate from the capability Integration matrix below.
CI requires both `mysql-8.4.13` and `mariadb-11.8.9` smoke jobs on PHP 8.4 and on PHP 8.6. This smoke matrix is separate from the capability Integration matrix below. The [Host Snapshot B example](../../examples/pagination_host_snapshot_usage.php) requires an application-owned source and registered page plan. It runs under the PHP syntax and static-analysis gates, with Host B behavior exercised independently in the installed Consumer Verification Harness.

On each of PHP 8.4 and 8.6, [Consumer verification](../guides/CONSUMER_VERIFICATION.md) runs two fresh lifecycles per engine on MySQL 8.4.13 and MariaDB 11.8.9, with separate production Composer roots.

Expand Down
10 changes: 5 additions & 5 deletions docs/guides/USAGE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ This guide covers the Stable `1.0.0` target. Follow the [installation instructio
| Pagination · Optional static composite sort | `PdoPaginator::paginateWithStaticSort()` | [Static composite sorting](#optional-static-composite-sorting) | [examples/pagination_static_sort_usage.php](../../examples/pagination_static_sort_usage.php) |
| Pagination · Optional dynamic sort | `PdoPaginator::paginateWithDynamicSort()` | [Dynamic sorting](#optional-dynamic-sorting) | [examples/pagination_dynamic_sort_usage.php](../../examples/pagination_dynamic_sort_usage.php) |
| Pagination · Optional delegated snapshot (C1) | `PdoSnapshotPaginator::forExclusiveRead()` then `paginate()` | [C1 snapshot pagination](#optional-c1-snapshot-pagination) | [examples/pagination_snapshot_usage.php](../../examples/pagination_snapshot_usage.php) |
| Pagination · Optional Host transaction snapshot (B) | `PdoHostSnapshotSource::attachExclusive()` then `PdoHostSnapshotPaginator::paginate()` with an authorized page attempt | [B pagination in a Host transaction](#optional-b-pagination-in-a-host-transaction) | [Inline Host B page-attempt example](../../PHP_PERSISTENCE_PACKAGE_REFERENCE.md#533-optional-b-pagination-in-a-host-owned-transaction) |
| Pagination · Optional Host transaction snapshot (B) | `PdoHostSnapshotSource::attachExclusive()` then `PdoHostSnapshotPaginator::paginate()` with an authorized page attempt | [B pagination in a Host transaction](#optional-b-pagination-in-a-host-transaction) | [Host integration example](../../examples/pagination_host_snapshot_usage.php) |
| Pagination · Optional forward-only Keyset | `PdoKeysetPaginator::paginate()` | [Forward-only Keyset pagination](#optional-forward-only-keyset-pagination) | [examples/pagination_keyset_usage.php](../../examples/pagination_keyset_usage.php) |
| Ordering | `ScopedOrderingManager::moveWithinScope()` (and the next-position reads) | [§3](#3-ordering) | [examples/ordering_basic_usage.php](../../examples/ordering_basic_usage.php) |
| Ordering · Optional protected UNIQUE-safe lists (B1) | `ProtectedScopedOrderingManager::getNextUniquePositionForAppend()`, `moveUniqueWithinScope()`, or `deleteUniqueWithinScope()` | [Protected UNIQUE-safe Ordering B1](#protected-unique-safe-ordering-b1) | [examples/ordering_unique_usage.php](../../examples/ordering_unique_usage.php) |

## Run the examples from a 1.0.0 install

After [installing the exact version](../../README.md#installation), choose a row with a linked PHP file in the capability map. Create an `examples/` directory in your Composer project and copy that file and `_bootstrap.php` from `vendor/maatify/php-persistence/examples/`. Run the copied file with PHP from your project root so it loads your Composer autoloader. Use a disposable InnoDB database with the connection variables and privileges in the example setup below. The B1 example also requires `DELETE`.
After [installing the exact version](../../README.md#installation), choose a standalone example from the capability map. Create an `examples/` directory in your Composer project and copy that file and `_bootstrap.php` from `vendor/maatify/php-persistence/examples/`. Run the copied file with PHP from your project root so it loads your Composer autoloader. Use a disposable InnoDB database with the connection variables and privileges in the example setup below. The B1 example also requires `DELETE`.

The inline Host Snapshot B example runs inside a Host integration. Use the [Host B walkthrough](#optional-b-pagination-in-a-host-transaction) to prepare an eligible idle `pdo_mysql` connection for exclusive delegation, register an InnoDB page plan, and build the source and paginator. The Host completes the transaction and handles connection handoff or discard.
Load the [Host Snapshot B example](../../examples/pagination_host_snapshot_usage.php) within an application that has loaded its production Composer autoloader. Use the [Host B walkthrough](#optional-b-pagination-in-a-host-transaction) to attach an eligible idle `pdo_mysql` connection exclusively to a source with a registered InnoDB page plan. Call `Maatify\PhpPersistence\Examples\readHostSnapshotPage()` with that source, the registered plan ID, its bindings, and a page request. The example depends on those application objects and is outside standalone smoke execution. The Host accesses the delegated connection only through its source and checkout. The example discards the source when a normal commit leaves reuse unconfirmed. On failure it attempts to discard the source and rethrows the original failure. After discard or a thrown failure, drop all retained references to the original PDO and keep it out of circulation even if discard could not complete. A returned page does not authorize direct reuse of that PDO.

## Run the published RC.2 examples from a clean install

Expand Down Expand Up @@ -84,7 +84,7 @@ Each command provisions two disposable services for that engine. Look for `CONSU

### Run examples from the repository checkout

With the checkout's Composer dependencies installed and Docker running, `composer examples:smoke` provisions a disposable database and runs the examples. To run an individual example manually, use the disposable database variables above and run the script from the repository root.
With the checkout's Composer dependencies installed and Docker running, `composer examples:smoke` provisions a disposable database and runs the standalone examples. To run a standalone example manually, use the disposable database variables above and run the script from the repository root. For Host Snapshot B, follow the [application integration instructions](#run-the-examples-from-a-100-install) above.

---

Expand Down Expand Up @@ -285,7 +285,7 @@ Use B when the Host needs eligible page reads, including its earlier writes, wit
3. **Read** — Call `$checkout->authorizePage($queryId, $bindings, $request)`, pass the grant to `$checkout->newAttempt()`, and use `(new PdoHostSnapshotPaginator())->paginate($attempt)` to receive a `PageResultDTO`.
4. **Boundary** — Eligible page reads share the InnoDB read view within the confirmed transaction and can see the Host's own writes in that transaction. A later transaction has its own read view. Inspect `$attempt->settlement()` after return or exception. The Host directs `commit()` or `rollBack()` on the checkout and handles handoff or discard. The page settlement has a JSON projection of disposition and reason. If the Host calls `retireForHost()` on the source, the returned `HostSnapshotRetirement` transfers the original PDO as a PHP object. If B cannot confirm that startup consumed the isolation setting, the Host must reconcile the connection before reuse.

See the [B contract](../../PHP_PERSISTENCE_PACKAGE_REFERENCE.md#533-optional-b-pagination-in-a-host-owned-transaction) for a page-attempt example, confirmation and handoff rules. The [installed consumer verification](CONSUMER_VERIFICATION.md) exercises a registered write followed by a page in the same transaction.
See the [B contract](../../PHP_PERSISTENCE_PACKAGE_REFERENCE.md#533-optional-b-pagination-in-a-host-owned-transaction) for confirmation and handoff rules. The [Host integration example](../../examples/pagination_host_snapshot_usage.php) shows a read-only page transaction and a conservative discard policy. The [installed consumer verification](CONSUMER_VERIFICATION.md) exercises a registered write followed by a page in the same transaction.

### Optional forward-only Keyset pagination

Expand Down
Loading