Skip to content

feat(#97): bind AdminClient::createSnapshot() and forceRecoveryWithDataLoss() (direct C API) - #106

Merged
s2x merged 1 commit into
masterfrom
feat/97-admin-snapshot-force-recovery-c-api
Sep 9, 2026
Merged

feat(#97): bind AdminClient::createSnapshot() and forceRecoveryWithDataLoss() (direct C API)#106
s2x merged 1 commit into
masterfrom
feat/97-admin-snapshot-force-recovery-c-api

Conversation

@s2x

@s2x s2x commented Sep 9, 2026

Copy link
Copy Markdown
Member

Closes #97

What

  1. NativeClient: binds fdb_database_create_snapshot() and fdb_database_force_recovery_with_data_loss().
  2. AdminClient::createSnapshot(string $uid, string $snapCommand) — validates the UID against [0-9a-fA-F]{32} and the command against printable ASCII (0x20–0x7E, 1–256 bytes) before the FFI call.
  3. AdminClient::forceRecoveryWithDataLoss(string $dcId) — the direct C API call, dcId validated against the token allow-list. The docblock states plainly that data loss is in the name.
  4. AdminClient::forceRecovery() is reimplemented on top of the C call (now an alias of forceRecoveryWithDataLoss()) instead of throwing LogicException — this removes the last attempted special-key write for an operation the special-key space never supported ([Security] AdminClient writes unvalidated input into privileged special keys; several special-key paths unverified #43). The existing configure() LogicException behavior is unchanged.

Tests

  • tests/Unit/AdminClientTest.php: UID/command/dcId validation rejection tests.
  • tests/Integration/AdminInputValidationTest.php: force-recovery validation now exercises the new C-API path.
  • tests/Integration/AdminDestructiveOperationsTest.php: destructive happy-path coverage, skipped unless FDB_ENABLE_DESTRUCTIVE_ADMIN_TESTS=1 (and FDB_DR_TARGET_DC_ID for the actual recovery), since create_snapshot requires snapshot support and force recovery destroys data.

Docs

  • docs/admin.md: Force Recovery section rewritten, new DR Snapshots section, validation-contract table and methods reference updated.
  • CHANGELOG.md: Added + Changed entries under Unreleased.

Verification

  • composer lint clean (PHPCS + Rector dry-run + PHPStan 9)
  • composer test:unit: 562 tests OK (one pre-existing FFI::cast deprecation, unrelated)
  • Integration suite in Docker: 272 tests OK, 4 skipped (guarded destructive tests). One unrelated flaky failure observed in DirectoryTest::directoryInsidePartitionHasSingleContentPrefix reproduces on master and passes on retry.

…ecovery_with_data_loss in AdminClient

- NativeClient: declare fdb_database_create_snapshot() and
  fdb_database_force_recovery_with_data_loss()
- AdminClient::createSnapshot(uid, snapCommand) with 32-hex-char UID
  validation and printable-ASCII command validation
- AdminClient::forceRecoveryWithDataLoss(dcId) with token validation
- AdminClient::forceRecovery() reimplemented on the direct C API call
  (alias of forceRecoveryWithDataLoss), no longer throws LogicException
- Guarded destructive integration tests (FDB_ENABLE_DESTRUCTIVE_ADMIN_TESTS)
- docs/admin.md and CHANGELOG.md updated
@s2x
s2x merged commit a3afb61 into master Sep 9, 2026
6 checks passed
@s2x
s2x deleted the feat/97-admin-snapshot-force-recovery-c-api branch September 9, 2026 05:57
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.

Add AdminClient::createSnapshot() and forceRecoveryWithDataLoss() (direct C API)

1 participant